From 12b97faf90f837fdeea9643df79800207746e1a6 Mon Sep 17 00:00:00 2001 From: Ian Harrigan Date: Sat, 13 Apr 2024 10:27:02 +0200 Subject: [PATCH] scale-mode css directive --- haxe/ui/components/Image.hx | 7 +++++++ haxe/ui/styles/Style.hx | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/haxe/ui/components/Image.hx b/haxe/ui/components/Image.hx index d3d8fa616..f88843984 100644 --- a/haxe/ui/components/Image.hx +++ b/haxe/ui/components/Image.hx @@ -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; @@ -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; + } } } diff --git a/haxe/ui/styles/Style.hx b/haxe/ui/styles/Style.hx index f17e191a7..d13f12216 100644 --- a/haxe/ui/styles/Style.hx +++ b/haxe/ui/styles/Style.hx @@ -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; /** The width in % unit of the component at which the children will be clipped inside a scrollview **/ @:optional public var contentWidthPercent:Null; @@ -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); @@ -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; @@ -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;