[demo] update

This commit is contained in:
2019-06-27 10:51:28 +03:00
parent 68c0c4d35f
commit 34cb98beb1
17 changed files with 195 additions and 95 deletions

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
echo "`pwd`/target" > ~/.macromedia/Flash_Player/#Security/FlashPlayerTrust/haxework_demo.cfg
. /opt/sdk/neko/2.2.0/activate
. /opt/sdk/haxe/3.4.7/activate
haxe build.hxml && flashplayerdebugger target/demo.swf &
tail -f ~/.macromedia/Flash_Player/Logs/flashlog.txt

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env bash
echo "`pwd`/target/flash/bin" > ~/.macromedia/Flash_Player/#Security/FlashPlayerTrust/haxework_demo.cfg
. /opt/sdk/neko/2.2.0/activate
. /opt/sdk/haxe/3.4.7/activate
haxelib run openfl test linux
haxelib run openfl test flash

View File

@@ -16,7 +16,7 @@ import haxework.log.TraceLogger;
@:view var tabs:IGroupView;
private function init():Void {
switcher.change("list_form");
switcher.change("list");
}
private function onFrameSwitch(frame:IView<Dynamic>):Void {

View File

@@ -6,31 +6,20 @@ views:
geometry.padding: 10
image: $r:image:logo
- id: tabs
$type: haxework.view.HGroupView
$type: haxework.view.ButtonGroup<String>
layout.margin: 5
layout.hAlign: left
geometry.size.width: 100%
geometry.padding.left: 5
geometry.margin.bottom: -3
views:
- id: list_form
$type: haxework.view.ToggleButtonView
skinId: tab
geometry.padding: [25, 8]
text: List
+onPress: "$code:switcher.change('list_form')"
- id: tail_form
$type: haxework.view.ToggleButtonView
skinId: tab
geometry.padding: [25, 8]
text: Tail
+onPress: "$code:switcher.change('tail_form')"
- id: data_form
$type: haxework.view.ToggleButtonView
skinId: tab
geometry.padding: [25, 8]
text: Data
+onPress: "$code:switcher.change('data_form')"
buttonSkinId: tab
+onDataSelect: $code:function(id) switcher.change(id)
data:
- "list"
- "tail"
- "data"
- "test_layout"
selected: "list"
- id: switcher
$type: haxework.view.frame.FrameSwitcher
skinId: panel
@@ -38,19 +27,11 @@ views:
+onSwitch: $this:onFrameSwitch
geometry.size.stretch: true
geometry.padding: 5
views:
- id: list_form
$type: demo.form.ListForm
skinId: background
geometry.size.stretch: true
- id: tail_form
$type: demo.form.TailForm
skinId: background
geometry.size.stretch: true
- id: data_form
$type: demo.form.DataForm
skinId: background
geometry.size.stretch: true
factory:
_list_: {$class: demo.form.ListForm}
_tail_: {$class: demo.form.TailForm}
_data_: {$class: demo.form.DataForm}
_test_layout_: {$class: demo.form.TestLayoutForm}
- $type: haxework.view.HGroupView
geometry.size.percent.width: 100
geometry.padding: 10

View File

@@ -1,33 +1,40 @@
package demo;
import haxework.color.ColorUtil;
import haxework.color.Color;
import haxework.resources.IResources;
import haxework.view.core.Geometry;
import haxework.view.skin.Skin;
import haxework.view.skin.TextSkin;
using haxework.color.ColorUtil;
class Theme {
@:provide static var resources:IResources;
public static function setColor(color:Int, textColor:Int = 0xffffff):Void {
public static function setColor(color:Color, ?textColor:Color):Void {
if (textColor == null) {
textColor = 0xffffff;
}
var text = new TextSkin(textColor, 16, "Courirer");
var background = Skin.color(0x000000);
var border = Skin.border(ColorUtil.multiply(color, 1.5), 1, 2);
var border = Skin.border(color.multiply(1.5), 1, 2);
resources.skin.put("text0", [
Skin.color(ColorUtil.diff(color, 128)),
new TextSkin(ColorUtil.diff(color, -128), 16, "Courirer"),
Skin.color(color.diff(128)),
new TextSkin(color.diff(-128), 16, "Courirer"),
]);
resources.skin.put("text1", [
Skin.color(ColorUtil.diff(color, 64)),
new TextSkin(ColorUtil.diff(color, -128), 16, "Courirer"),
Skin.color(color.diff(64)),
new TextSkin(color.diff(-128), 16, "Courirer"),
]);
resources.skin.put("text", resources.skin.get("text0"));
resources.skin.put("background", [background]);
resources.skin.put("button", [Skin.buttonColor(color), text]);
resources.skin.put("tab", [Skin.tabColor(color), text]);
resources.skin.put("tab", [Skin.tabColor(color), text, Skin.geometry(new Geometry().setPadding([25, 8]))]);
resources.skin.put("view", [Skin.color(color), border, text]);
resources.skin.put("scroll", [Skin.scrollVertical(color, ColorUtil.diff(color, 128))]);
resources.skin.put("scroll", [Skin.scrollVertical(color, color.diff(128))]);
resources.skin.put("border", [border]);
resources.skin.put("panel", [background, border]);
resources.skin.put("test", [Skin.color(0x00ffff)]);
}
}

View File

@@ -1,9 +1,13 @@
package demo.form;
import haxework.view.frame.FrameView;
import haxework.view.TextView;
import haxework.view.VGroupView;
@:template class DataForm extends VGroupView {
@:template class DataForm extends FrameView<Dynamic> {
public function new() {
super("data");
}
private function factory(index:Int, value:Model):TextView {
var label = new TextView();

View File

@@ -1,15 +1,13 @@
---
views:
- $type: haxework.view.ScrollView
geometry.size.stretch: true
view:
id: data
$type: haxework.view.DataView
layout:
$type: haxework.view.layout.VerticalLayout
factory: $this:factory
geometry.size.width: 100%
data: $r:any:data
scroll:
$type: haxework.view.list.VScrollBarView
skinId: scroll
- $type: haxework.view.ScrollView
geometry.size.stretch: true
scroll.skinId: scroll
view:
id: data
$type: haxework.view.DataView
layout:
$type: haxework.view.layout.VerticalLayout
factory: $this:factory
geometry.size.width: 100%
data: $r:any:data

View File

@@ -1,13 +1,17 @@
package demo.form;
import haxework.view.frame.FrameView;
import haxework.view.list.LabelListItem;
import haxework.view.list.ListView.IListItemView;
import haxework.view.list.VListView;
import haxework.view.VGroupView;
@:template class ListForm extends VGroupView {
@:template class ListForm extends FrameView<Dynamic> {
@:view public var list(default, null):VListView<Model>;
public function new() {
super("list");
}
private function factory() {
return new LabelListItem(function(index:Int, value:Model) return '${index}. ${value.id}: ${value.title}');
}

View File

@@ -1,11 +1,11 @@
---
views:
- id: list
$type: haxework.view.list.VListView
+onItemSelect: $this:onItemSelect
factory: $this:factory
geometry.size.stretch: true
scroll:
$type: haxework.view.list.VScrollBarView
skinId: scroll
data: $r:any:data50
- id: list
$type: haxework.view.list.VListView
+onItemSelect: $this:onItemSelect
factory: $this:factory
geometry.size.stretch: true
scroll:
$type: haxework.view.list.VScrollBarView
skinId: scroll
data: $r:any:data50

View File

@@ -1,12 +1,16 @@
package demo.form;
import haxework.view.HGroupView;
import haxework.view.frame.FrameView;
import haxework.view.ImageView;
import haxework.view.IView;
import haxework.view.TextView;
import haxework.view.utils.DrawUtil.FillType;
import haxework.view.utils.DrawUtil;
@:template class TailForm extends HGroupView {
@:template class TailForm extends FrameView<Dynamic> {
public function new() {
super("tail");
}
private function factory(index:Int, value:Model):IView<Dynamic> {
var view:IView<Dynamic>;

View File

@@ -1,16 +1,14 @@
---
views:
- $type: haxework.view.ScrollView
geometry.size.stretch: true
view:
id: data
$type: haxework.view.DataView
layout:
$type: haxework.view.layout.TailLayout
margin: 2
factory: $this:factory
geometry.size.width: 100%
data: $r:any:data
scroll:
$type: haxework.view.list.VScrollBarView
skinId: scroll
- $type: haxework.view.ScrollView
geometry.size.stretch: true
scroll.skinId: scroll
view:
id: data
$type: haxework.view.DataView
layout:
$type: haxework.view.layout.TailLayout
margin: 2
factory: $this:factory
geometry.size.width: 100%
data: $r:any:data

View File

@@ -0,0 +1,27 @@
package demo.form;
import flash.events.MouseEvent;
import haxework.view.frame.FrameView;
import haxework.view.SpriteView;
@:template class TestLayoutForm extends FrameView<Dynamic> {
@:view var render:SpriteView;
public function new() {
super("test_layout");
}
public function init():Void {
resize();
content.addEventListener(MouseEvent.CLICK, function(_) {
resize();
});
}
private function resize():Void {
var w = 200 + 400 * Math.random();
var h = 100 + 200 * Math.random();
render.setContentSize(w, h, "render");
}
}

View File

@@ -0,0 +1,53 @@
---
views:
- id: main
$type: haxework.view.VGroupView
geometry.size.stretch: true
layout.hAlign: center
layout.vAlign: middle
views:
- id: container
$type: haxework.view.VGroupView
layout.margin: 10
skin:
- $type: [haxework.view.skin.Skin.color, 0xffff00]
views:
- id: top
$type: haxework.view.GroupView
layout.hAlign: center
geometry.size.width: 100%
geometry.size.height: 20
skinId: test
- id: middle
$type: haxework.view.HGroupView
layout.margin: 10
views:
- id: left
$type: haxework.view.GroupView
layout.vAlign: middle
geometry.size.width: 20
geometry.size.height: 100%
skinId: test
- id: render
$type: haxework.view.SpriteView
#geometry.size.width: 300
#geometry.size.height: 200
skinId: test
- id: right
$type: haxework.view.GroupView
layout.vAlign: middle
geometry.size.width: 20
geometry.size.height: 100%
skinId: test
views:
- $type: haxework.view.SpriteView
geometry.size.width: 100
geometry.size.height: 100%
skin:
- $type: [haxework.view.skin.Skin.color, 0xff0000]
- id: bottom
$type: haxework.view.GroupView
layout.hAlign: center
skinId: test
geometry.size.width: 100%
geometry.size.height: 20

View File

@@ -0,0 +1,10 @@
package haxework.utils;
using StringTools;
class StringUtil {
public static function title(value:String):String {
return (value.substr(0, 1).toUpperCase() + value.substr(1)).replace("_", " ");
}
}

View File

@@ -1,6 +1,9 @@
package haxework.view;
using haxework.utils.StringUtil;
import haxework.view.DataView.Factory;
import haxe.EnumTools;
import haxework.view.layout.HorizontalLayout;
import haxework.view.layout.ILayout;
class ButtonGroup<D> extends DataView<D, ToggleButtonView> {
@@ -9,8 +12,8 @@ class ButtonGroup<D> extends DataView<D, ToggleButtonView> {
public var buttonSkinId(default, set):String;
public function new(?layout:ILayout) {
super(layout);
factory = defaultFactory;
super(layout != null ? layout : new HorizontalLayout());
factory = buildFactory();
onDataSelect.connect(function(value:D) selected = value);
}
@@ -57,9 +60,14 @@ class ButtonGroup<D> extends DataView<D, ToggleButtonView> {
}
}
public static function defaultFactory<D>(index:Int, value:D):ToggleButtonView {
var result = new ToggleButtonView();
result.text = Std.string(value);
return result;
public static function buildFactory<D>(?label:D -> String):Factory<D, ToggleButtonView> {
if (label == null) {
label = function(value:D) return Std.string(value).title();
}
return function(index:Int, value:D):ToggleButtonView {
var result = new ToggleButtonView();
result.text = label(value);
return result;
}
}
}

View File

@@ -3,10 +3,11 @@ package haxework.view;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.MouseEvent;
import haxework.signal.Signal;
import haxework.view.core.Geometry.Position;
import haxework.view.list.ScrollBarView;
import haxework.view.list.VScrollBarView;
import haxework.view.skin.Skin;
import haxework.signal.Signal;
class ScrollView extends HGroupView {
@@ -25,6 +26,7 @@ class ScrollView extends HGroupView {
mask = new Sprite();
content.addChild(mask);
content.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheelEvent);
scroll = new VScrollBarView();
}
private function onMouseWheelEvent(event:MouseEvent):Void {

View File

@@ -1,13 +1,15 @@
package haxework.view.frame;
import haxework.view.layout.ILayout;
import haxework.view.layout.VerticalLayout;
class FrameView<D> extends GroupView {
public var frameId(default, null):String;
public function new(frameId:String, ?layout:ILayout) {
super(layout);
super(layout != null ? layout : new VerticalLayout());
this.frameId = frameId;
this.geometry.size.stretch = true;
}
public function onShow(data:D):Void {}