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 | let filters = toolbar(vec![ | 277 | let filters = toolbar(vec![ |
| 278 | fixed(size::THUMB, field(palette, &self.chat.builder_log_actor)), | 278 | fixed(size::THUMB, field(palette, &self.chat.builder_log_actor)), |
| 279 | fixed(size::THUMB, field(palette, &self.chat.builder_log_target)), | 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 | fixed(size::THUMB, field(palette, &self.chat.builder_log_from)), | 287 | fixed(size::THUMB, field(palette, &self.chat.builder_log_from)), |
| 282 | fixed(size::THUMB, field(palette, &self.chat.builder_log_to)), | 288 | fixed(size::THUMB, field(palette, &self.chat.builder_log_to)), |
| 283 | accent_button( | 289 | accent_button( |
crates/client/src/gui/composer.rsmodified+16 -11
| @@ -21,7 +21,6 @@ use gpui_kit::{ | |||
| 21 | assets::IconName, | 21 | assets::IconName, |
| 22 | component::{ | 22 | component::{ |
| 23 | Icon, WindowExt, | 23 | Icon, WindowExt, |
| 24 | - checkbox::Checkbox, | ||
| 25 | input::{InputEvent, InputState, TextareaState}, | 24 | input::{InputEvent, InputState, TextareaState}, |
| 26 | notification::Notification, | 25 | notification::Notification, |
| 27 | popover::Popover, | 26 | popover::Popover, |
| @@ -756,24 +755,30 @@ pub fn plus_popover(chat: &Chat, entity: &Entity<Yumush>, palette: Palette) -> i | |||
| 756 | .items_center() | 755 | .items_center() |
| 757 | .gap(px(space::MD)) | 756 | .gap(px(space::MD)) |
| 758 | .child( | 757 | .child( |
| 759 | - Checkbox::new("poll_multiple") | 758 | + super::parts::labeled_toggle( |
| 760 | - .label(w().composer.multiple_answers) | 759 | + "poll_multiple", |
| 761 | - .checked(multiple) | 760 | + w().composer.multiple_answers, |
| 762 | - .on_click(move |_, _, cx| { | 761 | + multiple, |
| 762 | + palette.tokens, | ||
| 763 | + move |_, cx| { | ||
| 763 | toggle.update(cx, |yumush, cx| { | 764 | toggle.update(cx, |yumush, cx| { |
| 764 | yumush.chat.poll_multiple = !yumush.chat.poll_multiple; | 765 | yumush.chat.poll_multiple = !yumush.chat.poll_multiple; |
| 765 | cx.notify(); | 766 | cx.notify(); |
| 766 | }) | 767 | }) |
| 767 | - }), | 768 | + }, |
| 769 | + ), | ||
| 768 | ) | 770 | ) |
| 769 | .child( | 771 | .child( |
| 770 | - Checkbox::new("poll_public") | 772 | + super::parts::labeled_toggle( |
| 771 | - .label(w().composer.show_voters) | 773 | + "poll_public", |
| 772 | - .checked(public) | 774 | + w().composer.show_voters, |
| 773 | - .on_click(move |_, _, cx| { | 775 | + public, |
| 776 | + palette.tokens, | ||
| 777 | + move |_, cx| { | ||
| 774 | toggle_public | 778 | toggle_public |
| 775 | .update(cx, |yumush, cx| yumush.toggle_poll_public(cx)) | 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 | StatefulInteractiveElement, Styled, Window, | 7 | StatefulInteractiveElement, Styled, Window, |
| 8 | component::{ | 8 | component::{ |
| 9 | WindowExt, | 9 | WindowExt, |
| 10 | - checkbox::Checkbox, | ||
| 11 | input::{InputEvent, InputState}, | 10 | input::{InputEvent, InputState}, |
| 12 | }, | 11 | }, |
| 13 | div, px, | 12 | div, px, |
| @@ -110,15 +109,18 @@ impl Render for Forward { | |||
| 110 | .gap(px(space::MD)) | 109 | .gap(px(space::MD)) |
| 111 | .child(compact_field(palette, &self.filter)) | 110 | .child(compact_field(palette, &self.filter)) |
| 112 | .child( | 111 | .child( |
| 113 | - Checkbox::new("keep_authors") | 112 | + super::parts::labeled_toggle( |
| 114 | - .label(w().forward.keep_authors) | 113 | + "keep_authors", |
| 115 | - .checked(keep_authors) | 114 | + w().forward.keep_authors, |
| 116 | - .on_click(move |_, _, cx| { | 115 | + keep_authors, |
| 116 | + palette.tokens, | ||
| 117 | + move |_, cx| { | ||
| 117 | entity.update(cx, |this, cx| { | 118 | entity.update(cx, |this, cx| { |
| 118 | this.keep_authors = !this.keep_authors; | 119 | this.keep_authors = !this.keep_authors; |
| 119 | cx.notify(); | 120 | cx.notify(); |
| 120 | }); | 121 | }); |
| 121 | - }), | 122 | + }, |
| 123 | + ), | ||
| 122 | ) | 124 | ) |
| 123 | .child( | 125 | .child( |
| 124 | div() | 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 | pub fn toggle( | 166 | pub fn toggle( |
| 152 | id: impl Into<ElementId>, | 167 | id: impl Into<ElementId>, |
| 153 | on: bool, | 168 | on: bool, |
crates/client/src/gui/voice_settings.rsmodified+10 -10
| @@ -239,19 +239,19 @@ impl Yumush { | |||
| 239 | let mut rows = vec![ | 239 | let mut rows = vec![ |
| 240 | row( | 240 | row( |
| 241 | w().voice_settings.input_device, | 241 | w().voice_settings.input_device, |
| 242 | - div().child( | 242 | + super::widget::underline( |
| 243 | - Select::new(&controls.inputs) | 243 | + palette, |
| 244 | - .appearance(false) | 244 | + Select::new(&controls.inputs).appearance(false), |
| 245 | - .w(px(size::SIDEBAR)), | 245 | + ) |
| 246 | - ), | 246 | + .w(px(size::SIDEBAR)), |
| 247 | ), | 247 | ), |
| 248 | row( | 248 | row( |
| 249 | w().voice_settings.output_device, | 249 | w().voice_settings.output_device, |
| 250 | - div().child( | 250 | + super::widget::underline( |
| 251 | - Select::new(&controls.outputs) | 251 | + palette, |
| 252 | - .appearance(false) | 252 | + Select::new(&controls.outputs).appearance(false), |
| 253 | - .w(px(size::SIDEBAR)), | 253 | + ) |
| 254 | - ), | 254 | + .w(px(size::SIDEBAR)), |
| 255 | ), | 255 | ), |
| 256 | row( | 256 | row( |
| 257 | w().voice_settings.input_volume, | 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 | .child(bare_input(palette, input)) | 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 | pub(super) fn bare_input(palette: Palette, input: Input) -> Input { | 79 | pub(super) fn bare_input(palette: Palette, input: Input) -> Input { |
| 70 | input | 80 | input |
| 71 | .appearance(false) | 81 | .appearance(false) |