Skip to content

Commit

Permalink
added domkit ScaleGrid.tileCenter and Flow.backgroundRepeat
Browse files Browse the repository at this point in the history
  • Loading branch information
ncannasse committed Jan 18, 2024
1 parent 8f8cafc commit d501d7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 6 additions & 3 deletions h2d/ScaleGrid.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ class ScaleGrid extends h2d.TileGroup {
The height of the bitmap. Setting to values less than `borderTop + borderBottom` leads to undefined results.
**/
public var height(default,set) : Float;
/**
When enabled, borders will be tiled along the edges instead of stretching to match the desired dimensions.

Center tile is always stretched.

/**
When enabled, borders will be repeated along the edges instead of stretching to match the desired dimensions.
**/
public var tileBorders(default, set) : Bool;

/**
When enabled, center will be repeated along the edges instead of stretching to match the desired dimensions.
**/
public var tileCenter(default, set) : Bool;

/**
Expand Down
11 changes: 11 additions & 0 deletions h2d/domkit/BaseComponents.hx
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ class ScaleGridComp extends DrawableComp implements domkit.Component.ComponentDe
@:p var ignoreScale : Bool;
@:p var borderScale : Float;
@:p var tileBorders : Bool;
@:p var tileCenter : Bool;
@:p var width : Float;
@:p var height : Float;

Expand All @@ -766,6 +767,10 @@ class ScaleGridComp extends DrawableComp implements domkit.Component.ComponentDe
o.tileBorders = v;
}

static function set_tileCenter(o : h2d.ScaleGrid, v) {
o.tileCenter = v;
}

static function set_width( o : h2d.ScaleGrid, v : Float ) {
o.width = v;
}
Expand All @@ -791,6 +796,7 @@ class FlowComp extends ObjectComp implements domkit.Component.ComponentDecl<h2d.
@:p var backgroundTilePosY : Null<Int>;
@:p var backgroundAlpha : Float = 1;
@:p(auto) var backgroundSmooth : Null<Bool>;
@:p var backgroundRepeat : Bool;
@:p var debug : Bool;
@:p var layout : h2d.Flow.FlowLayout;
@:p var vertical : Bool;
Expand Down Expand Up @@ -868,6 +874,11 @@ class FlowComp extends ObjectComp implements domkit.Component.ComponentDecl<h2d.
o.backgroundTile = t;
}

static function set_backgroundRepeat( o : h2d.Flow, v ) {
@:privateAccess if( o.background != null )
o.background.tileBorders = o.background.tileCenter = v;
}

static function set_backgroundTilePos( o : h2d.Flow, pos ) {
o.backgroundTile = @:privateAccess BitmapComp.setTilePos(o.backgroundTile, pos);
}
Expand Down

0 comments on commit d501d7c

Please sign in to comment.