Merge branch 'fix/composer-toolbar' into feat/appearance-themes
@@ -16,16 +16,14 @@ pub const PREVIEW_MAX_LINES: usize = 2;
16
16
pub const TOAST_PADDING: f32 = 12.;
17
17
pub const AVATAR_SIZE: f32 = 40.;
18
18
pub const AVATAR_GAP: f32 = 12.;
19
pub const MENTION_BORDER: f32 = 2.;
20
pub const PREVIEW_WIDTH: f32 =
21
TOAST_WIDTH - 2. * (TOAST_PADDING + MENTION_BORDER) - AVATAR_SIZE - AVATAR_GAP;
19
pub const PREVIEW_WIDTH: f32 = TOAST_WIDTH - 2. * TOAST_PADDING - AVATAR_SIZE - AVATAR_GAP;
22
20
const ACTION_ROW_SPACING: f32 = 4.;
23
21
const REPLY_FIELD_FRAME: f32 = 14.;
24
22
const REPLY_HINT_ROW: f32 = 20.;
25
23
const REPLY_SPACING: f32 = 8.;
26
24
const CONFIRM_HEIGHT: f32 = 56.;
27
25
const AGENT_CHROME_HEIGHT: f32 = 116.;
28
pub const AGENT_BODY_WIDTH: f32 = TOAST_WIDTH - 2. * TOAST_PADDING - 2.;
26
pub const AGENT_BODY_WIDTH: f32 = TOAST_WIDTH - 2. * TOAST_PADDING;
29
27
const RING_BASE_HEIGHT: f32 = 120.;
30
28
pub const MEETING_HEIGHT: f32 = 112.;
31
29
const RING_NOTE_HEIGHT: f32 = 18.;
@@ -16,16 +16,14 @@ pub const PREVIEW_MAX_LINES: usize = 2;16
pub const TOAST_PADDING: f32 = 12.;16
pub const TOAST_PADDING: f32 = 12.;17
pub const AVATAR_SIZE: f32 = 40.;17
pub const AVATAR_SIZE: f32 = 40.;18
pub const AVATAR_GAP: f32 = 12.;18
pub const AVATAR_GAP: f32 = 12.;19
pub const MENTION_BORDER: f32 = 2.;19
pub const PREVIEW_WIDTH: f32 = TOAST_WIDTH - 2. * TOAST_PADDING - AVATAR_SIZE - AVATAR_GAP;20
pub const PREVIEW_WIDTH: f32 =21
TOAST_WIDTH - 2. * (TOAST_PADDING + MENTION_BORDER) - AVATAR_SIZE - AVATAR_GAP;22
const ACTION_ROW_SPACING: f32 = 4.;20
const ACTION_ROW_SPACING: f32 = 4.;23
const REPLY_FIELD_FRAME: f32 = 14.;21
const REPLY_FIELD_FRAME: f32 = 14.;24
const REPLY_HINT_ROW: f32 = 20.;22
const REPLY_HINT_ROW: f32 = 20.;25
const REPLY_SPACING: f32 = 8.;23
const REPLY_SPACING: f32 = 8.;26
const CONFIRM_HEIGHT: f32 = 56.;24
const CONFIRM_HEIGHT: f32 = 56.;27
const AGENT_CHROME_HEIGHT: f32 = 116.;25
const AGENT_CHROME_HEIGHT: f32 = 116.;28
pub const AGENT_BODY_WIDTH: f32 = TOAST_WIDTH - 2. * TOAST_PADDING - 2.;26
pub const AGENT_BODY_WIDTH: f32 = TOAST_WIDTH - 2. * TOAST_PADDING;29
const RING_BASE_HEIGHT: f32 = 120.;27
const RING_BASE_HEIGHT: f32 = 120.;30
pub const MEETING_HEIGHT: f32 = 112.;28
pub const MEETING_HEIGHT: f32 = 112.;31
const RING_NOTE_HEIGHT: f32 = 18.;29
const RING_NOTE_HEIGHT: f32 = 18.;@@ -176,8 +176,8 @@ 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::conversation::MEMBERS_BUTTON;
180
179
use crate::views::composer::{COMPOSER_BOX_TAG, COMPOSER_LEADING_TAG, COMPOSER_SEND_TAG};
180
use crate::views::conversation::MEMBERS_BUTTON;
181
181
use crate::views::message_row::BUBBLE_TAGS;
182
182
use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};
183
183
use crate::views::reaction_proposal_pill::REACTION_PILL;
@@ -1318,28 +1318,13 @@ const OUTLINE_ALLOWLIST: &[(&str, &str, &str)] = &[
1318
1318
(
1319
1319
"notify/ring_view.rs",
1320
1320
"theme::green()",
1321
"OS toast window: no compositor shadow, the edge separates it from the desktop; accent = Teams state",
1322
),
1323
(
1324
"notify/meeting_view.rs",
1325
"theme::accent()",
1326
"OS toast window: no compositor shadow, the edge separates it from the desktop; accent = Teams state",
1321
"state signal (pulsing ring around the caller while it rings), not a resting outline",
1327
1322
),
1328
1323
(
1329
1324
"notify/meeting_view.rs",
1330
1325
"theme::border_strong()",
1331
1326
"outlined button, not a surface",
1332
1327
),
1333
(
1334
"notify/toast.rs",
1335
"border)",
1336
"OS toast window: no compositor shadow, the edge separates it from the desktop; accent = Teams state",
1337
),
1338
(
1339
"notify/toast.rs",
1340
"theme::border_strong()",
1341
"OS toast window: no compositor shadow, the edge separates it from the desktop; accent = Teams state",
1342
),
1343
1328
(
1344
1329
"settings/mcp.rs",
1345
1330
"theme::border_strong()",
@@ -176,8 +176,8 @@ 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::conversation::MEMBERS_BUTTON;180
use crate::views::composer::{COMPOSER_BOX_TAG, COMPOSER_LEADING_TAG, COMPOSER_SEND_TAG};179
use crate::views::composer::{COMPOSER_BOX_TAG, COMPOSER_LEADING_TAG, COMPOSER_SEND_TAG};180
use crate::views::conversation::MEMBERS_BUTTON;181
use crate::views::message_row::BUBBLE_TAGS;181
use crate::views::message_row::BUBBLE_TAGS;182
use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};182
use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};183
use crate::views::reaction_proposal_pill::REACTION_PILL;183
use crate::views::reaction_proposal_pill::REACTION_PILL;@@ -1318,28 +1318,13 @@ const OUTLINE_ALLOWLIST: &[(&str, &str, &str)] = &[1318
(1318
(1319
"notify/ring_view.rs",1319
"notify/ring_view.rs",1320
"theme::green()",1320
"theme::green()",1321
"OS toast window: no compositor shadow, the edge separates it from the desktop; accent = Teams state",1321
"state signal (pulsing ring around the caller while it rings), not a resting outline",1322
),1323
(1324
"notify/meeting_view.rs",1325
"theme::accent()",1326
"OS toast window: no compositor shadow, the edge separates it from the desktop; accent = Teams state",1327
),1322
),1328
(1323
(1329
"notify/meeting_view.rs",1324
"notify/meeting_view.rs",1330
"theme::border_strong()",1325
"theme::border_strong()",1331
"outlined button, not a surface",1326
"outlined button, not a surface",1332
),1327
),1333
(1334
"notify/toast.rs",1335
"border)",1336
"OS toast window: no compositor shadow, the edge separates it from the desktop; accent = Teams state",1337
),1338
(1339
"notify/toast.rs",1340
"theme::border_strong()",1341
"OS toast window: no compositor shadow, the edge separates it from the desktop; accent = Teams state",1342
),1343
(1328
(1344
"settings/mcp.rs",1329
"settings/mcp.rs",1345
"theme::border_strong()",1330
"theme::border_strong()",@@ -6,7 +6,7 @@ use gpui_kit::*;
6
6
7
7
use super::center::NotificationCenter;
8
8
use super::layout::{AVATAR_GAP, TOAST_PADDING};
9
use super::ring_view::{RING_AVATAR, RING_BORDER, TOAST_RADIUS, answer_button};
9
use super::ring_view::{RING_AVATAR, TOAST_RADIUS, answer_button};
10
10
use crate::app_state::AppState;
11
11
use crate::call::ReminderPhase;
12
12
use crate::call::meeting_subtitle;
@@ -45,10 +45,7 @@ impl MeetingToastView {
45
45
impl Render for MeetingToastView {
46
46
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
47
47
let Some(toast) = self.app.read(cx).meeting_toasts.get(self.toast_id).cloned() else {
48
return div()
49
.size_full()
50
.bg(theme::surface_raised())
51
.into_any_element();
48
return div().size_full().bg(theme::popup()).into_any_element();
52
49
};
53
50
window.set_window_title(&toast.subject);
54
51
let subtitle = meeting_subtitle(&toast, Utc::now(), Local::now().offset().fix());
@@ -60,7 +57,7 @@ impl Render for MeetingToastView {
60
57
"meeting-snooze",
61
58
"Snooze",
62
59
IconName::AlarmClock,
63
theme::surface_raised(),
60
theme::popup(),
64
61
)
65
62
.border_1()
66
63
.border_color(theme::border_strong())
@@ -102,9 +99,7 @@ impl Render for MeetingToastView {
102
99
.id(("meeting-toast", toast_id))
103
100
.size_full()
104
101
.rounded(px(TOAST_RADIUS))
105
.bg(theme::surface_raised())
106
.border(px(RING_BORDER))
107
.border_color(theme::accent())
102
.bg(theme::popup())
108
103
.overflow_hidden()
109
104
.child(
110
105
div().size_full().p(px(TOAST_PADDING)).child(
@@ -6,7 +6,7 @@ use gpui_kit::*;6
6
7
use super::center::NotificationCenter;7
use super::center::NotificationCenter;8
use super::layout::{AVATAR_GAP, TOAST_PADDING};8
use super::layout::{AVATAR_GAP, TOAST_PADDING};9
use super::ring_view::{RING_AVATAR, RING_BORDER, TOAST_RADIUS, answer_button};9
use super::ring_view::{RING_AVATAR, TOAST_RADIUS, answer_button};10
use crate::app_state::AppState;10
use crate::app_state::AppState;11
use crate::call::ReminderPhase;11
use crate::call::ReminderPhase;12
use crate::call::meeting_subtitle;12
use crate::call::meeting_subtitle;@@ -45,10 +45,7 @@ impl MeetingToastView {45
impl Render for MeetingToastView {45
impl Render for MeetingToastView {46
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {46
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {47
let Some(toast) = self.app.read(cx).meeting_toasts.get(self.toast_id).cloned() else {47
let Some(toast) = self.app.read(cx).meeting_toasts.get(self.toast_id).cloned() else {48
return div()48
return div().size_full().bg(theme::popup()).into_any_element();49
.size_full()50
.bg(theme::surface_raised())51
.into_any_element();52
};49
};53
window.set_window_title(&toast.subject);50
window.set_window_title(&toast.subject);54
let subtitle = meeting_subtitle(&toast, Utc::now(), Local::now().offset().fix());51
let subtitle = meeting_subtitle(&toast, Utc::now(), Local::now().offset().fix());@@ -60,7 +57,7 @@ impl Render for MeetingToastView {60
"meeting-snooze",57
"meeting-snooze",61
"Snooze",58
"Snooze",62
IconName::AlarmClock,59
IconName::AlarmClock,63
theme::surface_raised(),60
theme::popup(),64
)61
)65
.border_1()62
.border_1()66
.border_color(theme::border_strong())63
.border_color(theme::border_strong())@@ -102,9 +99,7 @@ impl Render for MeetingToastView {102
.id(("meeting-toast", toast_id))99
.id(("meeting-toast", toast_id))103
.size_full()100
.size_full()104
.rounded(px(TOAST_RADIUS))101
.rounded(px(TOAST_RADIUS))105
.bg(theme::surface_raised())102
.bg(theme::popup())106
.border(px(RING_BORDER))107
.border_color(theme::accent())108
.overflow_hidden()103
.overflow_hidden()109
.child(104
.child(110
div().size_full().p(px(TOAST_PADDING)).child(105
div().size_full().p(px(TOAST_PADDING)).child(@@ -14,7 +14,6 @@ use crate::views::call_view::pulsing;
14
14
use crate::views::widgets::icon;
15
15
16
16
pub const RING_AVATAR: f32 = 56.;
17
pub(super) const RING_BORDER: f32 = 2.;
18
17
const RING_WIDTH: f32 = 3.;
19
18
const RING_GAP: f32 = 3.;
20
19
pub(super) const TOAST_RADIUS: f32 = 12.;
@@ -84,10 +83,7 @@ impl Render for RingView {
84
83
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
85
84
let state = self.app.read(cx);
86
85
let Some(entry) = state.rings.get(self.ring_id).cloned() else {
87
return div()
88
.size_full()
89
.bg(theme::surface_raised())
90
.into_any_element();
86
return div().size_full().bg(theme::popup()).into_any_element();
91
87
};
92
88
window.set_window_title(&format!("{}: {}", entry.caller_name(), entry.subtitle()));
93
89
let ends_current = state.call.is_some();
@@ -131,9 +127,7 @@ impl Render for RingView {
131
127
.id(("ring", ring_id))
132
128
.size_full()
133
129
.rounded(px(TOAST_RADIUS))
134
.bg(theme::surface_raised())
135
.border(px(RING_BORDER))
136
.border_color(theme::green())
130
.bg(theme::popup())
137
131
.overflow_hidden()
138
132
.child(
139
133
div().size_full().p(px(TOAST_PADDING)).child(
@@ -14,7 +14,6 @@ use crate::views::call_view::pulsing;14
use crate::views::widgets::icon;14
use crate::views::widgets::icon;15
15
16
pub const RING_AVATAR: f32 = 56.;16
pub const RING_AVATAR: f32 = 56.;17
pub(super) const RING_BORDER: f32 = 2.;18
const RING_WIDTH: f32 = 3.;17
const RING_WIDTH: f32 = 3.;19
const RING_GAP: f32 = 3.;18
const RING_GAP: f32 = 3.;20
pub(super) const TOAST_RADIUS: f32 = 12.;19
pub(super) const TOAST_RADIUS: f32 = 12.;@@ -84,10 +83,7 @@ impl Render for RingView {84
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {83
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {85
let state = self.app.read(cx);84
let state = self.app.read(cx);86
let Some(entry) = state.rings.get(self.ring_id).cloned() else {85
let Some(entry) = state.rings.get(self.ring_id).cloned() else {87
return div()86
return div().size_full().bg(theme::popup()).into_any_element();88
.size_full()89
.bg(theme::surface_raised())90
.into_any_element();91
};87
};92
window.set_window_title(&format!("{}: {}", entry.caller_name(), entry.subtitle()));88
window.set_window_title(&format!("{}: {}", entry.caller_name(), entry.subtitle()));93
let ends_current = state.call.is_some();89
let ends_current = state.call.is_some();@@ -131,9 +127,7 @@ impl Render for RingView {131
.id(("ring", ring_id))127
.id(("ring", ring_id))132
.size_full()128
.size_full()133
.rounded(px(TOAST_RADIUS))129
.rounded(px(TOAST_RADIUS))134
.bg(theme::surface_raised())130
.bg(theme::popup())135
.border(px(RING_BORDER))136
.border_color(theme::green())137
.overflow_hidden()131
.overflow_hidden()138
.child(132
.child(139
div().size_full().p(px(TOAST_PADDING)).child(133
div().size_full().p(px(TOAST_PADDING)).child(@@ -11,8 +11,8 @@ use gpui_kit::*;
11
11
use super::agent_toast::agent_toast_content;
12
12
use super::center::NotificationCenter;
13
13
use super::layout::{
14
ACTION_BUTTON, AVATAR_GAP, AVATAR_SIZE, MENTION_BORDER, PREVIEW_MAX_LINES, PREVIEW_SIZE,
15
SEND_BUTTON, TOAST_PADDING,
14
ACTION_BUTTON, AVATAR_GAP, AVATAR_SIZE, PREVIEW_MAX_LINES, PREVIEW_SIZE, SEND_BUTTON,
15
TOAST_PADDING,
16
16
};
17
17
use super::platform;
18
18
use super::rules::ChatKind;
@@ -488,10 +488,7 @@ impl Render for ToastView {
488
488
(center.model(id).cloned(), center.settings().preview)
489
489
};
490
490
let Some(model) = model else {
491
return div()
492
.size_full()
493
.bg(theme::surface_raised())
494
.into_any_element();
491
return div().size_full().bg(theme::popup()).into_any_element();
495
492
};
496
493
let text = describe(&model, preview_on);
497
494
let narration = model
@@ -506,14 +503,8 @@ impl Render for ToastView {
506
503
let fill = if mention {
507
504
theme::toast_mention_fill()
508
505
} else {
509
theme::surface_raised()
510
};
511
let border = if mention {
512
theme::accent()
513
} else {
514
theme::border_strong()
506
theme::popup()
515
507
};
516
let border_width = if mention { MENTION_BORDER } else { 1. };
517
508
let hovered = model.hovered;
518
509
let content = match model.reply {
519
510
_ if model.agent.is_some() => {
@@ -554,8 +545,6 @@ impl Render for ToastView {
554
545
.opacity(model.opacity(Instant::now()))
555
546
.rounded(px(TOAST_RADIUS))
556
547
.bg(fill)
557
.border(px(border_width))
558
.border_color(border)
559
548
.overflow_hidden()
560
549
.cursor_pointer()
561
550
.on_hover(move |is_hovered, _, cx| {
@@ -611,11 +600,9 @@ impl Render for PillView {
611
600
.justify_center()
612
601
.opacity(opacity)
613
602
.rounded(px(TOAST_RADIUS))
614
.bg(theme::surface_raised())
615
.border_1()
616
.border_color(theme::border_strong())
603
.bg(theme::popup())
617
604
.cursor_pointer()
618
.hover(|bar| bar.bg(theme::border_strong()))
605
.hover(|bar| bar.bg(theme::popup_hover()))
619
606
.text_size(px(12.5))
620
607
.font_weight(FontWeight::SEMIBOLD)
621
608
.text_color(theme::text_soft())
@@ -640,9 +627,9 @@ mod tests {
640
627
641
628
use gpui_kit::component::input::{Textarea, TextareaState};
642
629
use gpui_kit::{
643
AppContext as _, Context, Entity, Focusable as _, InteractiveElement as _, IntoElement, Modifiers,
644
ParentElement as _, Render, StatefulInteractiveElement as _, Styled as _, TestAppContext,
645
Window, div, point, px,
630
AppContext as _, Context, Entity, Focusable as _, InteractiveElement as _, IntoElement,
631
Modifiers, ParentElement as _, Render, StatefulInteractiveElement as _, Styled as _,
632
TestAppContext, Window, div, point, px,
646
633
};
647
634
648
635
use super::keep_clicks_in_toast;
@@ -11,8 +11,8 @@ use gpui_kit::*;11
use super::agent_toast::agent_toast_content;11
use super::agent_toast::agent_toast_content;12
use super::center::NotificationCenter;12
use super::center::NotificationCenter;13
use super::layout::{13
use super::layout::{14
ACTION_BUTTON, AVATAR_GAP, AVATAR_SIZE, MENTION_BORDER, PREVIEW_MAX_LINES, PREVIEW_SIZE,14
ACTION_BUTTON, AVATAR_GAP, AVATAR_SIZE, PREVIEW_MAX_LINES, PREVIEW_SIZE, SEND_BUTTON,15
SEND_BUTTON, TOAST_PADDING,15
TOAST_PADDING,16
};16
};17
use super::platform;17
use super::platform;18
use super::rules::ChatKind;18
use super::rules::ChatKind;@@ -488,10 +488,7 @@ impl Render for ToastView {488
(center.model(id).cloned(), center.settings().preview)488
(center.model(id).cloned(), center.settings().preview)489
};489
};490
let Some(model) = model else {490
let Some(model) = model else {491
return div()491
return div().size_full().bg(theme::popup()).into_any_element();492
.size_full()493
.bg(theme::surface_raised())494
.into_any_element();495
};492
};496
let text = describe(&model, preview_on);493
let text = describe(&model, preview_on);497
let narration = model494
let narration = model@@ -506,14 +503,8 @@ impl Render for ToastView {506
let fill = if mention {503
let fill = if mention {507
theme::toast_mention_fill()504
theme::toast_mention_fill()508
} else {505
} else {509
theme::surface_raised()506
theme::popup()510
};511
let border = if mention {512
theme::accent()513
} else {514
theme::border_strong()515
};507
};516
let border_width = if mention { MENTION_BORDER } else { 1. };517
let hovered = model.hovered;508
let hovered = model.hovered;518
let content = match model.reply {509
let content = match model.reply {519
_ if model.agent.is_some() => {510
_ if model.agent.is_some() => {@@ -554,8 +545,6 @@ impl Render for ToastView {554
.opacity(model.opacity(Instant::now()))545
.opacity(model.opacity(Instant::now()))555
.rounded(px(TOAST_RADIUS))546
.rounded(px(TOAST_RADIUS))556
.bg(fill)547
.bg(fill)557
.border(px(border_width))558
.border_color(border)559
.overflow_hidden()548
.overflow_hidden()560
.cursor_pointer()549
.cursor_pointer()561
.on_hover(move |is_hovered, _, cx| {550
.on_hover(move |is_hovered, _, cx| {@@ -611,11 +600,9 @@ impl Render for PillView {611
.justify_center()600
.justify_center()612
.opacity(opacity)601
.opacity(opacity)613
.rounded(px(TOAST_RADIUS))602
.rounded(px(TOAST_RADIUS))614
.bg(theme::surface_raised())603
.bg(theme::popup())615
.border_1()616
.border_color(theme::border_strong())617
.cursor_pointer()604
.cursor_pointer()618
.hover(|bar| bar.bg(theme::border_strong()))605
.hover(|bar| bar.bg(theme::popup_hover()))619
.text_size(px(12.5))606
.text_size(px(12.5))620
.font_weight(FontWeight::SEMIBOLD)607
.font_weight(FontWeight::SEMIBOLD)621
.text_color(theme::text_soft())608
.text_color(theme::text_soft())@@ -640,9 +627,9 @@ mod tests {640
627
641
use gpui_kit::component::input::{Textarea, TextareaState};628
use gpui_kit::component::input::{Textarea, TextareaState};642
use gpui_kit::{629
use gpui_kit::{643
AppContext as _, Context, Entity, Focusable as _, InteractiveElement as _, IntoElement, Modifiers,630
AppContext as _, Context, Entity, Focusable as _, InteractiveElement as _, IntoElement,644
ParentElement as _, Render, StatefulInteractiveElement as _, Styled as _, TestAppContext,631
Modifiers, ParentElement as _, Render, StatefulInteractiveElement as _, Styled as _,645
Window, div, point, px,632
TestAppContext, Window, div, point, px,646
};633
};647
634
648
use super::keep_clicks_in_toast;635
use super::keep_clicks_in_toast;@@ -947,6 +947,10 @@ impl Composer {
947
947
FormatButton::Bulleted => self.toggle_lines(LineKind::Bullet(0), window, cx),
948
948
FormatButton::Numbered => self.toggle_lines(LineKind::Numbered(0), window, cx),
949
949
FormatButton::Quote => self.toggle_lines(LineKind::Quote, window, cx),
950
FormatButton::Table => {
951
self.toolbar_dismissed = Some(self.selection(cx));
952
self.open_table_picker(cx);
953
}
950
954
}
951
955
}
952
956
@@ -967,6 +971,8 @@ impl Composer {
967
971
FormatButton::Bulleted => self.draft.line_state(range, &LineKind::Bullet(0)),
968
972
FormatButton::Numbered => self.draft.line_state(range, &LineKind::Numbered(0)),
969
973
FormatButton::Quote => self.draft.line_state(range, &LineKind::Quote),
974
FormatButton::Table if self.table_picker.is_some() => FormatState::On,
975
FormatButton::Table => FormatState::Off,
970
976
}
971
977
}
972
978
@@ -2573,24 +2579,6 @@ impl Render for Composer {
2573
2579
))
2574
2580
.on_click(cx.listener(|this, _, window, cx| this.open_picker(window, cx)))
2575
2581
});
2576
let table_button = can_attach.then(|| {
2577
div()
2578
.id("composer-table")
2579
.size(px(COMPOSER_BUTTON_SIZE))
2580
.flex_none()
2581
.flex()
2582
.items_center()
2583
.justify_center()
2584
.rounded(px(8.))
2585
.cursor_pointer()
2586
.hover(|button| button.bg(theme::popup_hover()))
2587
.when(self.table_picker.is_some(), |button| {
2588
button.bg(theme::popup_hover())
2589
})
2590
.tooltip(|window, cx| Tooltip::new("Insert table").build(window, cx))
2591
.child(symbol("table", COMPOSER_ICON_SIZE, theme::text_muted()))
2592
.on_click(cx.listener(|this, _, _, cx| this.open_table_picker(cx)))
2593
});
2594
2582
let composer = cx.weak_entity();
2595
2583
let tokens_composer = composer.clone();
2596
2584
let input = Textarea::new(&self.input)
@@ -2969,8 +2957,7 @@ impl Render for Composer {
2969
2957
.flex_none()
2970
2958
.gap(px(COMPOSER_BUTTON_INSET))
2971
2959
.children(fun)
2972
.children(attach)
2973
.children(table_button),
2960
.children(attach),
2974
2961
)
2975
2962
})
2976
2963
.child(
@@ -947,6 +947,10 @@ impl Composer {947
FormatButton::Bulleted => self.toggle_lines(LineKind::Bullet(0), window, cx),947
FormatButton::Bulleted => self.toggle_lines(LineKind::Bullet(0), window, cx),948
FormatButton::Numbered => self.toggle_lines(LineKind::Numbered(0), window, cx),948
FormatButton::Numbered => self.toggle_lines(LineKind::Numbered(0), window, cx),949
FormatButton::Quote => self.toggle_lines(LineKind::Quote, window, cx),949
FormatButton::Quote => self.toggle_lines(LineKind::Quote, window, cx),950
FormatButton::Table => {951
self.toolbar_dismissed = Some(self.selection(cx));952
self.open_table_picker(cx);953
}950
}954
}951
}955
}952
956
@@ -967,6 +971,8 @@ impl Composer {967
FormatButton::Bulleted => self.draft.line_state(range, &LineKind::Bullet(0)),971
FormatButton::Bulleted => self.draft.line_state(range, &LineKind::Bullet(0)),968
FormatButton::Numbered => self.draft.line_state(range, &LineKind::Numbered(0)),972
FormatButton::Numbered => self.draft.line_state(range, &LineKind::Numbered(0)),969
FormatButton::Quote => self.draft.line_state(range, &LineKind::Quote),973
FormatButton::Quote => self.draft.line_state(range, &LineKind::Quote),974
FormatButton::Table if self.table_picker.is_some() => FormatState::On,975
FormatButton::Table => FormatState::Off,970
}976
}971
}977
}972
978
@@ -2573,24 +2579,6 @@ impl Render for Composer {2573
))2579
))2574
.on_click(cx.listener(|this, _, window, cx| this.open_picker(window, cx)))2580
.on_click(cx.listener(|this, _, window, cx| this.open_picker(window, cx)))2575
});2581
});2576
let table_button = can_attach.then(|| {2577
div()2578
.id("composer-table")2579
.size(px(COMPOSER_BUTTON_SIZE))2580
.flex_none()2581
.flex()2582
.items_center()2583
.justify_center()2584
.rounded(px(8.))2585
.cursor_pointer()2586
.hover(|button| button.bg(theme::popup_hover()))2587
.when(self.table_picker.is_some(), |button| {2588
button.bg(theme::popup_hover())2589
})2590
.tooltip(|window, cx| Tooltip::new("Insert table").build(window, cx))2591
.child(symbol("table", COMPOSER_ICON_SIZE, theme::text_muted()))2592
.on_click(cx.listener(|this, _, _, cx| this.open_table_picker(cx)))2593
});2594
let composer = cx.weak_entity();2582
let composer = cx.weak_entity();2595
let tokens_composer = composer.clone();2583
let tokens_composer = composer.clone();2596
let input = Textarea::new(&self.input)2584
let input = Textarea::new(&self.input)@@ -2969,8 +2957,7 @@ impl Render for Composer {2969
.flex_none()2957
.flex_none()2970
.gap(px(COMPOSER_BUTTON_INSET))2958
.gap(px(COMPOSER_BUTTON_INSET))2971
.children(fun)2959
.children(fun)2972
.children(attach)2960
.children(attach),2973
.children(table_button),2974
)2961
)2975
})2962
})2976
.child(2963
.child(@@ -42,9 +42,10 @@ pub enum FormatButton {
42
42
Bulleted,
43
43
Numbered,
44
44
Quote,
45
Table,
45
46
}
46
47
47
pub const GROUPS: [&[FormatButton]; 5] = [
48
pub const GROUPS: [&[FormatButton]; 6] = [
48
49
&[
49
50
FormatButton::Bold,
50
51
FormatButton::Italic,
@@ -63,6 +64,7 @@ pub const GROUPS: [&[FormatButton]; 5] = [
63
64
FormatButton::Numbered,
64
65
FormatButton::Quote,
65
66
],
67
&[FormatButton::Table],
66
68
];
67
69
68
70
impl FormatButton {
@@ -82,6 +84,7 @@ impl FormatButton {
82
84
FormatButton::Bulleted => "Bulleted list",
83
85
FormatButton::Numbered => "Numbered list",
84
86
FormatButton::Quote => "Quote",
87
FormatButton::Table => "Insert table",
85
88
}
86
89
}
87
90
@@ -102,6 +105,7 @@ impl FormatButton {
102
105
FormatButton::Bulleted => symbol("format_list_bulleted", 18., color).into_any_element(),
103
106
FormatButton::Numbered => symbol("format_list_numbered", 18., color).into_any_element(),
104
107
FormatButton::Quote => symbol("format_quote", 18., color).into_any_element(),
108
FormatButton::Table => symbol("table", 18., color).into_any_element(),
105
109
}
106
110
}
107
111
}
@@ -353,7 +357,7 @@ pub fn render(placement: Placement, mode: Mode<'_>) -> AnyElement {
353
357
mod tests {
354
358
use gpui_kit::px;
355
359
356
use super::{ARROW_MARGIN, BUTTON, GROUPS, bar_width, place};
360
use super::{ARROW_MARGIN, BUTTON, FormatButton, GROUPS, bar_width, place};
357
361
358
362
#[test]
359
363
fn the_bar_centers_over_the_selection() {
@@ -381,8 +385,9 @@ mod tests {
381
385
}
382
386
383
387
#[test]
384
fn the_bar_holds_fourteen_buttons_in_five_groups() {
385
assert_eq!(GROUPS.iter().map(|group| group.len()).sum::<usize>(), 14);
386
assert!(bar_width() > 14. * BUTTON);
388
fn the_bar_holds_fifteen_buttons_in_six_groups_with_the_table_last() {
389
assert_eq!(GROUPS.iter().map(|group| group.len()).sum::<usize>(), 15);
390
assert_eq!(GROUPS.last().copied(), Some(&[FormatButton::Table][..]));
391
assert!(bar_width() > 15. * BUTTON);
387
392
}
388
393
}
@@ -42,9 +42,10 @@ pub enum FormatButton {42
Bulleted,42
Bulleted,43
Numbered,43
Numbered,44
Quote,44
Quote,45
Table,45
}46
}46
47
47
pub const GROUPS: [&[FormatButton]; 5] = [48
pub const GROUPS: [&[FormatButton]; 6] = [48
&[49
&[49
FormatButton::Bold,50
FormatButton::Bold,50
FormatButton::Italic,51
FormatButton::Italic,@@ -63,6 +64,7 @@ pub const GROUPS: [&[FormatButton]; 5] = [63
FormatButton::Numbered,64
FormatButton::Numbered,64
FormatButton::Quote,65
FormatButton::Quote,65
],66
],67
&[FormatButton::Table],66
];68
];67
69
68
impl FormatButton {70
impl FormatButton {@@ -82,6 +84,7 @@ impl FormatButton {82
FormatButton::Bulleted => "Bulleted list",84
FormatButton::Bulleted => "Bulleted list",83
FormatButton::Numbered => "Numbered list",85
FormatButton::Numbered => "Numbered list",84
FormatButton::Quote => "Quote",86
FormatButton::Quote => "Quote",87
FormatButton::Table => "Insert table",85
}88
}86
}89
}87
90
@@ -102,6 +105,7 @@ impl FormatButton {102
FormatButton::Bulleted => symbol("format_list_bulleted", 18., color).into_any_element(),105
FormatButton::Bulleted => symbol("format_list_bulleted", 18., color).into_any_element(),103
FormatButton::Numbered => symbol("format_list_numbered", 18., color).into_any_element(),106
FormatButton::Numbered => symbol("format_list_numbered", 18., color).into_any_element(),104
FormatButton::Quote => symbol("format_quote", 18., color).into_any_element(),107
FormatButton::Quote => symbol("format_quote", 18., color).into_any_element(),108
FormatButton::Table => symbol("table", 18., color).into_any_element(),105
}109
}106
}110
}107
}111
}@@ -353,7 +357,7 @@ pub fn render(placement: Placement, mode: Mode<'_>) -> AnyElement {353
mod tests {357
mod tests {354
use gpui_kit::px;358
use gpui_kit::px;355
359
356
use super::{ARROW_MARGIN, BUTTON, GROUPS, bar_width, place};360
use super::{ARROW_MARGIN, BUTTON, FormatButton, GROUPS, bar_width, place};357
361
358
#[test]362
#[test]359
fn the_bar_centers_over_the_selection() {363
fn the_bar_centers_over_the_selection() {@@ -381,8 +385,9 @@ mod tests {381
}385
}382
386
383
#[test]387
#[test]384
fn the_bar_holds_fourteen_buttons_in_five_groups() {388
fn the_bar_holds_fifteen_buttons_in_six_groups_with_the_table_last() {385
assert_eq!(GROUPS.iter().map(|group| group.len()).sum::<usize>(), 14);389
assert_eq!(GROUPS.iter().map(|group| group.len()).sum::<usize>(), 15);386
assert!(bar_width() > 14. * BUTTON);390
assert_eq!(GROUPS.last().copied(), Some(&[FormatButton::Table][..]));391
assert!(bar_width() > 15. * BUTTON);387
}392
}388
}393
}