2023-08-11 06:26:58 +00:00
|
|
|
#![allow(dead_code, unused_variables)]
|
2023-08-28 21:13:59 +00:00
|
|
|
use crate::{element::ParentElement, style::StyleHelpers};
|
|
|
|
use element::{Element, IntoElement};
|
2023-08-22 15:07:45 +00:00
|
|
|
use gpui::{
|
2023-08-28 20:24:27 +00:00
|
|
|
geometry::{pixels, rect::RectF, vector::vec2f},
|
2023-08-22 15:07:45 +00:00
|
|
|
platform::WindowOptions,
|
2023-08-28 20:24:27 +00:00
|
|
|
ViewContext,
|
2023-08-22 15:07:45 +00:00
|
|
|
};
|
2023-07-14 21:34:31 +00:00
|
|
|
use log::LevelFilter;
|
2023-08-28 21:13:59 +00:00
|
|
|
use playground_macros::Element;
|
2023-07-14 21:34:31 +00:00
|
|
|
use simplelog::SimpleLogger;
|
2023-08-28 21:13:59 +00:00
|
|
|
use themes::{current_theme, rose_pine, Theme, ThemeColors};
|
2023-08-22 15:07:45 +00:00
|
|
|
use view::view;
|
2023-07-25 05:27:14 +00:00
|
|
|
|
2023-08-14 03:20:41 +00:00
|
|
|
mod adapter;
|
2023-08-11 06:26:58 +00:00
|
|
|
mod color;
|
2023-08-16 01:29:57 +00:00
|
|
|
mod components;
|
2023-08-19 02:08:29 +00:00
|
|
|
mod div;
|
2023-08-14 01:47:49 +00:00
|
|
|
mod element;
|
2023-08-18 07:03:46 +00:00
|
|
|
mod hoverable;
|
2023-08-22 16:42:26 +00:00
|
|
|
mod interactive;
|
2023-08-20 01:51:17 +00:00
|
|
|
mod layout_context;
|
2023-08-16 19:52:42 +00:00
|
|
|
mod paint_context;
|
2023-08-23 18:18:12 +00:00
|
|
|
mod pressable;
|
2023-08-13 23:29:07 +00:00
|
|
|
mod style;
|
2023-08-16 12:22:47 +00:00
|
|
|
mod text;
|
2023-08-11 06:26:58 +00:00
|
|
|
mod themes;
|
2023-08-14 15:26:35 +00:00
|
|
|
mod view;
|
2023-08-11 06:26:58 +00:00
|
|
|
|
2023-08-14 20:46:09 +00:00
|
|
|
fn main() {
|
|
|
|
SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger");
|
2023-08-11 06:26:58 +00:00
|
|
|
|
2023-08-14 20:46:09 +00:00
|
|
|
gpui::App::new(()).unwrap().run(|cx| {
|
2023-08-22 15:07:45 +00:00
|
|
|
cx.add_window(
|
|
|
|
WindowOptions {
|
|
|
|
bounds: gpui::platform::WindowBounds::Fixed(RectF::new(
|
|
|
|
vec2f(0., 0.),
|
|
|
|
vec2f(400., 300.),
|
|
|
|
)),
|
|
|
|
center: true,
|
|
|
|
..Default::default()
|
|
|
|
},
|
2023-08-28 21:13:59 +00:00
|
|
|
|_| {
|
|
|
|
view(|cx| {
|
|
|
|
playground(Theme {
|
|
|
|
colors: rose_pine::dawn(),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
2023-08-22 15:07:45 +00:00
|
|
|
);
|
2023-08-14 20:46:09 +00:00
|
|
|
cx.platform().activate(true);
|
|
|
|
});
|
2023-07-25 05:27:14 +00:00
|
|
|
}
|
|
|
|
|
2023-08-28 21:13:59 +00:00
|
|
|
fn playground<V: 'static>(theme: Theme) -> impl Element<V> {
|
|
|
|
workspace().themed(theme)
|
|
|
|
}
|
2023-08-22 15:07:45 +00:00
|
|
|
|
2023-08-28 21:13:59 +00:00
|
|
|
fn workspace<V: 'static>() -> impl Element<V> {
|
|
|
|
WorkspaceElement
|
2023-08-22 15:07:45 +00:00
|
|
|
}
|
2023-08-28 20:24:27 +00:00
|
|
|
|
2023-08-28 21:13:59 +00:00
|
|
|
use crate as playground;
|
|
|
|
#[derive(Element)]
|
|
|
|
struct WorkspaceElement;
|
|
|
|
|
|
|
|
impl WorkspaceElement {
|
|
|
|
fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl Element<V> {
|
|
|
|
use div::div;
|
|
|
|
let theme = &cx.theme::<Theme>().colors;
|
|
|
|
// one line change1!
|
|
|
|
div()
|
|
|
|
.full()
|
|
|
|
.flex()
|
|
|
|
.flex_col()
|
|
|
|
.fill(theme.base(0.5))
|
|
|
|
.child(self.title_bar(cx))
|
|
|
|
.child(self.stage(cx))
|
|
|
|
.child(self.status_bar(cx))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn title_bar<V: 'static>(&mut self, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
|
|
|
|
use div::div;
|
|
|
|
|
|
|
|
let theme = ¤t_theme(cx).colors;
|
|
|
|
div().h(pixels(cx.titlebar_height())).fill(theme.base(0.))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn status_bar<V: 'static>(&mut self, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
|
|
|
|
use div::div;
|
|
|
|
|
|
|
|
let theme = ¤t_theme(cx).colors;
|
|
|
|
div().h(pixels(cx.titlebar_height())).fill(theme.base(0.))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn stage<V: 'static>(&mut self, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
|
|
|
|
use div::div;
|
|
|
|
|
|
|
|
let theme = ¤t_theme(cx).colors;
|
|
|
|
div().flex_grow()
|
|
|
|
}
|
2023-08-28 20:24:27 +00:00
|
|
|
}
|