Skip to content

Commit

Permalink
scale-mode css directive
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Apr 13, 2024
1 parent c86ba92 commit 12b97fa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions haxe/ui/components/Image.hx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ private class ImageLayout extends DefaultLayout {

private function updateClipRect() {
if (component.hasImageDisplay()) {
if (component.style != null && component.style.clip == false) {
return;
}

var usz:Size = usableSize;
var imageDisplay:ImageDisplay = component.getImageDisplay();
var rc:Rectangle = imageDisplay.imageClipRect;
Expand Down Expand Up @@ -319,5 +323,8 @@ private class Builder extends CompositeBuilder {
if (style.resource != null) {
_image.resource = style.resource;
}
if (style.scaleMode != null) {
_image.scaleMode = style.scaleMode;
}
}
}
12 changes: 11 additions & 1 deletion haxe/ui/styles/Style.hx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ class Style {

@:optional public var contentType:String;
@:optional public var direction:String;
@:optional public var scaleMode:String;


/** The width at which the children will be clipped inside a scrollview **/ @:optional public var contentWidth:Null<Float>;
/** The width in % unit of the component at which the children will be clipped inside a scrollview **/ @:optional public var contentWidthPercent:Null<Float>;
Expand Down Expand Up @@ -476,7 +478,13 @@ class Style {
contentType = ValueTools.string(v.value);
case "direction":
direction = ValueTools.string(v.value);


case "scale-mode":
if (ValueTools.none(v.value)) {
scaleMode = "none";
} else {
scaleMode = ValueTools.string(v.value);
}
case "content-width":
contentWidth = ValueTools.calcDimension(v.value);
contentWidthPercent = ValueTools.percent(v.value);
Expand Down Expand Up @@ -658,6 +666,7 @@ class Style {
if (s.pointerEvents != null) pointerEvents = s.pointerEvents;
if (s.contentType != null) contentType = s.contentType;
if (s.direction != null) direction = s.direction;
if (s.scaleMode != null) scaleMode = s.scaleMode;

if (s.contentWidth != null) contentWidth = s.contentWidth;
if (s.contentWidthPercent != null) contentWidthPercent = s.contentWidthPercent;
Expand Down Expand Up @@ -803,6 +812,7 @@ class Style {
if (s.pointerEvents != pointerEvents) return false;
if (s.contentType != contentType) return false;
if (s.direction != direction) return false;
if (s.scaleMode != scaleMode) return false;

if (s.contentWidth != contentWidth) return false;
if (s.contentWidthPercent != contentWidthPercent) return false;
Expand Down

0 comments on commit 12b97fa

Please sign in to comment.