2024-03-06 19:12:14 -06:00
|
|
|
|
//TODO: finish this demo
|
|
|
|
|
|
|
|
|
|
use hui::{
|
|
|
|
|
color, size,
|
2024-03-06 19:40:47 -06:00
|
|
|
|
draw::{ImageHandle, TextureFormat},
|
2024-03-06 19:12:14 -06:00
|
|
|
|
layout::{Alignment, Direction},
|
|
|
|
|
element::{
|
|
|
|
|
container::Container,
|
2024-04-17 08:47:22 -05:00
|
|
|
|
frame_view::FrameView,
|
2024-03-06 19:40:47 -06:00
|
|
|
|
image::Image,
|
|
|
|
|
text::Text,
|
2024-03-06 19:12:14 -06:00
|
|
|
|
UiElementExt
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#[path = "../boilerplate.rs"]
|
|
|
|
|
#[macro_use]
|
|
|
|
|
mod boilerplate;
|
|
|
|
|
|
2024-03-06 19:40:47 -06:00
|
|
|
|
struct Stuff {
|
|
|
|
|
vscode_icon: ImageHandle,
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-06 19:12:14 -06:00
|
|
|
|
ui_main!(
|
|
|
|
|
"hUI: vscode demo",
|
2024-03-06 19:40:47 -06:00
|
|
|
|
init: |ui| {
|
|
|
|
|
let handle = ui.add_font(include_bytes!("../assets/fira/FiraSans-Light.ttf"));
|
|
|
|
|
ui.push_font(handle);
|
|
|
|
|
Stuff {
|
|
|
|
|
vscode_icon: ui.add_image(TextureFormat::Rgba, include_bytes!("../assets/icons/visual-studio-code-icon_32x32.rgba"), 32),
|
|
|
|
|
}
|
2024-03-06 19:12:14 -06:00
|
|
|
|
},
|
2024-03-06 19:40:47 -06:00
|
|
|
|
run: |ui, size, stuff| {
|
2024-03-06 19:12:14 -06:00
|
|
|
|
Container::default()
|
|
|
|
|
.with_size(size!(100%))
|
2024-03-06 19:40:47 -06:00
|
|
|
|
.with_children(|ui| {
|
|
|
|
|
Container::default()
|
|
|
|
|
.with_size(size!(100%, auto))
|
|
|
|
|
.with_direction(Direction::Horizontal)
|
|
|
|
|
.with_align((Alignment::Begin, Alignment::Center))
|
2024-03-25 08:14:12 -05:00
|
|
|
|
.with_padding(5.)
|
2024-03-06 19:40:47 -06:00
|
|
|
|
.with_gap(15.)
|
|
|
|
|
.with_background(color::rgb_hex(0x3d3c3e))
|
2024-03-06 19:44:04 -06:00
|
|
|
|
.with_wrap(true) //XXX: not authentic but great for demostration
|
2024-03-06 19:40:47 -06:00
|
|
|
|
.with_children(|ui| {
|
|
|
|
|
Image::new(stuff.vscode_icon)
|
|
|
|
|
.with_size(size!(auto, 24))
|
|
|
|
|
.add_child(ui);
|
|
|
|
|
for item in ["File", "Edit", "Selection", "View", "Go", "Run", "Terminal", "Help"] {
|
|
|
|
|
Text::new(item)
|
|
|
|
|
.with_text_size(15)
|
|
|
|
|
.add_child(ui);
|
|
|
|
|
}
|
2024-03-25 08:08:04 -05:00
|
|
|
|
Container::default()
|
2024-03-25 08:14:12 -05:00
|
|
|
|
.with_size(size!(100%=, 100%))
|
2024-03-25 08:08:04 -05:00
|
|
|
|
.with_align((Alignment::End, Alignment::Center))
|
|
|
|
|
.with_children(|ui| {
|
|
|
|
|
Text::new("- ×")
|
|
|
|
|
.with_text_size(32)
|
|
|
|
|
.add_child(ui);
|
|
|
|
|
})
|
|
|
|
|
.add_child(ui);
|
2024-03-06 19:40:47 -06:00
|
|
|
|
})
|
|
|
|
|
.add_child(ui);
|
2024-04-17 08:44:47 -05:00
|
|
|
|
FrameView::default()
|
2024-03-06 19:40:47 -06:00
|
|
|
|
.with_size(size!(100%, 1))
|
2024-03-24 16:18:15 -05:00
|
|
|
|
.with_frame(color::rgb_hex(0x2d2d30))
|
2024-03-06 19:40:47 -06:00
|
|
|
|
.add_child(ui);
|
|
|
|
|
Container::default()
|
2024-03-25 08:08:04 -05:00
|
|
|
|
.with_size(size!(100%, 100%=))
|
2024-03-06 19:40:47 -06:00
|
|
|
|
.with_direction(Direction::Horizontal)
|
|
|
|
|
.with_children(|ui| {
|
2024-03-25 08:08:04 -05:00
|
|
|
|
// Sidebar:
|
2024-03-06 19:40:47 -06:00
|
|
|
|
Container::default()
|
2024-03-06 19:56:05 -06:00
|
|
|
|
.with_size(size!(54, 100%))
|
2024-03-06 19:40:47 -06:00
|
|
|
|
.with_background(color::rgb_hex(0x343334))
|
|
|
|
|
.add_child(ui);
|
2024-04-17 08:44:47 -05:00
|
|
|
|
FrameView::default()
|
2024-03-06 19:40:47 -06:00
|
|
|
|
.with_size(size!(1, 100%))
|
2024-03-24 16:18:15 -05:00
|
|
|
|
.with_frame(color::rgb_hex(0x2d2d30))
|
2024-03-06 19:40:47 -06:00
|
|
|
|
.add_child(ui);
|
2024-03-25 08:08:04 -05:00
|
|
|
|
|
|
|
|
|
// Explorer pane:
|
2024-03-06 19:40:47 -06:00
|
|
|
|
Container::default()
|
|
|
|
|
.with_size(size!(200, 100%))
|
|
|
|
|
.with_padding((15., 8.))
|
2024-03-06 19:56:05 -06:00
|
|
|
|
.with_background(color::rgb_hex(0x262526))
|
2024-03-06 19:40:47 -06:00
|
|
|
|
.with_children(|ui| {
|
|
|
|
|
Text::new("EXPLORER")
|
|
|
|
|
.add_child(ui);
|
|
|
|
|
})
|
|
|
|
|
.add_child(ui);
|
2024-03-25 08:08:04 -05:00
|
|
|
|
|
|
|
|
|
// "Code" pane
|
2024-03-06 19:56:05 -06:00
|
|
|
|
Container::default()
|
2024-03-25 08:08:04 -05:00
|
|
|
|
.with_size(size!(100%=, 100%))
|
2024-03-06 19:56:05 -06:00
|
|
|
|
.with_background(color::rgb_hex(0x1f1e1f))
|
|
|
|
|
.add_child(ui);
|
2024-03-06 19:40:47 -06:00
|
|
|
|
})
|
|
|
|
|
.add_child(ui);
|
2024-03-06 19:56:05 -06:00
|
|
|
|
|
2024-03-25 08:08:04 -05:00
|
|
|
|
//Status bar
|
2024-03-06 19:56:05 -06:00
|
|
|
|
Container::default()
|
|
|
|
|
.with_size(size!(100%, auto))
|
|
|
|
|
.with_background(color::rgb_hex(0x0079cc))
|
|
|
|
|
.with_direction(Direction::Horizontal)
|
|
|
|
|
.with_gap(5.)
|
|
|
|
|
.with_children(|ui| {
|
|
|
|
|
Container::default()
|
|
|
|
|
.with_background(color::rgb_hex(0x16815e))
|
|
|
|
|
.with_padding((10., 2.))
|
|
|
|
|
.with_children(|ui| {
|
|
|
|
|
Text::new("><")
|
|
|
|
|
.with_text_size(13)
|
|
|
|
|
.add_child(ui);
|
|
|
|
|
})
|
|
|
|
|
.add_child(ui);
|
|
|
|
|
Text::new("master")
|
|
|
|
|
.with_text_size(15)
|
|
|
|
|
.add_child(ui);
|
|
|
|
|
})
|
2024-03-25 08:08:04 -05:00
|
|
|
|
.add_child(ui);
|
|
|
|
|
})
|
|
|
|
|
.add_root(ui, size);
|
2024-03-06 19:12:14 -06:00
|
|
|
|
}
|
|
|
|
|
);
|