@@ -118,6 +118,7 @@ static SPECIAL_DIRS: Lazy<HashMap<PathBuf, &'static str>> = Lazy::new(|| {
118
118
fn button_appearance (
119
119
theme : & theme:: Theme ,
120
120
selected : bool ,
121
+ highlighted : bool ,
121
122
focused : bool ,
122
123
accent : bool ,
123
124
condensed_radius : bool ,
@@ -133,6 +134,14 @@ fn button_appearance(
133
134
} else {
134
135
appearance. background = Some ( Color :: from ( cosmic. bg_component_color ( ) ) . into ( ) ) ;
135
136
}
137
+ } else if highlighted {
138
+ if accent {
139
+ appearance. background = Some ( Color :: from ( cosmic. bg_component_color ( ) ) . into ( ) ) ;
140
+ appearance. icon_color = Some ( Color :: from ( cosmic. on_bg_component_color ( ) ) ) ;
141
+ appearance. text_color = Some ( Color :: from ( cosmic. on_bg_component_color ( ) ) ) ;
142
+ } else {
143
+ appearance. background = Some ( Color :: from ( cosmic. bg_component_color ( ) ) . into ( ) ) ;
144
+ }
136
145
} else if desktop {
137
146
appearance. background = Some ( Color :: from ( cosmic. bg_color ( ) ) . into ( ) ) ;
138
147
appearance. icon_color = Some ( Color :: from ( cosmic. on_bg_color ( ) ) ) ;
@@ -154,23 +163,56 @@ fn button_appearance(
154
163
155
164
fn button_style (
156
165
selected : bool ,
166
+ highlighted : bool ,
157
167
accent : bool ,
158
168
condensed_radius : bool ,
159
169
desktop : bool ,
160
170
) -> theme:: Button {
161
171
//TODO: move to libcosmic?
162
172
theme:: Button :: Custom {
163
173
active : Box :: new ( move |focused, theme| {
164
- button_appearance ( theme, selected, focused, accent, condensed_radius, desktop)
174
+ button_appearance (
175
+ theme,
176
+ selected,
177
+ highlighted,
178
+ focused,
179
+ accent,
180
+ condensed_radius,
181
+ desktop,
182
+ )
165
183
} ) ,
166
184
disabled : Box :: new ( move |theme| {
167
- button_appearance ( theme, selected, false , accent, condensed_radius, desktop)
185
+ button_appearance (
186
+ theme,
187
+ selected,
188
+ highlighted,
189
+ false ,
190
+ accent,
191
+ condensed_radius,
192
+ desktop,
193
+ )
168
194
} ) ,
169
195
hovered : Box :: new ( move |focused, theme| {
170
- button_appearance ( theme, selected, focused, accent, condensed_radius, desktop)
196
+ button_appearance (
197
+ theme,
198
+ selected,
199
+ highlighted,
200
+ focused,
201
+ accent,
202
+ condensed_radius,
203
+ desktop,
204
+ )
171
205
} ) ,
172
206
pressed : Box :: new ( move |focused, theme| {
173
- button_appearance ( theme, selected, focused, accent, condensed_radius, desktop)
207
+ button_appearance (
208
+ theme,
209
+ selected,
210
+ highlighted,
211
+ focused,
212
+ accent,
213
+ condensed_radius,
214
+ desktop,
215
+ )
174
216
} ) ,
175
217
}
176
218
}
@@ -444,6 +486,7 @@ pub fn item_from_entry(
444
486
pos_opt : Cell :: new ( None ) ,
445
487
rect_opt : Cell :: new ( None ) ,
446
488
selected : false ,
489
+ highlighted : false ,
447
490
overlaps_drag_rect : false ,
448
491
}
449
492
}
@@ -672,6 +715,7 @@ pub fn scan_trash(sizes: IconSizes) -> Vec<Item> {
672
715
pos_opt : Cell :: new ( None ) ,
673
716
rect_opt : Cell :: new ( None ) ,
674
717
selected : false ,
718
+ highlighted : false ,
675
719
overlaps_drag_rect : false ,
676
720
} ) ;
677
721
}
@@ -854,6 +898,7 @@ pub fn scan_desktop(
854
898
pos_opt : Cell :: new ( None ) ,
855
899
rect_opt : Cell :: new ( None ) ,
856
900
selected : false ,
901
+ highlighted : false ,
857
902
overlaps_drag_rect : false ,
858
903
} )
859
904
}
@@ -1022,6 +1067,8 @@ pub enum Message {
1022
1067
WindowToggleMaximize ,
1023
1068
ZoomIn ,
1024
1069
ZoomOut ,
1070
+ HighlightDeactivate ( usize ) ,
1071
+ HighlightActivate ( usize ) ,
1025
1072
}
1026
1073
1027
1074
#[ derive( Copy , Clone , Debug , Eq , PartialEq ) ]
@@ -1247,6 +1294,7 @@ pub struct Item {
1247
1294
pub pos_opt : Cell < Option < ( usize , usize ) > > ,
1248
1295
pub rect_opt : Cell < Option < Rectangle > > ,
1249
1296
pub selected : bool ,
1297
+ pub highlighted : bool ,
1250
1298
pub overlaps_drag_rect : bool ,
1251
1299
}
1252
1300
@@ -2592,6 +2640,16 @@ impl Tab {
2592
2640
}
2593
2641
}
2594
2642
}
2643
+ Message :: HighlightDeactivate ( i) => {
2644
+ if let Some ( item) = self . items_opt . as_mut ( ) . and_then ( |f| f. get_mut ( i) ) {
2645
+ item. highlighted = false ;
2646
+ }
2647
+ }
2648
+ Message :: HighlightActivate ( i) => {
2649
+ if let Some ( item) = self . items_opt . as_mut ( ) . and_then ( |f| f. get_mut ( i) ) {
2650
+ item. highlighted = true ;
2651
+ }
2652
+ }
2595
2653
2596
2654
Message :: Scroll ( viewport) => {
2597
2655
self . scroll_opt = Some ( viewport. absolute_offset ( ) ) ;
@@ -3554,14 +3612,21 @@ impl Tab {
3554
3612
. size( icon_sizes. grid( ) ) ,
3555
3613
)
3556
3614
. padding( space_xxxs)
3557
- . class( button_style( item. selected, false , false , false ) )
3615
+ . class( button_style(
3616
+ item. selected,
3617
+ item. highlighted,
3618
+ false ,
3619
+ false ,
3620
+ false ,
3621
+ ) )
3558
3622
. into( ) ,
3559
3623
widget:: tooltip(
3560
3624
widget:: button:: custom( widget:: text:: body( & item. display_name) )
3561
3625
. id( item. button_id. clone( ) )
3562
3626
. padding( [ 0 , space_xxxs] )
3563
3627
. class( button_style(
3564
3628
item. selected,
3629
+ item. highlighted,
3565
3630
true ,
3566
3631
true ,
3567
3632
matches!( self . mode, Mode :: Desktop ) ,
@@ -3606,7 +3671,9 @@ impl Tab {
3606
3671
. on_press ( move |_| Message :: Click ( Some ( i) ) )
3607
3672
. on_double_click ( move |_| Message :: DoubleClick ( Some ( i) ) )
3608
3673
. on_release ( move |_| Message :: ClickRelease ( Some ( i) ) )
3609
- . on_middle_press ( move |_| Message :: MiddleClick ( i) ) ;
3674
+ . on_middle_press ( move |_| Message :: MiddleClick ( i) )
3675
+ . on_enter ( move || Message :: HighlightActivate ( i) )
3676
+ . on_exit ( move || Message :: HighlightDeactivate ( i) ) ;
3610
3677
3611
3678
//TODO: error if the row or col is already set?
3612
3679
while grid_elements. len ( ) <= row {
@@ -3703,6 +3770,7 @@ impl Tab {
3703
3770
. padding( space_xxxs)
3704
3771
. class( button_style(
3705
3772
item. selected,
3773
+ item. highlighted,
3706
3774
false ,
3707
3775
false ,
3708
3776
false ,
@@ -3711,7 +3779,13 @@ impl Tab {
3711
3779
. id( item. button_id. clone( ) )
3712
3780
. on_press( Message :: Click ( Some ( * i) ) )
3713
3781
. padding( [ 0 , space_xxxs] )
3714
- . class( button_style( item. selected, true , true , false ) ) ,
3782
+ . class( button_style(
3783
+ item. selected,
3784
+ item. highlighted,
3785
+ true ,
3786
+ true ,
3787
+ false ,
3788
+ ) ) ,
3715
3789
] ;
3716
3790
3717
3791
let mut column = widget:: column:: with_capacity ( buttons. len ( ) )
@@ -3922,12 +3996,20 @@ impl Tab {
3922
3996
. width ( Length :: Fill )
3923
3997
. id ( item. button_id . clone ( ) )
3924
3998
. padding ( [ 0 , space_xxs] )
3925
- . class ( button_style ( item. selected , true , false , false ) ) ,
3999
+ . class ( button_style (
4000
+ item. selected ,
4001
+ item. highlighted ,
4002
+ true ,
4003
+ false ,
4004
+ false ,
4005
+ ) ) ,
3926
4006
)
3927
4007
. on_press ( move |_| Message :: Click ( Some ( i) ) )
3928
4008
. on_double_click ( move |_| Message :: DoubleClick ( Some ( i) ) )
3929
4009
. on_release ( move |_| Message :: ClickRelease ( Some ( i) ) )
3930
- . on_middle_press ( move |_| Message :: MiddleClick ( i) ) ;
4010
+ . on_middle_press ( move |_| Message :: MiddleClick ( i) )
4011
+ . on_enter ( move || Message :: HighlightActivate ( i) )
4012
+ . on_exit ( move || Message :: HighlightDeactivate ( i) ) ;
3931
4013
3932
4014
if self . context_menu . is_some ( ) {
3933
4015
mouse_area
0 commit comments