mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Use hack to customise expander colour in treeview branches. Closes #3319
This commit is contained in:
@@ -257,16 +257,12 @@ void RDTweakedNativeStyle::drawPrimitive(PrimitiveElement element, const QStyleO
|
||||
|
||||
QColor col = opt->palette.color(QPalette::Text);
|
||||
|
||||
if(opt->state & State_MouseOver)
|
||||
{
|
||||
QColor highlightCol = opt->palette.color(QPalette::Highlight);
|
||||
|
||||
col.setRedF(col.redF() * 0.6 + highlightCol.redF() * 0.4);
|
||||
col.setGreenF(col.greenF() * 0.6 + highlightCol.greenF() * 0.4);
|
||||
col.setBlueF(col.blueF() * 0.6 + highlightCol.blueF() * 0.4);
|
||||
}
|
||||
|
||||
p->setPen(QPen(col, 2.0));
|
||||
// turbo hack to pass desired colour through QTreeView::drawBranches when it can't customise
|
||||
// the colour and doesn't set the model index to let us look up this data ourselves :(
|
||||
if(oldPen.widthF() == 1234.5f)
|
||||
p->setPen(QPen(oldPen.color(), 2.0));
|
||||
else
|
||||
p->setPen(QPen(col, 2.0));
|
||||
|
||||
QPainterPath path;
|
||||
|
||||
|
||||
@@ -774,10 +774,19 @@ void RDTreeView::drawBranches(QPainter *painter, const QRect &rect, const QModel
|
||||
opt.rect = allLinesRect;
|
||||
opt.showDecorationSelected = true;
|
||||
opt.backgroundBrush = index.data(Qt::BackgroundRole).value<QBrush>();
|
||||
QColor foreCol = index.data(Qt::ForegroundRole).value<QBrush>().color();
|
||||
opt.palette.setColor(QPalette::Foreground, foreCol);
|
||||
opt.palette.setColor(QPalette::Text, foreCol);
|
||||
|
||||
style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, this);
|
||||
|
||||
QPen oldPen = painter->pen();
|
||||
|
||||
if(m_VisibleBranches)
|
||||
{
|
||||
// set the desired colour for RDTweakedNativeStyle via a huge hack - see
|
||||
// RDTweakedNativeStyle::drawPrimitive for QStyle::PE_IndicatorBranch
|
||||
painter->setPen(QPen(foreCol, 1234.5));
|
||||
QTreeView::drawBranches(painter, rect, index);
|
||||
}
|
||||
else
|
||||
@@ -804,12 +813,13 @@ void RDTreeView::drawBranches(QPainter *painter, const QRect &rect, const QModel
|
||||
if(isExpanded(index))
|
||||
branchopt.state |= QStyle::State_Open;
|
||||
|
||||
branchopt.palette = opt.palette;
|
||||
|
||||
style()->drawPrimitive(QStyle::PE_IndicatorBranch, &branchopt, painter, this);
|
||||
}
|
||||
|
||||
// we now iterate from the top-most parent down, moving in from the left
|
||||
// we draw this after calling into drawBranches() so we paint on top of the built-in lines
|
||||
QPen oldPen = painter->pen();
|
||||
while(!parents.isEmpty())
|
||||
{
|
||||
parent = parents.pop();
|
||||
|
||||
Reference in New Issue
Block a user