BlueGit

ict rusty-teams

Files

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

call_toolbar.rs

9ee83b18 History
call_toolbar.rs 2.4 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.;
15pub(super) const GROUP_DIVIDER_WIDTH: f32 = 1.;
16const TOOL_ICON: f32 = 20.;
17const TOOL_LABEL: f32 = 11.;
18const TOOL_RADIUS: f32 = 6.;
19const CHEVRON_ICON: f32 = 12.;
20
21pub(super) fn tool_face(
22 id: impl Into<ElementId>,
23 glyph: IconName,
24 label: impl Into<SharedString>,
25 active: bool,
26) -> Stateful<Div> {
27 let color = if active {
28 theme::accent_text()
29 } else {
30 theme::text()
31 };
32 v_flex()
33 .id(id)
34 .w(px(TOOL_WIDTH))
35 .h(px(TOOL_HEIGHT))
36 .flex_none()
37 .items_center()
38 .justify_center()
39 .gap(px(3.))
40 .rounded(px(TOOL_RADIUS))
41 .cursor_pointer()
42 .hover(|face| face.bg(theme::row_hover()))
43 .child(icon(glyph, TOOL_ICON, color))
44 .child(
45 div()
46 .text_size(px(TOOL_LABEL))
47 .line_height(px(TOOL_LABEL + 3.))
48 .text_color(color)
49 .child(label.into()),
50 )
51}
52
53pub(super) fn tool_trigger(button_id: &'static str, face: Stateful<Div>) -> Button {
54 Button::new(button_id)
55 .ghost()
56 .p_0()
57 .w(px(TOOL_WIDTH))
58 .h(px(TOOL_HEIGHT))
59 .rounded(px(TOOL_RADIUS))
60 .child(face)
61}
62
63pub(super) fn split_chevron(button_id: &'static str, face_id: &'static str) -> Button {
64 Button::new(button_id)
65 .ghost()
66 .p_0()
67 .w(px(SPLIT_CHEVRON_WIDTH))
68 .h(px(TOOL_HEIGHT))
69 .rounded(px(TOOL_RADIUS))
70 .child(
71 div()
72 .id(face_id)
73 .w(px(SPLIT_CHEVRON_WIDTH))
74 .h(px(TOOL_HEIGHT))
75 .flex()
76 .items_center()
77 .justify_center()
78 .rounded(px(TOOL_RADIUS))
79 .hover(|face| face.bg(theme::row_hover()))
80 .child(icon(IconName::ChevronDown, CHEVRON_ICON, theme::text())),
81 )
82}
83
84pub(super) fn group_divider() -> Div {
85 div()
86 .flex_none()
87 .w(px(GROUP_DIVIDER_WIDTH))
88 .h(px(TOOL_HEIGHT - 16.))
89 .bg(theme::border())
90}