From c59041fd6451f83c31de7730c83967eea4467204 Mon Sep 17 00:00:00 2001 From: KhalilSelyan Date: Tue, 21 May 2024 14:00:50 +0300 Subject: [PATCH] refactor: improve disabled custom button appearance Signed-off-by: KhalilSelyan --- .../src/custom_button.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/common/tier4_state_rviz_plugin/src/custom_button.cpp b/common/tier4_state_rviz_plugin/src/custom_button.cpp index 6e2475f0e0064..0ef2628577135 100644 --- a/common/tier4_state_rviz_plugin/src/custom_button.cpp +++ b/common/tier4_state_rviz_plugin/src/custom_button.cpp @@ -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)