From d2c264d20e7735f81c2235637e8b87d27d96e26d Mon Sep 17 00:00:00 2001 From: Madeline Sparkles Date: Fri, 12 Apr 2024 14:26:04 +0800 Subject: [PATCH] try to fix #149 (clipping issue) --- crates/yakui-core/src/paint/paint_dom.rs | 1 + crates/yakui/examples/dropdown.rs | 25 ++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/crates/yakui-core/src/paint/paint_dom.rs b/crates/yakui-core/src/paint/paint_dom.rs index 0a568eac..c5fde0f3 100644 --- a/crates/yakui-core/src/paint/paint_dom.rs +++ b/crates/yakui-core/src/paint/paint_dom.rs @@ -185,6 +185,7 @@ impl PaintDom { .expect("an active layer is required to call add_mesh"); let current_clip = self.clip_stack.last().copied(); + dbg!(current_clip); let call = match layer.calls.last_mut() { Some(PaintCall::Yakui(call)) if call.texture == texture_id diff --git a/crates/yakui/examples/dropdown.rs b/crates/yakui/examples/dropdown.rs index 09ef7ad1..bd0d3d5d 100644 --- a/crates/yakui/examples/dropdown.rs +++ b/crates/yakui/examples/dropdown.rs @@ -3,8 +3,9 @@ #![allow(clippy::collapsible_if)] -use yakui::widgets::Layer; +use yakui::widgets::{Layer, Scrollable}; use yakui::{align, button, column, reflow, use_state, widgets::Pad, Alignment, Dim2}; +use yakui::{constrained, Constraints, Vec2}; use yakui_core::Pivot; pub fn run() { @@ -27,16 +28,20 @@ pub fn run() { Pad::ZERO.show(|| { Layer::new().show(|| { reflow(Alignment::BOTTOM_LEFT, Pivot::TOP_LEFT, Dim2::ZERO, || { - column(|| { - let current = selected.get(); - for (i, option) in options.iter().enumerate() { - if i != current { - if button(*option).clicked { - selected.set(i); - open.set(false); + constrained(Constraints::loose(Vec2::new(100.0, 20.0)), || { + Scrollable::vertical().show(|| { + column(|| { + let current = selected.get(); + for (i, option) in options.iter().enumerate() { + if i != current { + if button(*option).clicked { + selected.set(i); + open.set(false); + } + } } - } - } + }); + }); }); }); });