Skip to content

Commit

Permalink
Minor godoc tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
gmlewis authored and andydotxyz committed Feb 15, 2019
1 parent 145de86 commit 63e13a5
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 56 deletions.
13 changes: 7 additions & 6 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ package fyne
import "net/url"

// An App is the definition of a graphical application.
// Apps can have multiple windows, it will exit when the first windows to be
// Apps can have multiple windows, it will exit when the first window to be
// shown is closed. You can also cause the app to exit by calling Quit().
// To start an application you need to call Run() somewhere in your main() function.
// Alternatively use the window.ShowAndRun() function for your main window.
type App interface {
// Create a new window for the application.
// The first window to open is considered the "master" and when closed
// the application will exit
// the application will exit.
NewWindow(title string) Window

// Open a URL in the default browser application
// Open a URL in the default browser application.
OpenURL(url *url.URL) error

// Icon returns the application icon, this is used in various ways depending on operating system.
// Icon returns the application icon, this is used in various ways
// depending on operating system.
// This is also the default icon for new windows.
Icon() Resource

// SetIcon sets the icon resource used for this application instance
// SetIcon sets the icon resource used for this application instance.
SetIcon(Resource)

// Run the application - this starts the event loop and waits until Quit()
Expand All @@ -42,7 +43,7 @@ type App interface {

var app App

// SetCurrentApp is an internal function to set the app instance currently running
// SetCurrentApp is an internal function to set the app instance currently running.
func SetCurrentApp(current App) {
app = current
}
Expand Down
18 changes: 9 additions & 9 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ func (c *Container) layout() {
}
}

// Size returns the current size of this container
// Size returns the current size of this container.
func (c *Container) Size() Size {
return c.size
}

// Resize sets a new size for the Container
// Resize sets a new size for the Container.
func (c *Container) Resize(size Size) {
c.size = size
c.layout()
}

// Position gets the current position of this Container, relative to it's parent
// Position gets the current position of this Container, relative to its parent.
func (c *Container) Position() Position {
return c.position
}

// Move the container (and all it's children) to a new position, relative to it's parent
// Move the container (and all its children) to a new position, relative to its parent.
func (c *Container) Move(pos Position) {
c.position = pos
c.layout()
Expand All @@ -65,29 +65,29 @@ func (c *Container) Visible() bool {
return !c.Hidden
}

// Show sets this container, and all it's children, to be visible
// Show sets this container, and all its children, to be visible.
func (c *Container) Show() {
c.Hidden = false
for _, child := range c.Objects {
child.Show()
}
}

// Hide sets this container, and all it's children, to be not visible
// Hide sets this container, and all its children, to be not visible.
func (c *Container) Hide() {
c.Hidden = true
for _, child := range c.Objects {
child.Hide()
}
}

// AddObject adds another CanvasObject to the set this Container holds
// AddObject adds another CanvasObject to the set this Container holds.
func (c *Container) AddObject(o CanvasObject) {
c.Objects = append(c.Objects, o)
c.layout()
}

// NewContainer returns a new Container instance holding the specified CanvasObjects
// NewContainer returns a new Container instance holding the specified CanvasObjects.
func NewContainer(objects ...CanvasObject) *Container {
ret := &Container{
Objects: objects,
Expand All @@ -100,7 +100,7 @@ func NewContainer(objects ...CanvasObject) *Container {
}

// NewContainerWithLayout returns a new Container instance holding the specified
// CanvasObjects which will be laid out according to the specified Layout
// CanvasObjects which will be laid out according to the specified Layout.
func NewContainerWithLayout(layout Layout, objects ...CanvasObject) *Container {
ret := &Container{
Objects: objects,
Expand Down
13 changes: 7 additions & 6 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ package fyne
// Driver defines an abstract concept of a Fyne render driver.
// Any implementation must provide at least these methods.
type Driver interface {
// Create a new UI Window
// Create a new UI Window.
CreateWindow(string) Window
// Get a slice containing all app windows
// Get a slice containing all app windows.
AllWindows() []Window

// Return the size required to render the given string of specified font size and style
// Return the size required to render the given string of specified
// font size and style.
RenderedTextSize(string, int, TextStyle) Size

// Get the canvas that is associated with a given CanvasObject
// Get the canvas that is associated with a given CanvasObject.
CanvasForObject(CanvasObject) Canvas

// Start the main event loop of the driver
// Start the main event loop of the driver.
Run()
// Close the driver and open windows then exit the application
// Close the driver and open windows then exit the application.
Quit()
}
6 changes: 3 additions & 3 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ type KeyEvent struct {
Name KeyName
}

// PointEvent describes a pointer input event. The position is relative to the top-left
// of the CanvasObject this is triggered on.
// PointEvent describes a pointer input event. The position is relative to the
// top-left of the CanvasObject this is triggered on.
type PointEvent struct {
Position Position // The position of the event
}

// ScrollEvent defines the parameters of a pointer or other scroll event.
// The DeltaX and DeltaY represent how many large the scroll was in two dimensions.
// The DeltaX and DeltaY represent how large the scroll was in two dimensions.
type ScrollEvent struct {
PointEvent
DeltaX, DeltaY int
Expand Down
27 changes: 16 additions & 11 deletions geometry.go
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}
}
6 changes: 3 additions & 3 deletions layout.go
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
}
4 changes: 2 additions & 2 deletions math.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package fyne

// Min returns the smaller of the passed values
// Min returns the smaller of the passed values.
func Min(x, y int) int {
if x < y {
return x
}
return y
}

// Max returns the larger of the passed values
// Max returns the larger of the passed values.
func Max(x, y int) int {
if x > y {
return x
Expand Down
2 changes: 1 addition & 1 deletion serialise.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func toFile(res *StaticResource) {
}

// GoString converts a Resource object to Go code.
// This is useful if serialising to a go file for compilation into a binary
// This is useful if serialising to a Go file for compilation into a binary.
func (r *StaticResource) GoString() string {
var buffer bytes.Buffer

Expand Down
8 changes: 4 additions & 4 deletions text.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package fyne

// TextAlign represents the horizontal alignment of text within a widget or
// canvas object
// canvas object.
type TextAlign int

const (
// TextAlignLeading specifies a left alignment for left-to-right languages
// TextAlignLeading specifies a left alignment for left-to-right languages.
TextAlignLeading TextAlign = iota
// TextAlignCenter places the text centrally within the available space
// TextAlignCenter places the text centrally within the available space.
TextAlignCenter
// TextAlignTrailing will align the text right for a left-to-right language
// TextAlignTrailing will align the text right for a left-to-right language.
TextAlignTrailing
)

Expand Down
2 changes: 1 addition & 1 deletion theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fyne

import "image/color"

// Theme defines the requirements of any Fyne theme
// Theme defines the requirements of any Fyne theme.
type Theme interface {
BackgroundColor() color.Color
ButtonColor() color.Color
Expand Down
23 changes: 13 additions & 10 deletions window.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ type Window interface {
// Title returns the current window title.
// This is typically displayed in the window decorations.
Title() string
// SetTitle updates the current title of the window
// SetTitle updates the current title of the window.
SetTitle(string)

// FullScreen returns whether or not this window is currently full screen
// FullScreen returns whether or not this window is currently full screen.
FullScreen() bool
// SetFullScreen changes the requested fullScreen property
// true for a fullScreen window and false to unset this.
SetFullScreen(bool)

// Resize this window to the requested content size.
// The result may not be exactly as desired due to various desktop or platform constraints.
// The result may not be exactly as desired due to various desktop or
// platform constraints.
Resize(Size)

// FixedSize returns whether or not this window should disable resizing.
Expand All @@ -26,7 +27,7 @@ type Window interface {
SetFixedSize(bool)

// CenterOnScreen places a window at the center of the monitor
// the Window object is currently positioned on
// the Window object is currently positioned on.
CenterOnScreen()

// Padded, normally true, states whether the window should have inner
Expand All @@ -36,8 +37,9 @@ type Window interface {
// no inner padding. Useful for fullscreen or graphic based applications.
SetPadded(bool)

// Icon returns the window icon, this is used in various ways depending on operating system.
// Most commonly this is displayed on the window border or task switcher
// Icon returns the window icon, this is used in various ways
// depending on operating system.
// Most commonly this is displayed on the window border or task switcher.
Icon() Resource

// SetIcon sets the icon resource used for this window.
Expand All @@ -46,7 +48,7 @@ type Window interface {

SetOnClosed(func())

// Show the window on screen
// Show the window on screen.
Show()
// Hide the window from the user.
// This will not destroy the window or cause the app to exit.
Expand All @@ -59,10 +61,11 @@ type Window interface {
// This should be called near the end of a main() function as it will block.
ShowAndRun()

// Content returns the content of this window
// Content returns the content of this window.
Content() CanvasObject
// SetContent sets the content of this window
// SetContent sets the content of this window.
SetContent(CanvasObject)
// Canvas returns the canvas context to render in the window
// Canvas returns the canvas context to render in the window.
// This can be useful to set a key handler for the window, for example.
Canvas() Canvas
}

0 comments on commit 63e13a5

Please sign in to comment.