-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
145de86
commit 63e13a5
Showing
11 changed files
with
66 additions
and
56 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
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 |
---|---|---|
@@ -1,51 +1,56 @@ | ||
package fyne | ||
|
||
// Size describes something with width and height | ||
// Size describes something with width and height. | ||
type Size struct { | ||
Width int // The number of units along the X axis | ||
Height int // The number of units along the Y axis | ||
Width int // The number of units along the X axis. | ||
Height int // The number of units along the Y axis. | ||
} | ||
|
||
// Add returns a new Size that is the result of increasing the current size by s2 Width and Height | ||
// Add returns a new Size that is the result of increasing the current size by | ||
// s2 Width and Height. | ||
func (s1 Size) Add(s2 Size) Size { | ||
return Size{s1.Width + s2.Width, s1.Height + s2.Height} | ||
} | ||
|
||
// Subtract returns a new Size that is the result of decreasing the current size by s2 Width and Height | ||
// Subtract returns a new Size that is the result of decreasing the current size | ||
// by s2 Width and Height. | ||
func (s1 Size) Subtract(s2 Size) Size { | ||
return Size{s1.Width - s2.Width, s1.Height - s2.Height} | ||
} | ||
|
||
// Union returns a new Size that is the maximum of the current Size and s2 | ||
// Union returns a new Size that is the maximum of the current Size and s2. | ||
func (s1 Size) Union(s2 Size) Size { | ||
maxW := Max(s1.Width, s2.Width) | ||
maxH := Max(s1.Height, s2.Height) | ||
|
||
return NewSize(maxW, maxH) | ||
} | ||
|
||
// NewSize returns a newly allocated Size of the specified dimensions | ||
// NewSize returns a newly allocated Size of the specified dimensions. | ||
func NewSize(w int, h int) Size { | ||
return Size{w, h} | ||
} | ||
|
||
// Position describes a generic X, Y coordinate relative to a parent Canvas or CanvasObject | ||
// Position describes a generic X, Y coordinate relative to a parent Canvas | ||
// or CanvasObject. | ||
type Position struct { | ||
X int // The position from the parent' left edge | ||
Y int // The position from the parent's top edge | ||
} | ||
|
||
// Add returns a new Position that is the result of offsetting the current position by p2 X and Y | ||
// Add returns a new Position that is the result of offsetting the current | ||
// position by p2 X and Y. | ||
func (p1 Position) Add(p2 Position) Position { | ||
return Position{p1.X + p2.X, p1.Y + p2.Y} | ||
} | ||
|
||
// Subtract returns a new Position that is the result of offsetting the current position by p2 -X and -Y | ||
// Subtract returns a new Position that is the result of offsetting the current | ||
// position by p2 -X and -Y. | ||
func (p1 Position) Subtract(p2 Position) Position { | ||
return Position{p1.X - p2.X, p1.Y - p2.Y} | ||
} | ||
|
||
// NewPos returns a newly allocated Position representing the specified coordinates | ||
// NewPos returns a newly allocated Position representing the specified coordinates. | ||
func NewPos(x int, y int) Position { | ||
return Position{x, y} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package fyne | ||
|
||
// Layout defines how CanvasObjects may be laid out in a specified Size | ||
// Layout defines how CanvasObjects may be laid out in a specified Size. | ||
type Layout interface { | ||
// Layout will manipulate the listed CanvasObjects Size and Position | ||
// to fit within the specified size | ||
// to fit within the specified size. | ||
Layout([]CanvasObject, Size) | ||
// MinSize calculates the smallest size that will fit the listed | ||
// CanvasObjects using this Layout algorithm | ||
// CanvasObjects using this Layout algorithm. | ||
MinSize(objects []CanvasObject) Size | ||
} |
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