lib/app/ui & platforms: intro Label
authorAlexis Laferrière <alexis.laf@xymus.net>
Wed, 28 Oct 2015 12:45:56 +0000 (08:45 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 10 Nov 2015 19:04:33 +0000 (14:04 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/android/ui/ui.nit
lib/app/ui.nit
lib/linux/ui.nit

index 2661d0e..75e1a12 100644 (file)
@@ -114,6 +114,11 @@ redef class TextView
        end
 end
 
+redef class Label
+       redef type NATIVE: NativeTextView
+       redef var native do return (new NativeTextView(app.native_activity)).new_global_ref
+end
+
 redef class TextInput
        redef type NATIVE: NativeEditText
        redef var native = (new NativeEditText(app.native_activity)).new_global_ref
index 65bcffe..01ef5ca 100644 (file)
@@ -169,6 +169,11 @@ class Button
        super TextView
 end
 
+# A text label
+class Label
+       super TextView
+end
+
 # A `Button` press event
 class ButtonPressEvent
        super AppEvent
index 7c0d6d2..c8200d4 100644 (file)
@@ -134,6 +134,14 @@ redef class Button
        init do native.signal_connect("clicked", self, null)
 end
 
+redef class Label
+       redef type NATIVE: GtkLabel
+       redef var native = new GtkLabel("")
+
+       redef fun text do return native.text
+       redef fun text=(value) do native.text = (value or else "").to_s
+end
+
 redef class TextInput
        redef type NATIVE: GtkEntry
        redef var native = new GtkEntry