fix(ui): Fluent menu, dropdown list, badge and banner metrics
- menus: Fluent v9 MenuItem metrics (32 px rows, 6 px padding, 20 px icon slot, 18 px glyph, icon to label 6 px, list padding 4, row gap 2), constants in gpui-component fluent.rs - menu icons: shared widgets::menu_icon with no size and no color, so icons inherit the label color; per-file MENU_ICON_SIZE helpers removed - dropdown lists: PopupMenu/DropdownMenuPopover listbox mode (16 px check column at 6, list left aligned 2 px under the trigger, at least the trigger width), used by the settings selects, the meeting repeat select and the status expiry select - buttons use Fluent icon spacing 6 / 4, toasts a 16 px icon centred on the 20 px line with an 8 px gap, Select/Combobox open 2 px below the trigger - count badges: one shared badge_pill for rail and lists, digit ink centred in the circle - pinned banner inset 20 -> 8 px, banner text in line with the message column - layout_guard: menu icon gap and centring, dropdown list alignment and padding, badge text centring, banner inset value - deviation from SPEC "menu item 30 high px10 gap 8": now the Fluent values Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -132,6 +132,7 @@ pub fn dropdown(id: &'static str, label: String, entries: Vec<MenuEntry>) -> imp
132
132
)
133
133
})
134
134
})
135
.listbox()
135
136
}
136
137
137
138
pub fn link_dropdown(
@@ -132,6 +132,7 @@ pub fn dropdown(id: &'static str, label: String, entries: Vec<MenuEntry>) -> imp132
)132
)133
})133
})134
})134
})135
.listbox()135
}136
}136
137
137
pub fn link_dropdown(138
pub fn link_dropdown(@@ -23,6 +23,10 @@ pub fn icon(name: IconName, size: f32, color: Hsla) -> Icon {
23
23
Icon::new(name).size(px(size)).text_color(color)
24
24
}
25
25
26
pub fn menu_icon(name: IconName) -> Icon {
27
Icon::new(name)
28
}
29
26
30
pub fn symbol(name: &str, size: f32, color: Hsla) -> Icon {
27
31
Icon::empty()
28
32
.path(format!("symbols/{name}.svg"))
@@ -44,27 +48,113 @@ pub fn corner_badge(corner: Corner, overhang: f32) -> Div {
44
48
}
45
49
}
46
50
47
pub fn count_badge(count: u32, muted: bool) -> Div {
48
let (background, foreground) = if muted {
49
(theme::badge_muted(), theme::text_strong())
50
} else {
51
(theme::accent(), theme::on_accent())
52
};
51
#[derive(Clone, Copy)]
52
pub struct BadgeMetrics {
53
pub height: f32,
54
pub padding_x: f32,
55
pub font_size: f32,
56
}
57
58
pub const COUNT_BADGE: BadgeMetrics = BadgeMetrics {
59
height: 18.,
60
padding_x: 5.,
61
font_size: 11.,
62
};
63
64
pub const RAIL_BADGE: BadgeMetrics = BadgeMetrics {
65
height: 16.,
66
padding_x: 4.,
67
font_size: 10.,
68
};
69
70
pub fn badge_selector(text: &str) -> String {
71
format!("count-badge/{text}")
72
}
73
74
pub fn badge_text_selector(text: &str) -> String {
75
format!("count-badge/{text}/text")
76
}
77
78
pub fn badge_pill(count: u32, metrics: BadgeMetrics, background: Hsla, foreground: Hsla) -> Div {
79
let text = format::badge_text(count);
53
80
div()
54
.min_w(px(18.))
55
.h(px(18.))
56
.px(px(5.))
81
.debug_selector(|| badge_selector(&text))
82
.min_w(px(metrics.height))
83
.h(px(metrics.height))
84
.px(px(metrics.padding_x))
57
85
.flex()
58
86
.flex_none()
59
87
.items_center()
60
88
.justify_center()
61
.rounded(px(9.))
89
.rounded(px(metrics.height / 2.))
62
90
.bg(background)
63
91
.text_color(foreground)
64
.text_size(px(11.))
65
.line_height(px(18.))
92
.text_size(px(metrics.font_size))
93
.line_height(px(metrics.height))
66
94
.font_weight(FontWeight::BOLD)
67
.child(format::badge_text(count))
95
.child(BadgeText {
96
text,
97
font_size: metrics.font_size,
98
line_height: metrics.height,
99
})
100
}
101
102
#[derive(IntoElement)]
103
struct BadgeText {
104
text: String,
105
font_size: f32,
106
line_height: f32,
107
}
108
109
impl RenderOnce for BadgeText {
110
fn render(self, window: &mut Window, _: &mut App) -> impl IntoElement {
111
let (shift_x, shift_y) = badge_ink_offset(window, &self.text, self.font_size);
112
div()
113
.debug_selector(|| badge_text_selector(&self.text))
114
.relative()
115
.left(px(-shift_x))
116
.top(px(-shift_y))
117
.flex_none()
118
.h(px(self.line_height))
119
.child(self.text)
120
}
121
}
122
123
pub fn badge_ink_offset(window: &Window, text: &str, font_size: f32) -> (f32, f32) {
124
let mut font = window.text_style().font();
125
font.weight = FontWeight::BOLD;
126
let text_system = window.text_system();
127
let font_id = text_system.resolve_font(&font);
128
let size = px(font_size);
129
let ascent = f32::from(text_system.ascent(font_id, size));
130
let descent = f32::from(text_system.descent(font_id, size)).abs();
131
let cap_height = f32::from(text_system.cap_height(font_id, size));
132
let shift_y = (ascent - descent - cap_height) / 2.;
133
let mut pen = 0.;
134
let mut ink_left = None;
135
let mut ink_right = 0.;
136
for character in text.chars() {
137
let advance = text_system
138
.advance(font_id, size, character)
139
.map_or(0., |advance| f32::from(advance.width));
140
if let Ok(bounds) = text_system.typographic_bounds(font_id, size, character) {
141
let left = pen + f32::from(bounds.origin.x);
142
ink_left.get_or_insert(left);
143
ink_right = left + f32::from(bounds.size.width);
144
}
145
pen += advance;
146
}
147
let shift_x = ink_left.map_or(0., |left| (left + ink_right) / 2. - pen / 2.);
148
(shift_x, shift_y)
149
}
150
151
pub fn count_badge(count: u32, muted: bool) -> Div {
152
let (background, foreground) = if muted {
153
(theme::badge_muted(), theme::text_strong())
154
} else {
155
(theme::accent(), theme::on_accent())
156
};
157
badge_pill(count, COUNT_BADGE, background, foreground)
68
158
}
69
159
70
160
pub fn page_header(title: &str) -> Div {
@@ -23,6 +23,10 @@ pub fn icon(name: IconName, size: f32, color: Hsla) -> Icon {23
Icon::new(name).size(px(size)).text_color(color)23
Icon::new(name).size(px(size)).text_color(color)24
}24
}25
25
26
pub fn menu_icon(name: IconName) -> Icon {27
Icon::new(name)28
}29
26
pub fn symbol(name: &str, size: f32, color: Hsla) -> Icon {30
pub fn symbol(name: &str, size: f32, color: Hsla) -> Icon {27
Icon::empty()31
Icon::empty()28
.path(format!("symbols/{name}.svg"))32
.path(format!("symbols/{name}.svg"))@@ -44,27 +48,113 @@ pub fn corner_badge(corner: Corner, overhang: f32) -> Div {44
}48
}45
}49
}46
50
47
pub fn count_badge(count: u32, muted: bool) -> Div {51
#[derive(Clone, Copy)]48
let (background, foreground) = if muted {52
pub struct BadgeMetrics {49
(theme::badge_muted(), theme::text_strong())53
pub height: f32,50
} else {54
pub padding_x: f32,51
(theme::accent(), theme::on_accent())55
pub font_size: f32,52
};56
}57
58
pub const COUNT_BADGE: BadgeMetrics = BadgeMetrics {59
height: 18.,60
padding_x: 5.,61
font_size: 11.,62
};63
64
pub const RAIL_BADGE: BadgeMetrics = BadgeMetrics {65
height: 16.,66
padding_x: 4.,67
font_size: 10.,68
};69
70
pub fn badge_selector(text: &str) -> String {71
format!("count-badge/{text}")72
}73
74
pub fn badge_text_selector(text: &str) -> String {75
format!("count-badge/{text}/text")76
}77
78
pub fn badge_pill(count: u32, metrics: BadgeMetrics, background: Hsla, foreground: Hsla) -> Div {79
let text = format::badge_text(count);53
div()80
div()54
.min_w(px(18.))81
.debug_selector(|| badge_selector(&text))55
.h(px(18.))82
.min_w(px(metrics.height))56
.px(px(5.))83
.h(px(metrics.height))84
.px(px(metrics.padding_x))57
.flex()85
.flex()58
.flex_none()86
.flex_none()59
.items_center()87
.items_center()60
.justify_center()88
.justify_center()61
.rounded(px(9.))89
.rounded(px(metrics.height / 2.))62
.bg(background)90
.bg(background)63
.text_color(foreground)91
.text_color(foreground)64
.text_size(px(11.))92
.text_size(px(metrics.font_size))65
.line_height(px(18.))93
.line_height(px(metrics.height))66
.font_weight(FontWeight::BOLD)94
.font_weight(FontWeight::BOLD)67
.child(format::badge_text(count))95
.child(BadgeText {96
text,97
font_size: metrics.font_size,98
line_height: metrics.height,99
})100
}101
102
#[derive(IntoElement)]103
struct BadgeText {104
text: String,105
font_size: f32,106
line_height: f32,107
}108
109
impl RenderOnce for BadgeText {110
fn render(self, window: &mut Window, _: &mut App) -> impl IntoElement {111
let (shift_x, shift_y) = badge_ink_offset(window, &self.text, self.font_size);112
div()113
.debug_selector(|| badge_text_selector(&self.text))114
.relative()115
.left(px(-shift_x))116
.top(px(-shift_y))117
.flex_none()118
.h(px(self.line_height))119
.child(self.text)120
}121
}122
123
pub fn badge_ink_offset(window: &Window, text: &str, font_size: f32) -> (f32, f32) {124
let mut font = window.text_style().font();125
font.weight = FontWeight::BOLD;126
let text_system = window.text_system();127
let font_id = text_system.resolve_font(&font);128
let size = px(font_size);129
let ascent = f32::from(text_system.ascent(font_id, size));130
let descent = f32::from(text_system.descent(font_id, size)).abs();131
let cap_height = f32::from(text_system.cap_height(font_id, size));132
let shift_y = (ascent - descent - cap_height) / 2.;133
let mut pen = 0.;134
let mut ink_left = None;135
let mut ink_right = 0.;136
for character in text.chars() {137
let advance = text_system138
.advance(font_id, size, character)139
.map_or(0., |advance| f32::from(advance.width));140
if let Ok(bounds) = text_system.typographic_bounds(font_id, size, character) {141
let left = pen + f32::from(bounds.origin.x);142
ink_left.get_or_insert(left);143
ink_right = left + f32::from(bounds.size.width);144
}145
pen += advance;146
}147
let shift_x = ink_left.map_or(0., |left| (left + ink_right) / 2. - pen / 2.);148
(shift_x, shift_y)149
}150
151
pub fn count_badge(count: u32, muted: bool) -> Div {152
let (background, foreground) = if muted {153
(theme::badge_muted(), theme::text_strong())154
} else {155
(theme::accent(), theme::on_accent())156
};157
badge_pill(count, COUNT_BADGE, background, foreground)68
}158
}69
159
70
pub fn page_header(title: &str) -> Div {160
pub fn page_header(title: &str) -> Div {@@ -171,6 +171,7 @@ mod frames {
171
171
use crate::app_state::{AppHandle, AppState, Mode, Selection};
172
172
use crate::call::{ActiveCall, CallModel, ConsultCall};
173
173
use crate::demo;
174
use crate::settings::select_selector;
174
175
use crate::settings::{item_selector, label, label_selector, metrics};
175
176
use crate::settings_section::SettingsSection;
176
177
use crate::user_activity::UserInput;
@@ -186,7 +187,7 @@ mod frames {
186
187
};
187
188
use crate::views::conversation::{HEADER_DIVIDER, MEMBERS_BUTTON, TIMELINE_TAG};
188
189
use crate::views::message_row::BUBBLE_TAGS;
189
use crate::views::pin_banner::PIN_BANNER_TAG;
190
use crate::views::pin_banner::{BANNER_INSET, PIN_BANNER_TAG};
190
191
use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};
191
192
use crate::views::reaction_proposal_pill::REACTION_PILL;
192
193
use crate::views::recap_tab::RECAP_REGION;
@@ -197,7 +198,21 @@ mod frames {
197
198
OpenActivity, OpenAgents, OpenCallsTab, OpenChannelsTab, OpenSaved,
198
199
};
199
200
use crate::views::sidebar::SIDEBAR_SCROLL_DIVIDER;
201
use crate::views::sidebar::chat_row_selector;
200
202
use crate::views::status_menu::{OWN_AVATAR_DISC, TITLE_AVATAR_SIZE};
203
use crate::views::widgets::{
204
COUNT_BADGE, RAIL_BADGE, badge_ink_offset, badge_pill, badge_selector, badge_text_selector,
205
count_badge,
206
};
207
use gpui_kit::MouseButton;
208
use gpui_kit::component::fluent::{
209
DROPDOWN_OFFSET, MENU_ICON_LABEL_GAP, MENU_LIST_PADDING, OPTION_CHECK_GAP,
210
OPTION_CHECK_INSET,
211
};
212
use gpui_kit::component::menu::selectors::{
213
ITEMS_SELECTOR, icon_selector, item_selector as menu_item_selector,
214
label_selector as menu_label_selector,
215
};
201
216
202
217
const GUARDED: &[&str] = &[
203
218
"shell",
@@ -1429,6 +1444,343 @@ mod frames {
1429
1444
}
1430
1445
}
1431
1446
1447
const MENU_ITEMS_SCANNED: usize = 40;
1448
const MENU_CHAT: &str = "demo-chat-release";
1449
const THEME_SELECT: &str = "settings-theme";
1450
1451
struct MenuRow {
1452
index: usize,
1453
item: Bounds<Pixels>,
1454
icon: Option<Bounds<Pixels>>,
1455
label: Option<Bounds<Pixels>>,
1456
}
1457
1458
fn menu_rows(visual: &mut VisualTestContext) -> Vec<MenuRow> {
1459
(0..MENU_ITEMS_SCANNED)
1460
.filter_map(|index| {
1461
let item =
1462
visual.debug_bounds(Box::leak(menu_item_selector(index).into_boxed_str()))?;
1463
Some(MenuRow {
1464
index,
1465
item,
1466
icon: visual.debug_bounds(Box::leak(icon_selector(index).into_boxed_str())),
1467
label: visual
1468
.debug_bounds(Box::leak(menu_label_selector(index).into_boxed_str())),
1469
})
1470
})
1471
.collect()
1472
}
1473
1474
fn menu_row_violations(rows: &[MenuRow], expected_gap: f32) -> Vec<(String, String)> {
1475
let mut found = Vec::new();
1476
for row in rows {
1477
let Some(icon) = row.icon else {
1478
continue;
1479
};
1480
let key = format!("{MENU}/item-{}", row.index);
1481
if let Some(label) = row.label {
1482
let gap = f32::from(label.left() - icon.right());
1483
if (gap - expected_gap).abs() > TOLERANCE {
1484
found.push((
1485
format!("{key}:icon-gap"),
1486
format!(
1487
"icon {} to label {} is {gap} px, expected {expected_gap}",
1488
describe(icon),
1489
describe(label)
1490
),
1491
));
1492
}
1493
}
1494
let offset = f32::from(icon.center().y - row.item.center().y);
1495
if offset.abs() > TOLERANCE {
1496
found.push((
1497
format!("{key}:icon-off-centre"),
1498
format!(
1499
"icon {} sits {offset} px off the centre of item {}",
1500
describe(icon),
1501
describe(row.item)
1502
),
1503
));
1504
}
1505
}
1506
found
1507
}
1508
1509
fn listbox_violations(
1510
trigger: Bounds<Pixels>,
1511
menu: Bounds<Pixels>,
1512
items: Bounds<Pixels>,
1513
rows: &[MenuRow],
1514
) -> Vec<(String, String)> {
1515
let mut found = Vec::new();
1516
let near = |value: f32, expected: f32| (value - expected).abs() <= TOLERANCE;
1517
if !near(f32::from(menu.left() - trigger.left()), 0.) {
1518
found.push((
1519
format!("{MENU}:not-aligned-to-trigger"),
1520
format!(
1521
"list {} must start at the trigger's left edge {}",
1522
describe(menu),
1523
describe(trigger)
1524
),
1525
));
1526
}
1527
if !near(
1528
f32::from(menu.top() - trigger.bottom()),
1529
f32::from(DROPDOWN_OFFSET),
1530
) {
1531
found.push((
1532
format!("{MENU}:trigger-offset"),
1533
format!(
1534
"list {} must open {} px below the trigger {}",
1535
describe(menu),
1536
f32::from(DROPDOWN_OFFSET),
1537
describe(trigger)
1538
),
1539
));
1540
}
1541
if menu.size.width < trigger.size.width - px(TOLERANCE) {
1542
found.push((
1543
format!("{MENU}:narrower-than-trigger"),
1544
format!(
1545
"list {} is narrower than the trigger {}",
1546
describe(menu),
1547
describe(trigger)
1548
),
1549
));
1550
}
1551
if let (Some(first), Some(last)) = (rows.first(), rows.last()) {
1552
let top = f32::from(first.item.top() - items.top());
1553
let bottom = f32::from(items.bottom() - last.item.bottom());
1554
let padding = f32::from(MENU_LIST_PADDING);
1555
if !near(top, padding) || !near(bottom, padding) {
1556
found.push((
1557
format!("{MENU}:uneven-padding"),
1558
format!("list padding top {top} / bottom {bottom}, both must be {padding}"),
1559
));
1560
}
1561
let expected_inset = f32::from(MENU_LIST_PADDING + OPTION_CHECK_INSET);
1562
match first.icon {
1563
Some(check) if near(f32::from(check.left() - menu.left()), expected_inset) => {}
1564
check => found.push((
1565
format!("{MENU}:check-inset"),
1566
format!(
1567
"check column {check:?} must start {expected_inset} px inside the list {}",
1568
describe(menu)
1569
),
1570
)),
1571
}
1572
}
1573
found
1574
}
1575
1576
#[test]
1577
fn menu_rules_flag_gaps_offsets_and_misaligned_lists() {
1578
let row =
1579
|index: usize, item_top: f32, icon_left: f32, icon_top: f32, label_left: f32| MenuRow {
1580
index,
1581
item: rectangle(4., item_top, 120., 32.),
1582
icon: Some(rectangle(icon_left, icon_top, 20., 20.)),
1583
label: Some(rectangle(label_left, item_top + 6., 60., 20.)),
1584
};
1585
let rows = [row(0, 4., 10., 10., 36.), row(1, 38., 10., 46., 32.)];
1586
let keys: Vec<String> = menu_row_violations(&rows, f32::from(MENU_ICON_LABEL_GAP))
1587
.into_iter()
1588
.map(|(key, _)| key)
1589
.collect();
1590
assert_eq!(
1591
keys,
1592
[
1593
"popup-menu/item-1:icon-gap",
1594
"popup-menu/item-1:icon-off-centre"
1595
]
1596
);
1597
1598
let trigger = rectangle(100., 50., 216., 32.);
1599
let option = |index: usize, top: f32| MenuRow {
1600
index,
1601
item: rectangle(104., top, 208., 32.),
1602
icon: Some(rectangle(110., top + 8., 16., 16.)),
1603
label: Some(rectangle(132., top + 6., 80., 20.)),
1604
};
1605
let aligned = [option(0, 88.), option(1, 122.)];
1606
let menu = rectangle(100., 84., 216., 74.);
1607
assert!(listbox_violations(trigger, menu, menu, &aligned).is_empty());
1608
let shifted = rectangle(96., 90., 200., 80.);
1609
let keys: Vec<String> = listbox_violations(trigger, shifted, shifted, &aligned)
1610
.into_iter()
1611
.map(|(key, _)| key)
1612
.collect();
1613
assert_eq!(
1614
keys,
1615
[
1616
"popup-menu:not-aligned-to-trigger",
1617
"popup-menu:trigger-offset",
1618
"popup-menu:narrower-than-trigger",
1619
"popup-menu:uneven-padding",
1620
"popup-menu:check-inset",
1621
]
1622
);
1623
}
1624
1625
#[gpui_kit::test]
1626
fn menu_items_keep_one_icon_gap_and_centred_icons(cx: &mut TestAppContext) {
1627
let (handle, _) = mount(cx);
1628
let mut visual = VisualTestContext::from_window(handle, cx);
1629
visual.simulate_resize(size(px(1280.), px(800.)));
1630
let chat_row: &'static str = Box::leak(chat_row_selector(MENU_CHAT).into_boxed_str());
1631
collect(&mut visual, Some(chat_row));
1632
let mut found = Vec::new();
1633
let own_status = visual
1634
.debug_bounds(OWN_STATUS)
1635
.expect("own status button rendered");
1636
visual.simulate_click(own_status.center(), Default::default());
1637
collect(&mut visual, Some(MENU));
1638
let status_rows = menu_rows(&mut visual);
1639
assert!(
1640
status_rows.iter().any(|row| row.icon.is_some()),
1641
"status menu shows icons"
1642
);
1643
found.extend(menu_row_violations(
1644
&status_rows,
1645
f32::from(MENU_ICON_LABEL_GAP),
1646
));
1647
visual.simulate_keystrokes("escape");
1648
collect(&mut visual, None);
1649
let row = visual.debug_bounds(chat_row).expect("chat row rendered");
1650
visual.simulate_mouse_down(row.center(), MouseButton::Right, Default::default());
1651
visual.simulate_mouse_up(row.center(), MouseButton::Right, Default::default());
1652
collect(&mut visual, Some(MENU));
1653
let chat_rows = menu_rows(&mut visual);
1654
assert!(
1655
chat_rows.iter().any(|row| row.icon.is_some()),
1656
"chat menu shows icons"
1657
);
1658
found.extend(menu_row_violations(
1659
&chat_rows,
1660
f32::from(MENU_ICON_LABEL_GAP),
1661
));
1662
let found: Vec<String> = found
1663
.into_iter()
1664
.map(|(key, message)| format!("{key}: {message}"))
1665
.collect();
1666
assert!(found.is_empty(), "{}", found.join("\n"));
1667
}
1668
1669
#[gpui_kit::test]
1670
fn settings_select_list_lines_up_with_its_trigger(cx: &mut TestAppContext) {
1671
let (handle, state) = mount(cx);
1672
let mut visual = VisualTestContext::from_window(handle, cx);
1673
visual.simulate_resize(size(px(1280.), px(800.)));
1674
visual.update(|_, cx| {
1675
state.update(cx, |state, cx| {
1676
state.open_settings(SettingsSection::Appearance, cx)
1677
})
1678
});
1679
let select: &'static str = Box::leak(select_selector(THEME_SELECT).into_boxed_str());
1680
collect(&mut visual, Some(select));
1681
let trigger = visual.debug_bounds(select).expect("theme select rendered");
1682
visual.simulate_click(trigger.center(), Default::default());
1683
collect(&mut visual, Some(MENU));
1684
let menu = visual.debug_bounds(MENU).expect("list rendered");
1685
let items = visual
1686
.debug_bounds(ITEMS_SELECTOR)
1687
.expect("list items rendered");
1688
let rows = menu_rows(&mut visual);
1689
let found: Vec<String> = listbox_violations(trigger, menu, items, &rows)
1690
.into_iter()
1691
.chain(menu_row_violations(&rows, f32::from(OPTION_CHECK_GAP)))
1692
.map(|(key, message)| format!("{key}: {message}"))
1693
.collect();
1694
assert!(found.is_empty(), "{}", found.join("\n"));
1695
}
1696
1697
const BADGE_SAMPLES: [(u32, bool); 5] =
1698
[(1, false), (42, false), (120, false), (7, true), (15, true)];
1699
1700
struct BadgeSamples;
1701
1702
impl gpui_kit::Render for BadgeSamples {
1703
fn render(
1704
&mut self,
1705
_: &mut gpui_kit::Window,
1706
_: &mut gpui_kit::Context<Self>,
1707
) -> impl gpui_kit::IntoElement {
1708
use gpui_kit::{ParentElement as _, Styled as _};
1709
gpui_kit::div()
1710
.flex()
1711
.gap(px(12.))
1712
.p(px(12.))
1713
.children(BADGE_SAMPLES.map(|(count, rail)| {
1714
if rail {
1715
badge_pill(
1716
count,
1717
RAIL_BADGE,
1718
crate::theme::accent(),
1719
crate::theme::on_accent(),
1720
)
1721
} else {
1722
count_badge(count, false)
1723
}
1724
}))
1725
}
1726
}
1727
1728
fn badge_violation(
1729
text: &str,
1730
pill: Bounds<Pixels>,
1731
label: Bounds<Pixels>,
1732
ink_offset: (f32, f32),
1733
) -> Option<(String, String)> {
1734
let ink_x = f32::from(label.center().x) + ink_offset.0;
1735
let ink_y = f32::from(label.center().y) + ink_offset.1;
1736
let off_x = ink_x - f32::from(pill.center().x);
1737
let off_y = ink_y - f32::from(pill.center().y);
1738
(off_x.abs() > TOLERANCE || off_y.abs() > TOLERANCE).then(|| {
1739
(
1740
format!("count-badge/{text}:off-centre"),
1741
format!("text ink of {text:?} sits ({off_x:.2}, {off_y:.2}) px off the centre of its circle {}", describe(pill)),
1742
)
1743
})
1744
}
1745
1746
#[test]
1747
fn badge_rule_flags_off_centre_text() {
1748
let pill = rectangle(0., 0., 18., 18.);
1749
assert!(badge_violation("1", pill, rectangle(6., 0., 6., 18.), (0., 0.)).is_none());
1750
assert!(badge_violation("1", pill, rectangle(6., 0., 6., 18.), (1., 0.)).is_some());
1751
assert!(badge_violation("1", pill, rectangle(6., 0., 6., 18.), (0., -1.)).is_some());
1752
}
1753
1754
#[gpui_kit::test]
1755
fn count_badge_text_sits_in_the_centre_of_its_circle(cx: &mut TestAppContext) {
1756
cx.update(gpui_kit::init);
1757
cx.update(crate::theme::apply);
1758
let (_, visual) = cx.add_window_view(|_, _| BadgeSamples);
1759
collect(visual, None);
1760
let mut found = Vec::new();
1761
for (count, rail) in BADGE_SAMPLES {
1762
let text = crate::format::badge_text(count);
1763
let pill = visual
1764
.debug_bounds(Box::leak(badge_selector(&text).into_boxed_str()))
1765
.expect("badge rendered");
1766
let label = visual
1767
.debug_bounds(Box::leak(badge_text_selector(&text).into_boxed_str()))
1768
.expect("badge text rendered");
1769
let font_size = if rail {
1770
RAIL_BADGE.font_size
1771
} else {
1772
COUNT_BADGE.font_size
1773
};
1774
let offset = visual.update(|window, _| badge_ink_offset(window, &text, font_size));
1775
found.extend(badge_violation(&text, pill, label, offset));
1776
}
1777
let found: Vec<String> = found
1778
.into_iter()
1779
.map(|(key, message)| format!("{key}: {message}"))
1780
.collect();
1781
assert!(found.is_empty(), "{}", found.join("\n"));
1782
}
1783
1432
1784
const PINNED_CHAT: &str = "demo-chat-release";
1433
1785
const PINNED_CHANNEL: &str = "demo-channel-1-1";
1434
1786
@@ -1455,12 +1807,13 @@ mod frames {
1455
1807
("below divider", f32::from(banner.top() - divider.bottom())),
1456
1808
];
1457
1809
let side = gaps[1].1;
1458
if gaps
1459
.iter()
1460
.any(|(_, gap)| (gap - side).abs() > INSET_TOLERANCE)
1810
if (side - BANNER_INSET).abs() > INSET_TOLERANCE
1811
|| gaps
1812
.iter()
1813
.any(|(_, gap)| (gap - side).abs() > INSET_TOLERANCE)
1461
1814
{
1462
1815
found.push(format!(
1463
"pin banner@{width}x{height}: gaps {gaps:?} must match"
1816
"pin banner@{width}x{height}: gaps {gaps:?} must all be {BANNER_INSET}"
1464
1817
));
1465
1818
}
1466
1819
}
@@ -171,6 +171,7 @@ mod frames {171
use crate::app_state::{AppHandle, AppState, Mode, Selection};171
use crate::app_state::{AppHandle, AppState, Mode, Selection};172
use crate::call::{ActiveCall, CallModel, ConsultCall};172
use crate::call::{ActiveCall, CallModel, ConsultCall};173
use crate::demo;173
use crate::demo;174
use crate::settings::select_selector;174
use crate::settings::{item_selector, label, label_selector, metrics};175
use crate::settings::{item_selector, label, label_selector, metrics};175
use crate::settings_section::SettingsSection;176
use crate::settings_section::SettingsSection;176
use crate::user_activity::UserInput;177
use crate::user_activity::UserInput;@@ -186,7 +187,7 @@ mod frames {186
};187
};187
use crate::views::conversation::{HEADER_DIVIDER, MEMBERS_BUTTON, TIMELINE_TAG};188
use crate::views::conversation::{HEADER_DIVIDER, MEMBERS_BUTTON, TIMELINE_TAG};188
use crate::views::message_row::BUBBLE_TAGS;189
use crate::views::message_row::BUBBLE_TAGS;189
use crate::views::pin_banner::PIN_BANNER_TAG;190
use crate::views::pin_banner::{BANNER_INSET, PIN_BANNER_TAG};190
use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};191
use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};191
use crate::views::reaction_proposal_pill::REACTION_PILL;192
use crate::views::reaction_proposal_pill::REACTION_PILL;192
use crate::views::recap_tab::RECAP_REGION;193
use crate::views::recap_tab::RECAP_REGION;@@ -197,7 +198,21 @@ mod frames {197
OpenActivity, OpenAgents, OpenCallsTab, OpenChannelsTab, OpenSaved,198
OpenActivity, OpenAgents, OpenCallsTab, OpenChannelsTab, OpenSaved,198
};199
};199
use crate::views::sidebar::SIDEBAR_SCROLL_DIVIDER;200
use crate::views::sidebar::SIDEBAR_SCROLL_DIVIDER;201
use crate::views::sidebar::chat_row_selector;200
use crate::views::status_menu::{OWN_AVATAR_DISC, TITLE_AVATAR_SIZE};202
use crate::views::status_menu::{OWN_AVATAR_DISC, TITLE_AVATAR_SIZE};203
use crate::views::widgets::{204
COUNT_BADGE, RAIL_BADGE, badge_ink_offset, badge_pill, badge_selector, badge_text_selector,205
count_badge,206
};207
use gpui_kit::MouseButton;208
use gpui_kit::component::fluent::{209
DROPDOWN_OFFSET, MENU_ICON_LABEL_GAP, MENU_LIST_PADDING, OPTION_CHECK_GAP,210
OPTION_CHECK_INSET,211
};212
use gpui_kit::component::menu::selectors::{213
ITEMS_SELECTOR, icon_selector, item_selector as menu_item_selector,214
label_selector as menu_label_selector,215
};201
216
202
const GUARDED: &[&str] = &[217
const GUARDED: &[&str] = &[203
"shell",218
"shell",@@ -1429,6 +1444,343 @@ mod frames {1429
}1444
}1430
}1445
}1431
1446
1447
const MENU_ITEMS_SCANNED: usize = 40;1448
const MENU_CHAT: &str = "demo-chat-release";1449
const THEME_SELECT: &str = "settings-theme";1450
1451
struct MenuRow {1452
index: usize,1453
item: Bounds<Pixels>,1454
icon: Option<Bounds<Pixels>>,1455
label: Option<Bounds<Pixels>>,1456
}1457
1458
fn menu_rows(visual: &mut VisualTestContext) -> Vec<MenuRow> {1459
(0..MENU_ITEMS_SCANNED)1460
.filter_map(|index| {1461
let item =1462
visual.debug_bounds(Box::leak(menu_item_selector(index).into_boxed_str()))?;1463
Some(MenuRow {1464
index,1465
item,1466
icon: visual.debug_bounds(Box::leak(icon_selector(index).into_boxed_str())),1467
label: visual1468
.debug_bounds(Box::leak(menu_label_selector(index).into_boxed_str())),1469
})1470
})1471
.collect()1472
}1473
1474
fn menu_row_violations(rows: &[MenuRow], expected_gap: f32) -> Vec<(String, String)> {1475
let mut found = Vec::new();1476
for row in rows {1477
let Some(icon) = row.icon else {1478
continue;1479
};1480
let key = format!("{MENU}/item-{}", row.index);1481
if let Some(label) = row.label {1482
let gap = f32::from(label.left() - icon.right());1483
if (gap - expected_gap).abs() > TOLERANCE {1484
found.push((1485
format!("{key}:icon-gap"),1486
format!(1487
"icon {} to label {} is {gap} px, expected {expected_gap}",1488
describe(icon),1489
describe(label)1490
),1491
));1492
}1493
}1494
let offset = f32::from(icon.center().y - row.item.center().y);1495
if offset.abs() > TOLERANCE {1496
found.push((1497
format!("{key}:icon-off-centre"),1498
format!(1499
"icon {} sits {offset} px off the centre of item {}",1500
describe(icon),1501
describe(row.item)1502
),1503
));1504
}1505
}1506
found1507
}1508
1509
fn listbox_violations(1510
trigger: Bounds<Pixels>,1511
menu: Bounds<Pixels>,1512
items: Bounds<Pixels>,1513
rows: &[MenuRow],1514
) -> Vec<(String, String)> {1515
let mut found = Vec::new();1516
let near = |value: f32, expected: f32| (value - expected).abs() <= TOLERANCE;1517
if !near(f32::from(menu.left() - trigger.left()), 0.) {1518
found.push((1519
format!("{MENU}:not-aligned-to-trigger"),1520
format!(1521
"list {} must start at the trigger's left edge {}",1522
describe(menu),1523
describe(trigger)1524
),1525
));1526
}1527
if !near(1528
f32::from(menu.top() - trigger.bottom()),1529
f32::from(DROPDOWN_OFFSET),1530
) {1531
found.push((1532
format!("{MENU}:trigger-offset"),1533
format!(1534
"list {} must open {} px below the trigger {}",1535
describe(menu),1536
f32::from(DROPDOWN_OFFSET),1537
describe(trigger)1538
),1539
));1540
}1541
if menu.size.width < trigger.size.width - px(TOLERANCE) {1542
found.push((1543
format!("{MENU}:narrower-than-trigger"),1544
format!(1545
"list {} is narrower than the trigger {}",1546
describe(menu),1547
describe(trigger)1548
),1549
));1550
}1551
if let (Some(first), Some(last)) = (rows.first(), rows.last()) {1552
let top = f32::from(first.item.top() - items.top());1553
let bottom = f32::from(items.bottom() - last.item.bottom());1554
let padding = f32::from(MENU_LIST_PADDING);1555
if !near(top, padding) || !near(bottom, padding) {1556
found.push((1557
format!("{MENU}:uneven-padding"),1558
format!("list padding top {top} / bottom {bottom}, both must be {padding}"),1559
));1560
}1561
let expected_inset = f32::from(MENU_LIST_PADDING + OPTION_CHECK_INSET);1562
match first.icon {1563
Some(check) if near(f32::from(check.left() - menu.left()), expected_inset) => {}1564
check => found.push((1565
format!("{MENU}:check-inset"),1566
format!(1567
"check column {check:?} must start {expected_inset} px inside the list {}",1568
describe(menu)1569
),1570
)),1571
}1572
}1573
found1574
}1575
1576
#[test]1577
fn menu_rules_flag_gaps_offsets_and_misaligned_lists() {1578
let row =1579
|index: usize, item_top: f32, icon_left: f32, icon_top: f32, label_left: f32| MenuRow {1580
index,1581
item: rectangle(4., item_top, 120., 32.),1582
icon: Some(rectangle(icon_left, icon_top, 20., 20.)),1583
label: Some(rectangle(label_left, item_top + 6., 60., 20.)),1584
};1585
let rows = [row(0, 4., 10., 10., 36.), row(1, 38., 10., 46., 32.)];1586
let keys: Vec<String> = menu_row_violations(&rows, f32::from(MENU_ICON_LABEL_GAP))1587
.into_iter()1588
.map(|(key, _)| key)1589
.collect();1590
assert_eq!(1591
keys,1592
[1593
"popup-menu/item-1:icon-gap",1594
"popup-menu/item-1:icon-off-centre"1595
]1596
);1597
1598
let trigger = rectangle(100., 50., 216., 32.);1599
let option = |index: usize, top: f32| MenuRow {1600
index,1601
item: rectangle(104., top, 208., 32.),1602
icon: Some(rectangle(110., top + 8., 16., 16.)),1603
label: Some(rectangle(132., top + 6., 80., 20.)),1604
};1605
let aligned = [option(0, 88.), option(1, 122.)];1606
let menu = rectangle(100., 84., 216., 74.);1607
assert!(listbox_violations(trigger, menu, menu, &aligned).is_empty());1608
let shifted = rectangle(96., 90., 200., 80.);1609
let keys: Vec<String> = listbox_violations(trigger, shifted, shifted, &aligned)1610
.into_iter()1611
.map(|(key, _)| key)1612
.collect();1613
assert_eq!(1614
keys,1615
[1616
"popup-menu:not-aligned-to-trigger",1617
"popup-menu:trigger-offset",1618
"popup-menu:narrower-than-trigger",1619
"popup-menu:uneven-padding",1620
"popup-menu:check-inset",1621
]1622
);1623
}1624
1625
#[gpui_kit::test]1626
fn menu_items_keep_one_icon_gap_and_centred_icons(cx: &mut TestAppContext) {1627
let (handle, _) = mount(cx);1628
let mut visual = VisualTestContext::from_window(handle, cx);1629
visual.simulate_resize(size(px(1280.), px(800.)));1630
let chat_row: &'static str = Box::leak(chat_row_selector(MENU_CHAT).into_boxed_str());1631
collect(&mut visual, Some(chat_row));1632
let mut found = Vec::new();1633
let own_status = visual1634
.debug_bounds(OWN_STATUS)1635
.expect("own status button rendered");1636
visual.simulate_click(own_status.center(), Default::default());1637
collect(&mut visual, Some(MENU));1638
let status_rows = menu_rows(&mut visual);1639
assert!(1640
status_rows.iter().any(|row| row.icon.is_some()),1641
"status menu shows icons"1642
);1643
found.extend(menu_row_violations(1644
&status_rows,1645
f32::from(MENU_ICON_LABEL_GAP),1646
));1647
visual.simulate_keystrokes("escape");1648
collect(&mut visual, None);1649
let row = visual.debug_bounds(chat_row).expect("chat row rendered");1650
visual.simulate_mouse_down(row.center(), MouseButton::Right, Default::default());1651
visual.simulate_mouse_up(row.center(), MouseButton::Right, Default::default());1652
collect(&mut visual, Some(MENU));1653
let chat_rows = menu_rows(&mut visual);1654
assert!(1655
chat_rows.iter().any(|row| row.icon.is_some()),1656
"chat menu shows icons"1657
);1658
found.extend(menu_row_violations(1659
&chat_rows,1660
f32::from(MENU_ICON_LABEL_GAP),1661
));1662
let found: Vec<String> = found1663
.into_iter()1664
.map(|(key, message)| format!("{key}: {message}"))1665
.collect();1666
assert!(found.is_empty(), "{}", found.join("\n"));1667
}1668
1669
#[gpui_kit::test]1670
fn settings_select_list_lines_up_with_its_trigger(cx: &mut TestAppContext) {1671
let (handle, state) = mount(cx);1672
let mut visual = VisualTestContext::from_window(handle, cx);1673
visual.simulate_resize(size(px(1280.), px(800.)));1674
visual.update(|_, cx| {1675
state.update(cx, |state, cx| {1676
state.open_settings(SettingsSection::Appearance, cx)1677
})1678
});1679
let select: &'static str = Box::leak(select_selector(THEME_SELECT).into_boxed_str());1680
collect(&mut visual, Some(select));1681
let trigger = visual.debug_bounds(select).expect("theme select rendered");1682
visual.simulate_click(trigger.center(), Default::default());1683
collect(&mut visual, Some(MENU));1684
let menu = visual.debug_bounds(MENU).expect("list rendered");1685
let items = visual1686
.debug_bounds(ITEMS_SELECTOR)1687
.expect("list items rendered");1688
let rows = menu_rows(&mut visual);1689
let found: Vec<String> = listbox_violations(trigger, menu, items, &rows)1690
.into_iter()1691
.chain(menu_row_violations(&rows, f32::from(OPTION_CHECK_GAP)))1692
.map(|(key, message)| format!("{key}: {message}"))1693
.collect();1694
assert!(found.is_empty(), "{}", found.join("\n"));1695
}1696
1697
const BADGE_SAMPLES: [(u32, bool); 5] =1698
[(1, false), (42, false), (120, false), (7, true), (15, true)];1699
1700
struct BadgeSamples;1701
1702
impl gpui_kit::Render for BadgeSamples {1703
fn render(1704
&mut self,1705
_: &mut gpui_kit::Window,1706
_: &mut gpui_kit::Context<Self>,1707
) -> impl gpui_kit::IntoElement {1708
use gpui_kit::{ParentElement as _, Styled as _};1709
gpui_kit::div()1710
.flex()1711
.gap(px(12.))1712
.p(px(12.))1713
.children(BADGE_SAMPLES.map(|(count, rail)| {1714
if rail {1715
badge_pill(1716
count,1717
RAIL_BADGE,1718
crate::theme::accent(),1719
crate::theme::on_accent(),1720
)1721
} else {1722
count_badge(count, false)1723
}1724
}))1725
}1726
}1727
1728
fn badge_violation(1729
text: &str,1730
pill: Bounds<Pixels>,1731
label: Bounds<Pixels>,1732
ink_offset: (f32, f32),1733
) -> Option<(String, String)> {1734
let ink_x = f32::from(label.center().x) + ink_offset.0;1735
let ink_y = f32::from(label.center().y) + ink_offset.1;1736
let off_x = ink_x - f32::from(pill.center().x);1737
let off_y = ink_y - f32::from(pill.center().y);1738
(off_x.abs() > TOLERANCE || off_y.abs() > TOLERANCE).then(|| {1739
(1740
format!("count-badge/{text}:off-centre"),1741
format!("text ink of {text:?} sits ({off_x:.2}, {off_y:.2}) px off the centre of its circle {}", describe(pill)),1742
)1743
})1744
}1745
1746
#[test]1747
fn badge_rule_flags_off_centre_text() {1748
let pill = rectangle(0., 0., 18., 18.);1749
assert!(badge_violation("1", pill, rectangle(6., 0., 6., 18.), (0., 0.)).is_none());1750
assert!(badge_violation("1", pill, rectangle(6., 0., 6., 18.), (1., 0.)).is_some());1751
assert!(badge_violation("1", pill, rectangle(6., 0., 6., 18.), (0., -1.)).is_some());1752
}1753
1754
#[gpui_kit::test]1755
fn count_badge_text_sits_in_the_centre_of_its_circle(cx: &mut TestAppContext) {1756
cx.update(gpui_kit::init);1757
cx.update(crate::theme::apply);1758
let (_, visual) = cx.add_window_view(|_, _| BadgeSamples);1759
collect(visual, None);1760
let mut found = Vec::new();1761
for (count, rail) in BADGE_SAMPLES {1762
let text = crate::format::badge_text(count);1763
let pill = visual1764
.debug_bounds(Box::leak(badge_selector(&text).into_boxed_str()))1765
.expect("badge rendered");1766
let label = visual1767
.debug_bounds(Box::leak(badge_text_selector(&text).into_boxed_str()))1768
.expect("badge text rendered");1769
let font_size = if rail {1770
RAIL_BADGE.font_size1771
} else {1772
COUNT_BADGE.font_size1773
};1774
let offset = visual.update(|window, _| badge_ink_offset(window, &text, font_size));1775
found.extend(badge_violation(&text, pill, label, offset));1776
}1777
let found: Vec<String> = found1778
.into_iter()1779
.map(|(key, message)| format!("{key}: {message}"))1780
.collect();1781
assert!(found.is_empty(), "{}", found.join("\n"));1782
}1783
1432
const PINNED_CHAT: &str = "demo-chat-release";1784
const PINNED_CHAT: &str = "demo-chat-release";1433
const PINNED_CHANNEL: &str = "demo-channel-1-1";1785
const PINNED_CHANNEL: &str = "demo-channel-1-1";1434
1786
@@ -1455,12 +1807,13 @@ mod frames {1455
("below divider", f32::from(banner.top() - divider.bottom())),1807
("below divider", f32::from(banner.top() - divider.bottom())),1456
];1808
];1457
let side = gaps[1].1;1809
let side = gaps[1].1;1458
if gaps1810
if (side - BANNER_INSET).abs() > INSET_TOLERANCE1459
.iter()1811
|| gaps1460
.any(|(_, gap)| (gap - side).abs() > INSET_TOLERANCE)1812
.iter()1813
.any(|(_, gap)| (gap - side).abs() > INSET_TOLERANCE)1461
{1814
{1462
found.push(format!(1815
found.push(format!(1463
"pin banner@{width}x{height}: gaps {gaps:?} must match"1816
"pin banner@{width}x{height}: gaps {gaps:?} must all be {BANNER_INSET}"1464
));1817
));1465
}1818
}1466
}1819
}@@ -15,4 +15,4 @@ pub use dialog::metrics;
15
15
pub use dialog::{SettingsDialog, SettingsDialogEvent};
16
16
#[cfg(test)]
17
17
pub use nav::{item_selector, label, label_selector};
18
pub(crate) use rows::switch;
18
pub(crate) use rows::{select_selector, switch};
@@ -15,4 +15,4 @@ pub use dialog::metrics;15
pub use dialog::{SettingsDialog, SettingsDialogEvent};15
pub use dialog::{SettingsDialog, SettingsDialogEvent};16
#[cfg(test)]16
#[cfg(test)]17
pub use nav::{item_selector, label, label_selector};17
pub use nav::{item_selector, label, label_selector};18
pub(crate) use rows::switch;18
pub(crate) use rows::{select_selector, switch};@@ -162,6 +162,10 @@ pub fn text_button(id: impl Into<ElementId>, label: impl Into<SharedString>) ->
162
162
.child(label.into())
163
163
}
164
164
165
pub fn select_selector(id: &str) -> String {
166
format!("settings-select/{id}")
167
}
168
165
169
pub fn select(
166
170
id: impl Into<ElementId>,
167
171
label: impl Into<SharedString>,
@@ -179,7 +183,9 @@ pub fn select_with_width(
179
183
choices: Vec<Choice>,
180
184
) -> impl IntoElement {
181
185
let scrollable = choices.len() > SCROLL_MENU_AFTER;
182
Button::new(id)
186
let id: ElementId = id.into();
187
Button::new(id.clone())
188
.debug_selector(|| select_selector(&id.to_string()))
183
189
.outline()
184
190
.w(px(width))
185
191
.flex_none()
@@ -209,4 +215,5 @@ pub fn select_with_width(
209
215
)
210
216
})
211
217
})
218
.listbox()
212
219
}
@@ -162,6 +162,10 @@ pub fn text_button(id: impl Into<ElementId>, label: impl Into<SharedString>) ->162
.child(label.into())162
.child(label.into())163
}163
}164
164
165
pub fn select_selector(id: &str) -> String {166
format!("settings-select/{id}")167
}168
165
pub fn select(169
pub fn select(166
id: impl Into<ElementId>,170
id: impl Into<ElementId>,167
label: impl Into<SharedString>,171
label: impl Into<SharedString>,@@ -179,7 +183,9 @@ pub fn select_with_width(179
choices: Vec<Choice>,183
choices: Vec<Choice>,180
) -> impl IntoElement {184
) -> impl IntoElement {181
let scrollable = choices.len() > SCROLL_MENU_AFTER;185
let scrollable = choices.len() > SCROLL_MENU_AFTER;182
Button::new(id)186
let id: ElementId = id.into();187
Button::new(id.clone())188
.debug_selector(|| select_selector(&id.to_string()))183
.outline()189
.outline()184
.w(px(width))190
.w(px(width))185
.flex_none()191
.flex_none()@@ -209,4 +215,5 @@ pub fn select_with_width(209
)215
)210
})216
})211
})217
})218
.listbox()212
}219
}@@ -13,7 +13,7 @@ use super::join_dialog::open_join_with_id;
13
13
use super::new_meeting_dialog::open_new_meeting;
14
14
use super::scroll_edge::with_top_edge;
15
15
use super::sidebar::SIDEBAR_SCROLL_DIVIDER;
16
use super::widgets::icon;
16
use super::widgets::{icon, menu_icon};
17
17
use crate::app_state::AppState;
18
18
use crate::call::{
19
19
AGENDA_ROW_HEIGHT, AgendaRow, CALL_ROW_HEIGHT, CallRow, DAY_HEIGHT, EMPTY_HEIGHT, ListEntry,
@@ -25,7 +25,6 @@ const FALLBACK_VIEWPORT: f32 = 900.;
25
25
const VIEWPORT_MARGIN: f32 = 300.;
26
26
const TIME_COLUMN_WIDTH: f32 = 96.;
27
27
const AVATAR_SIZE: f32 = 36.;
28
const MENU_ICON_SIZE: f32 = 15.;
29
28
30
29
fn meeting_avatar() -> Div {
31
30
div()
@@ -122,7 +121,7 @@ fn call_row(
122
121
.when(can_call_back, |popup| {
123
122
popup.item(
124
123
PopupMenuItem::new("Call back")
125
.icon(icon(IconName::Phone, MENU_ICON_SIZE, theme::text_muted()))
124
.icon(menu_icon(IconName::Phone))
126
125
.on_click(move |_, _, cx| {
127
126
call_state.update(cx, |state, cx| {
128
127
state.call_back_from_history(&call_row, cx)
@@ -133,11 +132,7 @@ fn call_row(
133
132
.when(can_open_chat, |popup| {
134
133
popup.item(
135
134
PopupMenuItem::new("Open chat")
136
.icon(icon(
137
IconName::MessageSquare,
138
MENU_ICON_SIZE,
139
theme::text_muted(),
140
))
135
.icon(menu_icon(IconName::MessageSquare))
141
136
.on_click(move |_, _, cx| {
142
137
chat_state.update(cx, |state, cx| {
143
138
state.open_chat_of_call_row(&chat_row, cx)
@@ -13,7 +13,7 @@ use super::join_dialog::open_join_with_id;13
use super::new_meeting_dialog::open_new_meeting;13
use super::new_meeting_dialog::open_new_meeting;14
use super::scroll_edge::with_top_edge;14
use super::scroll_edge::with_top_edge;15
use super::sidebar::SIDEBAR_SCROLL_DIVIDER;15
use super::sidebar::SIDEBAR_SCROLL_DIVIDER;16
use super::widgets::icon;16
use super::widgets::{icon, menu_icon};17
use crate::app_state::AppState;17
use crate::app_state::AppState;18
use crate::call::{18
use crate::call::{19
AGENDA_ROW_HEIGHT, AgendaRow, CALL_ROW_HEIGHT, CallRow, DAY_HEIGHT, EMPTY_HEIGHT, ListEntry,19
AGENDA_ROW_HEIGHT, AgendaRow, CALL_ROW_HEIGHT, CallRow, DAY_HEIGHT, EMPTY_HEIGHT, ListEntry,@@ -25,7 +25,6 @@ const FALLBACK_VIEWPORT: f32 = 900.;25
const VIEWPORT_MARGIN: f32 = 300.;25
const VIEWPORT_MARGIN: f32 = 300.;26
const TIME_COLUMN_WIDTH: f32 = 96.;26
const TIME_COLUMN_WIDTH: f32 = 96.;27
const AVATAR_SIZE: f32 = 36.;27
const AVATAR_SIZE: f32 = 36.;28
const MENU_ICON_SIZE: f32 = 15.;29
28
30
fn meeting_avatar() -> Div {29
fn meeting_avatar() -> Div {31
div()30
div()@@ -122,7 +121,7 @@ fn call_row(122
.when(can_call_back, |popup| {121
.when(can_call_back, |popup| {123
popup.item(122
popup.item(124
PopupMenuItem::new("Call back")123
PopupMenuItem::new("Call back")125
.icon(icon(IconName::Phone, MENU_ICON_SIZE, theme::text_muted()))124
.icon(menu_icon(IconName::Phone))126
.on_click(move |_, _, cx| {125
.on_click(move |_, _, cx| {127
call_state.update(cx, |state, cx| {126
call_state.update(cx, |state, cx| {128
state.call_back_from_history(&call_row, cx)127
state.call_back_from_history(&call_row, cx)@@ -133,11 +132,7 @@ fn call_row(133
.when(can_open_chat, |popup| {132
.when(can_open_chat, |popup| {134
popup.item(133
popup.item(135
PopupMenuItem::new("Open chat")134
PopupMenuItem::new("Open chat")136
.icon(icon(135
.icon(menu_icon(IconName::MessageSquare))137
IconName::MessageSquare,138
MENU_ICON_SIZE,139
theme::text_muted(),140
))141
.on_click(move |_, _, cx| {136
.on_click(move |_, _, cx| {142
chat_state.update(cx, |state, cx| {137
chat_state.update(cx, |state, cx| {143
state.open_chat_of_call_row(&chat_row, cx)138
state.open_chat_of_call_row(&chat_row, cx)@@ -176,7 +176,8 @@ impl Render for MeetingForm {
176
176
}),
177
177
)
178
178
})
179
});
179
})
180
.listbox();
180
181
v_flex()
181
182
.debug_selector(|| "new-meeting".into())
182
183
.gap(px(FIELD_GAP))
@@ -176,7 +176,8 @@ impl Render for MeetingForm {176
}),176
}),177
)177
)178
})178
})179
});179
})180
.listbox();180
v_flex()181
v_flex()181
.debug_selector(|| "new-meeting".into())182
.debug_selector(|| "new-meeting".into())182
.gap(px(FIELD_GAP))183
.gap(px(FIELD_GAP))@@ -10,10 +10,10 @@ use super::widgets::icon;
10
10
use crate::theme;
11
11
12
12
const BANNER_HEIGHT: f32 = 40.;
13
const BANNER_INSET: f32 = ROW_PADDING;
14
13
pub const PIN_BANNER_TAG: &str = "shell/islands/main/pin-banner";
15
14
const BANNER_GAP: f32 = 8.;
16
15
const BANNER_PADDING: f32 = 12.;
16
pub const BANNER_INSET: f32 = ROW_PADDING - BANNER_PADDING;
17
17
const BUTTON_SIZE: f32 = 28.;
18
18
const FALLBACK_PREVIEW: &str = "Pinned message";
19
19
@@ -10,10 +10,10 @@ use super::widgets::icon;10
use crate::theme;10
use crate::theme;11
11
12
const BANNER_HEIGHT: f32 = 40.;12
const BANNER_HEIGHT: f32 = 40.;13
const BANNER_INSET: f32 = ROW_PADDING;14
pub const PIN_BANNER_TAG: &str = "shell/islands/main/pin-banner";13
pub const PIN_BANNER_TAG: &str = "shell/islands/main/pin-banner";15
const BANNER_GAP: f32 = 8.;14
const BANNER_GAP: f32 = 8.;16
const BANNER_PADDING: f32 = 12.;15
const BANNER_PADDING: f32 = 12.;16
pub const BANNER_INSET: f32 = ROW_PADDING - BANNER_PADDING;17
const BUTTON_SIZE: f32 = 28.;17
const BUTTON_SIZE: f32 = 28.;18
const FALLBACK_PREVIEW: &str = "Pinned message";18
const FALLBACK_PREVIEW: &str = "Pinned message";19
19
@@ -5,11 +5,10 @@ use gpui_kit::*;
5
5
6
6
use super::shortcuts::keys_for_label;
7
7
use super::sidebar::{SidebarTab, SidebarView};
8
use super::widgets::icon;
8
use super::widgets::{RAIL_BADGE, badge_pill, icon};
9
9
use crate::activity::ActivityCenter;
10
10
use crate::agents::{AgentRuns, runs_handle};
11
11
use crate::app_state::AppState;
12
use crate::format;
13
12
use crate::sidebar_model::{any_unread_channel, unread_chat_count};
14
13
use crate::theme;
15
14
use app_ui_kit::layout::{RAIL_ITEM_WIDTH, RAIL_WIDTH};
@@ -208,23 +207,12 @@ fn badge(badge: RailBadge) -> Option<Div> {
208
207
.size(px(7.))
209
208
.rounded_full()
210
209
.bg(theme::accent()),
211
RailBadge::Count(count) => div()
212
.absolute()
213
.top(px(5.))
214
.left(px(28.))
215
.min_w(px(16.))
216
.h(px(16.))
217
.px(px(4.))
218
.flex()
219
.items_center()
220
.justify_center()
221
.rounded(px(8.))
222
.bg(theme::accent())
223
.text_color(theme::on_accent())
224
.text_size(px(10.))
225
.line_height(px(16.))
226
.font_weight(FontWeight::BOLD)
227
.child(format::badge_text(count)),
210
RailBadge::Count(count) => {
211
badge_pill(count, RAIL_BADGE, theme::accent(), theme::on_accent())
212
.absolute()
213
.top(px(5.))
214
.left(px(28.))
215
}
228
216
})
229
217
}
230
218
@@ -5,11 +5,10 @@ use gpui_kit::*;5
5
6
use super::shortcuts::keys_for_label;6
use super::shortcuts::keys_for_label;7
use super::sidebar::{SidebarTab, SidebarView};7
use super::sidebar::{SidebarTab, SidebarView};8
use super::widgets::icon;8
use super::widgets::{RAIL_BADGE, badge_pill, icon};9
use crate::activity::ActivityCenter;9
use crate::activity::ActivityCenter;10
use crate::agents::{AgentRuns, runs_handle};10
use crate::agents::{AgentRuns, runs_handle};11
use crate::app_state::AppState;11
use crate::app_state::AppState;12
use crate::format;13
use crate::sidebar_model::{any_unread_channel, unread_chat_count};12
use crate::sidebar_model::{any_unread_channel, unread_chat_count};14
use crate::theme;13
use crate::theme;15
use app_ui_kit::layout::{RAIL_ITEM_WIDTH, RAIL_WIDTH};14
use app_ui_kit::layout::{RAIL_ITEM_WIDTH, RAIL_WIDTH};@@ -208,23 +207,12 @@ fn badge(badge: RailBadge) -> Option<Div> {208
.size(px(7.))207
.size(px(7.))209
.rounded_full()208
.rounded_full()210
.bg(theme::accent()),209
.bg(theme::accent()),211
RailBadge::Count(count) => div()210
RailBadge::Count(count) => {212
.absolute()211
badge_pill(count, RAIL_BADGE, theme::accent(), theme::on_accent())213
.top(px(5.))212
.absolute()214
.left(px(28.))213
.top(px(5.))215
.min_w(px(16.))214
.left(px(28.))216
.h(px(16.))215
}217
.px(px(4.))218
.flex()219
.items_center()220
.justify_center()221
.rounded(px(8.))222
.bg(theme::accent())223
.text_color(theme::on_accent())224
.text_size(px(10.))225
.line_height(px(16.))226
.font_weight(FontWeight::BOLD)227
.child(format::badge_text(count)),228
})216
})229
}217
}230
218
@@ -21,7 +21,7 @@ use super::calls_tab::calls_body;
21
21
use super::saved_panel::SavedPanel;
22
22
use super::scroll_edge::with_top_edge;
23
23
use super::section_dialog::{SectionNameTarget, open_section_name_dialog};
24
use super::widgets::{count_badge, icon, page_header, unread_marker};
24
use super::widgets::{count_badge, icon, menu_icon, page_header, unread_marker};
25
25
use crate::agents::AgentsPanel;
26
26
use crate::app_state::{AppEvent, AppState, Selection};
27
27
use crate::channel_menu::{
@@ -63,7 +63,6 @@ const HIDDEN_TEAMS_LABEL: &str = "Hidden teams";
63
63
const TEAM_ROW_HEIGHT: f32 = 40.;
64
64
const REVEAL_ROW_HEIGHT: f32 = 32.;
65
65
const NEW_CHAT_BUTTON_SIZE: f32 = 32.;
66
const MENU_ICON_SIZE: f32 = 15.;
67
66
const NOTIFICATION_ICON_SIZE: f32 = 13.;
68
67
const MENTION_ICON_SIZE: f32 = 15.;
69
68
@@ -90,6 +89,10 @@ impl SidebarTab {
90
89
}
91
90
}
92
91
92
pub fn chat_row_selector(chat_id: &str) -> String {
93
format!("chat-row/{chat_id}")
94
}
95
93
96
#[derive(Clone)]
94
97
struct DraggedChat {
95
98
id: String,
@@ -131,10 +134,6 @@ struct MenuContext {
131
134
folders: Vec<(String, String)>,
132
135
}
133
136
134
fn menu_icon(name: IconName) -> gpui_kit::component::Icon {
135
icon(name, MENU_ICON_SIZE, theme::text_muted())
136
}
137
138
137
fn chat_menu(
139
138
popup: PopupMenu,
140
139
window: &mut Window,
@@ -255,7 +254,7 @@ fn chat_menu(
255
254
PopupMenuItem::element(|_, _| {
256
255
div().text_color(theme::red_soft()).child("Leave chat...")
257
256
})
258
.icon(icon(IconName::LogOut, MENU_ICON_SIZE, theme::red_soft()))
257
.icon(menu_icon(IconName::LogOut).text_color(theme::red_soft()))
259
258
.on_click(move |_, window, cx| {
260
259
confirm_leave(&leave_state, &leave_id, &title, member_count, window, cx);
261
260
}),
@@ -406,7 +405,7 @@ fn section_menu(
406
405
PopupMenuItem::element(|_, _| {
407
406
div().text_color(theme::red_soft()).child("Delete section")
408
407
})
409
.icon(icon(IconName::Trash, MENU_ICON_SIZE, theme::red_soft()))
408
.icon(menu_icon(IconName::Trash).text_color(theme::red_soft()))
410
409
.disabled(target.read_only)
411
410
.on_click(move |_, window, cx| {
412
411
confirm_delete_section(&delete_state, &folder_id, &name, window, cx);
@@ -1092,6 +1091,7 @@ impl SidebarView {
1092
1091
};
1093
1092
h_flex()
1094
1093
.id(SharedString::from(format!("chat-{}", item.id)))
1094
.debug_selector(|| chat_row_selector(&item.id))
1095
1095
.mx(px(6.))
1096
1096
.h(px(ROW_HEIGHT))
1097
1097
.flex_none()
@@ -21,7 +21,7 @@ use super::calls_tab::calls_body;21
use super::saved_panel::SavedPanel;21
use super::saved_panel::SavedPanel;22
use super::scroll_edge::with_top_edge;22
use super::scroll_edge::with_top_edge;23
use super::section_dialog::{SectionNameTarget, open_section_name_dialog};23
use super::section_dialog::{SectionNameTarget, open_section_name_dialog};24
use super::widgets::{count_badge, icon, page_header, unread_marker};24
use super::widgets::{count_badge, icon, menu_icon, page_header, unread_marker};25
use crate::agents::AgentsPanel;25
use crate::agents::AgentsPanel;26
use crate::app_state::{AppEvent, AppState, Selection};26
use crate::app_state::{AppEvent, AppState, Selection};27
use crate::channel_menu::{27
use crate::channel_menu::{@@ -63,7 +63,6 @@ const HIDDEN_TEAMS_LABEL: &str = "Hidden teams";63
const TEAM_ROW_HEIGHT: f32 = 40.;63
const TEAM_ROW_HEIGHT: f32 = 40.;64
const REVEAL_ROW_HEIGHT: f32 = 32.;64
const REVEAL_ROW_HEIGHT: f32 = 32.;65
const NEW_CHAT_BUTTON_SIZE: f32 = 32.;65
const NEW_CHAT_BUTTON_SIZE: f32 = 32.;66
const MENU_ICON_SIZE: f32 = 15.;67
const NOTIFICATION_ICON_SIZE: f32 = 13.;66
const NOTIFICATION_ICON_SIZE: f32 = 13.;68
const MENTION_ICON_SIZE: f32 = 15.;67
const MENTION_ICON_SIZE: f32 = 15.;69
68
@@ -90,6 +89,10 @@ impl SidebarTab {90
}89
}91
}90
}92
91
92
pub fn chat_row_selector(chat_id: &str) -> String {93
format!("chat-row/{chat_id}")94
}95
93
#[derive(Clone)]96
#[derive(Clone)]94
struct DraggedChat {97
struct DraggedChat {95
id: String,98
id: String,@@ -131,10 +134,6 @@ struct MenuContext {131
folders: Vec<(String, String)>,134
folders: Vec<(String, String)>,132
}135
}133
136
134
fn menu_icon(name: IconName) -> gpui_kit::component::Icon {135
icon(name, MENU_ICON_SIZE, theme::text_muted())136
}137
138
fn chat_menu(137
fn chat_menu(139
popup: PopupMenu,138
popup: PopupMenu,140
window: &mut Window,139
window: &mut Window,@@ -255,7 +254,7 @@ fn chat_menu(255
PopupMenuItem::element(|_, _| {254
PopupMenuItem::element(|_, _| {256
div().text_color(theme::red_soft()).child("Leave chat...")255
div().text_color(theme::red_soft()).child("Leave chat...")257
})256
})258
.icon(icon(IconName::LogOut, MENU_ICON_SIZE, theme::red_soft()))257
.icon(menu_icon(IconName::LogOut).text_color(theme::red_soft()))259
.on_click(move |_, window, cx| {258
.on_click(move |_, window, cx| {260
confirm_leave(&leave_state, &leave_id, &title, member_count, window, cx);259
confirm_leave(&leave_state, &leave_id, &title, member_count, window, cx);261
}),260
}),@@ -406,7 +405,7 @@ fn section_menu(406
PopupMenuItem::element(|_, _| {405
PopupMenuItem::element(|_, _| {407
div().text_color(theme::red_soft()).child("Delete section")406
div().text_color(theme::red_soft()).child("Delete section")408
})407
})409
.icon(icon(IconName::Trash, MENU_ICON_SIZE, theme::red_soft()))408
.icon(menu_icon(IconName::Trash).text_color(theme::red_soft()))410
.disabled(target.read_only)409
.disabled(target.read_only)411
.on_click(move |_, window, cx| {410
.on_click(move |_, window, cx| {412
confirm_delete_section(&delete_state, &folder_id, &name, window, cx);411
confirm_delete_section(&delete_state, &folder_id, &name, window, cx);@@ -1092,6 +1091,7 @@ impl SidebarView {1092
};1091
};1093
h_flex()1092
h_flex()1094
.id(SharedString::from(format!("chat-{}", item.id)))1093
.id(SharedString::from(format!("chat-{}", item.id)))1094
.debug_selector(|| chat_row_selector(&item.id))1095
.mx(px(6.))1095
.mx(px(6.))1096
.h(px(ROW_HEIGHT))1096
.h(px(ROW_HEIGHT))1097
.flex_none()1097
.flex_none()@@ -206,7 +206,8 @@ impl StatusMessageDialog {
206
206
}),
207
207
)
208
208
})
209
}),
209
})
210
.listbox(),
210
211
)
211
212
}
212
213
@@ -206,7 +206,8 @@ impl StatusMessageDialog {206
}),206
}),207
)207
)208
})208
})209
}),209
})210
.listbox(),210
)211
)211
}212
}212
213
@@ -745,9 +745,8 @@ impl RenderOnce for Button {
745
745
.justify_center()
746
746
.button_text_size(self.size)
747
747
.map(|this| match self.size {
748
Size::XSmall => this.gap_1(),
749
Size::Small => this.gap_1(),
750
_ => this.gap_2(),
748
Size::XSmall | Size::Small => this.gap(crate::fluent::BUTTON_ICON_GAP_SMALL),
749
_ => this.gap(crate::fluent::BUTTON_ICON_GAP),
751
750
})
752
751
.refine_style(&self.content_style)
753
752
.when_some(self.icon, |this, icon| {
@@ -745,9 +745,8 @@ impl RenderOnce for Button {745
.justify_center()745
.justify_center()746
.button_text_size(self.size)746
.button_text_size(self.size)747
.map(|this| match self.size {747
.map(|this| match self.size {748
Size::XSmall => this.gap_1(),748
Size::XSmall | Size::Small => this.gap(crate::fluent::BUTTON_ICON_GAP_SMALL),749
Size::Small => this.gap_1(),749
_ => this.gap(crate::fluent::BUTTON_ICON_GAP),750
_ => this.gap_2(),751
})750
})752
.refine_style(&self.content_style)751
.refine_style(&self.content_style)753
.when_some(self.icon, |this, icon| {752
.when_some(self.icon, |this, icon| {@@ -0,0 +1,29 @@
1
//! Fluent UI v9 metrics as shipped in the Teams web bundle.
2
3
use gpui::{Pixels, px};
4
5
pub const MENU_ITEM_HEIGHT: Pixels = px(32.);
6
pub const MENU_ITEM_PADDING_X: Pixels = px(6.);
7
pub const MENU_ICON_SLOT: Pixels = px(20.);
8
// A Lucide glyph at 18 px covers what a Fluent 20 px regular icon covers.
9
pub const MENU_ICON_GLYPH: Pixels = px(18.);
10
pub const MENU_ICON_GAP: Pixels = px(4.);
11
pub const MENU_LABEL_INSET: Pixels = px(2.);
12
pub const MENU_ICON_LABEL_GAP: Pixels = px(6.);
13
pub const MENU_LIST_PADDING: Pixels = px(4.);
14
pub const MENU_ITEM_GAP: Pixels = px(2.);
15
pub const MENU_DIVIDER_MARGIN_Y: Pixels = px(4.);
16
17
pub const OPTION_CHECK_INSET: Pixels = px(6.);
18
pub const OPTION_PADDING_RIGHT: Pixels = px(8.);
19
pub const OPTION_CHECK_SIZE: Pixels = px(16.);
20
pub const OPTION_CHECK_GAP: Pixels = px(6.);
21
pub const LISTBOX_MIN_WIDTH: Pixels = px(160.);
22
pub const DROPDOWN_OFFSET: Pixels = px(2.);
23
24
pub const BUTTON_ICON_GAP: Pixels = px(6.);
25
pub const BUTTON_ICON_GAP_SMALL: Pixels = px(4.);
26
27
pub const TOAST_ICON_SIZE: Pixels = px(16.);
28
pub const TOAST_ICON_GAP: Pixels = px(8.);
29
pub const TOAST_LINE_HEIGHT: Pixels = px(20.);
@@ -0,0 +1,29 @@1
//! Fluent UI v9 metrics as shipped in the Teams web bundle.2
3
use gpui::{Pixels, px};4
5
pub const MENU_ITEM_HEIGHT: Pixels = px(32.);6
pub const MENU_ITEM_PADDING_X: Pixels = px(6.);7
pub const MENU_ICON_SLOT: Pixels = px(20.);8
// A Lucide glyph at 18 px covers what a Fluent 20 px regular icon covers.9
pub const MENU_ICON_GLYPH: Pixels = px(18.);10
pub const MENU_ICON_GAP: Pixels = px(4.);11
pub const MENU_LABEL_INSET: Pixels = px(2.);12
pub const MENU_ICON_LABEL_GAP: Pixels = px(6.);13
pub const MENU_LIST_PADDING: Pixels = px(4.);14
pub const MENU_ITEM_GAP: Pixels = px(2.);15
pub const MENU_DIVIDER_MARGIN_Y: Pixels = px(4.);16
17
pub const OPTION_CHECK_INSET: Pixels = px(6.);18
pub const OPTION_PADDING_RIGHT: Pixels = px(8.);19
pub const OPTION_CHECK_SIZE: Pixels = px(16.);20
pub const OPTION_CHECK_GAP: Pixels = px(6.);21
pub const LISTBOX_MIN_WIDTH: Pixels = px(160.);22
pub const DROPDOWN_OFFSET: Pixels = px(2.);23
24
pub const BUTTON_ICON_GAP: Pixels = px(6.);25
pub const BUTTON_ICON_GAP_SMALL: Pixels = px(4.);26
27
pub const TOAST_ICON_SIZE: Pixels = px(16.);28
pub const TOAST_ICON_GAP: Pixels = px(8.);29
pub const TOAST_LINE_HEIGHT: Pixels = px(20.);@@ -164,6 +164,10 @@ impl Icon {
164
164
Self::default()
165
165
}
166
166
167
pub(crate) fn has_explicit_size(&self) -> bool {
168
self.size.is_some() || self.style.size.width.is_some() || self.style.size.height.is_some()
169
}
170
167
171
/// Rotate the icon by the given angle
168
172
///
169
173
/// Replaces any previous transformation or rotation.
@@ -164,6 +164,10 @@ impl Icon {164
Self::default()164
Self::default()165
}165
}166
166
167
pub(crate) fn has_explicit_size(&self) -> bool {168
self.size.is_some() || self.style.size.width.is_some() || self.style.size.height.is_some()169
}170
167
/// Rotate the icon by the given angle171
/// Rotate the icon by the given angle168
///172
///169
/// Replaces any previous transformation or rotation.173
/// Replaces any previous transformation or rotation.@@ -44,6 +44,7 @@ pub mod dialog;
44
44
pub mod dock;
45
45
pub mod elevation;
46
46
pub mod empty;
47
pub mod fluent;
47
48
pub mod form;
48
49
pub mod group_box;
49
50
pub mod highlighter;
@@ -44,6 +44,7 @@ pub mod dialog;44
pub mod dock;44
pub mod dock;45
pub mod elevation;45
pub mod elevation;46
pub mod empty;46
pub mod empty;47
pub mod fluent;47
pub mod form;48
pub mod form;48
pub mod group_box;49
pub mod group_box;49
pub mod highlighter;50
pub mod highlighter;@@ -19,6 +19,7 @@ use gpui_base::{
19
19
ToastTransitionStatus,
20
20
};
21
21
22
use crate::fluent::{TOAST_ICON_GAP, TOAST_ICON_SIZE, TOAST_LINE_HEIGHT};
22
23
use crate::{
23
24
ActiveTheme as _, Edges, Icon, IconName, Sizable as _, StyledExt, TITLE_BAR_HEIGHT,
24
25
animation::cubic_bezier,
@@ -30,6 +31,8 @@ const NOTIFICATION_TRANSITION_DURATION: Duration = Duration::from_millis(400);
30
31
const NOTIFICATION_EXIT_DURATION: Duration = Duration::from_millis(200);
31
32
const NOTIFICATION_TRANSITION_OFFSET: Pixels = px(96.);
32
33
const DEFAULT_NOTIFICATION_WIDTH: Pixels = px(382.);
34
const TOAST_PADDING_X: Pixels = px(16.);
35
const TOAST_PADDING_Y: Pixels = px(14.);
33
36
const NOTIFICATION_ADVANCE_INTERVAL: Duration = Duration::from_millis(50);
34
37
struct DismissRequest;
35
38
@@ -432,18 +435,28 @@ impl Render for Notification {
432
435
.bg(toast_elevation.fill)
433
436
.rounded(cx.theme().radius_lg)
434
437
.shadow(resting_shadow)
435
.py_3p5()
436
.px_4()
438
.py(TOAST_PADDING_Y)
439
.px(TOAST_PADDING_X)
437
440
.gap_3()
438
441
.refine_style(&self.style)
439
442
.when_some(icon, |this, icon| {
440
this.child(div().absolute().top(px(18.)).left_4().child(icon))
443
this.child(
444
div()
445
.absolute()
446
.top(TOAST_PADDING_Y)
447
.left(TOAST_PADDING_X)
448
.h(TOAST_LINE_HEIGHT)
449
.flex()
450
.items_center()
451
.child(icon.with_size(TOAST_ICON_SIZE)),
452
)
441
453
})
442
454
.child(
443
455
v_flex()
444
456
.flex_1()
445
457
.overflow_hidden()
446
.when(has_icon, |this| this.pl_6())
458
.line_height(TOAST_LINE_HEIGHT)
459
.when(has_icon, |this| this.pl(TOAST_ICON_SIZE + TOAST_ICON_GAP))
447
460
.when_some(self.title.clone(), |this, title| {
448
461
this.child(div().text_sm().font_semibold().child(title))
449
462
})
@@ -19,6 +19,7 @@ use gpui_base::{19
ToastTransitionStatus,19
ToastTransitionStatus,20
};20
};21
21
22
use crate::fluent::{TOAST_ICON_GAP, TOAST_ICON_SIZE, TOAST_LINE_HEIGHT};22
use crate::{23
use crate::{23
ActiveTheme as _, Edges, Icon, IconName, Sizable as _, StyledExt, TITLE_BAR_HEIGHT,24
ActiveTheme as _, Edges, Icon, IconName, Sizable as _, StyledExt, TITLE_BAR_HEIGHT,24
animation::cubic_bezier,25
animation::cubic_bezier,@@ -30,6 +31,8 @@ const NOTIFICATION_TRANSITION_DURATION: Duration = Duration::from_millis(400);30
const NOTIFICATION_EXIT_DURATION: Duration = Duration::from_millis(200);31
const NOTIFICATION_EXIT_DURATION: Duration = Duration::from_millis(200);31
const NOTIFICATION_TRANSITION_OFFSET: Pixels = px(96.);32
const NOTIFICATION_TRANSITION_OFFSET: Pixels = px(96.);32
const DEFAULT_NOTIFICATION_WIDTH: Pixels = px(382.);33
const DEFAULT_NOTIFICATION_WIDTH: Pixels = px(382.);34
const TOAST_PADDING_X: Pixels = px(16.);35
const TOAST_PADDING_Y: Pixels = px(14.);33
const NOTIFICATION_ADVANCE_INTERVAL: Duration = Duration::from_millis(50);36
const NOTIFICATION_ADVANCE_INTERVAL: Duration = Duration::from_millis(50);34
struct DismissRequest;37
struct DismissRequest;35
38
@@ -432,18 +435,28 @@ impl Render for Notification {432
.bg(toast_elevation.fill)435
.bg(toast_elevation.fill)433
.rounded(cx.theme().radius_lg)436
.rounded(cx.theme().radius_lg)434
.shadow(resting_shadow)437
.shadow(resting_shadow)435
.py_3p5()438
.py(TOAST_PADDING_Y)436
.px_4()439
.px(TOAST_PADDING_X)437
.gap_3()440
.gap_3()438
.refine_style(&self.style)441
.refine_style(&self.style)439
.when_some(icon, |this, icon| {442
.when_some(icon, |this, icon| {440
this.child(div().absolute().top(px(18.)).left_4().child(icon))443
this.child(444
div()445
.absolute()446
.top(TOAST_PADDING_Y)447
.left(TOAST_PADDING_X)448
.h(TOAST_LINE_HEIGHT)449
.flex()450
.items_center()451
.child(icon.with_size(TOAST_ICON_SIZE)),452
)441
})453
})442
.child(454
.child(443
v_flex()455
v_flex()444
.flex_1()456
.flex_1()445
.overflow_hidden()457
.overflow_hidden()446
.when(has_icon, |this| this.pl_6())458
.line_height(TOAST_LINE_HEIGHT)459
.when(has_icon, |this| this.pl(TOAST_ICON_SIZE + TOAST_ICON_GAP))447
.when_some(self.title.clone(), |this, title| {460
.when_some(self.title.clone(), |this, title| {448
this.child(div().text_sm().font_semibold().child(title))461
this.child(div().text_sm().font_semibold().child(title))449
})462
})@@ -36,7 +36,7 @@ fn dropdown_positioner(bounds: Bounds<Pixels>) -> gpui_base::Positioner {
36
36
gpui_base::Positioner::side(bounds)
37
37
.placement(gpui_base::Placement::Bottom)
38
38
.align(gpui_base::Align::Start)
39
.offset(px(6.))
39
.offset(crate::fluent::DROPDOWN_OFFSET)
40
40
.margin(px(8.))
41
41
}
42
42
@@ -36,7 +36,7 @@ fn dropdown_positioner(bounds: Bounds<Pixels>) -> gpui_base::Positioner {36
gpui_base::Positioner::side(bounds)36
gpui_base::Positioner::side(bounds)37
.placement(gpui_base::Placement::Bottom)37
.placement(gpui_base::Placement::Bottom)38
.align(gpui_base::Align::Start)38
.align(gpui_base::Align::Start)39
.offset(px(6.))39
.offset(crate::fluent::DROPDOWN_OFFSET)40
.margin(px(8.))40
.margin(px(8.))41
}41
}42
42