Skip to content

UI.Style

Name - Description Default Type
<input> A table describing the style to apply. { Any }&{ Any }
<output> The output of this shard will be its input. Any

Apply style changes to the current UI scope.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(def style
  {:override_text_style "MyStyle"
   :text_styles
   [{:name "MyStyle"
     :size (float 36)
     :family "Monospace"}]
   :visuals
   {:override_text_color (color 64 250 0)}})

(GFX.MainWindow
 :Contents
 (->
  (Setup
   (GFX.DrawQueue) >= .ui-draw-queue
   (GFX.UIPass .ui-draw-queue) >> .render-steps)
  (UI
   .ui-draw-queue
   (UI.CentralPanel
    :Contents
    (->
     style (UI.Style)
     "Hello Shards!" (UI.Label))))

  (GFX.Render :Steps .render-steps)))

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(GFX.MainWindow
 :Contents
 (->
  (Setup
   (GFX.DrawQueue) >= .ui-draw-queue
   (GFX.UIPass .ui-draw-queue) >> .render-steps)
  (UI
   .ui-draw-queue
   (UI.CentralPanel
    (->
     (Setup
      64 >= .hue
      0 >= .r >= .g
      (color 0 0 0 0) >= .color
      16.0 >= .size)

     255 (Math.Subtract .hue) (Math.Multiply 2) (Min 255) > .r
     .hue (Math.Multiply 2) (Min 255) > .g
     [.r .g 0 255] (ToColor) > .color

     (UI.Scope
      (->
       {:override_text_style "MyStyle"
        :text_styles
        [{:name "MyStyle"
          :size .size
          :family "Monospace"}]
        :visuals
        {:override_text_color .color}}
       (UI.Style)
       (UI.IntSlider
        :Variable .hue
        :Min 0 :Max 255)
       (UI.FloatSlider
        :Variable .size
        :Min 8.0 :Max 96.0)
       "Hello Shards!" (UI.Label)))

     "This text is not affected" (UI.Label))))

  (GFX.Render :Steps .render-steps)))