Introduce layer clipping
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use crate::{
|
||||
geometry::vector::Vector2F, AfterLayoutContext, Element, ElementBox, Event, EventContext,
|
||||
LayoutContext, PaintContext, SizeConstraint,
|
||||
geometry::{rect::RectF, vector::Vector2F},
|
||||
AfterLayoutContext, Element, ElementBox, Event, EventContext, LayoutContext, PaintContext,
|
||||
SizeConstraint,
|
||||
};
|
||||
|
||||
pub struct Stack {
|
||||
@@ -44,12 +45,12 @@ impl Element for Stack {
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
bounds: pathfinder_geometry::rect::RectF,
|
||||
bounds: RectF,
|
||||
_: &mut Self::LayoutState,
|
||||
ctx: &mut PaintContext,
|
||||
) -> Self::PaintState {
|
||||
for child in &mut self.children {
|
||||
ctx.scene.push_layer();
|
||||
ctx.scene.push_layer(None);
|
||||
child.paint(bounds.origin(), ctx);
|
||||
ctx.scene.pop_layer();
|
||||
}
|
||||
@@ -58,7 +59,7 @@ impl Element for Stack {
|
||||
fn dispatch_event(
|
||||
&mut self,
|
||||
event: &Event,
|
||||
_: pathfinder_geometry::rect::RectF,
|
||||
_: RectF,
|
||||
_: &mut Self::LayoutState,
|
||||
_: &mut Self::PaintState,
|
||||
ctx: &mut EventContext,
|
||||
|
||||
@@ -195,10 +195,7 @@ where
|
||||
layout: &mut Self::LayoutState,
|
||||
ctx: &mut PaintContext,
|
||||
) -> Self::PaintState {
|
||||
// ctx.canvas.save();
|
||||
// let mut clip_path = Path2D::new();
|
||||
// clip_path.rect(RectF::new(origin, self.size.unwrap()));
|
||||
// ctx.canvas.clip_path(clip_path, FillRule::Winding);
|
||||
ctx.scene.push_layer(Some(bounds));
|
||||
|
||||
let mut item_origin =
|
||||
bounds.origin() - vec2f(0.0, self.state.scroll_top() % layout.item_height);
|
||||
@@ -207,7 +204,8 @@ where
|
||||
item.paint(item_origin, ctx);
|
||||
item_origin += vec2f(0.0, layout.item_height);
|
||||
}
|
||||
// ctx.canvas.restore();
|
||||
|
||||
ctx.scene.pop_layer();
|
||||
}
|
||||
|
||||
fn dispatch_event(
|
||||
|
||||
Reference in New Issue
Block a user