Commit ff15ee3 2 people authored and committed
1 parent cd0ca1d commit ff15ee3 Copy full SHA for ff15ee3
File tree 2 files changed +13
-10
lines changed
2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,9 @@ pub struct Spacing {
281
281
/// Default width of a [`Slider`].
282
282
pub slider_width : f32 ,
283
283
284
+ /// Default rail height of a [`Slider`].
285
+ pub slider_rail_height : f32 ,
286
+
284
287
/// Default (minimum) width of a [`ComboBox`](crate::ComboBox).
285
288
pub combo_width : f32 ,
286
289
@@ -1224,6 +1227,7 @@ impl Default for Spacing {
1224
1227
indent : 18.0 , // match checkbox/radio-button with `button_padding.x + icon_width + icon_spacing`
1225
1228
interact_size : vec2 ( 40.0 , 18.0 ) ,
1226
1229
slider_width : 100.0 ,
1230
+ slider_rail_height : 8.0 ,
1227
1231
combo_width : 100.0 ,
1228
1232
text_edit_width : 280.0 ,
1229
1233
icon_width : 14.0 ,
@@ -1573,6 +1577,7 @@ impl Spacing {
1573
1577
indent,
1574
1578
interact_size,
1575
1579
slider_width,
1580
+ slider_rail_height,
1576
1581
combo_width,
1577
1582
text_edit_width,
1578
1583
icon_width,
@@ -1601,6 +1606,10 @@ impl Spacing {
1601
1606
ui. add ( DragValue :: new ( slider_width) . clamp_range ( 0.0 ..=1000.0 ) ) ;
1602
1607
ui. label ( "Slider width" ) ;
1603
1608
} ) ;
1609
+ ui. horizontal ( |ui| {
1610
+ ui. add ( DragValue :: new ( slider_rail_height) . clamp_range ( 0.0 ..=50.0 ) ) ;
1611
+ ui. label ( "Slider rail height" ) ;
1612
+ } ) ;
1604
1613
ui. horizontal ( |ui| {
1605
1614
ui. add ( DragValue :: new ( combo_width) . clamp_range ( 0.0 ..=1000.0 ) ) ;
1606
1615
ui. label ( "ComboBox width" ) ;
Original file line number Diff line number Diff line change @@ -680,11 +680,12 @@ impl<'a> Slider<'a> {
680
680
if ui. is_rect_visible ( response. rect ) {
681
681
let value = self . get_value ( ) ;
682
682
683
- let rail_radius = ui. painter ( ) . round_to_pixel ( self . rail_radius_limit ( rect) ) ;
684
- let rail_rect = self . rail_rect ( rect, rail_radius) ;
685
-
686
683
let visuals = ui. style ( ) . interact ( response) ;
687
684
let widget_visuals = & ui. visuals ( ) . widgets ;
685
+ let spacing = & ui. style ( ) . spacing ;
686
+
687
+ let rail_radius = ( spacing. slider_rail_height / 2.0 ) . at_least ( 0.0 ) ;
688
+ let rail_rect = self . rail_rect ( rect, rail_radius) ;
688
689
689
690
ui. painter ( ) . rect_filled (
690
691
rail_rect,
@@ -800,13 +801,6 @@ impl<'a> Slider<'a> {
800
801
limit / 2.5
801
802
}
802
803
803
- fn rail_radius_limit ( & self , rect : & Rect ) -> f32 {
804
- match self . orientation {
805
- SliderOrientation :: Horizontal => ( rect. height ( ) / 4.0 ) . at_least ( 2.0 ) ,
806
- SliderOrientation :: Vertical => ( rect. width ( ) / 4.0 ) . at_least ( 2.0 ) ,
807
- }
808
- }
809
-
810
804
fn value_ui ( & mut self , ui : & mut Ui , position_range : Rangef ) -> Response {
811
805
// If [`DragValue`] is controlled from the keyboard and `step` is defined, set speed to `step`
812
806
let change = ui. input ( |input| {
You can’t perform that action at this time.
0 commit comments