Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/haxeui/haxeui-core
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed May 7, 2024
2 parents 1a412e9 + 6114b4d commit 3364b2e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
13 changes: 12 additions & 1 deletion haxe/ui/backend/ComponentGraphicsBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ class ComponentGraphicsBase {
public function image(resource:Variant, x:Null<Float> = null, y:Null<Float> = null, width:Null<Float> = null, height:Null<Float> = null) {
addDrawCommand(Image(resource, x, y, width, height));
}

public function beginPath() {
addDrawCommand(BeginPath);
}

public function closePath() {
addDrawCommand(ClosePath);
}

private function addDrawCommand(command:DrawCommand) {
_drawCommands.push(command);
Expand Down Expand Up @@ -106,7 +114,10 @@ class ComponentGraphicsBase {
rectangle(x, y, width, height);
case Image(resource, x, y, width, height):
image(resource, x, y, width, height);

case BeginPath:
beginPath();
case ClosePath:
closePath();
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions haxe/ui/components/Canvas.hx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ private class DataSourceBehaviour extends DataBehaviour {
var x:Null<Float> = (item.x != null) ? Std.parseFloat(item.x) : 0;
var y:Null<Float> = (item.y != null) ? Std.parseFloat(item.y) : 0;
g.lineTo(x, y);
case "curveTo" | "curve-to":
var controlX:Null<Float> = (item.controlX != null) ? Std.parseFloat(item.controlX) : 0;
var controlY:Null<Float> = (item.controlY != null) ? Std.parseFloat(item.controlY) : 0;
var anchorX:Null<Float> = (item.anchorX != null) ? Std.parseFloat(item.anchorX) : 0;
var anchorY:Null<Float> = (item.anchorY != null) ? Std.parseFloat(item.anchorY) : 0;
g.curveTo(controlX, controlY, anchorX, anchorY);
case "cubicCurveTo" | "cubic-curve-to":
var controlX:Null<Float> = (item.controlX != null) ? Std.parseFloat(item.controlX) : 0;
var controlY:Null<Float> = (item.controlY != null) ? Std.parseFloat(item.controlY) : 0;
var controlX2:Null<Float> = (item.controlX2 != null) ? Std.parseFloat(item.controlX2) : 0;
var controlY2:Null<Float> = (item.controlY2 != null) ? Std.parseFloat(item.controlY2) : 0;
var anchorX:Null<Float> = (item.anchorX != null) ? Std.parseFloat(item.anchorX) : 0;
var anchorY:Null<Float> = (item.anchorY != null) ? Std.parseFloat(item.anchorY) : 0;
g.cubicCurveTo(controlX, controlY, controlX2, controlY2, anchorX, anchorY);
case "strokeStyle" | "stroke-style":
var color:String = item.color;
var thickness:Null<Float> = (item.thickness != null) ? Std.parseFloat(item.thickness) : 1;
Expand Down Expand Up @@ -89,6 +103,10 @@ private class DataSourceBehaviour extends DataBehaviour {
var y:Null<Float> = Std.parseFloat(item.y);
var radius:Null<Float> = Std.parseFloat(item.radius);
g.circle(x, y, radius);
case "beginPath" | "begin-path":
g.beginPath();
case "closePath" | "close-path":
g.closePath();
case _:
trace("unrecognised draw command: " + item);
}
Expand Down
2 changes: 2 additions & 0 deletions haxe/ui/graphics/DrawCommand.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ enum DrawCommand {
CubicCurveTo(controlX1:Float, controlY1:Float, controlX2:Float, controlY2:Float, anchorX:Float, anchorY:Float);
Rectangle(x:Float, y:Float, width:Float, height:Float);
Image(resource:Variant, x:Float, y:Float, width:Float, height:Float);
BeginPath;
ClosePath;
}
8 changes: 8 additions & 0 deletions haxe/ui/layouts/HorizontalGridLayout.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ class HorizontalGridLayout extends Layout {
super();
}

public override function applyProperties(props:Map<String, Any>) {
if (props != null) {
if (props.exists("rows") && props.get("rows") != null) {
this.rows = props.get("rows");
}
}
}

private override function get_usableSize():Size {
var size:Size = super.get_usableSize();
var columnWidths:Array<Float> = calcColumnWidths(size, false);
Expand Down

0 comments on commit 3364b2e

Please sign in to comment.