MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / text_input_content_size

Method text_input_content_size

src/engine.rs:7087–7151  ·  view source on GitHub ↗
(
        &mut self,
        state: &crate::text_input::TextEditState,
        config: &crate::text_input::TextInputConfig,
        visible_width: f32,
    )

Source from the content-addressed store, hash-verified

7085 }
7086
7087 fn text_input_content_size(
7088 &mut self,
7089 state: &crate::text_input::TextEditState,
7090 config: &crate::text_input::TextInputConfig,
7091 visible_width: f32,
7092 ) -> (f32, f32) {
7093 if state.text.is_empty() || visible_width <= 0.0 {
7094 return (0.0, 0.0);
7095 }
7096
7097 let Some(measure_fn) = self.measure_text_fn.as_ref() else {
7098 return (0.0, 0.0);
7099 };
7100
7101 let display_text = crate::text_input::display_text(
7102 &state.text,
7103 &config.placeholder,
7104 config.is_password && !config.is_multiline,
7105 );
7106
7107 if config.is_multiline {
7108 let visual_lines = crate::text_input::wrap_lines(
7109 &display_text,
7110 visible_width,
7111 config.font_asset,
7112 config.font_size,
7113 measure_fn.as_ref(),
7114 );
7115
7116 let content_width = visual_lines
7117 .iter()
7118 .map(|line| {
7119 crate::text_input::compute_char_x_positions(
7120 &line.text,
7121 config.font_asset,
7122 config.font_size,
7123 measure_fn.as_ref(),
7124 )
7125 .last()
7126 .copied()
7127 .unwrap_or(0.0)
7128 })
7129 .fold(0.0_f32, |a, b| a.max(b));
7130
7131 let natural_height = self.font_height(config.font_asset, config.font_size);
7132 let line_height = if config.line_height > 0 {
7133 config.line_height as f32
7134 } else {
7135 natural_height
7136 };
7137
7138 (content_width, visual_lines.len() as f32 * line_height)
7139 } else {
7140 let positions = crate::text_input::compute_char_x_positions(
7141 &display_text,
7142 config.font_asset,
7143 config.font_size,
7144 measure_fn.as_ref(),

Callers 2

set_scroll_positionMethod · 0.80

Calls 5

display_textFunction · 0.85
wrap_linesFunction · 0.85
compute_char_x_positionsFunction · 0.85
is_emptyMethod · 0.80
font_heightMethod · 0.80

Tested by

no test coverage detected