@@ -193,25 +193,29 @@ impl CheckboxColors {
193193 }
194194}
195195
196+ fn indicator_layout ( context : & mut GraphicsContext < ' _ , ' _ , ' _ , ' _ > ) -> WidgetLayout {
197+ let size = Size :: squared (
198+ context
199+ . get ( & CheckboxSize )
200+ . into_upx ( context. gfx . scale ( ) )
201+ . ceil ( ) ,
202+ ) ;
203+ let icon_inset = Lp :: points ( 3 ) . into_upx ( context. gfx . scale ( ) ) . ceil ( ) ;
204+ let icon_height = size. height - icon_inset * 2 ;
205+
206+ let checkmark_lowest_point = ( icon_inset + icon_height * 3 / 4 ) . round ( ) ;
207+
208+ WidgetLayout {
209+ size,
210+ baseline : Baseline :: from ( checkmark_lowest_point) ,
211+ }
212+ }
213+
196214impl IndicatorBehavior for CheckboxIndicator {
197215 type Colors = CheckboxColors ;
198216
199217 fn size ( & self , context : & mut GraphicsContext < ' _ , ' _ , ' _ , ' _ > ) -> WidgetLayout {
200- let size = Size :: squared (
201- context
202- . get ( & CheckboxSize )
203- . into_upx ( context. gfx . scale ( ) )
204- . ceil ( ) ,
205- ) ;
206- let icon_inset = Lp :: points ( 3 ) . into_upx ( context. gfx . scale ( ) ) . ceil ( ) ;
207- let icon_height = size. height - icon_inset * 2 ;
208-
209- let checkmark_lowest_point = ( icon_inset + icon_height * 3 / 4 ) . round ( ) ;
210-
211- WidgetLayout {
212- size,
213- baseline : Baseline :: from ( checkmark_lowest_point) ,
214- }
218+ indicator_layout ( context)
215219 }
216220
217221 fn desired_colors (
@@ -378,7 +382,7 @@ fn draw_filled_checkbox(
378382 . line_to (
379383 Point :: new (
380384 icon_area. origin . x + icon_area. size . width ,
381- icon_area. origin . y ,
385+ icon_area. origin . y + icon_area . size . height / 4 ,
382386 )
383387 . round ( ) ,
384388 )
@@ -531,11 +535,7 @@ impl Widget for CheckboxOrnament {
531535 _available_space : Size < ConstraintLimit > ,
532536 context : & mut LayoutContext < ' _ , ' _ , ' _ , ' _ > ,
533537 ) -> WidgetLayout {
534- let checkbox_size = context
535- . get ( & CheckboxSize )
536- . into_upx ( context. gfx . scale ( ) )
537- . ceil ( ) ;
538- Size :: squared ( checkbox_size) . into ( )
538+ indicator_layout ( context)
539539 }
540540}
541541
0 commit comments