NodeObject::drawPanel

master
zetaPRIME 2021-11-12 04:29:23 -05:00
parent 80c90451f3
commit 6ee9a0db6b
4 changed files with 16 additions and 25 deletions

4
notes
View File

@ -32,8 +32,8 @@ parameters {
TODO {
immediate frontburner {
standardized "draw panel" function in nodeobject
^ use in both default draw and quicklevel
- standardized "draw panel" function in nodeobject
- ^ use in both default draw and quicklevel
distortion effect
single-selection sampler

View File

@ -127,22 +127,8 @@ namespace {
}
void QuickLevel::drawCustomChrome(QPainter* painter, const QStyleOptionGraphicsItem* opt) {
// first, draw backing panel
QColor outline = QColor(31, 31, 31);
if (opt->state & QStyle::State_Selected) outline = QColor(127, 127, 255);
auto r = obj->boundingRect();
QLinearGradient fill(QPointF(0, 0), QPointF(0, r.height()));
fill.setColorAt(0, QColor(95, 95, 95));
fill.setColorAt(16.0/r.height(), QColor(63, 63, 63));
fill.setColorAt(1.0 - (1.0 - 16.0/r.height()) / 2, QColor(55, 55, 55));
fill.setColorAt(1, QColor(35, 35, 35));
painter->setRenderHint(QPainter::RenderHint::Antialiasing);
painter->setBrush(QBrush(fill));
painter->setPen(QPen(QBrush(outline), 2));
painter->drawRoundedRect(r, 4, 4);
NodeObject::drawPanel(painter, opt, r, 4);
// set up bar geometry
QSizeF barSize(16, 81);

View File

@ -334,13 +334,7 @@ void NodeObject::focusInEvent(QFocusEvent *) {
bringToTop(true);
}
void NodeObject::paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget *) {
if (customChrome) {
node->drawCustomChrome(painter, opt);
return;
}
QRectF r = boundingRect();
void NodeObject::drawPanel(QPainter* painter, const QStyleOptionGraphicsItem* opt, QRectF r, double rad) {
QColor outline = QColor(31, 31, 31);
if (opt->state & QStyle::State_Selected) outline = QColor(127, 127, 255);
@ -353,7 +347,17 @@ void NodeObject::paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, Q
painter->setRenderHint(QPainter::RenderHint::Antialiasing);
painter->setBrush(QBrush(fill));
painter->setPen(QPen(QBrush(outline), 2));
painter->drawRoundedRect(r, 8, 8);
painter->drawRoundedRect(r, rad, rad);
}
void NodeObject::paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget *) {
if (customChrome) {
node->drawCustomChrome(painter, opt);
return;
}
QRectF r = boundingRect();
drawPanel(painter, opt, r);
if (showName) {
static QFont f = [] {

View File

@ -126,6 +126,7 @@ namespace Xybrid::UI {
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) override;
void contextMenuEvent(QGraphicsSceneContextMenuEvent*) override;
static void drawPanel(QPainter*, const QStyleOptionGraphicsItem*, QRectF, double radius = 8);
void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
QRectF boundingRect() const override;