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