examples: annotate examples
[nit.git] / lib / gamnit / examples / fonts_showcase / src / fonts_showcase.nit
index 0fae76d..91f3073 100644 (file)
@@ -7,6 +7,7 @@
 
 # Font support showcase
 module fonts_showcase is
+       example
        app_name "gamnit fonts"
        app_namespace "org.gamnit.fonts_showcase"
        app_version(1, 0, git_revision)
@@ -22,10 +23,13 @@ redef class App
        # Asset font used to display text
        var font = new BMFontAsset("Josefin_Sans/font.fnt")
 
-       # Anchor texture used to identify the anchor coordinate of each `TextSprites`
+       # Anchor texture identifying the anchor coordinates of each `TextSprites`
        var anchor = new Texture("anchor.png")
 
-       redef fun on_create
+       # Bottom right corner
+       var corner = new Texture("corner.png")
+
+       redef fun create_scene
        do
                super
 
@@ -46,7 +50,7 @@ redef class App
 
                # Shared content
                var description = "The anchor icon identifies the coordinate of TextSprites::anchor."
-               var lorem_ipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
+               var lorem_ipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et [dolore magna](my_link asdf) aliqua."
                var color = [0.0, 0.25, 0.5]
 
                # ---
@@ -77,8 +81,8 @@ redef class App
 
                texts.add new TextSprites(font,
                        ui_camera.top_left.offset(1000.0, -400.0, 0.0),
-                       "Right, max_width=400.0:\n"+lorem_ipsum,
-                       align=1.0, max_width=400.0)
+                       "Right, max_width=400.0, scale=0.66:\n"+lorem_ipsum,
+                       align=1.0, max_width=400.0, scale=0.66)
 
                texts.add new TextSprites(font,
                        ui_camera.top_left.offset(300.0, -700.0, 0.0),
@@ -121,6 +125,16 @@ redef class App
                        max_width=400.0, align=0.5, valign=0.5)
 
                # ---
+               # Links
+
+               for ts in texts do
+                       for link_name, sprites in ts.links do
+                               print "Link: {link_name}"
+                               for s in sprites do s.green = 0.0
+                       end
+               end
+
+               # ---
                # Anchors and background boxes
 
                # Gradient background for the max_width texts
@@ -160,6 +174,12 @@ redef class App
 
                # Add the anchor effects to all TextSprites
                for t in texts do ui_sprites.add new Sprite(anchor, t.anchor)
+
+               for t in texts do
+                       # Bottom right
+                       var br = t.anchor.offset(t.width*(1.0-t.align), -t.height*(1.0-t.valign), 1.0)
+                       ui_sprites.add new Sprite(corner, br)
+               end
        end
 
        redef fun accept_event(event)