@@ -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 ,
@@ -471,6 +470,7 @@ impl<T: TextStorage + EditableText> Widget<T> for TextBox<T> {
471
470
tracing:: warn!( "Widget::layout called with outstanding IME lock." ) ;
472
471
}
473
472
let min_width = env. get ( theme:: WIDE_WIDGET_WIDTH ) ;
473
+ let textbox_insets = env. get ( theme:: TEXTBOX_INSETS ) ;
474
474
475
475
self . placeholder . rebuild_if_needed ( ctx. text ( ) , env) ;
476
476
let min_size = bc. constrain ( ( min_width, 0.0 ) ) ;
@@ -488,7 +488,7 @@ impl<T: TextStorage + EditableText> Widget<T> for TextBox<T> {
488
488
let baseline_off = layout_baseline
489
489
- ( self . inner . wrapped ( ) . child_size ( ) . height
490
490
- self . inner . wrapped ( ) . viewport_rect ( ) . height ( ) )
491
- + TEXTBOX_INSETS . y1 ;
491
+ + textbox_insets . y1 ;
492
492
ctx. set_baseline_offset ( baseline_off) ;
493
493
if self . scroll_to_selection_after_layout {
494
494
self . scroll_to_selection_end ( ) ;
@@ -513,6 +513,7 @@ impl<T: TextStorage + EditableText> Widget<T> for TextBox<T> {
513
513
let background_color = env. get ( theme:: BACKGROUND_LIGHT ) ;
514
514
let cursor_color = env. get ( theme:: CURSOR_COLOR ) ;
515
515
let border_width = env. get ( theme:: TEXTBOX_BORDER_WIDTH ) ;
516
+ let textbox_insets = env. get ( theme:: TEXTBOX_INSETS ) ;
516
517
517
518
let is_focused = ctx. is_focused ( ) ;
518
519
@@ -537,7 +538,7 @@ impl<T: TextStorage + EditableText> Widget<T> for TextBox<T> {
537
538
ctx. with_save ( |ctx| {
538
539
ctx. clip ( clip_rect) ;
539
540
self . placeholder
540
- . draw ( ctx, ( TEXTBOX_INSETS . x0 , TEXTBOX_INSETS . y0 ) ) ;
541
+ . draw ( ctx, ( textbox_insets . x0 , textbox_insets . y0 ) ) ;
541
542
} )
542
543
}
543
544
@@ -551,7 +552,7 @@ impl<T: TextStorage + EditableText> Widget<T> for TextBox<T> {
551
552
. borrow ( )
552
553
. cursor_line_for_text_position ( cursor_pos) ;
553
554
554
- let padding_offset = Vec2 :: new ( TEXTBOX_INSETS . x0 , TEXTBOX_INSETS . y0 ) ;
555
+ let padding_offset = Vec2 :: new ( textbox_insets . x0 , textbox_insets . y0 ) ;
555
556
556
557
let cursor = if data. is_empty ( ) {
557
558
cursor_line + padding_offset
0 commit comments