-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb22518
commit efdf635
Showing
12 changed files
with
265 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require "../spec_helper" | ||
require "../../src/ltk/base/size" | ||
require "../../src/ltk/layout/box_layout_item_data" | ||
require "../../src/ltk/layout/layout_math" | ||
|
||
include Ltk | ||
|
||
describe Ltk do | ||
describe LayoutMath do | ||
describe "#calculateWidths" do | ||
it "properly calculates width for one item" do | ||
item = BoxLayoutItemData.new(Size.new(100, 0), Size.new(50, 0), Size.new(150, 0), 0, Alignment::Center) | ||
LayoutMath.calculateWidths([item], 100).should eq([100]) | ||
true.should eq(true) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require "./layout_item" | ||
|
||
module Ltk | ||
class BoxLayoutItem < LayoutItem | ||
DEFAULT_STRETCH = 0 | ||
MINIMUM_STRETCH = 0 | ||
|
||
property stretch : Int32 = DEFAULT_STRETCH | ||
|
||
def initialize(item : (Widget | Layout), @stretch : Int32 = DEFAULT_STETCH, alignment : Alignment = Alignment::None) | ||
raise ArgumentError.new("stretch cannot be less than #{MINIMUM_STRETCH}") if @stretch < MINIMUM_STRETCH | ||
super(item, alignment) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require "../base/rect" | ||
require "./alignment" | ||
require "./box_layout_item" | ||
|
||
module Ltk | ||
struct BoxLayoutItemData | ||
getter preferred_size : Size | ||
getter minimum_size : Size | ||
getter maximum_size : Size | ||
getter stretch : Int32 | ||
getter alignment : Alignment | ||
|
||
def initialize(@preferred_size, | ||
@minimum_size = Size::ZERO, | ||
@maximum_size = Size::MAX, | ||
@stretch = 0, | ||
@alignment : Alignment = Alignment::Center) | ||
end | ||
|
||
def initialize(item : BoxLayoutItem) | ||
@preferred_size = item.preferred_size | ||
@minimum_size = item.minimum_size | ||
@maximum_size = item.maximum_size | ||
@stretch = item.stretch | ||
@alignment = item.alignment | ||
end | ||
|
||
@[AlwaysInline] | ||
def preferred_width : Int32 | ||
@preferred_size.width | ||
end | ||
|
||
@[AlwaysInline] | ||
def preferred_height : Int32 | ||
@preferred_size.height | ||
end | ||
|
||
@[AlwaysInline] | ||
def minimum_width : Int32 | ||
@minimum_size.width | ||
end | ||
|
||
@[AlwaysInline] | ||
def minimum_height : Int32 | ||
@minimum_size.height | ||
end | ||
|
||
@[AlwaysInline] | ||
def maximum_width : Int32 | ||
@maximum_size.width | ||
end | ||
|
||
@[AlwaysInline] | ||
def maximum_height : Int32 | ||
@maximum_size.height | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.