BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / views / call_toolbar.rs

call_toolbar.rs

call_toolbar.rs 2.2 KiB Download Raw
1use gpui_kit::assets::IconName;
2use gpui_kit::component::button::{Button, ButtonVariants as _};
3use gpui_kit::component::v_flex;
4use gpui_kit::*;
5
6use super::widgets::icon;
7use crate::theme;
8
9pub(super) const TOOL_WIDTH: f32 = 56.;
10pub(super) const TOOL_HEIGHT: f32 = 48.;
11pub(super) const TOOL_GAP: f32 = 2.;
12pub(super) const GROUP_GAP: f32 = 12.;
13pub(super) const SPLIT_CHEVRON_WIDTH: f32 = 20.;
14pub(super) const LEAVE_HEIGHT: f32 = 32.;
15const TOOL_ICON: f32 = 20.;
16const TOOL_LABEL: f32 = 11.;
17const TOOL_RADIUS: f32 = 6.;
18const CHEVRON_ICON: f32 = 12.;
19
20pub(super) fn tool_face(
21 id: impl Into<ElementId>,
22 glyph: IconName,
23 label: impl Into<SharedString>,
24 active: bool,
25) -> Stateful<Div> {
26 let color = if active {
27 theme::accent_text()
28 } else {
29 theme::text()
30 };
31 v_flex()
32 .id(id)
33 .w(px(TOOL_WIDTH))
34 .h(px(TOOL_HEIGHT))
35 .flex_none()
36 .items_center()
37 .justify_center()
38 .gap(px(3.))
39 .rounded(px(TOOL_RADIUS))
40 .cursor_pointer()
41 .hover(|face| face.bg(theme::row_hover()))
42 .child(icon(glyph, TOOL_ICON, color))
43 .child(
44 div()
45 .text_size(px(TOOL_LABEL))
46 .line_height(px(TOOL_LABEL + 3.))
47 .text_color(color)
48 .child(label.into()),
49 )
50}
51
52pub(super) fn tool_trigger(button_id: &'static str, face: Stateful<Div>) -> Button {
53 Button::new(button_id)
54 .ghost()
55 .p_0()
56 .w(px(TOOL_WIDTH))
57 .h(px(TOOL_HEIGHT))
58 .rounded(px(TOOL_RADIUS))
59 .child(face)
60}
61
62pub(super) fn split_chevron(button_id: &'static str, face_id: &'static str) -> Button {
63 Button::new(button_id)
64 .ghost()
65 .p_0()
66 .w(px(SPLIT_CHEVRON_WIDTH))
67 .h(px(TOOL_HEIGHT))
68 .rounded(px(TOOL_RADIUS))
69 .child(
70 div()
71 .id(face_id)
72 .w(px(SPLIT_CHEVRON_WIDTH))
73 .h(px(TOOL_HEIGHT))
74 .flex()
75 .items_center()
76 .justify_center()
77 .rounded(px(TOOL_RADIUS))
78 .hover(|face| face.bg(theme::row_hover()))
79 .child(icon(IconName::ChevronDown, CHEVRON_ICON, theme::text())),
80 )
81}