@@ -26,7 +26,6 @@ use crate::{
26
26
theme, Color , FontDescriptor , KeyOrValue , Point , Rect , TextAlignment , TimerToken , Vec2 ,
27
27
} ;
28
28
29
- const TEXTBOX_INSETS : Insets = Insets :: new ( 4.0 , 2.0 , 4.0 , 2.0 ) ;
30
29
const CURSOR_BLINK_DURATION : Duration = Duration :: from_millis ( 500 ) ;
31
30
const MAC_OR_LINUX : bool = cfg ! ( any( target_os = "macos" , target_os = "linux" ) ) ;
32
31
@@ -73,7 +72,7 @@ impl<T: EditableText + TextStorage> TextBox<T> {
73
72
let mut scroll = Scroll :: new ( TextComponent :: default ( ) ) . content_must_fill ( true ) ;
74
73
scroll. set_enabled_scrollbars ( crate :: scroll_component:: ScrollbarsEnabled :: None ) ;
75
74
Self {
76
- inner : Padding :: new ( TEXTBOX_INSETS , scroll) ,
75
+ inner : Padding :: new ( theme :: TEXTBOX_INSETS , scroll) ,
77
76
scroll_to_selection_after_layout : false ,
78
77
placeholder,
79
78
multiline : false ,
@@ -474,6 +473,7 @@ impl<T: TextStorage + EditableText> Widget<T> for TextBox<T> {
474
473
tracing:: warn!( "Widget::layout called with outstanding IME lock." ) ;
475
474
}
476
475
let min_width = env. get ( theme:: WIDE_WIDGET_WIDTH ) ;
476
+ let textbox_insets = env. get ( theme:: TEXTBOX_INSETS ) ;
477
477
478
478
self . placeholder . rebuild_if_needed ( ctx. text ( ) , env) ;
479
479
let min_size = bc. constrain ( ( min_width, 0.0 ) ) ;
@@ -491,7 +491,7 @@ impl<T: TextStorage + EditableText> Widget<T> for TextBox<T> {
491
491
let baseline_off = layout_baseline
492
492
- ( self . inner . wrapped ( ) . child_size ( ) . height
493
493
- self . inner . wrapped ( ) . viewport_rect ( ) . height ( ) )
494
- + TEXTBOX_INSETS . y1 ;
494
+ + textbox_insets . y1 ;
495
495
ctx. set_baseline_offset ( baseline_off) ;
496
496
if self . scroll_to_selection_after_layout {
497
497
self . scroll_to_selection_end ( ) ;
@@ -516,6 +516,7 @@ impl<T: TextStorage + EditableText> Widget<T> for TextBox<T> {
516
516
let background_color = env. get ( theme:: BACKGROUND_LIGHT ) ;
517
517
let cursor_color = env. get ( theme:: CURSOR_COLOR ) ;
518
518
let border_width = env. get ( theme:: TEXTBOX_BORDER_WIDTH ) ;
519
+ let textbox_insets = env. get ( theme:: TEXTBOX_INSETS ) ;
519
520
520
521
let is_focused = ctx. is_focused ( ) ;
521
522
@@ -540,7 +541,7 @@ impl<T: TextStorage + EditableText> Widget<T> for TextBox<T> {
540
541
ctx. with_save ( |ctx| {
541
542
ctx. clip ( clip_rect) ;
542
543
self . placeholder
543
- . draw ( ctx, ( TEXTBOX_INSETS . x0 , TEXTBOX_INSETS . y0 ) ) ;
544
+ . draw ( ctx, ( textbox_insets . x0 , textbox_insets . y0 ) ) ;
544
545
} )
545
546
}
546
547
@@ -554,7 +555,7 @@ impl<T: TextStorage + EditableText> Widget<T> for TextBox<T> {
554
555
. borrow ( )
555
556
. cursor_line_for_text_position ( cursor_pos) ;
556
557
557
- let padding_offset = Vec2 :: new ( TEXTBOX_INSETS . x0 , TEXTBOX_INSETS . y0 ) ;
558
+ let padding_offset = Vec2 :: new ( textbox_insets . x0 , textbox_insets . y0 ) ;
558
559
559
560
let cursor = if data. is_empty ( ) {
560
561
cursor_line + padding_offset
0 commit comments