From 6a9764661ec85ad348509dcda0bbd349c535e311 Mon Sep 17 00:00:00 2001 From: Ian Harrigan Date: Fri, 26 Apr 2024 16:05:52 +0200 Subject: [PATCH] new atlas player and spinner components --- .../styles/atlases/default-spinner.json | 49 ++++ .../styles/atlases/default-spinner.png | Bin 0 -> 17577 bytes haxe/ui/components/AtlasPlayer.hx | 254 ++++++++++++++++++ haxe/ui/components/Spinner.hx | 5 + haxe/ui/module.xml | 14 +- 5 files changed, 319 insertions(+), 3 deletions(-) create mode 100644 haxe/ui/_module/styles/atlases/default-spinner.json create mode 100644 haxe/ui/_module/styles/atlases/default-spinner.png create mode 100644 haxe/ui/components/AtlasPlayer.hx create mode 100644 haxe/ui/components/Spinner.hx diff --git a/haxe/ui/_module/styles/atlases/default-spinner.json b/haxe/ui/_module/styles/atlases/default-spinner.json new file mode 100644 index 000000000..818145f2a --- /dev/null +++ b/haxe/ui/_module/styles/atlases/default-spinner.json @@ -0,0 +1,49 @@ +{ + "frames": [ + { "frame": { "w": 64, "h": 64, "x": 0, "y": 0 } }, + { "frame": { "w": 64, "h": 64, "x": 64, "y": 0 } }, + { "frame": { "w": 64, "h": 64, "x": 128, "y": 0 } }, + { "frame": { "w": 64, "h": 64, "x": 192, "y": 0 } }, + { "frame": { "w": 64, "h": 64, "x": 256, "y": 0 } }, + { "frame": { "w": 64, "h": 64, "x": 320, "y": 0 } }, + { "frame": { "w": 64, "h": 64, "x": 384, "y": 0 } }, + { "frame": { "w": 64, "h": 64, "x": 448, "y": 0 } }, + { "frame": { "w": 64, "h": 64, "x": 512, "y": 0 } }, + { "frame": { "w": 64, "h": 64, "x": 0, "y": 64 } }, + { "frame": { "w": 64, "h": 64, "x": 64, "y": 64 } }, + { "frame": { "w": 64, "h": 64, "x": 128, "y": 64 } }, + { "frame": { "w": 64, "h": 64, "x": 192, "y": 64 } }, + { "frame": { "w": 64, "h": 64, "x": 256, "y": 64 } }, + { "frame": { "w": 64, "h": 64, "x": 320, "y": 64 } }, + { "frame": { "w": 64, "h": 64, "x": 384, "y": 64 } }, + { "frame": { "w": 64, "h": 64, "x": 448, "y": 64 } }, + { "frame": { "w": 64, "h": 64, "x": 512, "y": 64 } }, + { "frame": { "w": 64, "h": 64, "x": 0, "y": 128 } }, + { "frame": { "w": 64, "h": 64, "x": 64, "y": 128 } }, + { "frame": { "w": 64, "h": 64, "x": 128, "y": 128 } }, + { "frame": { "w": 64, "h": 64, "x": 192, "y": 128 } }, + { "frame": { "w": 64, "h": 64, "x": 256, "y": 128 } }, + { "frame": { "w": 64, "h": 64, "x": 320, "y": 128 } }, + { "frame": { "w": 64, "h": 64, "x": 384, "y": 128 } }, + { "frame": { "w": 64, "h": 64, "x": 448, "y": 128 } }, + { "frame": { "w": 64, "h": 64, "x": 512, "y": 128 } }, + { "frame": { "w": 64, "h": 64, "x": 0, "y": 192 } }, + { "frame": { "w": 64, "h": 64, "x": 64, "y": 192 } }, + { "frame": { "w": 64, "h": 64, "x": 128, "y": 192 } }, + { "frame": { "w": 64, "h": 64, "x": 192, "y": 192 } }, + { "frame": { "w": 64, "h": 64, "x": 256, "y": 192 } }, + { "frame": { "w": 64, "h": 64, "x": 320, "y": 192 } }, + { "frame": { "w": 64, "h": 64, "x": 384, "y": 192 } }, + { "frame": { "w": 64, "h": 64, "x": 448, "y": 192 } }, + { "frame": { "w": 64, "h": 64, "x": 512, "y": 192 } }, + { "frame": { "w": 64, "h": 64, "x": 0, "y": 256 } }, + { "frame": { "w": 64, "h": 64, "x": 64, "y": 256 } }, + { "frame": { "w": 64, "h": 64, "x": 128, "y": 256 } }, + { "frame": { "w": 64, "h": 64, "x": 192, "y": 256 } }, + { "frame": { "w": 64, "h": 64, "x": 256, "y": 256 } }, + { "frame": { "w": 64, "h": 64, "x": 320, "y": 256 } }, + { "frame": { "w": 64, "h": 64, "x": 384, "y": 256 } }, + { "frame": { "w": 64, "h": 64, "x": 448, "y": 256 } }, + { "frame": { "w": 64, "h": 64, "x": 512, "y": 256 } } + ] +} \ No newline at end of file diff --git a/haxe/ui/_module/styles/atlases/default-spinner.png b/haxe/ui/_module/styles/atlases/default-spinner.png new file mode 100644 index 0000000000000000000000000000000000000000..3c879dbb410b481ee151ae0d89e28239d1502994 GIT binary patch literal 17577 zcmeIaX*iVc8$UcVCQGtQCHoS})`C!GEG4@TWfvlAS<5mrBwKwci3*`Y$i5RpDrC*h zV3d6sW1GQ@nfrh1_wD%n1I+!mqUu`~meh)763$_XsROAR-Vw9Zib|_Jj;0Kf#*vh3gCL zpR*T#o-|W`;1vB{d;6Spch^aKjHJmFyX?w`1*UJa`b_4vcfZpuR9N=}PxjLf1+3)nYf;On|#(161L5(59XWSxcCIg`KGazdd0 z7E?~-J=otrBj%Zr5GAWQ#p8b)Kw!)o5SYmSN}m9fIcvT^fbkK88S|$gAuUY*Nq-{_ zfezZfY<2uA4$3UD`?n?r=?@pdyeafMe&nw>2ox^--#FY8AaGOv8|;rX{|;6JGtKaC z#}HUI7Y5={{KHA{-;Oa5IA_@3n#e3w7$>s(hUyW;s>}E7u0Cw7Dd1d`rCk z`sDqSKTEESw5)&&^bfZpDdWP!sRB}6RJim!5`3XL<2ZWPW| zdA0Z)834PvBj#ug!|6uM62zh*Z#v4>&u?*-DotB*H)BIdy;2SAg${P2J9mY!ttA)? z99F%5Jx+#~6UqIVPdQ9NajHd8XKQtP(SPaVce251<%bc`RfY&jmQjl7-Me5lgAjg{ zx+*jt72r|z1T#SyL2_5-&v-~~zMOcyuF2{C3{%E&Ltih=R1>1KIGtpa`#CRk<&khq z2Y%2U?^}#b3Cl{QEi$}TzbHXH>%|a}!)z*CZ!i2=nb!2dR)je#=kpP4+CLZ#hHLpl zWoEcezG6TzW54my1ajM8M0N9Rxzd@iT2WZFtD>Iz7ZD7`beRE!|}ySKOS-3j|^cDIA)V1)Obflox3 zMJ|MLetd-~dXe;b+ZC7puF$-E7svK}k{spr%`SNBg5ws;R^SuJ$;%@W&I*yslP*x` z1ruCL2?nVQGryfRZ`{G?k+~XnPx*6E$mYZ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0`@U+ATqDNm5k zAoWYJMB#pxDs#QYy2DS2pdR-rodLr7|M7b?9v?kfgl_Gu}>XMs! zdFM$~RVD8=<4eZRba_85=Vmmnb0WvMX8xq?iwHwk^0(NoU<^ApPLT1wz<cxVWA_u8RZb+UsyK@8FE}cKh!D1K z44*tha@;q#3G3_?!v6P7g;LIl{29*NwQsH5qgqF!GQpSj-}FdrOv;z!@k>kfYm-4Z zKrN8-6x>vZynFiJabb`xAWVC>Sb&%9zkWDCRQ8hX#*M#+e?%k*+#a=6mFEAikq~&; zKdk*-_}}S&hzA2XUF&Ch;lDK@!yu0kKX;4BszPLBpP$3>Hj8)DuNS; zJi~P5|0aoQgD5hGRoKzLbIfuCCveD$J^ueDiN=6(g^K_Gh53IjOf$eFUMmp7o^($g R{PqY$?~1Wbv6f@x{{b|A89@L5 literal 0 HcmV?d00001 diff --git a/haxe/ui/components/AtlasPlayer.hx b/haxe/ui/components/AtlasPlayer.hx new file mode 100644 index 000000000..b726a240e --- /dev/null +++ b/haxe/ui/components/AtlasPlayer.hx @@ -0,0 +1,254 @@ +package haxe.ui.components; + +import haxe.Json; +import haxe.Timer; +import haxe.ui.Toolkit; +import haxe.ui.ToolkitAssets; +import haxe.ui.containers.Box; +import haxe.ui.events.UIEvent; +import haxe.ui.util.Variant; + +class AtlasPlayer extends Box { + public var animationDirection:String = "forward"; + public var autoPlay:Bool = true; + + private var _playing:Bool = false; + private var _frames:Array = []; + + private var _resource:Variant = null; + public var resource(get, set):Variant; + private function get_resource():Variant { + return _resource; + } + private function set_resource(value:Variant):Variant { + _resource = value; + checkAtlas(); + return value; + } + + public var _atlas:String; + public var atlas(get, set):String; + private function get_atlas():String { + return _atlas; + } + private function set_atlas(value:String):String { + _atlas = value; + checkAtlas(); + return value; + } + + @:bind(this, UIEvent.HIDDEN) + private function onHidden(_) { + if (_resource == null) { + return; + } + if (_atlas == null) { + return; + } + + stop(); + } + + @:bind(this, UIEvent.SHOWN) + private function onShown(_) { + if (_resource == null) { + return; + } + if (_atlas == null) { + return; + } + + if (autoPlay) { + play(); + } + } + + private function checkAtlas() { + if (_resource == null) { + return; + } + if (_atlas == null) { + return; + } + + var atlasData = ToolkitAssets.instance.getText(_atlas); + if (atlasData == null) { + return; + } + + _frames = []; + var atlasJson = Json.parse(atlasData); + var framesJson:Array = atlasJson.frames; + for (frameJson in framesJson) { + if (frameJson.frame != null) { + _frames.push({ + x: frameJson.frame.x, + y: frameJson.frame.y, + w: frameJson.frame.w, + h: frameJson.frame.h + }); + } + } + + showFrame(0); + this.customStyle.backgroundImage = _resource.toString(); + this.customStyle.backgroundImageRepeat = "stretch"; + if (autoPlay && !hidden) { + play(); + } + } + + private var _targetFrameRate:Int = 60; + public var targetFrameRate(get, set):Int; + private function get_targetFrameRate():Int { + return _targetFrameRate; + } + private function set_targetFrameRate(value:Int):Int { + _targetFrameRate = value; + _frameInterval = 1000 / value; + return value; + } + + + private var _frameInterval:Float = 0; + private var _timer:Timer; + private var _nextFrameMS:Float = 0; + public function play() { + if (_playing) { + return; + } + if (_frames == null || _frames.length <= 1) { + return; + } + if (_frameInterval == 0) { + _frameInterval = 1000 / _targetFrameRate; + } + + _playing = true; + showFrame(0); + #if haxeui_spinner_use_timer + stop(); + _timer = new Timer(Math.round(_frameInterval)); + _timer.run = onTimer; + #else + _nextFrameMS = timestamp() + _frameInterval; + Toolkit.callLater(onCallLater); + #end + } + + public function stop() { + _playing = false; + #if haxeui_spinner_use_timer + _timer.stop(); + _timer = null; + #end + } + + private function onCallLater() { + if (!_playing) { + return; + } + var current = timestamp(); + if (current >= _nextFrameMS) { + _nextFrameMS = current + _frameInterval; + onTimer(); + } + Toolkit.callLater(onCallLater); + } + + private inline function timestamp():Float { + #if sys + return Sys.time() * 1000; + #elseif js + return js.Syntax.code("Date.now()"); + #else + return Date.now().getTime(); + #end + } + + private function onTimer() { + if (animationDirection == "forward") { + nextFrame(); + } else if (animationDirection == "reverse") { + prevFrame(); + } else if (animationDirection == "bounce") { + boundFrame(); + } else { + nextFrame(); + } + } + + private var _currentFrameIndex:Int = -1; + public function showFrame(frameIndex:Int) { + if (_currentFrameIndex == frameIndex) { + return; + } + _currentFrameIndex = frameIndex; + var frame = _frames[frameIndex]; + if (frame == null) { + return; + } + + this.customStyle.backgroundImageClipLeft = frame.x; + this.customStyle.backgroundImageClipTop = frame.y; + this.customStyle.backgroundImageClipBottom = frame.y + frame.h; + this.customStyle.backgroundImageClipRight = frame.x + frame.w; + this.invalidateComponentStyle(); + } + + public function nextFrame() { + var nextIndex = _currentFrameIndex + 1; + if (nextIndex >= _frames.length) { + nextIndex = 0; + } + showFrame(nextIndex); + } + + private function prevFrame() { + var nextIndex = _currentFrameIndex - 1; + if (nextIndex < 0) { + nextIndex = _frames.length - 1; + } + showFrame(nextIndex); + } + + private var _currentBounceDirection = "forward"; + public function boundFrame() { + if (_currentBounceDirection == "forward") { + var nextIndex = _currentFrameIndex + 1; + if (nextIndex >= _frames.length) { + nextIndex = _frames.length - 1; + _currentBounceDirection = "reverse"; + } + showFrame(nextIndex); + } else { + var nextIndex = _currentFrameIndex - 1; + if (nextIndex < 0) { + nextIndex = 0; + _currentBounceDirection = "forward"; + } + showFrame(nextIndex); + } + } + + public override function validateComponentLayout():Bool { + if (_currentFrameIndex != -1) { + var frame = _frames[_currentFrameIndex]; + if (this.autoWidth) { + this.width = frame.w; + } + if (this.autoHeight) { + this.height = frame.h; + } + } + return false; + } +} + + +private typedef AtlasFrame = { + var x:Float; + var y:Float; + var w:Float; + var h:Float; +} \ No newline at end of file diff --git a/haxe/ui/components/Spinner.hx b/haxe/ui/components/Spinner.hx new file mode 100644 index 000000000..067b1a79d --- /dev/null +++ b/haxe/ui/components/Spinner.hx @@ -0,0 +1,5 @@ +package haxe.ui.components; + +class Spinner extends AtlasPlayer { + +} \ No newline at end of file diff --git a/haxe/ui/module.xml b/haxe/ui/module.xml index 4d774f4fe..a4f86de56 100644 --- a/haxe/ui/module.xml +++ b/haxe/ui/module.xml @@ -1,11 +1,13 @@ - - - + + + + + @@ -322,4 +324,10 @@ + + + + + +