[update] background choiser update

This commit is contained in:
2020-02-21 20:18:38 +03:00
parent 449f1e6d00
commit cef46b6251
5 changed files with 87 additions and 46 deletions

View File

@@ -0,0 +1,23 @@
package ru.m.puzzlez.view;
import haxework.view.skin.ButtonColorSkin;
import haxework.view.form.ButtonView;
import haxework.color.Color;
import haxework.view.popup.PopupView;
import promhx.Promise;
import ru.m.puzzlez.render.Background;
@:template class BackgroundPopup extends PopupView<Background> {
private function colorButtonFactory(index:Int, color:Color):ButtonView {
var result = new ButtonView();
result.text = " ";
result.skin = new ButtonColorSkin(color);
return result;
}
public static function choise(message:String = null):Promise<Background> {
var result = new BackgroundPopup();
return result.show();
}
}

View File

@@ -0,0 +1,61 @@
---
view:
$type: haxework.view.group.VGroupView
geometry.width: 400
geometry.height: 200
geometry.padding: 10
geometry.hAlign: center
geometry.vAlign: middle
layout.margin: 10
style: frame
views:
- $type: haxework.view.group.HGroupView
geometry.width: 100%
layout.margin: 10
views:
- id: header
text: Choise background
$type: haxework.view.form.LabelView
- $type: haxework.view.group.HGroupView
geometry.width: 100%
views:
- $type: haxework.view.form.ButtonView
text: Default
+onPress: ~close(NONE)
- $type: haxework.view.data.DataView
factory: ~colorButtonFactory
geometry.width: 100%
layout:
$type: haxework.view.layout.TailLayout
margin: 5
data:
- '#FFFFFF'
- '#001f3f'
- '#0074D9'
- '#7FDBFF'
- '#39CCCC'
- '#3D9970'
- '#2ECC40'
- '#01FF70'
- '#FFDC00'
- '#FF851B'
- '#FF4136'
- '#85144b'
- '#F012BE'
- '#B10DC9'
- '#111111'
- '#AAAAAA'
- '#DDDDDD'
+onDataSelect: ~(color) -> close(COLOR(color))
- id: image
$type: ru.m.view.ColorView
+onSelect: ~function(color) close(COLOR(color))
- $type: haxework.view.group.HGroupView
geometry.width: 100%
layout.hAlign: center
layout.margin: 10
views:
- $type: haxework.view.form.ButtonView
text: OK
+onPress: ~reject('ok')
visible: false

View File

@@ -1,7 +1,6 @@
package ru.m.puzzlez.view; package ru.m.puzzlez.view;
import haxe.Timer; import haxe.Timer;
import haxework.color.Color;
import haxework.view.frame.FrameSwitcher; import haxework.view.frame.FrameSwitcher;
import haxework.view.frame.FrameView; import haxework.view.frame.FrameView;
import ru.m.puzzlez.core.Game; import ru.m.puzzlez.core.Game;
@@ -12,7 +11,6 @@ import ru.m.puzzlez.render.Background;
import ru.m.puzzlez.render.IRender; import ru.m.puzzlez.render.IRender;
import ru.m.puzzlez.storage.GameStorage; import ru.m.puzzlez.storage.GameStorage;
import ru.m.puzzlez.storage.SettingsStorage; import ru.m.puzzlez.storage.SettingsStorage;
import ru.m.view.ColorPopup;
@:template class GameFrame extends FrameView<GameState> { @:template class GameFrame extends FrameView<GameState> {
public static var ID = "game"; public static var ID = "game";
@@ -75,9 +73,9 @@ import ru.m.view.ColorPopup;
} }
private function choiseBackground():Void { private function choiseBackground():Void {
ColorPopup.choise().then((color:Null<Color>) -> { BackgroundPopup.choise().then((background:Null<Background>) -> {
if (color != null) { if (background != null) {
settings.background = COLOR(color); settings.background = background;
render.toRedraw(); render.toRedraw();
} }
}); });

View File

@@ -1,13 +0,0 @@
package ru.m.view;
import promhx.Promise;
import haxework.color.Color;
import haxework.view.popup.PopupView;
@:template class ColorPopup extends PopupView<Color> {
public static function choise(message:String = null):Promise<Color> {
var result = new ColorPopup();
return result.show();
}
}

View File

@@ -1,28 +0,0 @@
---
view:
$type: haxework.view.group.VGroupView
geometry.width: 400
geometry.height: 200
geometry.padding: 10
geometry.hAlign: center
geometry.vAlign: middle
style: frame
views:
- $type: haxework.view.group.HGroupView
geometry.width: 100%
layout.margin: 10
views:
- id: header
$type: haxework.view.form.LabelView
- id: image
$type: ru.m.view.ColorView
+onSelect: ~close
- $type: haxework.view.group.HGroupView
geometry.width: 100%
layout.hAlign: center
layout.margin: 10
views:
- $type: haxework.view.form.ButtonView
text: OK
+onPress: ~close('ok')
visible: false