From cbf85e3ee4e6fa7ee98d227663cfd8e7539b4b1c Mon Sep 17 00:00:00 2001 From: Paris DOUADY Date: Wed, 24 Jan 2024 12:21:31 +0100 Subject: [PATCH] rounded cutouts --- Cargo.lock | 10 +++++----- Cargo.toml | 7 ++++++- engine/Cargo.toml | 4 ++-- goryak/Cargo.toml | 4 ++-- goryak/src/blur_bg.rs | 6 ++++-- native_app/src/newgui/topgui.rs | 30 ++++++++++++++++++++++++------ 6 files changed, 43 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 207da6b4..4150e115 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4030,7 +4030,7 @@ checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" [[package]] name = "yakui" version = "0.2.0" -source = "git+https://github.com/SecondHalfGames/yakui#7750ad6e1561e29956048c2d7dc4cced1c2ab26f" +source = "git+https://github.com/Uriopass/yakui?branch=rounded_cutout#4fdb7af116cebfff8156fea2e72ad5c615e99c04" dependencies = [ "yakui-core", "yakui-widgets", @@ -4039,7 +4039,7 @@ dependencies = [ [[package]] name = "yakui-core" version = "0.2.0" -source = "git+https://github.com/SecondHalfGames/yakui#7750ad6e1561e29956048c2d7dc4cced1c2ab26f" +source = "git+https://github.com/Uriopass/yakui?branch=rounded_cutout#4fdb7af116cebfff8156fea2e72ad5c615e99c04" dependencies = [ "anymap", "bitflags 1.3.2", @@ -4055,7 +4055,7 @@ dependencies = [ [[package]] name = "yakui-wgpu" version = "0.2.0" -source = "git+https://github.com/SecondHalfGames/yakui#7750ad6e1561e29956048c2d7dc4cced1c2ab26f" +source = "git+https://github.com/Uriopass/yakui?branch=rounded_cutout#4fdb7af116cebfff8156fea2e72ad5c615e99c04" dependencies = [ "bytemuck", "glam", @@ -4068,7 +4068,7 @@ dependencies = [ [[package]] name = "yakui-widgets" version = "0.2.0" -source = "git+https://github.com/SecondHalfGames/yakui#7750ad6e1561e29956048c2d7dc4cced1c2ab26f" +source = "git+https://github.com/Uriopass/yakui?branch=rounded_cutout#4fdb7af116cebfff8156fea2e72ad5c615e99c04" dependencies = [ "fontdue", "smol_str 0.1.24", @@ -4079,7 +4079,7 @@ dependencies = [ [[package]] name = "yakui-winit" version = "0.2.0" -source = "git+https://github.com/SecondHalfGames/yakui#7750ad6e1561e29956048c2d7dc4cced1c2ab26f" +source = "git+https://github.com/Uriopass/yakui?branch=rounded_cutout#4fdb7af116cebfff8156fea2e72ad5c615e99c04" dependencies = [ "winit", "yakui-core", diff --git a/Cargo.toml b/Cargo.toml index 30db0c4a..1d27cf3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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. diff --git a/engine/Cargo.toml b/engine/Cargo.toml index 5e7edfd1..6f272eda 100644 --- a/engine/Cargo.toml +++ b/engine/Cargo.toml @@ -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] diff --git a/goryak/Cargo.toml b/goryak/Cargo.toml index 9658cf99..7dfd77ae 100644 --- a/goryak/Cargo.toml +++ b/goryak/Cargo.toml @@ -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"] } diff --git a/goryak/src/blur_bg.rs b/goryak/src/blur_bg.rs index e58ea3cd..cac21c16 100644 --- a/goryak/src/blur_bg.rs +++ b/goryak/src/blur_bg.rs @@ -24,12 +24,14 @@ pub fn blur_texture() -> Option { } } -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); } diff --git a/native_app/src/newgui/topgui.rs b/native_app/src/newgui/topgui.rs index 31930c45..e653b1b0 100644 --- a/native_app/src/newgui/topgui.rs +++ b/native_app/src/newgui/topgui.rs @@ -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; @@ -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); + } }); }); }); @@ -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;