zed/crates/gpui/playground/src/playground.rs

61 lines
1.5 KiB
Rust
Raw Normal View History

2023-08-11 06:26:58 +00:00
#![allow(dead_code, unused_variables)]
2023-08-23 15:08:05 +00:00
use crate::{
2023-08-26 03:41:21 +00:00
color::black, element::ParentElement, style::StyleHelpers, themes::rose_pine::RosePinePalette,
2023-08-23 15:08:05 +00:00
};
2023-08-22 15:07:45 +00:00
use element::Element;
use gpui::{
geometry::{rect::RectF, vector::vec2f},
platform::WindowOptions,
};
use log::LevelFilter;
use simplelog::SimpleLogger;
2023-08-22 15:07:45 +00:00
use themes::{rose_pine, ThemeColors};
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;
mod div;
2023-08-14 01:47:49 +00:00
mod element;
mod hoverable;
mod interactive;
2023-08-20 01:51:17 +00:00
mod layout_context;
2023-08-16 19:52:42 +00:00
mod paint_context;
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
fn main() {
SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger");
2023-08-11 06:26:58 +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()
},
|_| view(|_| playground(&rose_pine::moon())),
);
cx.platform().activate(true);
});
2023-07-25 05:27:14 +00:00
}
2023-08-22 15:07:45 +00:00
fn playground<V: 'static>(theme: &ThemeColors) -> impl Element<V> {
use div::div;
2023-08-26 03:41:21 +00:00
let p = RosePinePalette::dawn();
2023-08-22 15:07:45 +00:00
div()
.text_color(black())
.h_full()
2023-08-26 03:41:21 +00:00
.w_full()
.fill(p.rose)
2023-08-26 04:19:49 +00:00
.child(div().fill(p.pine).child(div().fill(p.love).w_6().h_3()))
.child(div().fill(p.gold).child(div().fill(p.iris).w_3().h_3()))
2023-08-22 15:07:45 +00:00
}