@@ -18,7 +18,7 @@ use crate::input::{
1818 key_codes, FocusEvent , FocusEventResult , FocusReason , InputEventFilterResult , InputEventResult ,
1919 KeyEvent , KeyboardModifiers , MouseEvent , StandardShortcut , TextShortcut ,
2020} ;
21- use crate :: item_rendering:: { CachedRenderingData , HasFont , ItemRenderer , RenderText } ;
21+ use crate :: item_rendering:: { CachedRenderingData , HasFont , ItemRenderer , RenderString , RenderText } ;
2222use crate :: layout:: { LayoutInfo , Orientation } ;
2323use crate :: lengths:: { LogicalLength , LogicalPoint , LogicalRect , LogicalSize } ;
2424use crate :: platform:: Clipboard ;
@@ -168,15 +168,17 @@ impl HasFont for ComplexText {
168168 }
169169}
170170
171+ impl RenderString for ComplexText {
172+ fn text ( self : Pin < & Self > ) -> SharedString {
173+ self . text ( )
174+ }
175+ }
176+
171177impl RenderText for ComplexText {
172178 fn target_size ( self : Pin < & Self > ) -> LogicalSize {
173179 LogicalSize :: from_lengths ( self . width ( ) , self . height ( ) )
174180 }
175181
176- fn text ( self : Pin < & Self > ) -> SharedString {
177- self . text ( )
178- }
179-
180182 fn color ( self : Pin < & Self > ) -> Brush {
181183 self . color ( )
182184 }
@@ -386,15 +388,17 @@ impl HasFont for MarkdownText {
386388 }
387389}
388390
391+ impl RenderString for MarkdownText {
392+ fn text ( self : Pin < & Self > ) -> SharedString {
393+ self . text ( )
394+ }
395+ }
396+
389397impl RenderText for MarkdownText {
390398 fn target_size ( self : Pin < & Self > ) -> LogicalSize {
391399 LogicalSize :: from_lengths ( self . width ( ) , self . height ( ) )
392400 }
393401
394- fn text ( self : Pin < & Self > ) -> SharedString {
395- self . text ( )
396- }
397-
398402 fn color ( self : Pin < & Self > ) -> Brush {
399403 self . color ( )
400404 }
@@ -561,15 +565,17 @@ impl HasFont for SimpleText {
561565 }
562566}
563567
568+ impl RenderString for SimpleText {
569+ fn text ( self : Pin < & Self > ) -> SharedString {
570+ self . text ( )
571+ }
572+ }
573+
564574impl RenderText for SimpleText {
565575 fn target_size ( self : Pin < & Self > ) -> LogicalSize {
566576 LogicalSize :: from_lengths ( self . width ( ) , self . height ( ) )
567577 }
568578
569- fn text ( self : Pin < & Self > ) -> SharedString {
570- self . text ( )
571- }
572-
573579 fn color ( self : Pin < & Self > ) -> Brush {
574580 self . color ( )
575581 }
@@ -618,15 +624,8 @@ fn text_layout_info(
618624 orientation : Orientation ,
619625 width : Pin < & Property < LogicalLength > > ,
620626) -> LayoutInfo {
621- let text_string = text. text ( ) ;
622627 let implicit_size = |max_width, text_wrap| {
623- window_adapter. renderer ( ) . text_size (
624- text,
625- self_rc,
626- text_string. as_str ( ) ,
627- max_width,
628- text_wrap,
629- )
628+ window_adapter. renderer ( ) . text_size ( text, self_rc, max_width, text_wrap)
630629 } ;
631630
632631 // Stretch uses `round_layout` to explicitly align the top left and bottom right of layout nodes
@@ -758,12 +757,8 @@ impl Item for TextInput {
758757 window_adapter : & Rc < dyn WindowAdapter > ,
759758 self_rc : & ItemRc ,
760759 ) -> LayoutInfo {
761- let text = self . text ( ) ;
762760 let implicit_size = |max_width, text_wrap| {
763- if text. is_empty ( ) {
764- return window_adapter. renderer ( ) . char_size ( self , self_rc, '*' ) ;
765- }
766- window_adapter. renderer ( ) . text_size ( self , self_rc, text. as_str ( ) , max_width, text_wrap)
761+ window_adapter. renderer ( ) . text_size ( self , self_rc, max_width, text_wrap)
767762 } ;
768763
769764 // Stretch uses `round_layout` to explicitly align the top left and bottom right of layout nodes
@@ -1272,6 +1267,12 @@ impl HasFont for TextInput {
12721267 }
12731268}
12741269
1270+ impl RenderString for TextInput {
1271+ fn text ( self : Pin < & Self > ) -> SharedString {
1272+ self . as_ref ( ) . text ( )
1273+ }
1274+ }
1275+
12751276pub enum TextCursorDirection {
12761277 Forward ,
12771278 Backward ,
0 commit comments