Skip to content

Commit

Permalink
add: missing functions to LayoutItem
Browse files Browse the repository at this point in the history
  • Loading branch information
TamasSzekeres committed Aug 19, 2018
1 parent 4466182 commit e5864cc
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/ltk/layout/layout_item.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "../base/base_object"
require "../base/rect"
require "../base/size"
require "../widget/widget"
require "./alignment"
require "./layout"
Expand All @@ -8,10 +9,10 @@ module Ltk
abstract class LayoutItem < BaseObject
getter item : (Widget | Layout)
property alignment : Alignment = Alignment::Center

def initialize(@item : (Widget | Layout), @alignment = Alignment::Center)
end

@[AlwaysInline]
def x : Int32
geometry.x
Expand Down Expand Up @@ -48,6 +49,14 @@ module Ltk
end
end

def preferred_size : Size
case @item
when Widget then @item.as(Widget).preferred_size
else
Size.ZERO
end
end

def preferred_width : Int32
case @item
when Widget then @item.as(Widget).preferred_width
Expand All @@ -64,6 +73,14 @@ module Ltk
end
end

def minimum_size : Size
case @item
when Widget then @item.as(Widget).minimum_size
else
Size.ZERO
end
end

def minimum_width : Int32
case @item
when Widget then @item.as(Widget).minimum_width
Expand All @@ -80,6 +97,14 @@ module Ltk
end
end

def maximum_size : Size
case @item
when Widget then @item.as(Widget).maximum_size
else
Size.ZERO
end
end

def maximum_width : Int32
case @item
when Widget then @item.as(Widget).maximum_width
Expand Down

0 comments on commit e5864cc

Please sign in to comment.