-
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.
* add Point type and add BoundingBox constructor using Point * add layout.jl * use BoxLayout top place widgets in example.jl
- Loading branch information
1 parent
cdbdaec
commit 33d821b
Showing
4 changed files
with
42 additions
and
4 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
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,28 @@ | ||
abstract type AbstractLayout end | ||
|
||
struct BoxLayout <: AbstractLayout | ||
bounding_box::BoundingBox | ||
end | ||
|
||
abstract type AbstractDirection end | ||
|
||
struct Vertical <: AbstractDirection end | ||
const VERTICAL = Vertical() | ||
|
||
struct Horizontal <: AbstractDirection end | ||
const HORIZONTAL = Horizontal() | ||
|
||
update_layout(layout::BoxLayout, ::Vertical, height, width) = BoxLayout(BoundingBox(layout.bounding_box.i_min, layout.bounding_box.j_min, layout.bounding_box.i_max + height, max(layout.bounding_box.j_max, layout.bounding_box.j_min + width - one(width)))) | ||
|
||
update_layout(layout::BoxLayout, ::Horizontal, height, width) = BoxLayout(BoundingBox(layout.bounding_box.i_min, layout.bounding_box.j_min, max(layout.bounding_box.i_max, layout.bounding_box.i_min + height - one(height)), layout.bounding_box.j_max + width)) | ||
|
||
get_widget_position(layout::BoxLayout, ::Vertical) = Point(layout.bounding_box.i_max + one(layout.bounding_box.i_max), layout.bounding_box.j_min) | ||
|
||
get_widget_position(layout::BoxLayout, ::Horizontal) = Point(layout.bounding_box.i_min, layout.bounding_box.j_max + one(layout.bounding_box.j_max)) | ||
|
||
function get_widget_bounding_box(layout::BoxLayout, direction::AbstractDirection, height, width) | ||
widget_position = get_widget_position(layout, direction) | ||
return BoundingBox(widget_position, height, width) | ||
end | ||
|
||
add_widget(layout::BoxLayout, direction::AbstractDirection, height, width) = update_layout(layout, direction, height, width), get_widget_bounding_box(layout, direction, height, width) |