diff --git a/common/tier4_state_rviz_plugin/src/autoware_state_panel.cpp b/common/tier4_state_rviz_plugin/src/autoware_state_panel.cpp index 8109be3d7aca6..e02422a0b6f61 100644 --- a/common/tier4_state_rviz_plugin/src/autoware_state_panel.cpp +++ b/common/tier4_state_rviz_plugin/src/autoware_state_panel.cpp @@ -427,7 +427,7 @@ QVBoxLayout * AutowareStatePanel::makeVelocityLimitGroup() CustomSlider * pub_velocity_limit_slider_ = new CustomSlider(Qt::Horizontal); pub_velocity_limit_slider_->setRange(0, 100); pub_velocity_limit_slider_->setValue(0); - pub_velocity_limit_slider_->setMaximumWidth(300); + // pub_velocity_limit_slider_->setMaximumWidth(300); connect(pub_velocity_limit_slider_, &QSlider::sliderPressed, this, [this]() { sliderIsDragging = true; // User starts dragging the handle @@ -560,18 +560,26 @@ void AutowareStatePanel::onRoute(const RouteState::ConstSharedPtr msg) if (msg->state == RouteState::SET) { activateButton(clear_route_button_ptr_); + clear_route_button_ptr_->updateStyle( + "Clear Route", + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_low.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.primary.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_high.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_high.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.on_surface.c_str())); } else { - clear_route_button_ptr_->setStyleSheet( - QString("QPushButton {" - "background-color: %1;color: %2;" - "border: 2px solid %3;" - "font-weight: bold;" - "}") - .arg(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()) - .arg(autoware::state_rviz_plugin::colors::default_colors.outline.c_str()) - .arg( - autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str())); deactivateButton(clear_route_button_ptr_); + clear_route_button_ptr_->updateStyle( + "Clear Route", + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_low.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.primary.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_high.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_high.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.on_surface.c_str())); } } @@ -608,6 +616,15 @@ void AutowareStatePanel::onLocalization(const LocalizationInitializationState::C localization_icon->updateStyle(state, bgColor); localization_label_ptr_->setText(localization_state); + init_by_gnss_button_ptr_->updateStyle( + "Initialize with GNSS", + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_low.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.primary.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_high.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_high.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_high.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.on_surface.c_str())); } void AutowareStatePanel::onMotion(const MotionState::ConstSharedPtr msg) @@ -646,8 +663,26 @@ void AutowareStatePanel::onMotion(const MotionState::ConstSharedPtr msg) if (msg->state == MotionState::STARTING) { activateButton(accept_start_button_ptr_); + accept_start_button_ptr_->updateStyle( + "Accept Start", + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_low.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.primary.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_high.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_high.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.on_surface.c_str())); } else { deactivateButton(accept_start_button_ptr_); + accept_start_button_ptr_->updateStyle( + "Accept Start", + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_low.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.primary.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_high.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_high.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.on_surface.c_str())); } } @@ -748,14 +783,18 @@ void AutowareStatePanel::onEmergencyStatus( QColor(autoware::state_rviz_plugin::colors::default_colors.error_container.c_str()), QColor(autoware::state_rviz_plugin::colors::default_colors.on_error_container.c_str()), QColor(autoware::state_rviz_plugin::colors::default_colors.on_error.c_str()), - QColor(autoware::state_rviz_plugin::colors::default_colors.on_error_container.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.on_error.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.on_error.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.error_container.c_str()), QColor(autoware::state_rviz_plugin::colors::default_colors.error_container.c_str())); } else { emergency_button_ptr_->updateStyle( "Set Emergency", QColor(autoware::state_rviz_plugin::colors::default_colors.primary.c_str()), QColor(autoware::state_rviz_plugin::colors::default_colors.on_primary.c_str()), - QColor(autoware::state_rviz_plugin::colors::default_colors.on_primary_container.c_str()), - QColor(autoware::state_rviz_plugin::colors::default_colors.on_primary.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.hover_button_bg.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.pressed_button_bg.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.checked_button_bg.c_str()), + QColor(autoware::state_rviz_plugin::colors::default_colors.error_container.c_str()), QColor(autoware::state_rviz_plugin::colors::default_colors.surface_tint.c_str())); } } diff --git a/common/tier4_state_rviz_plugin/src/custom_button.cpp b/common/tier4_state_rviz_plugin/src/custom_button.cpp index 7ad43190b0f41..5e641c2a30c8c 100644 --- a/common/tier4_state_rviz_plugin/src/custom_button.cpp +++ b/common/tier4_state_rviz_plugin/src/custom_button.cpp @@ -17,11 +17,14 @@ CustomElevatedButton::CustomElevatedButton( const QString & text, const QColor & bgColor, const QColor & textColor, const QColor & hoverColor, - const QColor & disabledBgColor, const QColor & disabledTextColor, QWidget * parent) + const QColor & pressedColor, const QColor & checkedColor, const QColor & disabledBgColor, + const QColor & disabledTextColor, QWidget * parent) : QPushButton(text, parent), backgroundColor(bgColor), textColor(textColor), hoverColor(hoverColor), + pressedColor(pressedColor), + checkedColor(checkedColor), disabledBgColor(disabledBgColor), disabledTextColor(disabledTextColor) { @@ -63,12 +66,15 @@ QSize CustomElevatedButton::minimumSizeHint() const // cppcheck-suppress unusedFunction void CustomElevatedButton::updateStyle( const QString & text, const QColor & bgColor, const QColor & textColor, const QColor & hoverColor, - const QColor & disabledBgColor, const QColor & disabledTextColor) + const QColor & pressedColor, const QColor & checkedColor, const QColor & disabledBgColor, + const QColor & disabledTextColor) { setText(text); backgroundColor = bgColor; this->textColor = textColor; this->hoverColor = hoverColor; + this->pressedColor = pressedColor; + this->checkedColor = checkedColor; this->disabledBgColor = disabledBgColor; this->disabledTextColor = disabledTextColor; update(); // Force repaint @@ -89,10 +95,16 @@ void CustomElevatedButton::paintEvent(QPaintEvent *) if (!isEnabled()) { buttonColor = disabledBgColor; currentTextColor = disabledTextColor; - } else if (isHovered) { - buttonColor = hoverColor; } else { - buttonColor = backgroundColor; + if (isPressed) { + buttonColor = pressedColor; + } else if (isChecked) { + buttonColor = checkedColor; + } else if (isHovered) { + buttonColor = hoverColor; + } else { + buttonColor = backgroundColor; + } } int cornerRadius = height() / 2; // Making the corner radius proportional to the height @@ -101,8 +113,7 @@ void CustomElevatedButton::paintEvent(QPaintEvent *) QPainterPath backgroundPath; backgroundPath.addRoundedRect(r, cornerRadius, cornerRadius); if (!isEnabled()) { - painter.setBrush( - QColor(autoware::state_rviz_plugin::colors::default_colors.on_surface.c_str())); + painter.setBrush(disabledBgColor); painter.setOpacity(0.12); } else { painter.setBrush(buttonColor); @@ -131,3 +142,23 @@ void CustomElevatedButton::leaveEvent(QEvent * event) update(); QPushButton::leaveEvent(event); } + +void CustomElevatedButton::mousePressEvent(QMouseEvent * event) +{ + isPressed = true; + update(); + QPushButton::mousePressEvent(event); +} + +void CustomElevatedButton::mouseReleaseEvent(QMouseEvent * event) +{ + isPressed = false; + update(); + QPushButton::mouseReleaseEvent(event); +} + +void CustomElevatedButton::setChecked(bool checked) +{ + isChecked = checked; + update(); +} diff --git a/common/tier4_state_rviz_plugin/src/custom_segmented_button_item.cpp b/common/tier4_state_rviz_plugin/src/custom_segmented_button_item.cpp index 70f21ca1fec84..10ae20ded5b83 100644 --- a/common/tier4_state_rviz_plugin/src/custom_segmented_button_item.cpp +++ b/common/tier4_state_rviz_plugin/src/custom_segmented_button_item.cpp @@ -92,6 +92,8 @@ void CustomSegmentedButtonItem::paintEvent(QPaintEvent *) QColor buttonColor; if (isDisabled) { buttonColor = disabledBgColor; + } else if (isPressed) { + buttonColor = pressedColor; } else if (isHovered && !isChecked() && isCheckable()) { buttonColor = hoverColor; } else if (isActivated) { @@ -177,3 +179,21 @@ void CustomSegmentedButtonItem::leaveEvent(QEvent * event) } QPushButton::leaveEvent(event); } + +void CustomSegmentedButtonItem::mousePressEvent(QMouseEvent * event) +{ + if (event->button() == Qt::LeftButton && !isDisabled) { + isPressed = true; + update(); + } + QPushButton::mousePressEvent(event); +} + +void CustomSegmentedButtonItem::mouseReleaseEvent(QMouseEvent * event) +{ + if (event->button() == Qt::LeftButton && !isDisabled) { + isPressed = false; + update(); + } + QPushButton::mouseReleaseEvent(event); +} diff --git a/common/tier4_state_rviz_plugin/src/custom_toggle_switch.cpp b/common/tier4_state_rviz_plugin/src/custom_toggle_switch.cpp index 3b58ded626439..d4dafe2493918 100644 --- a/common/tier4_state_rviz_plugin/src/custom_toggle_switch.cpp +++ b/common/tier4_state_rviz_plugin/src/custom_toggle_switch.cpp @@ -44,14 +44,31 @@ void CustomToggleSwitch::paintEvent(QPaintEvent *) QColor(autoware::state_rviz_plugin::colors::default_colors.outline.c_str()); QColor checkedIndicatorColor = QColor(autoware::state_rviz_plugin::colors::default_colors.on_primary.c_str()); - QColor indicatorColor = isChecked ? checkedIndicatorColor : uncheckedIndicatorColor; + + QColor uncheckedHoverIndicatorColor = + QColor(autoware::state_rviz_plugin::colors::default_colors.surface.c_str()); + QColor checkedHoverIndicatorColor = + QColor(autoware::state_rviz_plugin::colors::default_colors.primary_container.c_str()); + + QColor indicatorColor = isChecked + ? (isHovered ? checkedHoverIndicatorColor : checkedIndicatorColor) + : (isHovered ? uncheckedHoverIndicatorColor : uncheckedIndicatorColor); QColor uncheckedBgColor = QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()); QColor checkedBgColor = QColor(autoware::state_rviz_plugin::colors::default_colors.primary.c_str()); - QColor bgColor = isChecked ? checkedBgColor : uncheckedBgColor; + QColor uncheckedHoverBgColor = + QColor(autoware::state_rviz_plugin::colors::default_colors.disabled_elevated_button_bg.c_str()); + + QColor bgColor = + isChecked ? checkedBgColor : (isHovered ? uncheckedHoverBgColor : uncheckedBgColor); + + // Surface color with 12% opacity for the hover circle + QColor hoverCircleColor = + QColor(autoware::state_rviz_plugin::colors::default_colors.surface.c_str()); + hoverCircleColor.setAlpha(255 * 0.12); // 12% opacity QRect borderR = r.adjusted(-margin, -margin, margin, margin); p.setBrush(bgColor); @@ -85,3 +102,17 @@ void CustomToggleSwitch::setCheckedState(bool state) blockSignalsGuard = false; update(); // Force repaint } + +void CustomToggleSwitch::enterEvent(QEvent * event) +{ + isHovered = true; + update(); + QCheckBox::enterEvent(event); +} + +void CustomToggleSwitch::leaveEvent(QEvent * event) +{ + isHovered = false; + update(); + QCheckBox::leaveEvent(event); +} diff --git a/common/tier4_state_rviz_plugin/src/include/custom_button.hpp b/common/tier4_state_rviz_plugin/src/include/custom_button.hpp index b10663ce09933..b37ac2fbd058c 100644 --- a/common/tier4_state_rviz_plugin/src/include/custom_button.hpp +++ b/common/tier4_state_rviz_plugin/src/include/custom_button.hpp @@ -37,6 +37,10 @@ class CustomElevatedButton : public QPushButton QColor(autoware::state_rviz_plugin::colors::default_colors.primary.c_str()), const QColor & hoverColor = QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()), + const QColor & pressedColor = + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()), + const QColor & checkedColor = + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()), const QColor & disabledBgColor = QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_high.c_str()), const QColor & disabledTextColor = @@ -44,26 +48,37 @@ class CustomElevatedButton : public QPushButton QWidget * parent = nullptr); void updateStyle( const QString & text, const QColor & bgColor, const QColor & textColor, - const QColor & hoverColor, const QColor & disabledBgColor, const QColor & disabledTextColor); + const QColor & hoverColor, const QColor & pressedColor, const QColor & checkedColor, + const QColor & disabledBgColor, const QColor & disabledTextColor); protected: void paintEvent(QPaintEvent * event) override; void enterEvent(QEvent * event) override; void leaveEvent(QEvent * event) override; + void mousePressEvent(QMouseEvent * event) override; + void mouseReleaseEvent(QMouseEvent * event) override; QSize sizeHint() const override; QSize minimumSizeHint() const override; + // set checked state + void setChecked(bool checked); private: QColor backgroundColor = QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_low.c_str()); QColor textColor = QColor(autoware::state_rviz_plugin::colors::default_colors.primary.c_str()); QColor hoverColor = - QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()); + QColor(autoware::state_rviz_plugin::colors::default_colors.hover_button_bg.c_str()); + QColor pressedColor = + QColor(autoware::state_rviz_plugin::colors::default_colors.pressed_button_bg.c_str()); + QColor checkedColor = + QColor(autoware::state_rviz_plugin::colors::default_colors.checked_button_bg.c_str()); QColor disabledBgColor = QColor(autoware::state_rviz_plugin::colors::default_colors.disabled_elevated_button_bg.c_str()); QColor disabledTextColor = QColor(autoware::state_rviz_plugin::colors::default_colors.on_surface.c_str()); bool isHovered = false; + bool isPressed = false; + bool isChecked = false; }; #endif // CUSTOM_BUTTON_HPP_ diff --git a/common/tier4_state_rviz_plugin/src/include/custom_segmented_button_item.hpp b/common/tier4_state_rviz_plugin/src/include/custom_segmented_button_item.hpp index ee6f48e285975..09d595f14e191 100644 --- a/common/tier4_state_rviz_plugin/src/include/custom_segmented_button_item.hpp +++ b/common/tier4_state_rviz_plugin/src/include/custom_segmented_button_item.hpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -39,6 +40,8 @@ class CustomSegmentedButtonItem : public QPushButton void paintEvent(QPaintEvent * event) override; void enterEvent(QEvent * event) override; void leaveEvent(QEvent * event) override; + void mousePressEvent(QMouseEvent * event) override; + void mouseReleaseEvent(QMouseEvent * event) override; private: void updateCheckableState(); @@ -47,6 +50,8 @@ class CustomSegmentedButtonItem : public QPushButton QColor checkedBgColor; QColor hoverColor = QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_highest.c_str()); + QColor pressedColor = + QColor(autoware::state_rviz_plugin::colors::default_colors.surface_container_high.c_str()); QColor inactiveTextColor; QColor activeTextColor; QColor disabledBgColor = @@ -56,6 +61,7 @@ class CustomSegmentedButtonItem : public QPushButton bool isHovered = false; bool isActivated = false; bool isDisabled = false; + bool isPressed = false; }; #endif // CUSTOM_SEGMENTED_BUTTON_ITEM_HPP_ diff --git a/common/tier4_state_rviz_plugin/src/include/custom_toggle_switch.hpp b/common/tier4_state_rviz_plugin/src/include/custom_toggle_switch.hpp index 107d45af8c3f3..39ed075cc5b32 100644 --- a/common/tier4_state_rviz_plugin/src/include/custom_toggle_switch.hpp +++ b/common/tier4_state_rviz_plugin/src/include/custom_toggle_switch.hpp @@ -32,9 +32,12 @@ class CustomToggleSwitch : public QCheckBox protected: void paintEvent(QPaintEvent * event) override; void mouseReleaseEvent(QMouseEvent * event) override; + void enterEvent(QEvent * event) override; + void leaveEvent(QEvent * event) override; private: - bool blockSignalsGuard = false; // Guard variable to block signals during updates + bool blockSignalsGuard = false; + bool isHovered = false; }; #endif // CUSTOM_TOGGLE_SWITCH_HPP_ diff --git a/common/tier4_state_rviz_plugin/src/include/material_colors.hpp b/common/tier4_state_rviz_plugin/src/include/material_colors.hpp index d146b599ab600..b5989ff17b530 100644 --- a/common/tier4_state_rviz_plugin/src/include/material_colors.hpp +++ b/common/tier4_state_rviz_plugin/src/include/material_colors.hpp @@ -78,6 +78,12 @@ struct MaterialColors std::string warning = "#EEF08B"; std::string info = "#8BD0F0"; std::string danger = "#F08B8B"; + + std::string enabled_button_bg = "#8BD0F0"; + std::string hover_button_bg = "#84c2e6"; + std::string pressed_button_bg = "#699BB8"; + std::string checked_button_bg = "#699BB8"; + std::string disabled_button_bg = "#292d30"; }; inline MaterialColors default_colors;