diff --git a/haxe/ui/components/Label.hx b/haxe/ui/components/Label.hx index 57efa6dca..d7a9f3ab2 100644 --- a/haxe/ui/components/Label.hx +++ b/haxe/ui/components/Label.hx @@ -85,10 +85,12 @@ private class LabelLayout extends DefaultLayout { component.getTextDisplay().width = component.getTextDisplay().textWidth; } + //Extra space is needed to ensure the last line in multiline labels is visible. + var extraSpace:Int=(component.getTextDisplay().textField.numLines>1)?5:0; if (component.autoHeight == true) { - component.getTextDisplay().height = component.getTextDisplay().textHeight; + component.getTextDisplay().height = component.getTextDisplay().textHeight+extraSpace; } else { - component.getTextDisplay().height = component.height; + component.getTextDisplay().height = component.height+extraSpace; } } @@ -103,7 +105,9 @@ private class LabelLayout extends DefaultLayout { var size:Size = super.calcAutoSize(exclusions); if (component.hasTextDisplay() == true) { size.width += component.getTextDisplay().textWidth; - size.height += component.getTextDisplay().textHeight; + //Extra space is needed to ensure the last line in multiline labels is visible. + var extraSpace:Int=(component.getTextDisplay().textField.numLines>1)?5:0; + size.height += component.getTextDisplay().textHeight+extraSpace; } return size; } diff --git a/haxe/ui/components/NumberStepper.hx b/haxe/ui/components/NumberStepper.hx index 5616ac909..a3012efec 100644 --- a/haxe/ui/components/NumberStepper.hx +++ b/haxe/ui/components/NumberStepper.hx @@ -79,39 +79,41 @@ class NumberStepper extends InteractiveComponent { @:dox(hide) @:noCompletion private class PosBehaviour extends DataBehaviour { public override function validateData() { - var stepper = cast(_component, NumberStepper); - var preciseValue:Null = _value; - if (preciseValue == null) { - preciseValue = stepper.min; - } - - preciseValue = MathUtil.clamp(preciseValue, stepper.min, stepper.max); - var wasRounded = false; - if (stepper.precision != null) { - var newPreciseValue = MathUtil.round(preciseValue, stepper.precision); - if (newPreciseValue != preciseValue) { - preciseValue = newPreciseValue; - wasRounded = true; + if (_value!=null) { + var stepper = cast(_component, NumberStepper); + var preciseValue:Null = _value; + if (preciseValue == null) { + preciseValue = stepper.min; } + + preciseValue = MathUtil.clamp(preciseValue, stepper.min, stepper.max); + var wasRounded = false; + if (stepper.precision != null) { + var newPreciseValue = MathUtil.round(preciseValue, stepper.precision); + if (newPreciseValue != preciseValue) { + preciseValue = newPreciseValue; + wasRounded = true; + } + } + _value = preciseValue; + + var stringValue = StringUtil.padDecimal(preciseValue, stepper.precision); + var value:TextField = stepper.findComponent("value", TextField); + var carentIndex = value.caretIndex; + stringValue = StringTools.replace(stringValue, ",", "."); + stringValue = StringTools.replace(stringValue, ".", stepper.decimalSeparator); + value.text = stringValue; + if (wasRounded) { + value.caretIndex = stringValue.length; + } else { + value.caretIndex = carentIndex; + } + + var event = new UIEvent(UIEvent.CHANGE); + event.previousValue = _previousValue; + event.value = _value; + _component.dispatch(event); } - _value = preciseValue; - - var stringValue = StringUtil.padDecimal(preciseValue, stepper.precision); - var value:TextField = stepper.findComponent("value", TextField); - var carentIndex = value.caretIndex; - stringValue = StringTools.replace(stringValue, ",", "."); - stringValue = StringTools.replace(stringValue, ".", stepper.decimalSeparator); - value.text = stringValue; - if (wasRounded) { - value.caretIndex = stringValue.length; - } else { - value.caretIndex = carentIndex; - } - - var event = new UIEvent(UIEvent.CHANGE); - event.previousValue = _previousValue; - event.value = _value; - _component.dispatch(event); } } diff --git a/haxe/ui/components/Stepper.hx b/haxe/ui/components/Stepper.hx index a234899ff..f3ecda804 100644 --- a/haxe/ui/components/Stepper.hx +++ b/haxe/ui/components/Stepper.hx @@ -40,12 +40,14 @@ class Stepper extends VBox implements IValueComponent { @:dox(hide) @:noCompletion private class PosBehaviour extends DataBehaviour { public override function validateData() { - var stepper:Stepper = cast(_component, Stepper); - var v:Float = MathUtil.clamp(_value, stepper.min, stepper.max); - stepper.pos = v; - _value = v; - var event = new UIEvent(UIEvent.CHANGE); - _component.dispatch(event); + if (_value!=null) { + var stepper:Stepper = cast(_component, Stepper); + var v:Float = MathUtil.clamp(_value, stepper.min, stepper.max); + stepper.pos = v; + _value = v; + var event = new UIEvent(UIEvent.CHANGE); + _component.dispatch(event); + } } } diff --git a/haxe/ui/containers/ScrollView.hx b/haxe/ui/containers/ScrollView.hx index fe4c888d5..9ab16b674 100644 --- a/haxe/ui/containers/ScrollView.hx +++ b/haxe/ui/containers/ScrollView.hx @@ -1038,11 +1038,10 @@ class ScrollViewBuilder extends CompositeBuilder { if (hscroll == null) { hscroll = createHScroll(); } - - hscroll.max = vcw - usableSize.width; - hscroll.pageSize = (usableSize.width / vcw) * hscroll.max; - - hscroll.syncComponentValidation(); //avoid another pass + //Any action might cause a resize->might cause the child to modify size->might cause the hscroll to disappear + if (hscroll != null) hscroll.max = vcw - usableSize.width; + if (hscroll != null) hscroll.pageSize = (usableSize.width / vcw) * hscroll.max; + if (hscroll != null) hscroll.syncComponentValidation(); //avoid another pass } else { if (hscroll != null) { destroyHScroll(); @@ -1054,15 +1053,18 @@ class ScrollViewBuilder extends CompositeBuilder { var verticalConstraint = _contents; var vscroll:VerticalScroll = _component.findComponent(VerticalScroll, false); var vch:Float = verticalConstraint.height + verticalConstraintModifier(); + //account for height of hscroll in case there is one + var hscroll:HorizontalScroll = _component.findComponent(HorizontalScroll, false); + if (hscroll!=null) vch-=hscroll.height; + if (vch > usableSize.height) { if (vscroll == null) { vscroll = createVScroll(); } - - vscroll.max = vch - usableSize.height; - vscroll.pageSize = (usableSize.height / vch) * vscroll.max; - - vscroll.syncComponentValidation(); //avoid another pass + //any action might cause a resize->might cause the child to modify size->might cause the vscroll to disappear + if (vscroll != null) vscroll.max = vch - usableSize.height; + if (vscroll != null) vscroll.pageSize = (usableSize.height / vch) * vscroll.max; + if (vscroll != null) vscroll.syncComponentValidation(); //avoid another pass } else { if (vscroll != null) { destroyVScroll(); diff --git a/haxe/ui/core/TextDisplay.hx b/haxe/ui/core/TextDisplay.hx index f9e826f7d..44c8a8a9c 100644 --- a/haxe/ui/core/TextDisplay.hx +++ b/haxe/ui/core/TextDisplay.hx @@ -170,7 +170,6 @@ class TextDisplay extends TextDisplayImpl implements IValidating { if (_htmlText != null && _htmlText.length == 0) { return 0; } - if (isComponentInvalid() == true) { validateComponent(); } @@ -180,6 +179,7 @@ class TextDisplay extends TextDisplayImpl implements IValidating { public var textHeight(get, null):Float; private function get_textHeight():Float { + /* //empty labels should have same height as labels with text. if (_text == null && _htmlText == null) { return 0; } @@ -190,7 +190,7 @@ class TextDisplay extends TextDisplayImpl implements IValidating { if (_htmlText != null && _htmlText.length == 0) { return 0; - } + }*/ if (isComponentInvalid() == true) { validateComponent();