Skip to content

Commit

Permalink
refactor: improve disabled custom button appearance
Browse files Browse the repository at this point in the history
Signed-off-by: KhalilSelyan <[email protected]>
  • Loading branch information
KhalilSelyan committed May 21, 2024
1 parent 5bc6eed commit c59041f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions common/tier4_state_rviz_plugin/src/custom_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,22 @@ void CustomElevatedButton::paintEvent(QPaintEvent *)
// Draw button background
QPainterPath backgroundPath;
backgroundPath.addRoundedRect(r, cornerRadius, cornerRadius);
painter.setBrush(buttonColor);
if (!isEnabled()) {
painter.setBrush(
QColor(autoware::state_rviz_plugin::colors::default_colors.on_surface.c_str()));
painter.setOpacity(0.12);
} else {
painter.setBrush(buttonColor);
}
painter.setPen(Qt::NoPen);
painter.drawPath(backgroundPath);

// Draw button text
painter.setPen(currentTextColor);
painter.drawText(r, Qt::AlignCenter, text());

if (!isEnabled()) {
painter.setBrush(
QColor(autoware::state_rviz_plugin::colors::default_colors.on_surface.c_str()));
painter.setPen(Qt::NoPen);
painter.setOpacity(0.12);
painter.drawPath(backgroundPath);
painter.setOpacity(0.38);
}
painter.setPen(currentTextColor);
painter.drawText(r, Qt::AlignCenter, text());
}

void CustomElevatedButton::enterEvent(QEvent * event)
Expand Down

0 comments on commit c59041f

Please sign in to comment.