File tree 3 files changed +18
-2
lines changed
3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -20,4 +20,7 @@ pub trait StyleSheet {
20
20
21
21
/// Produces the [`Appearance`] of the svg.
22
22
fn appearance ( & self , style : & Self :: Style ) -> Appearance ;
23
+
24
+ /// Produces the hovered [`Appearance`] of a svg content.
25
+ fn hovered ( & self , style : & Self :: Style ) -> Appearance ;
23
26
}
Original file line number Diff line number Diff line change @@ -939,6 +939,10 @@ impl svg::StyleSheet for Theme {
939
939
Svg :: Custom ( custom) => custom. appearance ( self ) ,
940
940
}
941
941
}
942
+
943
+ fn hovered ( & self , style : & Self :: Style ) -> svg:: Appearance {
944
+ self . appearance ( style)
945
+ }
942
946
}
943
947
944
948
impl svg:: StyleSheet for fn ( & Theme ) -> svg:: Appearance {
@@ -947,6 +951,10 @@ impl svg::StyleSheet for fn(&Theme) -> svg::Appearance {
947
951
fn appearance ( & self , style : & Self :: Style ) -> svg:: Appearance {
948
952
( self ) ( style)
949
953
}
954
+
955
+ fn hovered ( & self , style : & Self :: Style ) -> svg:: Appearance {
956
+ self . appearance ( style)
957
+ }
950
958
}
951
959
952
960
/// The style of a scrollable.
Original file line number Diff line number Diff line change @@ -141,14 +141,15 @@ where
141
141
theme : & Renderer :: Theme ,
142
142
_style : & renderer:: Style ,
143
143
layout : Layout < ' _ > ,
144
- _cursor : mouse:: Cursor ,
144
+ cursor : mouse:: Cursor ,
145
145
_viewport : & Rectangle ,
146
146
) {
147
147
let Size { width, height } = renderer. dimensions ( & self . handle ) ;
148
148
let image_size = Size :: new ( width as f32 , height as f32 ) ;
149
149
150
150
let bounds = layout. bounds ( ) ;
151
151
let adjusted_fit = self . content_fit . fit ( image_size, bounds. size ( ) ) ;
152
+ let is_mouse_over = cursor. is_over ( bounds) ;
152
153
153
154
let render = |renderer : & mut Renderer | {
154
155
let offset = Vector :: new (
@@ -162,7 +163,11 @@ where
162
163
..bounds
163
164
} ;
164
165
165
- let appearance = theme. appearance ( & self . style ) ;
166
+ let appearance = if is_mouse_over {
167
+ theme. hovered ( & self . style )
168
+ } else {
169
+ theme. appearance ( & self . style )
170
+ } ;
166
171
167
172
renderer. draw (
168
173
self . handle . clone ( ) ,
You can’t perform that action at this time.
0 commit comments