Skip to content

Commit 124d817

Browse files
committed
fix logic bug in push_scissor_stack
1 parent 2ddb419 commit 124d817

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

dash-frontend/assets/gui/tab/apps.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
flex_direction="row"
4545
flex_wrap="wrap"
4646
gap="4"
47-
overflow_y="scroll"
4847
/>
4948
</elements>
5049
</layout>

wgui/src/drawing.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -306,29 +306,33 @@ impl PushScissorStackResult {
306306
}
307307
}
308308

309-
/// Returns true if scissor has been pushed.
309+
/// Returns Some() if scissor has been pushed.
310310
pub fn push_scissor_stack(
311311
transform_stack: &mut TransformStack,
312312
scissor_stack: &mut ScissorStack,
313313
scroll_shift: Vec2,
314314
info: &Option<ScrollbarInfo>,
315315
style: &taffy::Style,
316-
) -> PushScissorStackResult {
316+
) -> Option<PushScissorStackResult> {
317317
let mut boundary_absolute = drawing::Boundary::construct_absolute(transform_stack);
318318
boundary_absolute.pos += scroll_shift;
319319

320320
let do_clip = info.is_some() && has_overflow_clip(style);
321321

322+
if !do_clip {
323+
return None; // Don't care
324+
}
325+
322326
scissor_stack.push(ScissorBoundary(boundary_absolute));
323327

324328
if scissor_stack.is_out_of_bounds() {
325-
return PushScissorStackResult::OutOfBounds;
329+
return Some(PushScissorStackResult::OutOfBounds);
326330
}
327331

328332
if do_clip {
329-
PushScissorStackResult::VisibleAndClip
333+
Some(PushScissorStackResult::VisibleAndClip)
330334
} else {
331-
PushScissorStackResult::VisibleDontClip
335+
Some(PushScissorStackResult::VisibleDontClip)
332336
}
333337
}
334338

@@ -380,7 +384,9 @@ fn draw_widget(
380384
let starting_scissor_set_count = internal.scissor_set_count;
381385
let scissor_result = push_scissor_stack(state.transform_stack, state.scissor_stack, scroll_shift, &info, style);
382386

383-
if scissor_result == PushScissorStackResult::VisibleAndClip {
387+
if let Some(scissor_result) = &scissor_result
388+
&& *scissor_result == PushScissorStackResult::VisibleAndClip
389+
{
384390
if params.debug_draw {
385391
let mut boundary_relative = drawing::Boundary::construct_relative(state.transform_stack);
386392
boundary_relative.pos += scroll_shift;
@@ -403,12 +409,17 @@ fn draw_widget(
403409
style,
404410
};
405411

406-
if scissor_result.should_display() {
412+
if scissor_result
413+
.as_ref()
414+
.is_none_or(PushScissorStackResult::should_display)
415+
{
407416
widget_state.draw_all(state, &draw_params);
408417
draw_children(params, state, node_id, internal, false);
409418
}
410419

411-
state.scissor_stack.pop();
420+
if scissor_result.is_some() {
421+
state.scissor_stack.pop();
422+
}
412423

413424
let current_scissor_set_count = internal.scissor_set_count;
414425

wgui/src/layout.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use std::{
88
use crate::{
99
animation::Animations,
1010
components::{self, Component, ComponentWeak, FocusChangeData, RefreshData},
11-
drawing::{self, ANSI_BOLD_CODE, ANSI_RESET_CODE, Boundary, push_scissor_stack, push_transform_stack},
11+
drawing::{
12+
self, ANSI_BOLD_CODE, ANSI_RESET_CODE, Boundary, PushScissorStackResult, push_scissor_stack, push_transform_stack,
13+
},
1214
event::{self, CallbackDataCommon, EventAlterables},
1315
globals::WguiGlobals,
1416
sound::WguiSoundType,
@@ -459,7 +461,10 @@ impl Layout {
459461
style,
460462
);
461463

462-
if scissor_result.should_display() {
464+
if scissor_result
465+
.as_ref()
466+
.is_none_or(PushScissorStackResult::should_display)
467+
{
463468
// check children first
464469
self.push_event_children(node_id, event, event_result, alterables, user_data)?;
465470

@@ -476,7 +481,9 @@ impl Layout {
476481
}
477482
}
478483

479-
alterables.scissor_stack.pop();
484+
if scissor_result.is_some() {
485+
alterables.scissor_stack.pop();
486+
}
480487
alterables.transform_stack.pop();
481488

482489
Ok(())

0 commit comments

Comments
 (0)