Checkboxes become the line toggle (forward keep authors, poll options)
Browse files at this commit3c05dfa13a14cf8e234e047b28dde9b4991507fbParent: 764cf77- style
- checkboxes become the line toggle (forward keep authors, poll options)
- selects sit on the underline frame (voice devices, builder log action)
6 changed files +66 -28
- crates/client/src/gui/builder/log.rs +7 -1
- crates/client/src/gui/composer.rs +16 -11
- crates/client/src/gui/forward.rs +8 -6
- crates/client/src/gui/parts.rs +15 -0
- crates/client/src/gui/voice_settings.rs +10 -10
- crates/client/src/gui/widget.rs +10 -0
crates/client/src/gui/builder/log.rsmodified+7 -1
| @@ -277,7 +277,13 @@ impl Yumush { | ||
| 277 | 277 | let filters = toolbar(vec![ |
| 278 | 278 | fixed(size::THUMB, field(palette, &self.chat.builder_log_actor)), |
| 279 | 279 | fixed(size::THUMB, field(palette, &self.chat.builder_log_target)), |
| 280 | - fixed(size::THUMB, Select::new(&self.chat.builder_log_action)), | |
| 280 | + fixed( | |
| 281 | + size::THUMB, | |
| 282 | + crate::gui::widget::underline( | |
| 283 | + palette, | |
| 284 | + Select::new(&self.chat.builder_log_action).appearance(false), | |
| 285 | + ), | |
| 286 | + ), | |
| 281 | 287 | fixed(size::THUMB, field(palette, &self.chat.builder_log_from)), |
| 282 | 288 | fixed(size::THUMB, field(palette, &self.chat.builder_log_to)), |
| 283 | 289 | accent_button( |
crates/client/src/gui/composer.rsmodified+16 -11
| @@ -21,7 +21,6 @@ use gpui_kit::{ | ||
| 21 | 21 | assets::IconName, |
| 22 | 22 | component::{ |
| 23 | 23 | Icon, WindowExt, |
| 24 | - checkbox::Checkbox, | |
| 25 | 24 | input::{InputEvent, InputState, TextareaState}, |
| 26 | 25 | notification::Notification, |
| 27 | 26 | popover::Popover, |
| @@ -756,24 +755,30 @@ pub fn plus_popover(chat: &Chat, entity: &Entity<Yumush>, palette: Palette) -> i | ||
| 756 | 755 | .items_center() |
| 757 | 756 | .gap(px(space::MD)) |
| 758 | 757 | .child( |
| 759 | - Checkbox::new("poll_multiple") | |
| 760 | - .label(w().composer.multiple_answers) | |
| 761 | - .checked(multiple) | |
| 762 | - .on_click(move |_, _, cx| { | |
| 758 | + super::parts::labeled_toggle( | |
| 759 | + "poll_multiple", | |
| 760 | + w().composer.multiple_answers, | |
| 761 | + multiple, | |
| 762 | + palette.tokens, | |
| 763 | + move |_, cx| { | |
| 763 | 764 | toggle.update(cx, |yumush, cx| { |
| 764 | 765 | yumush.chat.poll_multiple = !yumush.chat.poll_multiple; |
| 765 | 766 | cx.notify(); |
| 766 | 767 | }) |
| 767 | - }), | |
| 768 | + }, | |
| 769 | + ), | |
| 768 | 770 | ) |
| 769 | 771 | .child( |
| 770 | - Checkbox::new("poll_public") | |
| 771 | - .label(w().composer.show_voters) | |
| 772 | - .checked(public) | |
| 773 | - .on_click(move |_, _, cx| { | |
| 772 | + super::parts::labeled_toggle( | |
| 773 | + "poll_public", | |
| 774 | + w().composer.show_voters, | |
| 775 | + public, | |
| 776 | + palette.tokens, | |
| 777 | + move |_, cx| { | |
| 774 | 778 | toggle_public |
| 775 | 779 | .update(cx, |yumush, cx| yumush.toggle_poll_public(cx)) |
| 776 | - }), | |
| 780 | + }, | |
| 781 | + ), | |
| 777 | 782 | ), |
| 778 | 783 | ), |
| 779 | 784 | ) |
crates/client/src/gui/forward.rsmodified+8 -6
| @@ -7,7 +7,6 @@ use gpui_kit::{ | ||
| 7 | 7 | StatefulInteractiveElement, Styled, Window, |
| 8 | 8 | component::{ |
| 9 | 9 | WindowExt, |
| 10 | - checkbox::Checkbox, | |
| 11 | 10 | input::{InputEvent, InputState}, |
| 12 | 11 | }, |
| 13 | 12 | div, px, |
| @@ -110,15 +109,18 @@ impl Render for Forward { | ||
| 110 | 109 | .gap(px(space::MD)) |
| 111 | 110 | .child(compact_field(palette, &self.filter)) |
| 112 | 111 | .child( |
| 113 | - Checkbox::new("keep_authors") | |
| 114 | - .label(w().forward.keep_authors) | |
| 115 | - .checked(keep_authors) | |
| 116 | - .on_click(move |_, _, cx| { | |
| 112 | + super::parts::labeled_toggle( | |
| 113 | + "keep_authors", | |
| 114 | + w().forward.keep_authors, | |
| 115 | + keep_authors, | |
| 116 | + palette.tokens, | |
| 117 | + move |_, cx| { | |
| 117 | 118 | entity.update(cx, |this, cx| { |
| 118 | 119 | this.keep_authors = !this.keep_authors; |
| 119 | 120 | cx.notify(); |
| 120 | 121 | }); |
| 121 | - }), | |
| 122 | + }, | |
| 123 | + ), | |
| 122 | 124 | ) |
| 123 | 125 | .child( |
| 124 | 126 | div() |
crates/client/src/gui/parts.rsmodified+15 -0
| @@ -148,6 +148,21 @@ pub fn track(fill: Fill, bad: bool, t: Tokens) -> Div { | ||
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | +pub fn labeled_toggle( | |
| 152 | + id: impl Into<ElementId>, | |
| 153 | + label: &'static str, | |
| 154 | + on: bool, | |
| 155 | + t: Tokens, | |
| 156 | + flip: impl Fn(&mut Window, &mut App) + 'static, | |
| 157 | +) -> Div { | |
| 158 | + div() | |
| 159 | + .flex() | |
| 160 | + .items_center() | |
| 161 | + .gap(px(space::SM)) | |
| 162 | + .child(words(label, Text::Caption, Ink::Dim, t)) | |
| 163 | + .child(toggle(id, on, t, flip)) | |
| 164 | +} | |
| 165 | + | |
| 151 | 166 | pub fn toggle( |
| 152 | 167 | id: impl Into<ElementId>, |
| 153 | 168 | on: bool, |
crates/client/src/gui/voice_settings.rsmodified+10 -10
| @@ -239,19 +239,19 @@ impl Yumush { | ||
| 239 | 239 | let mut rows = vec![ |
| 240 | 240 | row( |
| 241 | 241 | w().voice_settings.input_device, |
| 242 | - div().child( | |
| 243 | - Select::new(&controls.inputs) | |
| 244 | - .appearance(false) | |
| 245 | - .w(px(size::SIDEBAR)), | |
| 246 | - ), | |
| 242 | + super::widget::underline( | |
| 243 | + palette, | |
| 244 | + Select::new(&controls.inputs).appearance(false), | |
| 245 | + ) | |
| 246 | + .w(px(size::SIDEBAR)), | |
| 247 | 247 | ), |
| 248 | 248 | row( |
| 249 | 249 | w().voice_settings.output_device, |
| 250 | - div().child( | |
| 251 | - Select::new(&controls.outputs) | |
| 252 | - .appearance(false) | |
| 253 | - .w(px(size::SIDEBAR)), | |
| 254 | - ), | |
| 250 | + super::widget::underline( | |
| 251 | + palette, | |
| 252 | + Select::new(&controls.outputs).appearance(false), | |
| 253 | + ) | |
| 254 | + .w(px(size::SIDEBAR)), | |
| 255 | 255 | ), |
| 256 | 256 | row( |
| 257 | 257 | w().voice_settings.input_volume, |
crates/client/src/gui/widget.rsmodified+10 -0
| @@ -66,6 +66,16 @@ pub(super) fn frame(palette: Palette, input: Input) -> Div { | ||
| 66 | 66 | .child(bare_input(palette, input)) |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | +pub(super) fn underline(palette: Palette, child: impl gpui_kit::IntoElement) -> Div { | |
| 70 | + div() | |
| 71 | + .h(px(size::CONTROL)) | |
| 72 | + .flex() | |
| 73 | + .items_center() | |
| 74 | + .border_b_1() | |
| 75 | + .border_color(palette.border) | |
| 76 | + .child(div().flex_1().min_w_0().child(child)) | |
| 77 | +} | |
| 78 | + | |
| 69 | 79 | pub(super) fn bare_input(palette: Palette, input: Input) -> Input { |
| 70 | 80 | input |
| 71 | 81 | .appearance(false) |