@@ -99,7 +99,7 @@ class NavIconButton : public views::Button {
9999 if (!nav_enabled_) return ;
100100 Button::OnMouseEntered (event);
101101 SetBackground (views::CreateRoundedRectBackground (
102- SkColorSetARGB ( 20 , 0 , 0 , 0 ) , kNavButtonRadius ));
102+ hover_bg_color_ , kNavButtonRadius ));
103103 SchedulePaint ();
104104 }
105105
@@ -116,6 +116,17 @@ class NavIconButton : public views::Button {
116116 SchedulePaint ();
117117 }
118118
119+ void SetHoverBgColor (SkColor color) {
120+ if (hover_bg_color_ == color) return ;
121+ hover_bg_color_ = color;
122+ if (background ()) {
123+ // Refresh the active hover background with the new color.
124+ SetBackground (views::CreateRoundedRectBackground (
125+ hover_bg_color_, kNavButtonRadius ));
126+ SchedulePaint ();
127+ }
128+ }
129+
119130 void SetNavEnabled (bool enabled) {
120131 nav_enabled_ = enabled;
121132 SetEnabled (enabled);
@@ -187,6 +198,7 @@ class NavIconButton : public views::Button {
187198 LucideIcon icon_;
188199 SkColor icon_color_ = SkColorSetARGB(180 , 100 , 100 , 100 );
189200 SkColor disabled_color_ = SkColorSetARGB(60 , 100 , 100 , 100 );
201+ SkColor hover_bg_color_ = SkColorSetARGB(20 , 0 , 0 , 0 );
190202 bool nav_enabled_ = true ;
191203 bool highlighted_ = false ;
192204 bool animate_on_press_ = false ;
@@ -606,11 +618,16 @@ void DaoAddressBarView::UpdateToggleButtonColor() {
606618 int g = SkColorGetG (bg_color);
607619 int b = SkColorGetB (bg_color);
608620 double luminance = 0.299 * r + 0.587 * g + 0.114 * b;
609- SkColor icon_color = luminance < 128
621+ bool dark_background = luminance < 128 ;
622+ SkColor icon_color = dark_background
610623 ? SkColorSetARGB (230 , 255 , 255 , 255 ) // dark bg → white icon
611624 : SkColorSetARGB (200 , 0 , 0 , 0 ); // light bg → dark icon
612- static_cast <NavIconButton*>(sidebar_toggle_button_.get ())
613- ->SetIconColor (icon_color);
625+ SkColor hover_bg = dark_background
626+ ? SkColorSetARGB (20 , 255 , 255 , 255 )
627+ : SkColorSetARGB (20 , 0 , 0 , 0 );
628+ auto * toggle = static_cast <NavIconButton*>(sidebar_toggle_button_.get ());
629+ toggle->SetIconColor (icon_color);
630+ toggle->SetHoverBgColor (hover_bg);
614631}
615632
616633void DaoAddressBarView::OnToggleButtonPressed () {
@@ -746,14 +763,22 @@ void DaoAddressBarView::UpdateNavButtonColors() {
746763 int g = SkColorGetG (bg_color);
747764 int b = SkColorGetB (bg_color);
748765 double luminance = 0.299 * r + 0.587 * g + 0.114 * b;
749- SkColor icon_color = luminance < 128
766+ bool dark_background = luminance < 128 ;
767+ SkColor icon_color = dark_background
750768 ? SkColorSetARGB (180 , 255 , 255 , 255 )
751769 : SkColorSetARGB (160 , 0 , 0 , 0 );
770+ // Adaptive hover background: dark surfaces need white tint, light surfaces
771+ // need black tint, to keep the rounded highlight visible against any page.
772+ SkColor hover_bg = dark_background
773+ ? SkColorSetARGB (20 , 255 , 255 , 255 )
774+ : SkColorSetARGB (20 , 0 , 0 , 0 );
752775
753776 for (views::Button* btn : {back_button_.get (), forward_button_.get (),
754777 stop_refresh_button_.get (), chat_button_.get ()}) {
755778 if (btn) {
756- static_cast <NavIconButton*>(btn)->SetIconColor (icon_color);
779+ auto * nav_btn = static_cast <NavIconButton*>(btn);
780+ nav_btn->SetIconColor (icon_color);
781+ nav_btn->SetHoverBgColor (hover_bg);
757782 }
758783 }
759784 if (control_center_button_) {
0 commit comments