components.rs

  1mod assistant_panel;
  2mod breadcrumb;
  3mod buffer;
  4mod chat_panel;
  5mod collab_panel;
  6mod command_palette;
  7mod context_menu;
  8mod editor_pane;
  9mod facepile;
 10mod icon_button;
 11mod keybinding;
 12mod list;
 13mod palette;
 14mod panel;
 15mod panes;
 16mod player_stack;
 17mod project_panel;
 18mod status_bar;
 19mod tab;
 20mod tab_bar;
 21mod terminal;
 22mod title_bar;
 23mod toolbar;
 24mod traffic_lights;
 25mod workspace;
 26
 27pub use assistant_panel::*;
 28pub use breadcrumb::*;
 29pub use buffer::*;
 30pub use chat_panel::*;
 31pub use collab_panel::*;
 32pub use command_palette::*;
 33pub use context_menu::*;
 34pub use editor_pane::*;
 35pub use facepile::*;
 36pub use icon_button::*;
 37pub use keybinding::*;
 38pub use list::*;
 39pub use palette::*;
 40pub use panel::*;
 41pub use panes::*;
 42pub use player_stack::*;
 43pub use project_panel::*;
 44pub use status_bar::*;
 45pub use tab::*;
 46pub use tab_bar::*;
 47pub use terminal::*;
 48pub use title_bar::*;
 49pub use toolbar::*;
 50pub use traffic_lights::*;
 51pub use workspace::*;
 52
 53// Nate: Commenting this out for now, unsure if we need it.
 54
 55// use std::marker::PhantomData;
 56// use std::rc::Rc;
 57
 58// use gpui2::elements::div;
 59// use gpui2::interactive::Interactive;
 60// use gpui2::platform::MouseButton;
 61// use gpui2::{ArcCow, Element, EventContext, IntoElement, ParentElement, ViewContext};
 62
 63// struct ButtonHandlers<V, D> {
 64//     click: Option<Rc<dyn Fn(&mut V, &D, &mut EventContext<V>)>>,
 65// }
 66
 67// impl<V, D> Default for ButtonHandlers<V, D> {
 68//     fn default() -> Self {
 69//         Self { click: None }
 70//     }
 71// }
 72
 73// #[derive(Element)]
 74// pub struct Button<V: 'static, D: 'static> {
 75//     handlers: ButtonHandlers<V, D>,
 76//     label: Option<ArcCow<'static, str>>,
 77//     icon: Option<ArcCow<'static, str>>,
 78//     data: Rc<D>,
 79//     view_type: PhantomData<V>,
 80// }
 81
 82// // Impl block for buttons without data.
 83// // See below for an impl block for any button.
 84// impl<V: 'static> Button<V, ()> {
 85//     fn new() -> Self {
 86//         Self {
 87//             handlers: ButtonHandlers::default(),
 88//             label: None,
 89//             icon: None,
 90//             data: Rc::new(()),
 91//             view_type: PhantomData,
 92//         }
 93//     }
 94
 95//     pub fn data<D: 'static>(self, data: D) -> Button<V, D> {
 96//         Button {
 97//             handlers: ButtonHandlers::default(),
 98//             label: self.label,
 99//             icon: self.icon,
100//             data: Rc::new(data),
101//             view_type: PhantomData,
102//         }
103//     }
104// }
105
106// // Impl block for button regardless of its data type.
107// impl<V: 'static, D: 'static> Button<V, D> {
108//     pub fn label(mut self, label: impl Into<ArcCow<'static, str>>) -> Self {
109//         self.label = Some(label.into());
110//         self
111//     }
112
113//     pub fn icon(mut self, icon: impl Into<ArcCow<'static, str>>) -> Self {
114//         self.icon = Some(icon.into());
115//         self
116//     }
117
118//     pub fn on_click(
119//         mut self,
120//         handler: impl Fn(&mut V, &D, &mut EventContext<V>) + 'static,
121//     ) -> Self {
122//         self.handlers.click = Some(Rc::new(handler));
123//         self
124//     }
125// }
126
127// pub fn button<V>() -> Button<V, ()> {
128//     Button::new()
129// }
130
131// impl<V: 'static, D: 'static> Button<V, D> {
132//     fn render(
133//         &mut self,
134//         view: &mut V,
135//         cx: &mut ViewContext<V>,
136//     ) -> impl IntoElement<V> + Interactive<V> {
137//         // let colors = &cx.theme::<Theme>().colors;
138
139//         let button = div()
140//             // .fill(colors.error(0.5))
141//             .h_4()
142//             .children(self.label.clone());
143
144//         if let Some(handler) = self.handlers.click.clone() {
145//             let data = self.data.clone();
146//             button.on_mouse_down(MouseButton::Left, move |view, event, cx| {
147//                 handler(view, data.as_ref(), cx)
148//             })
149//         } else {
150//             button
151//         }
152//     }
153// }