From 9dc3eb4e04b9d24a0f1647ca58222e682dc7bb3d Mon Sep 17 00:00:00 2001 From: shmyga Date: Mon, 23 Mar 2020 22:00:54 +0300 Subject: [PATCH] [view] add fullscreen icons --- package.json | 2 +- src/haxe/ru/m/Device.hx | 16 +++++++-- src/haxe/ru/m/puzzlez/PuzzlezTheme.hx | 34 +++++++++---------- src/haxe/ru/m/puzzlez/view/PuzzlezAppView.hx | 5 +++ .../ru/m/puzzlez/view/PuzzlezAppView.yaml | 9 +++++ src/haxe/ru/m/puzzlez/view/StartFrame.hx | 4 --- src/haxe/ru/m/puzzlez/view/StartFrame.yaml | 18 +++++----- src/resources/icon/compress-solid.svg | 1 + src/resources/icon/expand-solid.svg | 1 + 9 files changed, 56 insertions(+), 34 deletions(-) create mode 100644 src/resources/icon/compress-solid.svg create mode 100644 src/resources/icon/expand-solid.svg diff --git a/package.json b/package.json index f487377..42d98c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "puzzlez", - "version": "0.4.3", + "version": "0.4.4", "private": true, "devDependencies": { "dateformat": "^3.0.3", diff --git a/src/haxe/ru/m/Device.hx b/src/haxe/ru/m/Device.hx index 563ab3c..0f36266 100644 --- a/src/haxe/ru/m/Device.hx +++ b/src/haxe/ru/m/Device.hx @@ -1,7 +1,9 @@ package ru.m; import flash.display.StageDisplayState; +import flash.events.FullScreenEvent; import flash.Lib; +import haxework.signal.Signal; enum abstract Platform(String) from String to String { var ANDROID = "android"; @@ -52,14 +54,24 @@ class Device { #end } + public static var fullScreenSignal(get, null):Signal; + + private static function get_fullScreenSignal():Signal { + if (fullScreenSignal == null) { + fullScreenSignal = new Signal(); + Lib.current.stage.addEventListener(FullScreenEvent.FULL_SCREEN, (event:FullScreenEvent) -> fullScreenSignal.emit(event.fullScreen)); + } + return fullScreenSignal; + } + public static var fullScreenSupport(get, never):Bool; public static function get_fullScreenSupport():Bool { - return Lib.current.stage.allowsFullScreenInteractive; + return Lib.current.stage.allowsFullScreen; } public static function toggleFullScreen():Void { Lib.current.stage.displayState = Lib.current.stage.displayState == StageDisplayState.NORMAL ? - StageDisplayState.FULL_SCREEN_INTERACTIVE : StageDisplayState.NORMAL; + StageDisplayState.FULL_SCREEN : StageDisplayState.NORMAL; } } diff --git a/src/haxe/ru/m/puzzlez/PuzzlezTheme.hx b/src/haxe/ru/m/puzzlez/PuzzlezTheme.hx index 09765c3..a69a5df 100644 --- a/src/haxe/ru/m/puzzlez/PuzzlezTheme.hx +++ b/src/haxe/ru/m/puzzlez/PuzzlezTheme.hx @@ -1,16 +1,26 @@ package ru.m.puzzlez; -import haxework.view.geometry.VAlign; -import haxework.view.geometry.HAlign; import haxework.color.Color; import haxework.view.geometry.Box; +import haxework.view.geometry.HAlign; import haxework.view.geometry.SizeValue; +import haxework.view.geometry.VAlign; import haxework.view.theme.Theme; import openfl.Assets; import ru.m.skin.ButtonSVGSkin; class PuzzlezTheme extends Theme { + private static var ICONS:Map = [ + "close" => "times-circle-solid.svg", + "setting" => "cog-solid.svg", + "image" => "image-polaroid.svg", + "lock" => "lock-alt-solid.svg", + "restore" => "window-restore-solid.svg", + "compress" => "compress-solid.svg", + "expand" => "expand-solid.svg", + ]; + public function new() { super({embed: true}, {light: "gray"}, {base: Device.isMobile() ? 32 : 22}); register(new Style("frame", [ @@ -35,21 +45,11 @@ class PuzzlezTheme extends Theme { "skin" => function() return new ButtonSVGSkin(), "skin.color" => colors.light, ])); - register(new Style("icon.close", [ - "skin.svg" => Assets.getText("resources/icon/times-circle-solid.svg"), - ])); - register(new Style("icon.setting", [ - "skin.svg" => Assets.getText("resources/icon/cog-solid.svg"), - ])); - register(new Style("icon.image", [ - "skin.svg" => Assets.getText("resources/icon/image-polaroid.svg"), - ])); - register(new Style("icon.lock", [ - "skin.svg" => Assets.getText("resources/icon/lock-alt-solid.svg"), - ])); - register(new Style("icon.restore", [ - "skin.svg" => Assets.getText("resources/icon/window-restore-solid.svg"), - ])); + for (key in ICONS.keys()) { + register(new Style('icon.${key}', [ + "skin.svg" => Assets.getText('resources/icon/${ICONS.get(key)}'), + ])); + } register(new Style("icon.small", [ "geometry.width" => SizeValue.fromInt(smallSize), "geometry.height" => SizeValue.fromInt(smallSize), diff --git a/src/haxe/ru/m/puzzlez/view/PuzzlezAppView.hx b/src/haxe/ru/m/puzzlez/view/PuzzlezAppView.hx index a1d0626..bae88f2 100644 --- a/src/haxe/ru/m/puzzlez/view/PuzzlezAppView.hx +++ b/src/haxe/ru/m/puzzlez/view/PuzzlezAppView.hx @@ -3,12 +3,15 @@ package ru.m.puzzlez.view; import flash.events.KeyboardEvent; import flash.ui.Keyboard; import haxework.resources.IResources; +import haxework.view.form.ButtonView; import haxework.view.frame.FrameSwitcher; import haxework.view.group.VGroupView; @:template class PuzzlezAppView extends VGroupView { @:view("switcher") var switcherView:FrameSwitcher; + @:view("fullscreen") var fullscreenButton:ButtonView; + @:provide var switcher:FrameSwitcher; @:provide var resources:IResources; @@ -17,6 +20,8 @@ import haxework.view.group.VGroupView; resources.text.put("version", Const.instance.VERSION); resources.text.put("name", Const.instance.NAME); switcher = switcherView; + fullscreenButton.visible = Device.fullScreenSupport; + Device.fullScreenSignal.connect(fullscreen -> fullscreenButton.style = fullscreen ? "icon.compress" : "icon.expand"); } public function launch():Void { diff --git a/src/haxe/ru/m/puzzlez/view/PuzzlezAppView.yaml b/src/haxe/ru/m/puzzlez/view/PuzzlezAppView.yaml index 1a53b8c..343bb54 100644 --- a/src/haxe/ru/m/puzzlez/view/PuzzlezAppView.yaml +++ b/src/haxe/ru/m/puzzlez/view/PuzzlezAppView.yaml @@ -9,3 +9,12 @@ views: _image_list_: {$class: ru.m.puzzlez.view.ImageListFrame} _preset_: {$class: ru.m.puzzlez.view.PresetFrame} _game_: {$class: ru.m.puzzlez.view.GameFrame} + - id: fullscreen + $type: haxework.view.form.ButtonView + geometry.position: absolute + geometry.hAlign: right + geometry.vAlign: bottom + geometry.margin: 10 + style: icon.expand + +onPress: ~Device.toggleFullScreen() + visible: false diff --git a/src/haxe/ru/m/puzzlez/view/StartFrame.hx b/src/haxe/ru/m/puzzlez/view/StartFrame.hx index 9f019b4..fc952a9 100644 --- a/src/haxe/ru/m/puzzlez/view/StartFrame.hx +++ b/src/haxe/ru/m/puzzlez/view/StartFrame.hx @@ -1,7 +1,5 @@ package ru.m.puzzlez.view; -import openfl.display.StageDisplayState; -import flash.Lib; import haxework.view.data.DataView; import haxework.view.form.ButtonView; import haxework.view.frame.FrameSwitcher; @@ -24,7 +22,6 @@ import ru.m.update.Updater; @:view("load") var loadButton:ButtonView; @:view("complete") var completeButton:ButtonView; @:view("update") var updateButton:ButtonView; - @:view("fullscreen") var fullscreenButton:ButtonView; @:provide var storage:ImageStorage; @:provide var switcher:FrameSwitcher; @@ -33,7 +30,6 @@ import ru.m.update.Updater; public function new() { super(ID); - fullscreenButton.visible = Device.fullScreenSupport; var data:Array = []; data.push({title: "Assets", source: storage.sources.get(AssetSource.ID)}); data.push({title: "Files", source: storage.sources.get(FileSource.ID)}); diff --git a/src/haxe/ru/m/puzzlez/view/StartFrame.yaml b/src/haxe/ru/m/puzzlez/view/StartFrame.yaml index 275797f..794d4b4 100644 --- a/src/haxe/ru/m/puzzlez/view/StartFrame.yaml +++ b/src/haxe/ru/m/puzzlez/view/StartFrame.yaml @@ -42,18 +42,16 @@ views: +onPress: ~games('complete') - $type: haxework.view.SpriteView geometry.width: 100% - - id: update - $type: haxework.view.form.ButtonView - style: button.active - +onPress: ~appUpdater.download() - visible: false - - id: fullscreen - $type: haxework.view.form.ButtonView - text: Fullscreen - +onPress: ~Device.toggleFullScreen() - visible: false - $type: haxework.view.form.LabelView text: $r:text:version geometry.position: absolute geometry.hAlign: right geometry.vAlign: top + - id: update + $type: haxework.view.form.ButtonView + style: button.active + geometry.position: absolute + geometry.hAlign: left + geometry.vAlign: top + +onPress: ~appUpdater.download() + visible: false diff --git a/src/resources/icon/compress-solid.svg b/src/resources/icon/compress-solid.svg new file mode 100644 index 0000000..c34dbc6 --- /dev/null +++ b/src/resources/icon/compress-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icon/expand-solid.svg b/src/resources/icon/expand-solid.svg new file mode 100644 index 0000000..c5eb790 --- /dev/null +++ b/src/resources/icon/expand-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file