mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: convert the "ruler item" to qt-quick
Code is mostly based on the "tooltip item". The dragging code was slightly reworked to be more logical. A "disk item" was added for the handles. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b167e130a4
commit
ea0085fef6
14 changed files with 313 additions and 228 deletions
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include <cmath>
|
||||
#include <QApplication>
|
||||
#include <QFontMetrics>
|
||||
|
||||
static const int tooltipBorder = 2;
|
||||
static const double tooltipBorderRadius = 4.0; // Radius of rounded corners
|
||||
|
@ -37,8 +36,8 @@ static QFont makeFont(double dpr)
|
|||
|
||||
ToolTipItem::ToolTipItem(ChartView &view, double dpr) :
|
||||
AnimatedChartRectItem(view, ProfileZValue::ToolTipItem,
|
||||
QPen(tooltipBorderColor, tooltipBorder),
|
||||
QBrush(tooltipColor), tooltipBorderRadius,
|
||||
QPen(tooltipBorderColor, lrint(tooltipBorder * dpr)),
|
||||
QBrush(tooltipColor), tooltipBorderRadius * dpr,
|
||||
true),
|
||||
font(makeFont(dpr)),
|
||||
fm(font),
|
||||
|
@ -131,9 +130,9 @@ void ToolTipItem::update(const dive *d, double dpr, int time, const plot_info &p
|
|||
}
|
||||
|
||||
width += tissues.width();
|
||||
width += 6.0 * tooltipBorder;
|
||||
width += 6.0 * tooltipBorder * dpr;
|
||||
height = std::max(height, static_cast<double>(tissues.height()));
|
||||
height += 4.0 * tooltipBorder + title.height();
|
||||
height += 4.0 * tooltipBorder * dpr + title.height();
|
||||
|
||||
QPixmap pixmap(lrint(width), lrint(height));
|
||||
pixmap.fill(Qt::transparent);
|
||||
|
@ -141,12 +140,12 @@ void ToolTipItem::update(const dive *d, double dpr, int time, const plot_info &p
|
|||
|
||||
painter.setFont(font);
|
||||
painter.setPen(QPen(tooltipFontColor)); // QPainter uses QPen to set text color!
|
||||
double x = 4.0 * tooltipBorder + tissues.width();
|
||||
double y = 2.0 * tooltipBorder;
|
||||
double x = 4.0 * tooltipBorder * dpr + tissues.width();
|
||||
double y = 2.0 * tooltipBorder * dpr;
|
||||
double titleOffset = (width - title.width()) / 2.0;
|
||||
painter.drawPixmap(lrint(titleOffset), lrint(y), title, 0, 0, title.width(), title.height());
|
||||
y += round(fontHeight);
|
||||
painter.drawPixmap(lrint(2.0 * tooltipBorder), lrint(y), tissues, 0, 0, tissues.width(), tissues.height());
|
||||
painter.drawPixmap(lrint(2.0 * tooltipBorder * dpr), lrint(y), tissues, 0, 0, tissues.width(), tissues.height());
|
||||
y += round(fontHeight);
|
||||
for (auto &[s,w]: strings) {
|
||||
QRectF rect(x, y, w, fontHeight);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue