[demo] update
This commit is contained in:
10
src/main/haxework/utils/StringUtil.hx
Normal file
10
src/main/haxework/utils/StringUtil.hx
Normal 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("_", " ");
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
Reference in New Issue
Block a user