From 6274bd271e09b3dd2df621ece8c8e473aa511816 Mon Sep 17 00:00:00 2001 From: shmyga Date: Fri, 12 Jul 2019 21:15:01 +0300 Subject: [PATCH] [view] fixes --- demo/src/demo/Demo.hx | 25 +++++++++++++------- demo/src/demo/DemoView.yaml | 3 +-- demo/src/demo/form/TailForm.hx | 2 +- demo/src/demo/form/TailForm.yaml | 2 +- demo/src/demo/popup/ColorPopup.hx | 2 +- src/main/haxework/view/list/LabelListItem.hx | 1 + src/main/haxework/view/skin/TabColorSkin.hx | 2 ++ src/main/haxework/view/text/FontPreset.hx | 2 +- src/main/haxework/view/text/TextView.hx | 19 +++++++++++---- 9 files changed, 38 insertions(+), 20 deletions(-) diff --git a/demo/src/demo/Demo.hx b/demo/src/demo/Demo.hx index 86a4855..1078d2d 100644 --- a/demo/src/demo/Demo.hx +++ b/demo/src/demo/Demo.hx @@ -6,30 +6,37 @@ import demo.popup.FontPopup; import haxework.App; import haxework.log.TraceLogger; import haxework.net.JsonLoader; -import haxework.view.form.ToggleButtonView; +import haxework.view.data.ButtonGroup; import haxework.view.frame.FrameSwitcher; -import haxework.view.group.IGroupView; +import haxework.view.frame.FrameView; import haxework.view.group.VGroupView; -import haxework.view.IView; @:template class DemoView extends VGroupView { @:view var switcher:FrameSwitcher; - @:view var tabs:IGroupView; + @:view var tabs:ButtonGroup; private function init():Void { - switcher.change("test_layout"); + switcher.change("tail"); } - private function onFrameSwitch(frame:IView):Void { - for (view in tabs.views) cast(view, ToggleButtonView).on = view.id == frame.id; + private function onFrameSwitch(frame:FrameView):Void { + tabs.selected = frame.frameId; } private function choiceColor():Void { - new ColorPopup().show().then(function(color) theme.colors = {light: color}); + new ColorPopup().show().then(function(color) { + if (color != null) { + theme.colors = {light: color}; + } + }); } private function choiceFont():Void { - new FontPopup().show().then(function(font) theme.font = font); + new FontPopup().show().then(function(font) { + if (font != null) { + theme.font = font; + } + }); } } diff --git a/demo/src/demo/DemoView.yaml b/demo/src/demo/DemoView.yaml index dceed7a..2c4403a 100644 --- a/demo/src/demo/DemoView.yaml +++ b/demo/src/demo/DemoView.yaml @@ -10,7 +10,7 @@ views: layout.hAlign: left geometry.width: 100% geometry.padding.left: 5 - geometry.margin.bottom: -3 + geometry.margin.bottom: -6 buttonStyle: tab +onDataSelect: ~function(id) switcher.change(id) data: @@ -19,7 +19,6 @@ views: - "data" - "test_layout" - "select" - selected: "list" - id: switcher $type: haxework.view.frame.FrameSwitcher animateFactory: { $class: haxework.animate.SlideAnimate } diff --git a/demo/src/demo/form/TailForm.hx b/demo/src/demo/form/TailForm.hx index 52a2c1a..372c983 100644 --- a/demo/src/demo/form/TailForm.hx +++ b/demo/src/demo/form/TailForm.hx @@ -17,7 +17,7 @@ import haxework.view.utils.DrawUtil; if (value.image != null) { var imageView = new ImageView(); imageView.stretch = false; - imageView.style = "border"; + //imageView.style = "border"; imageView.fillType = FillType.CONTAIN; imageView.imageUrl = value.image.url; view = imageView; diff --git a/demo/src/demo/form/TailForm.yaml b/demo/src/demo/form/TailForm.yaml index ff5562f..a4ba11a 100644 --- a/demo/src/demo/form/TailForm.yaml +++ b/demo/src/demo/form/TailForm.yaml @@ -7,7 +7,7 @@ views: $type: haxework.view.data.DataView layout: $type: haxework.view.layout.TailLayout - margin: 2 + margin: 4 factory: ~factory geometry.width: 100% data: $r:any:data diff --git a/demo/src/demo/popup/ColorPopup.hx b/demo/src/demo/popup/ColorPopup.hx index 47bb881..ef89106 100644 --- a/demo/src/demo/popup/ColorPopup.hx +++ b/demo/src/demo/popup/ColorPopup.hx @@ -4,7 +4,7 @@ import haxework.view.form.ButtonView; import haxework.view.popup.PopupView; import haxework.view.skin.Skin; -@:template class ColorPopup extends PopupView { +@:template class ColorPopup extends PopupView> { private function colorViewFactory(index:Int, color:Int) { var view = new ButtonView(); diff --git a/src/main/haxework/view/list/LabelListItem.hx b/src/main/haxework/view/list/LabelListItem.hx index 7abc490..03954c4 100644 --- a/src/main/haxework/view/list/LabelListItem.hx +++ b/src/main/haxework/view/list/LabelListItem.hx @@ -18,6 +18,7 @@ class LabelListItem extends LabelView implements IListItemView { public function new(formatter:Formatter = null) { super(); + textField.wordWrap = true; this.formatter = formatter == null ? defaultFormatter : formatter; geometry.width.percent = 100; geometry.height.fixed = 20; diff --git a/src/main/haxework/view/skin/TabColorSkin.hx b/src/main/haxework/view/skin/TabColorSkin.hx index ff6a367..0e0f1d4 100644 --- a/src/main/haxework/view/skin/TabColorSkin.hx +++ b/src/main/haxework/view/skin/TabColorSkin.hx @@ -18,5 +18,7 @@ class TabColorSkin extends ButtonColorSkin { graphics.beginFill(color, 1.0); graphics.lineStyle(2, ColorUtil.multiply(color, 1.5)); graphics.drawRoundRectComplex(1, 1, view.width - 2, view.height - 2, 5, 5, 0, 0); + graphics.lineStyle(); + graphics.endFill(); } } diff --git a/src/main/haxework/view/text/FontPreset.hx b/src/main/haxework/view/text/FontPreset.hx index 900e013..b32c595 100644 --- a/src/main/haxework/view/text/FontPreset.hx +++ b/src/main/haxework/view/text/FontPreset.hx @@ -18,6 +18,6 @@ class FontPreset { this.color = color != null ? color : 0xffffff; this.size = size; this.bold = bold; - this.align = align; + this.align = align != null ? align : TextFormatAlign.LEFT; } } diff --git a/src/main/haxework/view/text/TextView.hx b/src/main/haxework/view/text/TextView.hx index ea0453e..bc8ca1b 100755 --- a/src/main/haxework/view/text/TextView.hx +++ b/src/main/haxework/view/text/TextView.hx @@ -31,8 +31,8 @@ class TextView extends SpriteView implements ITextView { style = "text"; layout = new Layout(); textField = buildTextField(); - textField.width = 1; - textField.height = 1; + textField.width = 100; + textField.height = 100; textField.multiline = true; textField.wordWrap = true; #if dev_layout @@ -77,13 +77,21 @@ class TextView extends SpriteView implements ITextView { private function updateTextSize():Void { var size = TextUtil.getSize(textField); if (!Math.isNaN(size.x) && !Math.isNaN(size.y)/* && size.x > 0 && size.y > 0*/) { - setSize(size.x, size.y, "text"); + setSize(textField.wordWrap ? 0 : size.x, size.y, "text"); } } override public function update():Void { + //Kludge + if (textField.wordWrap && width - geometry.padding.horizontal == 0) { + return; + } textField.embedFonts = font.embed; - textField.defaultTextFormat = new TextFormat(font.family, font.size, font.color, font.bold); + textField.defaultTextFormat = new TextFormat( + font.family, font.size, font.color, + font.bold, false, false, null, + font.align + ); textField.autoSize = fill ? TextFieldAutoSize.NONE : TextFieldAutoSize.LEFT; var t:String = currentText(); if (t != null) textField.text = t; @@ -102,7 +110,8 @@ class TextView extends SpriteView implements ITextView { private function placeTextField(textField:TextField):Void { textField.width = width; - textField.height = height; // ToDo: + textField.height = sizeSet.exists("text") ? sizeSet.get("text").height : height; + //textField.height = height; textField.x = switch (layout.hAlign) { case LEFT | NONE: geometry.padding.left;