123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- import unittest
- import siwin
- import sigui
- test "layers":
- let window = newOpenglWindow(size = ivec2(1280, 720), title = "layers").newUiWindow
-
- const typefaceFile = staticRead "Roboto-Regular.ttf"
- let typeface = parseTtf(typefaceFile)
- window.makeLayout:
- this.clearColor = color(1, 1, 1)
- - Styler():
- this.fill parent
- style = makeStyle:
- UiText:
- font = typeface.withSize(24)
- - UiText() as nonClipped_text:
- centerX = nonClipped_rect.center
- top = parent.top + 20
- text = "non-clipped"
- this.fontSize = 32
- - UiText() as clipped_text:
- centerX = clipped_rect.center
- top = parent.top + 20
- text = "clipped"
- this.fontSize = 32
-
- - UiText():
- left = parent.left + 20
- bottom = parent.bottom - 10
- text = "*not exacly parent, since object is in larger hierarchy: [ ClipRect ] > UiRect > Layout > this"
- this.fontSize = 16
- - Layout():
- left = parent.left + 20
- right = parent.right - 20
- top = nonClipped_text.bottom + 20
- bottom = parent.bottom - 40
- fillWithSpaces = true
-
- - UiRect() as nonClipped_rect:
- w = 300
- this.binding h: parent.h[]
-
- radius = 10
- color = color(0.7, 0.7, 0.7)
-
- - Layout():
- this.fillVertical(parent, 20)
- left = parent.left + 20
- orientation = vertical
- fillWithSpaces = true
- - UiRect() as ncr_a:
- h = 80
- w = 500
- radius = 10
- color = color(0.3, 0.3, 1)
- - UiText():
- centerY = parent.center
- left = parent.left + 20
- color = color(1, 1, 1)
- text = "no modifications"
-
- - UiRect():
- drawLayer = after nonClipped_rect
- h = 80
- w = 500
- radius = 10
- color = color(0.25, 0.25, 0.85)
- - UiText():
- centerY = parent.center
- left = parent.left + 20
- color = color(1, 1, 1)
- text = "after parent*"
-
- - UiRect():
- drawLayer = before nonClipped_rect
- h = 80
- w = 500
- radius = 10
- color = color(0.2, 0.2, 0.7)
- - UiText():
- centerY = parent.center
- right = parent.right - 20
- color = color(1, 1, 1)
- text = "before parent*"
- - ClipRect() as clipped_rect:
- w = 300
- this.binding h: parent.h[]
-
- radius = 10
- - UiRect():
- this.fill parent
- color = color(0.7, 0.7, 0.7)
-
- - Layout():
- top = parent.top + 30
- bottom = parent.bottom - 10
- left = parent.left - 220
- orientation = vertical
- fillWithSpaces = true
- - UiRect():
- h = 80
- w = 500
- radius = 10
- color = color(0.3, 1, 0.3)
- - UiText():
- centerY = parent.center
- right = parent.right - 20
- text = "no modifications"
-
- - UiRect():
- drawLayer = after clipped_rect
- h = 80
- w = 500
- radius = 10
- color = color(0.25, 0.85, 0.25)
- - UiText():
- centerY = parent.center
- left = parent.left + 20
- text = "after parent*"
-
- - UiRect():
- drawLayer = before clipped_rect
- h = 80
- w = 500
- this.radius[] = 10
- this.color[] = color(0.2, 0.7, 0.2)
- - UiText():
- centerY = parent.center
- left = parent.left + 20
- text = "before parent*"
- run window.siwinWindow
|