Skip to content

Commit

Permalink
allow for top level clipped components
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Nov 2, 2023
1 parent bc706d6 commit 95c7d66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions haxe/ui/backend/ComponentImpl.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1205,11 +1205,17 @@ class ComponentImpl extends ComponentBase {
var value = this.componentClipRect;
value.top = Std.int(value.top);
value.left = Std.int(value.left);
var rect = FlxRect.get((value.left * Toolkit.scaleX) + _surface.x - parentComponent.x,
(value.top * Toolkit.scaleY) + _surface.y - parentComponent.y,
(value.width * Toolkit.scaleX), (value.height * Toolkit.scaleY));
clipRect = rect;
rect.put();
if (parentComponent != null) {
var rect = FlxRect.get((value.left * Toolkit.scaleX) + _surface.x - parentComponent.x,
(value.top * Toolkit.scaleY) + _surface.y - parentComponent.y,
(value.width * Toolkit.scaleX), (value.height * Toolkit.scaleY));
clipRect = rect;
rect.put();
} else { // top-level (root) components can also clip (Absolute auto clips via a css style), but this means they wont have a parentComponent set, lets handle them differently
var rect = FlxRect.get(_surface.x, _surface.y, value.width, value.height);
clipRect = rect;
rect.put();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion haxe/ui/backend/ScreenImpl.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package haxe.ui.backend;

import haxe.ui.core.Screen;
import flixel.FlxBasic;
import flixel.FlxG;
import flixel.FlxSprite;
Expand All @@ -11,6 +10,7 @@ import haxe.ui.backend.flixel.CursorHelper;
import haxe.ui.backend.flixel.MouseHelper;
import haxe.ui.backend.flixel.StateHelper;
import haxe.ui.core.Component;
import haxe.ui.core.Screen;
import haxe.ui.events.KeyboardEvent;
import haxe.ui.events.MouseEvent;
import haxe.ui.events.UIEvent;
Expand Down

0 comments on commit 95c7d66

Please sign in to comment.