Skip to content

Commit

Permalink
Add Style contructor flags for alignment (#90)
Browse files Browse the repository at this point in the history
* Add Style contructor flags for alignment

* Update src/style.toit

Co-authored-by: Florian Loitsch <[email protected]>

---------

Co-authored-by: Florian Loitsch <[email protected]>
  • Loading branch information
Erik Corry and floitsch authored Dec 18, 2023
1 parent 9319730 commit b7a0d7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/style.toit
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,8 @@ class Style:
--class-map/Map?=null
--id-map/Map?=null
--type-map/Map?=null
--align-right/bool=false
--align-center/bool=false
.map_={:}:
if x != null: map_["x"] = x
if y != null: map_["y"] = y
Expand All @@ -646,6 +648,9 @@ class Style:
if color != null: map_["color"] = color
if font != null: map_["font"] = font
if border != null: map_["border"] = border
if align-right and align-center: throw "INVALID_ARGUMENT"
if align-right: map_["alignment"] = ALIGN-RIGHT
if align-center: map_["alignment"] = ALIGN-CENTER
Background.check-valid background
if background: map_["background"] = background
class-map_ = class-map
Expand Down
2 changes: 1 addition & 1 deletion tests/icons-visualized.toit
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ main args:
// Also includes the initial style parameters.
off-style := Style
--type-map={
"label": Style --x=30 --y=47 --color=0xc0c0c0 {"alignment": ALIGN_CENTER},
"label": Style --x=30 --y=47 --color=0xc0c0c0 --align-center,
}
--class-map={
"button-outer": Style --y=20 --w=70 --h=70 --border=rounded-35 --background=outer-background,
Expand Down

0 comments on commit b7a0d7f

Please sign in to comment.