Skip to content

Commit

Permalink
Merge pull request #1331 from srcejon/dial_darken
Browse files Browse the repository at this point in the history
Darken ValueDials when disabled
  • Loading branch information
f4exb authored Jul 9, 2022
2 parents f1395de + d17403f commit dcd0ee2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions sdrgui/gui/valuedial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,17 @@ void ValueDial::paintEvent(QPaintEvent *)
painter.drawRect(2 + m_hightlightedDigit * m_digitWidth, 1, m_digitWidth - 1, height() - 1);
}

QColor secondaryForegroundColor = m_colorMapper.getSecondaryForegroundColor();
if (!isEnabled()) {
secondaryForegroundColor = secondaryForegroundColor.darker();
}

if (m_animationState == 0)
{
for (int i = 0; i < m_text.length(); i++)
{
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
painter.setPen(secondaryForegroundColor);
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 0.6, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));

if (m_text[i] != m_groupSeparator)
Expand All @@ -257,7 +262,7 @@ void ValueDial::paintEvent(QPaintEvent *)
if ((m_cursor >= 0) && (m_cursorState))
{
painter.setPen(Qt::NoPen);
painter.setBrush(m_colorMapper.getSecondaryForegroundColor());
painter.setBrush(secondaryForegroundColor);
painter.drawRect(4 + m_cursor * m_digitWidth, 1 + m_digitHeight * 1.5, m_digitWidth - 5, m_digitHeight / 6);
}
}
Expand All @@ -268,7 +273,7 @@ void ValueDial::paintEvent(QPaintEvent *)
if (m_text[i] == m_textNew[i])
{
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
painter.setPen(secondaryForegroundColor);
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 0.6, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));

if (m_text[i] != m_groupSeparator)
Expand All @@ -282,7 +287,7 @@ void ValueDial::paintEvent(QPaintEvent *)
{
int h = m_digitHeight * 0.6 + m_digitHeight * m_animationState / 2.0;
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
painter.setPen(secondaryForegroundColor);
painter.drawText(QRect(1 + i * m_digitWidth, h, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));

if (m_text[i] != m_groupSeparator)
Expand Down
13 changes: 9 additions & 4 deletions sdrgui/gui/valuedialz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,17 @@ void ValueDialZ::paintEvent(QPaintEvent*)
painter.drawRect(2 + m_hightlightedDigit * m_digitWidth, 1, m_digitWidth - 1, height() - 1);
}

QColor secondaryForegroundColor = m_colorMapper.getSecondaryForegroundColor();
if (!isEnabled()) {
secondaryForegroundColor = secondaryForegroundColor.darker();
}

if (m_animationState == 0)
{
for (int i = 0; i < m_text.length(); i++)
{
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
painter.setPen(secondaryForegroundColor);
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 0.6, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));

if ((m_text[i] != m_groupSeparator) && (m_text[i] != m_decSeparator))
Expand All @@ -299,7 +304,7 @@ void ValueDialZ::paintEvent(QPaintEvent*)
if ((m_cursor >= 0) && (m_cursorState))
{
painter.setPen(Qt::NoPen);
painter.setBrush(m_colorMapper.getSecondaryForegroundColor());
painter.setBrush(secondaryForegroundColor);
painter.drawRect(4 + m_cursor * m_digitWidth, 1 + m_digitHeight * 1.5, m_digitWidth - 5, m_digitHeight / 6);
}
}
Expand All @@ -310,7 +315,7 @@ void ValueDialZ::paintEvent(QPaintEvent*)
if (m_text[i] == m_textNew[i])
{
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
painter.setPen(secondaryForegroundColor);
painter.drawText(QRect(1 + i * m_digitWidth, m_digitHeight * 0.6, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));

if ((m_text[i] != m_groupSeparator) && (m_text[i] != m_decSeparator))
Expand All @@ -324,7 +329,7 @@ void ValueDialZ::paintEvent(QPaintEvent*)
{
int h = m_digitHeight * 0.6 + m_digitHeight * m_animationState / 2.0;
painter.setClipRect(1 + i * m_digitWidth, 1, m_digitWidth, m_digitHeight * 2);
painter.setPen(m_colorMapper.getSecondaryForegroundColor());
painter.setPen(secondaryForegroundColor);
painter.drawText(QRect(1 + i * m_digitWidth, h, m_digitWidth, m_digitHeight), Qt::AlignCenter, m_text.mid(i, 1));

if ((m_text[i] != m_groupSeparator) && (m_text[i] != m_decSeparator))
Expand Down

0 comments on commit dcd0ee2

Please sign in to comment.