Skip to content

Commit

Permalink
rounded cutouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriopass committed Jan 24, 2024
1 parent cafdfa1 commit cbf85e3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 18 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ egui_plot = { git = "https://github.com/emilk/egui" }
ordered-float = { version = "4.2.0", default-features = false }
oddio = "0.7.4"
derive_more = "0.99.17"
yakui = { git = "https://github.com/SecondHalfGames/yakui" }
yakui = { git = "https://github.com/Uriopass/yakui", branch = "rounded_cutout" }
yakui-wgpu = { git = "https://github.com/Uriopass/yakui", branch = "rounded_cutout" }
yakui-winit = { git = "https://github.com/Uriopass/yakui", branch = "rounded_cutout" }
yakui-core = { git = "https://github.com/Uriopass/yakui", branch = "rounded_cutout" }
yakui-widgets = { git = "https://github.com/Uriopass/yakui", branch = "rounded_cutout" }

mlua = { version = "0.9.4", features = ["luau"] }

# Set the settings for build scripts and proc-macros.
Expand Down
4 changes: 2 additions & 2 deletions engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ lewton = "0.10.2"
serde = { version = "1.0.183", features = ["derive"] }

yakui = { workspace = true, optional = true }
yakui-wgpu = { git = "https://github.com/SecondHalfGames/yakui", optional = true }
yakui-winit = { git = "https://github.com/SecondHalfGames/yakui", optional = true }
yakui-wgpu = { workspace = true, optional = true }
yakui-winit = { workspace = true, optional = true }
lazy_static = "1.4.0"

[features]
Expand Down
4 changes: 2 additions & 2 deletions goryak/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ edition = "2021"
description = "Egregoria's yakui component library"

[dependencies]
yakui-core = { git = "https://github.com/SecondHalfGames/yakui" }
yakui-widgets = { git = "https://github.com/SecondHalfGames/yakui" }
yakui-core = { workspace = true }
yakui-widgets = { workspace = true }
nanoserde = "0.1.35"
lazy_static = "1.4.0"
serde = { version = "1.0.193", features = ["derive"] }
Expand Down
6 changes: 4 additions & 2 deletions goryak/src/blur_bg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ pub fn blur_texture() -> Option<TextureId> {
}
}

pub fn blur_bg(overlay_color: Color, children: impl FnOnce()) {
pub fn blur_bg(overlay_color: Color, radius: f32, children: impl FnOnce()) {
let id = blur_texture();
let Some(id) = id else {
colored_box_container(overlay_color, children);
return;
};

CutOut::new(id, overlay_color).show_children(children);
let mut c = CutOut::new(id, overlay_color);
c.radius = radius;
c.show_children(children);
}
30 changes: 24 additions & 6 deletions native_app/src/newgui/topgui.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use yakui::widgets::{List, Pad};
use yakui::{pad, reflow, row, Alignment, Color, Dim2, MainAxisAlignment, MainAxisSize, Vec2};
use yakui::{
colored_box, column, draggable, offset, pad, reflow, row, use_state, Alignment, Color, Dim2,
MainAxisAlignment, MainAxisSize, Vec2,
};

use goryak::{blur_bg, button_primary, constrained_viewport, labelc, on_primary_container, text};
use prototypes::GameTime;
Expand All @@ -25,11 +28,26 @@ impl Gui {
self.time_controls(uiworld, sim);
self.power_errors(uiworld, sim);

reflow(Alignment::CENTER, Dim2::pixels(-220.0, -220.0), || {
blur_bg(goryak::primary_container().with_alpha(0.3), || {
pad(Pad::all(100.0), || {
labelc(on_primary_container(), "Blurring test!");
reflow(Alignment::TOP_LEFT, Dim2::ZERO, || {
let off = use_state(|| Vec2::ZERO);

offset(off.get(), || {
let v = draggable(|| {
blur_bg(goryak::primary_container().with_alpha(0.3), 10.0, || {
column(|| {
colored_box(
on_primary_container().with_alpha(0.3),
Vec2::new(tweak!(500.0), 50.0),
);
pad(Pad::all(200.0), || {
labelc(on_primary_container(), "Blurring test!");
});
});
});
});
if let Some(v) = v.dragging {
off.set(v.current);
}
});
});
});
Expand Down Expand Up @@ -95,7 +113,7 @@ impl Gui {
let mut l = List::row();
l.main_axis_alignment = MainAxisAlignment::End;
l.show(|| {
blur_bg(goryak::primary_container().with_alpha(0.5), || {
blur_bg(goryak::primary_container().with_alpha(0.5), 10.0, || {
pad(Pad::all(3.0), || {
let mut l = List::column();
l.main_axis_size = MainAxisSize::Min;
Expand Down

0 comments on commit cbf85e3

Please sign in to comment.