This repository was archived by the owner on May 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParamWidget.cpp
More file actions
84 lines (69 loc) · 2.63 KB
/
ParamWidget.cpp
File metadata and controls
84 lines (69 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "ParamWidget.h"
ParamWidget::ParamWidget(QWidget *parent)
: RefreshableWidget(parent)
{
this->setMouseTracking(true);
}
ParamWidget::~ParamWidget()
{
}
void ParamWidget::setStateTop(bool isTop)
{
this->isTop = isTop;
this->update();
}
void ParamWidget::setStateBottom(bool isBottom)
{
this->isBottom = isBottom;
this->update();
}
void ParamWidget::paintEvent(QPaintEvent* event)
{
Q_UNUSED(event);
QPainter painter(this);
QSize screenSize = Infinity_global::getScreenSize();
QColor color_background = GetStyle::parseStringToColor(QString::fromStdString(StyleContainer::getContainer().getStyleObject()["central"]("color-background")));
double head_width = 0.15, scoll_width = 0.05, ruler_height = 0.05;
StyleContainer::getContainer().getStyleObject()["central"].Get("head-width", head_width);
StyleContainer::getContainer().getStyleObject()["central"].Get("scoll-width", scoll_width);
StyleContainer::getContainer().getStyleObject()["central"].Get("ruler-height", ruler_height);
int head_width_i = screenSize.width() * head_width;
int scoll_width_i = screenSize.width() * scoll_width;
int ruler_height_i = screenSize.width() * ruler_height;
bool pic_background_diy = false;
StyleContainer::getContainer().getStyleObject().Get("pic-background-diy", pic_background_diy);
QPen pen;
pen.setWidth(1);
pen.setColor(Qt::darkGray);
pen.setStyle(Qt::SolidLine);
pen.setCapStyle(Qt::RoundCap);
pen.setJoinStyle(Qt::RoundJoin);
painter.setPen(pen);
if (pic_background_diy) {
double background_diy_transparency = 1;
StyleContainer::getContainer().getStyleObject()["central"].Get("background-diy-transparency", background_diy_transparency);
QColor color_background_hover;
if ((color_background.red() + color_background.green() + color_background.blue()) > 255 * 1.5) {
color_background_hover.setRgb(255, 255, 255, 255 * (1 - background_diy_transparency));
}
else {
color_background_hover.setRgb(0, 0, 0, 255 * (1 - background_diy_transparency));
}
painter.fillRect(0, 0, this->width(), this->height(), color_background_hover);
}
else {
painter.fillRect(0, 0, this->width(), this->height(), color_background);
}
QLine head_line(head_width_i, 0, head_width_i, this->height());
QLine rscoll_line(this->width() - scoll_width_i, 0, this->width() - scoll_width_i, this->height());
QLine bscoll_line(0, this->height() - scoll_width_i, this->width(), this->height() - scoll_width_i);
QLine ruler_line(0, ruler_height_i, this->width(), ruler_height_i);
painter.drawLine(head_line);
painter.drawLine(rscoll_line);
if (this->isTop) {
painter.drawLine(ruler_line);
}
if (this->isBottom) {
painter.drawLine(bscoll_line);
}
}