BlueGit

ict rusty-teams

fix(composer): equal button insets to the composer box edge

- Input/Textarea line_box_height: vertical editor padding centers each line in a box of that height
- composer centers lines in a 32 px box, so a single line is exactly button height on any font/scale
- button size and inset as constants, composer box, leading buttons and send tagged
- layout_guard composer_buttons_keep_equal_insets: top/left/bottom/right insets equal, single line and 3 lines

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-10-17 · 6 weeks ago

Hash
4c11825e261cd7876ba481462b7380696077a95b
Parent
a95c9f2e
4 files changed +114 −16
crates/app/src/layout_guard.rs +61 −0
@@ -176,6 +176,7 @@ mod frames {
176 176 use crate::user_activity::UserInput;
177 177 use crate::views::call_transcript::TranscriptPanel;
178 178 use crate::views::call_view::CHAT_PANEL_TAG;
179 use crate::views::composer::{COMPOSER_BOX_TAG, COMPOSER_LEADING_TAG, COMPOSER_SEND_TAG};
179 180 use crate::views::message_row::BUBBLE_TAGS;
180 181 use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};
181 182 use crate::views::reaction_proposal_pill::REACTION_PILL;
@@ -865,6 +866,66 @@ mod frames {
865 866 }
866 867 }
867 868
869 fn composer_button_insets(visual: &mut VisualTestContext) -> [f32; 6] {
870 collect(visual, Some(COMPOSER_SEND_TAG));
871 let mut bounds_of = |path: &'static str| {
872 visual
873 .debug_bounds(path)
874 .unwrap_or_else(|| panic!("{path} rendered"))
875 };
876 let composer = bounds_of(COMPOSER_BOX_TAG);
877 let leading = bounds_of(COMPOSER_LEADING_TAG);
878 let send = bounds_of(COMPOSER_SEND_TAG);
879 [
880 f32::from(leading.left() - composer.left()),
881 f32::from(leading.top() - composer.top()),
882 f32::from(composer.bottom() - leading.bottom()),
883 f32::from(composer.right() - send.right()),
884 f32::from(send.top() - composer.top()),
885 f32::from(composer.bottom() - send.bottom()),
886 ]
887 }
888
889 #[gpui_kit::test]
890 fn composer_buttons_keep_equal_insets(cx: &mut TestAppContext) {
891 let (handle, _) = mount(cx);
892 let mut visual = VisualTestContext::from_window(handle, cx);
893 visual.simulate_resize(size(px(1280.), px(800.)));
894 let single_line = composer_button_insets(&mut visual);
895 let left = single_line[0];
896 assert!(
897 single_line
898 .iter()
899 .all(|inset| (inset - left).abs() < TOLERANCE),
900 "single line: insets left, top, bottom of the first button and right, top, bottom of send {single_line:?}"
901 );
902 let leading = visual
903 .debug_bounds(COMPOSER_LEADING_TAG)
904 .expect("leading buttons");
905 let send = visual.debug_bounds(COMPOSER_SEND_TAG).expect("send button");
906 visual.simulate_click(
907 point((leading.right() + send.left()) / 2., send.center().y),
908 Default::default(),
909 );
910 visual.simulate_keystrokes("o n e shift-enter t w o shift-enter t h r e e");
911 let three_lines = composer_button_insets(&mut visual);
912 assert!(
913 three_lines[1] > single_line[1] + 30.,
914 "three lines did not grow the composer: {three_lines:?}"
915 );
916 for inset in [
917 three_lines[0],
918 three_lines[2],
919 three_lines[3],
920 three_lines[5],
921 ] {
922 assert!(
923 (inset - left).abs() < TOLERANCE,
924 "three lines: insets left, top, bottom of the first button and right, top, bottom of send {three_lines:?}, expected {left}"
925 );
926 }
927 }
928
868 929 #[gpui_kit::test]
869 930 fn agent_proposals_stay_inside_the_main_island(cx: &mut TestAppContext) {
870 931 let (handle, state) = mount_with(cx, true);
@@ -176,6 +176,7 @@ mod frames {
176 use crate::user_activity::UserInput;
176 use crate::user_activity::UserInput;
177 use crate::views::call_transcript::TranscriptPanel;
177 use crate::views::call_transcript::TranscriptPanel;
178 use crate::views::call_view::CHAT_PANEL_TAG;
178 use crate::views::call_view::CHAT_PANEL_TAG;
179 use crate::views::composer::{COMPOSER_BOX_TAG, COMPOSER_LEADING_TAG, COMPOSER_SEND_TAG};
179 use crate::views::message_row::BUBBLE_TAGS;
180 use crate::views::message_row::BUBBLE_TAGS;
180 use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};
181 use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};
181 use crate::views::reaction_proposal_pill::REACTION_PILL;
182 use crate::views::reaction_proposal_pill::REACTION_PILL;
@@ -865,6 +866,66 @@ mod frames {
865 }
866 }
866 }
867 }
867
868
869 fn composer_button_insets(visual: &mut VisualTestContext) -> [f32; 6] {
870 collect(visual, Some(COMPOSER_SEND_TAG));
871 let mut bounds_of = |path: &'static str| {
872 visual
873 .debug_bounds(path)
874 .unwrap_or_else(|| panic!("{path} rendered"))
875 };
876 let composer = bounds_of(COMPOSER_BOX_TAG);
877 let leading = bounds_of(COMPOSER_LEADING_TAG);
878 let send = bounds_of(COMPOSER_SEND_TAG);
879 [
880 f32::from(leading.left() - composer.left()),
881 f32::from(leading.top() - composer.top()),
882 f32::from(composer.bottom() - leading.bottom()),
883 f32::from(composer.right() - send.right()),
884 f32::from(send.top() - composer.top()),
885 f32::from(composer.bottom() - send.bottom()),
886 ]
887 }
888
889 #[gpui_kit::test]
890 fn composer_buttons_keep_equal_insets(cx: &mut TestAppContext) {
891 let (handle, _) = mount(cx);
892 let mut visual = VisualTestContext::from_window(handle, cx);
893 visual.simulate_resize(size(px(1280.), px(800.)));
894 let single_line = composer_button_insets(&mut visual);
895 let left = single_line[0];
896 assert!(
897 single_line
898 .iter()
899 .all(|inset| (inset - left).abs() < TOLERANCE),
900 "single line: insets left, top, bottom of the first button and right, top, bottom of send {single_line:?}"
901 );
902 let leading = visual
903 .debug_bounds(COMPOSER_LEADING_TAG)
904 .expect("leading buttons");
905 let send = visual.debug_bounds(COMPOSER_SEND_TAG).expect("send button");
906 visual.simulate_click(
907 point((leading.right() + send.left()) / 2., send.center().y),
908 Default::default(),
909 );
910 visual.simulate_keystrokes("o n e shift-enter t w o shift-enter t h r e e");
911 let three_lines = composer_button_insets(&mut visual);
912 assert!(
913 three_lines[1] > single_line[1] + 30.,
914 "three lines did not grow the composer: {three_lines:?}"
915 );
916 for inset in [
917 three_lines[0],
918 three_lines[2],
919 three_lines[3],
920 three_lines[5],
921 ] {
922 assert!(
923 (inset - left).abs() < TOLERANCE,
924 "three lines: insets left, top, bottom of the first button and right, top, bottom of send {three_lines:?}, expected {left}"
925 );
926 }
927 }
928
868 #[gpui_kit::test]
929 #[gpui_kit::test]
869 fn agent_proposals_stay_inside_the_main_island(cx: &mut TestAppContext) {
930 fn agent_proposals_stay_inside_the_main_island(cx: &mut TestAppContext) {
870 let (handle, state) = mount_with(cx, true);
931 let (handle, state) = mount_with(cx, true);
crates/app/src/views/composer.rs +22 −9
@@ -72,6 +72,11 @@ const POPUP_WIDTH: f32 = 380.;
72 72 const POPUP_ROW_HEIGHT: f32 = 44.;
73 73 const DEMO_UPLOAD_STEPS: u8 = 10;
74 74 const COMPOSER_ICON_SIZE: f32 = 20.;
75 const COMPOSER_BUTTON_SIZE: f32 = 32.;
76 const COMPOSER_BUTTON_INSET: f32 = 6.;
77 pub const COMPOSER_BOX_TAG: &str = "composer";
78 pub const COMPOSER_LEADING_TAG: &str = "composer/leading";
79 pub const COMPOSER_SEND_TAG: &str = "composer/send";
75 80 /// gpui-kit draws a `Size::Size` button's icon at this fraction of the button size.
76 81 const BUTTON_ICON_SCALE: f32 = 0.75;
77 82 const DEMO_UPLOAD_STEP: Duration = Duration::from_millis(120);
@@ -2497,8 +2502,9 @@ impl Render for Composer {
2497 2502 let can_attach = self.editing.is_none();
2498 2503 let send = div()
2499 2504 .id("composer-send")
2500 .size(px(32.))
2501 .ml(px(6.))
2505 .debug_selector(|| COMPOSER_SEND_TAG.into())
2506 .size(px(COMPOSER_BUTTON_SIZE))
2507 .ml(px(COMPOSER_BUTTON_INSET))
2502 2508 .flex_none()
2503 2509 .flex()
2504 2510 .items_center()
@@ -2532,7 +2538,7 @@ impl Render for Composer {
2532 2538 )
2533 2539 .rounded(px(8.))
2534 2540 .with_size(px(COMPOSER_ICON_SIZE / BUTTON_ICON_SCALE))
2535 .size(px(32.))
2541 .size(px(COMPOSER_BUTTON_SIZE))
2536 2542 .tooltip("Emoji, GIFs und Sticker")
2537 2543 .icon(symbol("mood", COMPOSER_ICON_SIZE, theme::text_muted())),
2538 2544 )
@@ -2550,7 +2556,7 @@ impl Render for Composer {
2550 2556 let attach = can_attach.then(|| {
2551 2557 div()
2552 2558 .id("composer-attach")
2553 .size(px(32.))
2559 .size(px(COMPOSER_BUTTON_SIZE))
2554 2560 .flex_none()
2555 2561 .flex()
2556 2562 .items_center()
@@ -2569,7 +2575,7 @@ impl Render for Composer {
2569 2575 let table_button = can_attach.then(|| {
2570 2576 div()
2571 2577 .id("composer-table")
2572 .size(px(32.))
2578 .size(px(COMPOSER_BUTTON_SIZE))
2573 2579 .flex_none()
2574 2580 .flex()
2575 2581 .items_center()
@@ -2587,6 +2593,7 @@ impl Render for Composer {
2587 2593 let composer = cx.weak_entity();
2588 2594 let tokens_composer = composer.clone();
2589 2595 let input = Textarea::new(&self.input)
2596 .line_box_height(px(COMPOSER_BUTTON_SIZE))
2590 2597 .appearance(false)
2591 2598 .bordered(false)
2592 2599 .on_paste(move |item, window, cx| {
@@ -2917,6 +2924,7 @@ impl Render for Composer {
2917 2924 .children(self.render_table_picker(cx))
2918 2925 .child(
2919 2926 v_flex()
2927 .debug_selector(|| COMPOSER_BOX_TAG.into())
2920 2928 .relative()
2921 2929 .w_full()
2922 2930 .rounded(px(12.))
@@ -2946,14 +2954,19 @@ impl Render for Composer {
2946 2954 row.items_end()
2947 2955 }
2948 2956 })
2949 .py(px(6.))
2950 .pl(px(if can_attach { 6. } else { 12. }))
2951 .pr(px(6.))
2957 .py(px(COMPOSER_BUTTON_INSET))
2958 .pl(px(if can_attach {
2959 COMPOSER_BUTTON_INSET
2960 } else {
2961 12.
2962 }))
2963 .pr(px(COMPOSER_BUTTON_INSET))
2952 2964 .when(can_attach, |row| {
2953 2965 row.child(
2954 2966 h_flex()
2967 .debug_selector(|| COMPOSER_LEADING_TAG.into())
2955 2968 .flex_none()
2956 .gap(px(6.))
2969 .gap(px(COMPOSER_BUTTON_INSET))
2957 2970 .children(fun)
2958 2971 .children(attach)
2959 2972 .children(table_button),
@@ -72,6 +72,11 @@ const POPUP_WIDTH: f32 = 380.;
72const POPUP_ROW_HEIGHT: f32 = 44.;
72const POPUP_ROW_HEIGHT: f32 = 44.;
73const DEMO_UPLOAD_STEPS: u8 = 10;
73const DEMO_UPLOAD_STEPS: u8 = 10;
74const COMPOSER_ICON_SIZE: f32 = 20.;
74const COMPOSER_ICON_SIZE: f32 = 20.;
75const COMPOSER_BUTTON_SIZE: f32 = 32.;
76const COMPOSER_BUTTON_INSET: f32 = 6.;
77pub const COMPOSER_BOX_TAG: &str = "composer";
78pub const COMPOSER_LEADING_TAG: &str = "composer/leading";
79pub const COMPOSER_SEND_TAG: &str = "composer/send";
75/// gpui-kit draws a `Size::Size` button's icon at this fraction of the button size.
80/// gpui-kit draws a `Size::Size` button's icon at this fraction of the button size.
76const BUTTON_ICON_SCALE: f32 = 0.75;
81const BUTTON_ICON_SCALE: f32 = 0.75;
77const DEMO_UPLOAD_STEP: Duration = Duration::from_millis(120);
82const DEMO_UPLOAD_STEP: Duration = Duration::from_millis(120);
@@ -2497,8 +2502,9 @@ impl Render for Composer {
2497 let can_attach = self.editing.is_none();
2502 let can_attach = self.editing.is_none();
2498 let send = div()
2503 let send = div()
2499 .id("composer-send")
2504 .id("composer-send")
2500 .size(px(32.))
2505 .debug_selector(|| COMPOSER_SEND_TAG.into())
2501 .ml(px(6.))
2506 .size(px(COMPOSER_BUTTON_SIZE))
2507 .ml(px(COMPOSER_BUTTON_INSET))
2502 .flex_none()
2508 .flex_none()
2503 .flex()
2509 .flex()
2504 .items_center()
2510 .items_center()
@@ -2532,7 +2538,7 @@ impl Render for Composer {
2532 )
2538 )
2533 .rounded(px(8.))
2539 .rounded(px(8.))
2534 .with_size(px(COMPOSER_ICON_SIZE / BUTTON_ICON_SCALE))
2540 .with_size(px(COMPOSER_ICON_SIZE / BUTTON_ICON_SCALE))
2535 .size(px(32.))
2541 .size(px(COMPOSER_BUTTON_SIZE))
2536 .tooltip("Emoji, GIFs und Sticker")
2542 .tooltip("Emoji, GIFs und Sticker")
2537 .icon(symbol("mood", COMPOSER_ICON_SIZE, theme::text_muted())),
2543 .icon(symbol("mood", COMPOSER_ICON_SIZE, theme::text_muted())),
2538 )
2544 )
@@ -2550,7 +2556,7 @@ impl Render for Composer {
2550 let attach = can_attach.then(|| {
2556 let attach = can_attach.then(|| {
2551 div()
2557 div()
2552 .id("composer-attach")
2558 .id("composer-attach")
2553 .size(px(32.))
2559 .size(px(COMPOSER_BUTTON_SIZE))
2554 .flex_none()
2560 .flex_none()
2555 .flex()
2561 .flex()
2556 .items_center()
2562 .items_center()
@@ -2569,7 +2575,7 @@ impl Render for Composer {
2569 let table_button = can_attach.then(|| {
2575 let table_button = can_attach.then(|| {
2570 div()
2576 div()
2571 .id("composer-table")
2577 .id("composer-table")
2572 .size(px(32.))
2578 .size(px(COMPOSER_BUTTON_SIZE))
2573 .flex_none()
2579 .flex_none()
2574 .flex()
2580 .flex()
2575 .items_center()
2581 .items_center()
@@ -2587,6 +2593,7 @@ impl Render for Composer {
2587 let composer = cx.weak_entity();
2593 let composer = cx.weak_entity();
2588 let tokens_composer = composer.clone();
2594 let tokens_composer = composer.clone();
2589 let input = Textarea::new(&self.input)
2595 let input = Textarea::new(&self.input)
2596 .line_box_height(px(COMPOSER_BUTTON_SIZE))
2590 .appearance(false)
2597 .appearance(false)
2591 .bordered(false)
2598 .bordered(false)
2592 .on_paste(move |item, window, cx| {
2599 .on_paste(move |item, window, cx| {
@@ -2917,6 +2924,7 @@ impl Render for Composer {
2917 .children(self.render_table_picker(cx))
2924 .children(self.render_table_picker(cx))
2918 .child(
2925 .child(
2919 v_flex()
2926 v_flex()
2927 .debug_selector(|| COMPOSER_BOX_TAG.into())
2920 .relative()
2928 .relative()
2921 .w_full()
2929 .w_full()
2922 .rounded(px(12.))
2930 .rounded(px(12.))
@@ -2946,14 +2954,19 @@ impl Render for Composer {
2946 row.items_end()
2954 row.items_end()
2947 }
2955 }
2948 })
2956 })
2949 .py(px(6.))
2957 .py(px(COMPOSER_BUTTON_INSET))
2950 .pl(px(if can_attach { 6. } else { 12. }))
2958 .pl(px(if can_attach {
2951 .pr(px(6.))
2959 COMPOSER_BUTTON_INSET
2960 } else {
2961 12.
2962 }))
2963 .pr(px(COMPOSER_BUTTON_INSET))
2952 .when(can_attach, |row| {
2964 .when(can_attach, |row| {
2953 row.child(
2965 row.child(
2954 h_flex()
2966 h_flex()
2967 .debug_selector(|| COMPOSER_LEADING_TAG.into())
2955 .flex_none()
2968 .flex_none()
2956 .gap(px(6.))
2969 .gap(px(COMPOSER_BUTTON_INSET))
2957 .children(fun)
2970 .children(fun)
2958 .children(attach)
2971 .children(attach)
2959 .children(table_button),
2972 .children(table_button),
vendor/gpui-component/src/input/input.rs +18 −5
@@ -3,9 +3,9 @@ use std::rc::Rc;
3 3 use gpui::prelude::FluentBuilder as _;
4 4 use gpui::{
5 5 AccessibleAction, AnyElement, App, DefiniteLength, Edges, ElementId, Entity, Hsla,
6 InteractiveElement as _, IntoElement, ParentElement as _, Rems, RenderOnce, Role, SharedString,
7 StatefulInteractiveElement as _, StyleRefinement, Styled, TextAlign, TouchPhase, Window, div,
8 px, relative,
6 InteractiveElement as _, IntoElement, ParentElement as _, Pixels, Rems, RenderOnce, Role,
7 SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled, TextAlign, TouchPhase,
8 Window, div, px, relative,
9 9 };
10 10
11 11 use crate::button::{Button, ButtonRounded, ButtonVariants as _};
@@ -119,6 +119,7 @@ pub struct Input {
119 119 prefix: Option<AnyElement>,
120 120 suffix: Option<AnyElement>,
121 121 height: Option<DefiniteLength>,
122 line_box_height: Option<Pixels>,
122 123 appearance: bool,
123 124 cleanable: bool,
124 125 mask_toggle: bool,
@@ -246,6 +247,7 @@ impl Input {
246 247 aria_label: None,
247 248 context_menu_builder: None,
248 249 paste_handler: None,
250 line_box_height: None,
249 251 token_renderer: None,
250 252 token_click_listener: None,
251 253 token_hover_listener: None,
@@ -295,6 +297,14 @@ impl Input {
295 297 self
296 298 }
297 299
300 /// Center each text line of a multi-line input in a box this tall, in
301 /// place of the size's vertical padding, so a single line is exactly this
302 /// tall and lines up with controls of the same height beside it.
303 pub fn line_box_height(mut self, height: Pixels) -> Self {
304 self.line_box_height = Some(height);
305 self
306 }
307
298 308 /// Set the appearance of the input field, if false the input field will no border, background.
299 309 pub fn appearance(mut self, appearance: bool) -> Self {
300 310 self.appearance = appearance;
@@ -588,12 +598,15 @@ impl RenderOnce for Input {
588 598 },
589 599 cx,
590 600 );
601 let padding_y = self.line_box_height.map_or(self.size.input_py(), |height| {
602 ((height - LINE_HEIGHT.to_pixels(window.rem_size())) / 2.).max(px(0.))
603 });
591 604 state.set_editor_paddings(
592 605 if state.presentation(cx).is_multi_line() {
593 606 Edges {
594 top: self.size.input_py(),
607 top: padding_y,
595 608 right: self.size.input_px(),
596 bottom: self.size.input_py(),
609 bottom: padding_y,
597 610 left: if state.presentation(cx).is_code_editor() {
598 611 self.size.input_px().min(px(6.))
599 612 } else {
@@ -3,9 +3,9 @@ use std::rc::Rc;
3use gpui::prelude::FluentBuilder as _;
3use gpui::prelude::FluentBuilder as _;
4use gpui::{
4use gpui::{
5 AccessibleAction, AnyElement, App, DefiniteLength, Edges, ElementId, Entity, Hsla,
5 AccessibleAction, AnyElement, App, DefiniteLength, Edges, ElementId, Entity, Hsla,
6 InteractiveElement as _, IntoElement, ParentElement as _, Rems, RenderOnce, Role, SharedString,
6 InteractiveElement as _, IntoElement, ParentElement as _, Pixels, Rems, RenderOnce, Role,
7 StatefulInteractiveElement as _, StyleRefinement, Styled, TextAlign, TouchPhase, Window, div,
7 SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled, TextAlign, TouchPhase,
8 px, relative,
8 Window, div, px, relative,
9};
9};
10
10
11use crate::button::{Button, ButtonRounded, ButtonVariants as _};
11use crate::button::{Button, ButtonRounded, ButtonVariants as _};
@@ -119,6 +119,7 @@ pub struct Input {
119 prefix: Option<AnyElement>,
119 prefix: Option<AnyElement>,
120 suffix: Option<AnyElement>,
120 suffix: Option<AnyElement>,
121 height: Option<DefiniteLength>,
121 height: Option<DefiniteLength>,
122 line_box_height: Option<Pixels>,
122 appearance: bool,
123 appearance: bool,
123 cleanable: bool,
124 cleanable: bool,
124 mask_toggle: bool,
125 mask_toggle: bool,
@@ -246,6 +247,7 @@ impl Input {
246 aria_label: None,
247 aria_label: None,
247 context_menu_builder: None,
248 context_menu_builder: None,
248 paste_handler: None,
249 paste_handler: None,
250 line_box_height: None,
249 token_renderer: None,
251 token_renderer: None,
250 token_click_listener: None,
252 token_click_listener: None,
251 token_hover_listener: None,
253 token_hover_listener: None,
@@ -295,6 +297,14 @@ impl Input {
295 self
297 self
296 }
298 }
297
299
300 /// Center each text line of a multi-line input in a box this tall, in
301 /// place of the size's vertical padding, so a single line is exactly this
302 /// tall and lines up with controls of the same height beside it.
303 pub fn line_box_height(mut self, height: Pixels) -> Self {
304 self.line_box_height = Some(height);
305 self
306 }
307
298 /// Set the appearance of the input field, if false the input field will no border, background.
308 /// Set the appearance of the input field, if false the input field will no border, background.
299 pub fn appearance(mut self, appearance: bool) -> Self {
309 pub fn appearance(mut self, appearance: bool) -> Self {
300 self.appearance = appearance;
310 self.appearance = appearance;
@@ -588,12 +598,15 @@ impl RenderOnce for Input {
588 },
598 },
589 cx,
599 cx,
590 );
600 );
601 let padding_y = self.line_box_height.map_or(self.size.input_py(), |height| {
602 ((height - LINE_HEIGHT.to_pixels(window.rem_size())) / 2.).max(px(0.))
603 });
591 state.set_editor_paddings(
604 state.set_editor_paddings(
592 if state.presentation(cx).is_multi_line() {
605 if state.presentation(cx).is_multi_line() {
593 Edges {
606 Edges {
594 top: self.size.input_py(),
607 top: padding_y,
595 right: self.size.input_px(),
608 right: self.size.input_px(),
596 bottom: self.size.input_py(),
609 bottom: padding_y,
597 left: if state.presentation(cx).is_code_editor() {
610 left: if state.presentation(cx).is_code_editor() {
598 self.size.input_px().min(px(6.))
611 self.size.input_px().min(px(6.))
599 } else {
612 } else {
vendor/gpui-component/src/input/textarea.rs +13 −2
@@ -1,8 +1,8 @@
1 1 use std::rc::Rc;
2 2
3 3 use gpui::{
4 App, DefiniteLength, Entity, IntoElement, RenderOnce, SharedString, StyleRefinement, Styled,
5 Window, prelude::FluentBuilder as _,
4 App, DefiniteLength, Entity, IntoElement, Pixels, RenderOnce, SharedString, StyleRefinement,
5 Styled, Window, prelude::FluentBuilder as _,
6 6 };
7 7
8 8 use super::{Input, TextareaState};
@@ -19,6 +19,7 @@ pub struct Textarea {
19 19 style: StyleRefinement,
20 20 size: Size,
21 21 height: Option<DefiniteLength>,
22 line_box_height: Option<Pixels>,
22 23 appearance: bool,
23 24 bordered: bool,
24 25 disabled: bool,
@@ -73,6 +74,7 @@ impl Textarea {
73 74 style: StyleRefinement::default(),
74 75 size: Size::default(),
75 76 height: None,
77 line_box_height: None,
76 78 appearance: true,
77 79 bordered: true,
78 80 disabled: false,
@@ -94,6 +96,12 @@ impl Textarea {
94 96 self
95 97 }
96 98
99 /// See [`Input::line_box_height`].
100 pub fn line_box_height(mut self, height: Pixels) -> Self {
101 self.line_box_height = Some(height);
102 self
103 }
104
97 105 pub fn appearance(mut self, appearance: bool) -> Self {
98 106 self.appearance = appearance;
99 107 self
@@ -204,6 +212,9 @@ impl Textarea {
204 212 .role(self.role)
205 213 .with_size(self.size)
206 214 .when_some(self.height, |this, height| this.h(height))
215 .when_some(self.line_box_height, |this, height| {
216 this.line_box_height(height)
217 })
207 218 .when_some(self.accessibility_id, |this, id| this.accessibility_id(id))
208 219 .when_some(self.aria_label, |this, label| this.aria_label(label))
209 220 .when_some(self.context_menu_builder, |this, build| {
@@ -1,8 +1,8 @@
1use std::rc::Rc;
1use std::rc::Rc;
2
2
3use gpui::{
3use gpui::{
4 App, DefiniteLength, Entity, IntoElement, RenderOnce, SharedString, StyleRefinement, Styled,
4 App, DefiniteLength, Entity, IntoElement, Pixels, RenderOnce, SharedString, StyleRefinement,
5 Window, prelude::FluentBuilder as _,
5 Styled, Window, prelude::FluentBuilder as _,
6};
6};
7
7
8use super::{Input, TextareaState};
8use super::{Input, TextareaState};
@@ -19,6 +19,7 @@ pub struct Textarea {
19 style: StyleRefinement,
19 style: StyleRefinement,
20 size: Size,
20 size: Size,
21 height: Option<DefiniteLength>,
21 height: Option<DefiniteLength>,
22 line_box_height: Option<Pixels>,
22 appearance: bool,
23 appearance: bool,
23 bordered: bool,
24 bordered: bool,
24 disabled: bool,
25 disabled: bool,
@@ -73,6 +74,7 @@ impl Textarea {
73 style: StyleRefinement::default(),
74 style: StyleRefinement::default(),
74 size: Size::default(),
75 size: Size::default(),
75 height: None,
76 height: None,
77 line_box_height: None,
76 appearance: true,
78 appearance: true,
77 bordered: true,
79 bordered: true,
78 disabled: false,
80 disabled: false,
@@ -94,6 +96,12 @@ impl Textarea {
94 self
96 self
95 }
97 }
96
98
99 /// See [`Input::line_box_height`].
100 pub fn line_box_height(mut self, height: Pixels) -> Self {
101 self.line_box_height = Some(height);
102 self
103 }
104
97 pub fn appearance(mut self, appearance: bool) -> Self {
105 pub fn appearance(mut self, appearance: bool) -> Self {
98 self.appearance = appearance;
106 self.appearance = appearance;
99 self
107 self
@@ -204,6 +212,9 @@ impl Textarea {
204 .role(self.role)
212 .role(self.role)
205 .with_size(self.size)
213 .with_size(self.size)
206 .when_some(self.height, |this, height| this.h(height))
214 .when_some(self.height, |this, height| this.h(height))
215 .when_some(self.line_box_height, |this, height| {
216 this.line_box_height(height)
217 })
207 .when_some(self.accessibility_id, |this, id| this.accessibility_id(id))
218 .when_some(self.accessibility_id, |this, id| this.accessibility_id(id))
208 .when_some(self.aria_label, |this, label| this.aria_label(label))
219 .when_some(self.aria_label, |this, label| this.aria_label(label))
209 .when_some(self.context_menu_builder, |this, build| {
220 .when_some(self.context_menu_builder, |this, build| {