Skip to content

Commit

Permalink
Use automatic casting
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanyuan Li authored and Hanyuan Li committed Aug 7, 2018
1 parent eda3aa0 commit 98b07c2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
7 changes: 4 additions & 3 deletions examples/grid_gallery.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ class GridGallery < Hedron::Application
grid.padded = true

cell_info = Hedron::GridCell.new(
size: {1, 1},
expand: {false, false},
align: {Hedron::Align::Fill, Hedron::Align::Fill}
size: {1, 1},
expand: {false, false},
align_x: :fill,
align_y: :fill
)

grid.push(Hedron::Label.new("Name"), {0, 0}, cell_info)
Expand Down
4 changes: 2 additions & 2 deletions src/hedron/struct/side.cr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module Hedron
enum Side
Leading
Left
Top
Trailing
Right
Bottom
end
end
7 changes: 4 additions & 3 deletions src/hedron/ui/grid.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module Hedron
struct GridCell
property size : Tuple(Int32, Int32)
property expand : Tuple(Bool, Bool)
property align : Tuple(Align, Align)
property align_x : Align
property align_y : Align

def initialize(@size, @expand, @align); end
end
Expand All @@ -26,8 +27,8 @@ module Hedron
ui_control(next_to.control.to_unsafe),
side,
cell_info.size[0], cell_info.size[1],
to_int(cell_info.expand[0]), cell_info.align[0].value,
to_int(cell_info.expand[1]), cell_info.align[1].value
to_int(cell_info.expand[0]), cell_info.align_x.value,
to_int(cell_info.expand[1]), cell_info.align_y.value
)
end

Expand Down

0 comments on commit 98b07c2

Please sign in to comment.