X-Git-Url: http://nitlanguage.org?ds=sidebyside diff --git a/lib/app/ui.nit b/lib/app/ui.nit index 3006a47..4efbb87 100644 --- a/lib/app/ui.nit +++ b/lib/app/ui.nit @@ -20,7 +20,8 @@ import app_base # Platform variations # TODO: move on the platform once qualified names are understand in the condition import linux::ui is conditional(linux) -import android::ui is conditional(android) +import android::ui is conditional(android) # FIXME it should be conditional to `android::platform` +import ios::ui is conditional(ios) redef class App super AppComponent @@ -106,16 +107,19 @@ end class CompositeControl super Control - private var items = new HashSet[Control] + protected var items = new Array[Control] # Add `item` as a child of `self` protected fun add(item: Control) do items.add item # Remove `item` from `self` - protected fun remove(item: Control) do if has(item) then items.remove item + fun remove(item: Control) do if has(item) then items.remove item # Is `item` in `self`? - protected fun has(item: Control): Bool do return items.has(item) + fun has(item: Control): Bool do return items.has(item) + + # Remove all items from `self` + fun clear do for item in items.to_a do remove item redef fun on_create do for i in items do i.on_create @@ -146,7 +150,7 @@ abstract class View # Is this control enabled so the user can interact with it? # # By default, or if set to `null`, the control is enabled. - var enabled: nullable Bool is writable #, abstract FIXME with #1311 + var enabled: nullable Bool is writable, abstract, autoinit end # A control with some `text` @@ -156,12 +160,37 @@ abstract class TextView # Main `Text` of this control # # By default, or if set to `null`, no text is shown. - var text: nullable Text is writable #, abstract FIXME with #1311 + var text: nullable Text is writable, abstract, autoinit + + # Set the relative size of the text + # + # A value of 1.0, the default, use the platform default text size. + # Values under 1.0 set a smaller text size, and over 1.0 a larger size. + # + # Implementation varies per platform, and some controls may be unaffected + # depending on the customization options of each platform. + # For consistent results, it is recommended to use only on instances + # of `Label` and `size` should be either 0.5, 1.0 or 1.5. + fun size=(size: nullable Float) is autoinit do end + + # Align the text horizontally + # + # Use 0.0 to align left (the default), 0.5 to align in the center and + # 1.0 to align on the right. + # + # Implementation varies per platform, and some controls may be unaffected + # depending on the customization options of each platform. + # For consistent results, it is recommended to use only on instances + # of `Label` and `size` should be either 0.0, 0.5 or 1.0. + fun align=(center: nullable Float) is autoinit do end end # A control for the user to enter custom `text` class TextInput super TextView + + # Hide password or any content entered in this view? + var is_password: nullable Bool is writable end # A pushable button, raises `ButtonPressEvent` @@ -169,6 +198,19 @@ class Button super TextView end +# A text label +class Label + super TextView +end + +# Toggle control with two states and a label +class CheckBox + super TextView + + # Is this control in the checked/on state? + var is_checked = false is writable +end + # A `Button` press event class ButtonPressEvent super AppEvent @@ -192,3 +234,9 @@ end class VerticalLayout super Layout end + +# Scrollable list of views in a simple list +class ListLayout + super View + super CompositeControl +end