objects

package module
v0.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2024 License: GPL-3.0 Imports: 17 Imported by: 1

README

objects

Some of the objects in this package

Go Reference

Objects contains a standard collection of re-usable objects. It should also be viewed as a reference for how to create custom objects in Tomo.

Styling

All objects in this module have roles of the form:

objects.TypeName

Where TypeName is the exact Go type name of the object in question. Objects may also have different tags to indicate variations, states, etc. If applicable, they are listed and described in the doc comment for the object's type. More complex objects may have sub-components that are not accessible from the API. These are listed alongside the tags.

Setting Attributes

It is generally not recommended to set attributes on these objects. However, if you must, they can be set by obtaining the object's underlying box through the GetBox method. Be aware that the exact type of box that is returned here is not part of the API, and may change unexpectedly even after v1.0. This caveat also applies to boxes/sub-components making up the internal composition of the objects.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Button

type Button struct {
	// contains filtered or unexported fields
}

Button is a clickable button.

Tags:

  • [icon] The button has an icon.

func NewButton

func NewButton(text string) *Button

NewButton creates a new button with the specified text.

func (*Button) GetBox added in v0.23.0

func (this *Button) GetBox() tomo.Box

GetBox returns the underlying box.

func (*Button) OnClick

func (this *Button) OnClick(callback func()) event.Cookie

OnClick specifies a function to be called when the button is clicked.

func (*Button) SetFocused added in v0.23.0

func (this *Button) SetFocused(focused bool)

SetFocused sets whether or not this button has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (*Button) SetIcon added in v0.6.0

func (this *Button) SetIcon(id tomo.Icon)

SetIcon sets an icon for this button. Setting the icon to IconUnknown will remove it.

func (*Button) SetText added in v0.6.0

func (this *Button) SetText(text string)

SetText sets the text of the button's label.

type Calendar added in v0.18.0

type Calendar struct {
	// contains filtered or unexported fields
}

Calendar is an object that can display a date and allow the user to change it. It can display one month at a time.

Sub-components:

  • CalendarGrid organizes the days into a grid.
  • CalendarWeekdayHeader appears at the top of each grid column, and shows the day of the week that column represents.
  • CalendarDay appears within the grid for each day of the current month.

CalendarDay tags:

  • [weekend] The day is a weekend.
  • [weekday] The day is a weekday.

func NewCalendar added in v0.18.0

func NewCalendar(tm time.Time) *Calendar

NewCalendar creates a new calendar with the specified date.

func (*Calendar) GetBox added in v0.23.0

func (this *Calendar) GetBox() tomo.Box

GetBox returns the underlying box.

func (*Calendar) OnValueChange added in v0.20.0

func (this *Calendar) OnValueChange(callback func())

OnValueChange sets a function to be called when the user changes the date on the calendar.

func (*Calendar) SetValue added in v0.20.0

func (this *Calendar) SetValue(tm time.Time)

SetValue sets the date the calendar will display.

func (*Calendar) Value added in v0.20.0

func (this *Calendar) Value() time.Time

Value returns the time this calendar is displaying.

type Checkbox added in v0.10.0

type Checkbox struct {
	// contains filtered or unexported fields
}

Checkbox is a control that can be toggled.

Tags:

  • [checked] The checkbox's value is true.
  • [unchecked] The checkbox's value is false.

func NewCheckbox added in v0.10.0

func NewCheckbox(value bool) *Checkbox

NewCheckbox creates a new checkbox with the specified value.

func (*Checkbox) GetBox added in v0.23.0

func (this *Checkbox) GetBox() tomo.Box

GetBox returns the underlying box.

func (*Checkbox) OnValueChange added in v0.10.0

func (this *Checkbox) OnValueChange(callback func()) event.Cookie

OnValueChange specifies a function to be called when the user checks or unchecks the checkbox.

func (*Checkbox) SetFocused added in v0.23.0

func (this *Checkbox) SetFocused(focused bool)

SetFocused sets whether or not this checkbox has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (*Checkbox) SetValue added in v0.10.0

func (this *Checkbox) SetValue(value bool)

SetValue sets the value of the checkbox.

func (*Checkbox) Toggle added in v0.10.0

func (this *Checkbox) Toggle()

Toggle toggles the value of the checkbox between true and false.

func (*Checkbox) Value added in v0.10.0

func (this *Checkbox) Value() bool

Value returns the value of the checkbox.

type Container

type Container struct {
	// contains filtered or unexported fields
}

Container is an object that can contain other objects. It is plain looking, and is intended to be used within other containers as a primitive for building more complex layouts.

func NewContainer added in v0.24.0

func NewContainer(layout tomo.Layout, children ...tomo.Object) *Container

NewContainer creates a new container.

func NewRoot added in v0.24.0

func NewRoot(layout tomo.Layout, children ...tomo.Object) *Container

NewRoot creates a new container.

func (*Container) Add added in v0.23.0

func (this *Container) Add(object tomo.Object)

Add appends a child object. If the object is already a child of another object, it will be removed from that object first.

func (*Container) At added in v0.23.0

func (this *Container) At(index int) tomo.Object

At returns the child object at the specified index.

func (*Container) Clear added in v0.23.0

func (this *Container) Clear()

Clear removes all child objects.

func (*Container) ContentBounds added in v0.23.0

func (this *Container) ContentBounds() image.Rectangle

ContentBounds returns the bounds of the inner content of the container relative to the container's InnerBounds.

func (*Container) GetBox added in v0.23.0

func (this *Container) GetBox() tomo.Box

GetBox returns the underlying box.

func (*Container) Insert added in v0.23.0

func (this *Container) Insert(child tomo.Object, before tomo.Object)

Insert inserts a child object before a specified object. If the before object is nil or is not contained within this container, the inserted object is appended. If the inserted object is already a child of another object, it will be removed from that object first.

func (*Container) Len added in v0.23.0

func (this *Container) Len() int

Len returns hte amount of child objects.

func (*Container) OnContentBoundsChange added in v0.23.0

func (this *Container) OnContentBoundsChange(callback func()) event.Cookie

OnContentBoundsChange specifies a function to be called when the container's ContentBounds or InnerBounds changes.

func (*Container) Remove added in v0.23.0

func (this *Container) Remove(object tomo.Object)

Remove removes a child object, if it is a child of this container.

func (*Container) ScrollTo added in v0.23.0

func (this *Container) ScrollTo(position image.Point)

ScrollTo shifts the origin of the container's content to the origin of the container's InnerBounds, offset by the given point.

func (*Container) SetAlign added in v0.23.0

func (this *Container) SetAlign(x, y tomo.Align)

SetAlign sets the X and Y alignment of the container.

func (*Container) SetLayout added in v0.23.0

func (this *Container) SetLayout(layout tomo.Layout)

SetLayout sets the layout of the container.

func (*Container) SetOverflow added in v0.23.0

func (this *Container) SetOverflow(x, y bool)

SetOverflow sets the X and Y overflow of the container.

type Dialog added in v0.13.0

type Dialog struct {
	tomo.Window
}

Dialog is a modal dialog window.

func NewDialog added in v0.13.0

func NewDialog(kind DialogKind, parent tomo.Window, title, message string, options ...tomo.Object) (*Dialog, error)

NewDialog creates a new dialog window given a dialog kind.

func NewDialogOk added in v0.13.0

func NewDialogOk(kind DialogKind, parent tomo.Window, title, message string, onOk func()) (*Dialog, error)

NewDialogOk creates a new dialog window with an OK option.

func NewDialogOkCancel added in v0.13.0

func NewDialogOkCancel(kind DialogKind, parent tomo.Window, title, message string, onOk func()) (*Dialog, error)

NewDialogOkCancel creates a new dialog window with OK and Cancel options.

type DialogKind added in v0.13.0

type DialogKind int

DialogKind defines the semantic role of a dialog window.

const (
	DialogInformation DialogKind = iota
	DialogQuestion
	DialogWarning
	DialogError
)
type Dropdown struct {
	// contains filtered or unexported fields
}

Dropdown is a non-editable text input that allows the user to pick a value from a list.

func NewDropdown added in v0.22.0

func NewDropdown(items ...string) *Dropdown

NewDropdown creates a new dropdown input with the specified items

func (this *Dropdown) Choose()

Choose creates a menu that allows the user to pick a value.

func (this *Dropdown) GetBox() tomo.Box

GetBox returns the underlying box.

func (this *Dropdown) SetFocused(focused bool)

SetFocused sets whether or not this dropdown has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (this *Dropdown) SetItems(items ...string)

SetItems sets the items from which the user is able to pick.

func (this *Dropdown) SetValue(value string)

SetValue sets the value of the dropdown. This does not necissarily have to be in the list of items.

func (this *Dropdown) Value() string

Value returns the value of the dropdown. This does not necissarily have to be in the list of items.

type File added in v0.23.0

type File struct {
	// contains filtered or unexported fields
}

File is a representation of a file or directory.

func NewFile added in v0.23.0

func NewFile(name string, mime data.Mime) *File

NewFile creates a new file icon with the given name and MIME type.

func (*File) GetBox added in v0.23.0

func (this *File) GetBox() tomo.Box

GetBox returns the underlying box.

func (*File) OnDoubleClick added in v0.23.0

func (this *File) OnDoubleClick(callback func()) event.Cookie

OnDoubleClick specifies a function to be called when the file is double-clicked.

func (*File) SetFocused added in v0.23.0

func (this *File) SetFocused(focused bool)

SetFocused sets whether or not this file has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (*File) SetName added in v0.23.0

func (this *File) SetName(text string)

SetName sets the text of the file's label.

func (*File) SetType added in v0.23.0

func (this *File) SetType(mime data.Mime)

SetType sets the MIME type of the file.

type HSVAColorPicker added in v0.22.0

type HSVAColorPicker struct {
	// contains filtered or unexported fields
}

HSVAColorPicker allows the user to pick a color by controlling its HSVA parameters.

Sub-components:

  • ColorPickerMap is a rectangular control where the X axis controls saturation and the Y axis controls value.

func NewHSVAColorPicker added in v0.22.0

func NewHSVAColorPicker(value color.Color) *HSVAColorPicker

NewHSVAColorPicker creates a new color picker with the specified color.

func (*HSVAColorPicker) GetBox added in v0.23.0

func (this *HSVAColorPicker) GetBox() tomo.Box

GetBox returns the underlying box.

func (*HSVAColorPicker) OnValueChange added in v0.22.0

func (this *HSVAColorPicker) OnValueChange(callback func()) event.Cookie

OnValueChange specifies a function to be called when the user changes the swatch's color.

func (*HSVAColorPicker) RGBA added in v0.22.0

func (this *HSVAColorPicker) RGBA() (r, g, b, a uint32)

RGBA satisfies the color.Color interface

func (*HSVAColorPicker) SetFocused added in v0.23.0

func (this *HSVAColorPicker) SetFocused(focused bool)

SetFocused sets whether or not this color picker has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (*HSVAColorPicker) SetValue added in v0.22.0

func (this *HSVAColorPicker) SetValue(value color.Color)

SetValue sets the color of the picker.

func (*HSVAColorPicker) Value added in v0.22.0

func (this *HSVAColorPicker) Value() color.Color

Value returns the color of the picker.

type Heading

type Heading struct {
	// contains filtered or unexported fields
}

Heading is a label that denotes the start of some section of content. It can have a level from 0 to 2, with 0 being the most prominent and 2 being the most subtle.

Tags:

  • [0] The heading has a level of 0 (most prominent).
  • [1] The heading has a level of 1.
  • [2] The heading has a level of 2 (least prominent).

func NewHeading

func NewHeading(level int, text string) *Heading

NewHeading creates a new section heading. The level can be from 0 to 2.

func NewMenuHeading added in v0.22.0

func NewMenuHeading(text string) *Heading

NewMenuHeading creatss a new heading for use in menus.

func (*Heading) Dot added in v0.23.0

func (this *Heading) Dot() text.Dot

Dot returns the text cursor or selection.

func (*Heading) GetBox added in v0.23.0

func (this *Heading) GetBox() tomo.Box

GetBox returns the underlying box.

func (*Heading) OnDotChange added in v0.23.0

func (this *Heading) OnDotChange(callback func()) event.Cookie

OnDotChange specifies a function to be called when the text cursor or selection changes.

func (*Heading) Select added in v0.23.0

func (this *Heading) Select(dot text.Dot)

Select sets the text cursor or selection.

func (*Heading) SetFocused added in v0.23.0

func (this *Heading) SetFocused(focused bool)

SetFocused sets whether or not this heading has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (*Heading) SetText added in v0.23.0

func (this *Heading) SetText(text string)

SetText sets the text content of the heading.

type Icon added in v0.5.0

type Icon struct {
	// contains filtered or unexported fields
}

Icon displays a single icon.

Tags:

  • [large] The icon is large sized.
  • [medium] The icon is medium sized.
  • [small] The icon is small sized.

func NewIcon added in v0.5.0

func NewIcon(icon tomo.Icon, size tomo.IconSize) *Icon

NewIcon creates a new icon from an icon ID.

func (*Icon) GetBox added in v0.23.0

func (this *Icon) GetBox() tomo.Box

GetBox returns the underlying box.

func (*Icon) SetIcon added in v0.21.0

func (this *Icon) SetIcon(icon tomo.Icon, size tomo.IconSize)

SetIcon sets the icon.

type Label

type Label struct {
	// contains filtered or unexported fields
}

Label is a simple text label.

func NewLabel

func NewLabel(text string) *Label

NewLabel creates a new text label.

func (*Label) Dot added in v0.23.0

func (this *Label) Dot() text.Dot

Dot returns the text cursor or selection.

func (*Label) GetBox added in v0.23.0

func (this *Label) GetBox() tomo.Box

GetBox returns the underlying box.

func (*Label) OnDotChange added in v0.23.0

func (this *Label) OnDotChange(callback func()) event.Cookie

OnDotChange specifies a function to be called when the text cursor or selection changes.

func (*Label) Select added in v0.23.0

func (this *Label) Select(dot text.Dot)

Select sets the text cursor or selection.

func (*Label) SetAlign added in v0.23.0

func (this *Label) SetAlign(x, y tomo.Align)

SetAlign sets the X and Y alignment of the label.

func (*Label) SetFocused added in v0.23.0

func (this *Label) SetFocused(focused bool)

SetFocused sets whether or not this label has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (*Label) SetOverflow added in v0.24.0

func (this *Label) SetOverflow(x, y bool)

SetOverflow sets the X and Y overflow of the label.

func (*Label) SetText added in v0.23.0

func (this *Label) SetText(text string)

SetText sets the text content of the label.

type LabelCheckbox added in v0.10.0

type LabelCheckbox struct {
	// contains filtered or unexported fields
}

LabelCheckbox is a checkbox with a label.

func NewLabelCheckbox added in v0.10.0

func NewLabelCheckbox(value bool, text string) *LabelCheckbox

NewLabelCheckbox creates a new labeled checkbox with the specified value and label text.

func (*LabelCheckbox) GetBox added in v0.23.0

func (this *LabelCheckbox) GetBox() tomo.Box

GetBox returns the underlying box.

func (*LabelCheckbox) OnValueChange added in v0.10.0

func (this *LabelCheckbox) OnValueChange(callback func()) event.Cookie

OnValueChange specifies a function to be called when the user checks or unchecks the checkbox.

func (*LabelCheckbox) SetFocused added in v0.23.0

func (this *LabelCheckbox) SetFocused(focused bool)

SetFocused sets whether or not this checkbox has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (*LabelCheckbox) SetText added in v0.23.0

func (this *LabelCheckbox) SetText(text string)

SetText sets the text label of the checkbox.

func (*LabelCheckbox) SetValue added in v0.10.0

func (this *LabelCheckbox) SetValue(value bool)

SetValue sets the value of the checkbox.

func (*LabelCheckbox) Toggle added in v0.10.0

func (this *LabelCheckbox) Toggle()

Toggle toggles the value of the checkbox between true and false.

func (*LabelCheckbox) Value added in v0.10.0

func (this *LabelCheckbox) Value() bool

Value returns the value of the checkbox.

type LabelSwatch added in v0.20.0

type LabelSwatch struct {
	// contains filtered or unexported fields
}

LabelSwatch is a swatch with a label.

func NewLabelSwatch added in v0.20.0

func NewLabelSwatch(value color.Color, text string) *LabelSwatch

NewLabelSwatch creates a new labeled swatch with the specified color and label text.

func (*LabelSwatch) GetBox added in v0.23.0

func (this *LabelSwatch) GetBox() tomo.Box

GetBox returns the underlying box.

func (*LabelSwatch) OnConfirm added in v0.20.0

func (this *LabelSwatch) OnConfirm(callback func()) event.Cookie

OnConfirm specifies a function to be called when the user selects "OK" in the color picker.

func (*LabelSwatch) OnValueChange added in v0.20.0

func (this *LabelSwatch) OnValueChange(callback func()) event.Cookie

OnValueChange specifies a function to be called when the swatch's color is changed by the user.

func (*LabelSwatch) RGBA added in v0.20.0

func (this *LabelSwatch) RGBA() (r, g, b, a uint32)

RGBA satisfies the color.Color interface

func (*LabelSwatch) SetFocused added in v0.23.0

func (this *LabelSwatch) SetFocused(focused bool)

SetFocused sets whether or not this swatch has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (*LabelSwatch) SetText added in v0.23.0

func (this *LabelSwatch) SetText(text string)

SetText sets the text label of the swatch.

func (*LabelSwatch) SetValue added in v0.20.0

func (this *LabelSwatch) SetValue(value color.Color)

SetValue sets the color of the swatch.

func (*LabelSwatch) Value added in v0.20.0

func (this *LabelSwatch) Value() color.Color

Value returns the color of the swatch.

type Menu struct {
	tomo.Window
	// contains filtered or unexported fields
}

Menu is a menu window.

Sub-components:

  • Root is the root of the window. It is differentiated from a normal Root object in that it has the [menu] tag. If the menu has been torn off, it will have the [torn] tag.
  • TearLine is a horizontal line at the top of the menu that, when clicked, causes the menu to be "torn off" into a movable window.

func NewAnchoredMenu added in v0.22.0

func NewAnchoredMenu(anchor tomo.Object, items ...tomo.Object) (*Menu, error)

NewAnchoredMenu creates a new menu with the specified items. The menu will appear directly under the anchor.

func NewMenu added in v0.17.0

func NewMenu(parent tomo.Window, items ...tomo.Object) (*Menu, error)

NewMenu creates a new menu with the specified items. The menu will appear directly under the mouse pointer.

func (this *Menu) TearOff()

TearOff converts this menu into a tear-off menu.

type MenuItem struct {
	// contains filtered or unexported fields
}

MenuItem is a selectable memu item.

func NewIconMenuItem added in v0.22.0

func NewIconMenuItem(icon tomo.Icon, text string) *MenuItem

NewIconMenuItem creates a new menu item with the specified icon and text.

func NewMenuItem added in v0.17.0

func NewMenuItem(text string) *MenuItem

NewMenuItem creates a new menu item with the specified text.

func (this *MenuItem) GetBox() tomo.Box

GetBox returns the underlying box.

func (this *MenuItem) OnClick(callback func()) event.Cookie

OnClick specifies a function to be called when the menu item is clicked.

func (this *MenuItem) SetFocused(focused bool)

SetFocused sets whether or not this menu item has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (this *MenuItem) SetIcon(id tomo.Icon)

SetIcon sets an icon for this item. Setting the icon to IconUnknown will remove it.

func (this *MenuItem) SetText(text string)

SetText sets the text of the items's label.

type MimeIcon added in v0.21.0

type MimeIcon struct {
	// contains filtered or unexported fields
}

MimeIcon displays an icon of a MIME type.

func NewMimeIcon added in v0.5.0

func NewMimeIcon(mime data.Mime, size tomo.IconSize) *MimeIcon

NewMimeIcon creates a new icon from a MIME type.

func (*MimeIcon) GetBox added in v0.23.0

func (this *MimeIcon) GetBox() tomo.Box

GetBox returns the underlying box.

func (*MimeIcon) SetIcon added in v0.21.0

func (this *MimeIcon) SetIcon(mime data.Mime, size tomo.IconSize)

SetIcon sets the MIME type and size of the icon.

type Notebook added in v0.24.0

type Notebook struct {
	// contains filtered or unexported fields
}

Notebook holds multiple objects, each in their own page. The user can click the tab bar at the top to choose which one is activated.

Sub-components:

  • TabRow sits at the top of the container and contains a row of tabs.
  • TabSpacer sits at either end of the tab row, bookending the list of tabs.
  • Tab appears in the tab row for each tab in the notebook. The user can click on the tab to switch to it.

TabSpacer tags:

  • [left] The spacer is on the left.
  • [right] The spacer is on the right.

Tab tags:

  • [active] The tab is currently active and its page is visible.

func NewNotebook added in v0.24.0

func NewNotebook() *Notebook

NewNotebook creates a new tabbed notebook.

func (*Notebook) Activate added in v0.24.0

func (this *Notebook) Activate(name string)

Activate switches to a named page.

func (*Notebook) Add added in v0.24.0

func (this *Notebook) Add(name string, root tomo.Object)

Add adds an object as a page with the specified name.

func (*Notebook) Clear added in v0.24.0

func (this *Notebook) Clear()

Clear removes all tabs.

func (*Notebook) GetBox added in v0.24.0

func (this *Notebook) GetBox() tomo.Box

GetBox returns the underlying box.

func (*Notebook) Remove added in v0.24.0

func (this *Notebook) Remove(name string)

Remove removes the named page.

type NumberInput added in v0.10.0

type NumberInput struct {
	// contains filtered or unexported fields
}

NumberInput is an editable text box which accepts only numbers, and has controls to increment and decrement its value.

func NewNumberInput added in v0.10.0

func NewNumberInput(value float64) *NumberInput

NewNumberInput creates a new number input with the specified value.

func (*NumberInput) Dot added in v0.23.0

func (this *NumberInput) Dot() text.Dot

Dot returns the text cursor or selection.

func (*NumberInput) GetBox added in v0.23.0

func (this *NumberInput) GetBox() tomo.Box

GetBox returns the underlying box.

func (*NumberInput) OnConfirm added in v0.20.0

func (this *NumberInput) OnConfirm(callback func()) event.Cookie

OnConfirm specifies a function to be called when the user presses enter within the number input.

func (*NumberInput) OnValueChange added in v0.20.0

func (this *NumberInput) OnValueChange(callback func()) event.Cookie

OnValueChange specifies a function to be called when the user edits the input value.

func (*NumberInput) Select added in v0.23.0

func (this *NumberInput) Select(dot text.Dot)

Select sets the text cursor or selection.

func (*NumberInput) SetFocused added in v0.23.0

func (this *NumberInput) SetFocused(focused bool)

SetFocused sets whether or not this number input has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (*NumberInput) SetValue added in v0.10.0

func (this *NumberInput) SetValue(value float64)

SetValue sets the value of the input.

func (*NumberInput) Value added in v0.10.0

func (this *NumberInput) Value() float64

Value returns the value of the input.

type Pegboard added in v0.24.0

type Pegboard struct {
	// contains filtered or unexported fields
}

Pegboard is an object that can contain other objects. It is intended to contain a flowed list of objects which represent some data, such as files.

func NewPegboard added in v0.24.0

func NewPegboard(layout tomo.Layout, children ...tomo.Object) *Pegboard

NewPegboard creates a new pegboard. If the provided layout is nil, it will use a FlowHorizontal layout.

func (*Pegboard) Add added in v0.24.0

func (this *Pegboard) Add(object tomo.Object)

Add appends a child object. If the object is already a child of another object, it will be removed from that object first.

func (*Pegboard) At added in v0.24.0

func (this *Pegboard) At(index int) tomo.Object

At returns the child object at the specified index.

func (*Pegboard) Clear added in v0.24.0

func (this *Pegboard) Clear()

Clear removes all child objects.

func (*Pegboard) ContentBounds added in v0.24.0

func (this *Pegboard) ContentBounds() image.Rectangle

ContentBounds returns the bounds of the inner content of the container relative to the container's InnerBounds.

func (*Pegboard) GetBox added in v0.24.0

func (this *Pegboard) GetBox() tomo.Box

GetBox returns the underlying box.

func (*Pegboard) Insert added in v0.24.0

func (this *Pegboard) Insert(child tomo.Object, before tomo.Object)

Insert inserts a child object before a specified object. If the before object is nil or is not contained within this container, the inserted object is appended. If the inserted object is already a child of another object, it will be removed from that object first.

func (*Pegboard) Len added in v0.24.0

func (this *Pegboard) Len() int

Len returns hte amount of child objects.

func (*Pegboard) OnContentBoundsChange added in v0.24.0

func (this *Pegboard) OnContentBoundsChange(callback func()) event.Cookie

OnContentBoundsChange specifies a function to be called when the container's ContentBounds or InnerBounds changes.

func (*Pegboard) Remove added in v0.24.0

func (this *Pegboard) Remove(object tomo.Object)

Remove removes a child object, if it is a child of this container.

func (*Pegboard) ScrollTo added in v0.24.0

func (this *Pegboard) ScrollTo(position image.Point)

ScrollTo shifts the origin of the container's content to the origin of the container's InnerBounds, offset by the given point.

func (*Pegboard) SetAlign added in v0.24.0

func (this *Pegboard) SetAlign(x, y tomo.Align)

SetAlign sets the X and Y alignment of the container.

func (*Pegboard) SetLayout added in v0.24.0

func (this *Pegboard) SetLayout(layout tomo.Layout)

SetLayout sets the layout of the container.

func (*Pegboard) SetOverflow added in v0.24.0

func (this *Pegboard) SetOverflow(x, y bool)

SetOverflow sets the X and Y overflow of the container.

type Root added in v0.24.0

type Root struct {
	// contains filtered or unexported fields
}

Root is an object that can contain other objects. It is intended to be used as the root of a window in order to contain its segments.

func (*Root) Add added in v0.24.0

func (this *Root) Add(object tomo.Object)

Add appends a child object. If the object is already a child of another object, it will be removed from that object first.

func (*Root) At added in v0.24.0

func (this *Root) At(index int) tomo.Object

At returns the child object at the specified index.

func (*Root) Clear added in v0.24.0

func (this *Root) Clear()

Clear removes all child objects.

func (*Root) ContentBounds added in v0.24.0

func (this *Root) ContentBounds() image.Rectangle

ContentBounds returns the bounds of the inner content of the container relative to the container's InnerBounds.

func (*Root) GetBox added in v0.24.0

func (this *Root) GetBox() tomo.Box

GetBox returns the underlying box.

func (*Root) Insert added in v0.24.0

func (this *Root) Insert(child tomo.Object, before tomo.Object)

Insert inserts a child object before a specified object. If the before object is nil or is not contained within this container, the inserted object is appended. If the inserted object is already a child of another object, it will be removed from that object first.

func (*Root) Len added in v0.24.0

func (this *Root) Len() int

Len returns hte amount of child objects.

func (*Root) OnContentBoundsChange added in v0.24.0

func (this *Root) OnContentBoundsChange(callback func()) event.Cookie

OnContentBoundsChange specifies a function to be called when the container's ContentBounds or InnerBounds changes.

func (*Root) Remove added in v0.24.0

func (this *Root) Remove(object tomo.Object)

Remove removes a child object, if it is a child of this container.

func (*Root) ScrollTo added in v0.24.0

func (this *Root) ScrollTo(position image.Point)

ScrollTo shifts the origin of the container's content to the origin of the container's InnerBounds, offset by the given point.

func (*Root) SetAlign added in v0.24.0

func (this *Root) SetAlign(x, y tomo.Align)

SetAlign sets the X and Y alignment of the container.

func (*Root) SetLayout added in v0.24.0

func (this *Root) SetLayout(layout tomo.Layout)

SetLayout sets the layout of the container.

func (*Root) SetOverflow added in v0.24.0

func (this *Root) SetOverflow(x, y bool)

SetOverflow sets the X and Y overflow of the container.

type ScrollContainer added in v0.7.0

type ScrollContainer struct {
	// contains filtered or unexported fields
}

ScrollContainer couples a ContentBox with one or two Scrollbars.

func NewScrollContainer added in v0.7.0

func NewScrollContainer(sides ScrollSide) *ScrollContainer

NewScrollContainer creates a new scroll container.

func (*ScrollContainer) GetBox added in v0.23.0

func (this *ScrollContainer) GetBox() tomo.Box

GetBox returns the underlying box.

func (*ScrollContainer) OnValueChange added in v0.20.0

func (this *ScrollContainer) OnValueChange(callback func()) event.Cookie

OnValueChange specifies a function to be called when the user changes the position of the horizontal or vertical scrollbars.

func (*ScrollContainer) PageSize added in v0.20.0

func (this *ScrollContainer) PageSize() image.Point

PageSize returns the scroll distance of a page.

func (*ScrollContainer) SetRoot added in v0.7.0

func (this *ScrollContainer) SetRoot(root tomo.ContentObject)

SetRoot sets the root child of the ScrollContainer. There can only be one at a time, and setting it will remove and unlink the current child if there is one.

func (*ScrollContainer) SetValue added in v0.12.0

func (this *ScrollContainer) SetValue(x, y float64)

SetValue sets the horizontal and vertical scrollbar values where 0 is all the way to the left/top, and 1 is all the way to the right/bottom.

func (*ScrollContainer) StepSize added in v0.20.0

func (this *ScrollContainer) StepSize() image.Point

StepSize returns the scroll distance of a step.

func (*ScrollContainer) Value added in v0.12.0

func (this *ScrollContainer) Value() (x, y float64)

Value returns the horizontal and vertical scrollbar values where 0 is all the way to the left/top, and 1 is all the way to the right/bottom.

type ScrollSide added in v0.7.0

type ScrollSide int

ScrollSide determines which Scrollbars are active in a ScrollContainer.

const (
	ScrollVertical ScrollSide = 1 << iota
	ScrollHorizontal
	ScrollBoth = ScrollVertical | ScrollHorizontal
)

func (ScrollSide) Horizontal added in v0.7.0

func (sides ScrollSide) Horizontal() bool

Horizontal returns true if the side includes a horizontal bar.

func (ScrollSide) String added in v0.7.0

func (sides ScrollSide) String() string

String returns one of:

  • both
  • horizontal
  • vertical
  • none

func (ScrollSide) Vertical added in v0.7.0

func (sides ScrollSide) Vertical() bool

Vertical returns true if the side includes a vertical bar.

type Scrollbar added in v0.6.0

type Scrollbar struct {
	// contains filtered or unexported fields
}

Scrollbar is a special type of slider that can control the scroll of any overflowing ContainerObject.

Sub-components:

  • ScrollbarHandle is the grabbable handle of the scrollbar.

Tags:

  • [vertical] The scrollbar is oriented vertically.
  • [horizontall] The scrollbar is oriented horizontally.

ScrollbarHandle tags:

  • [vertical] The handle is oriented vertically.
  • [horizontall] The handle is oriented horizontally.

func NewHorizontalScrollbar added in v0.6.0

func NewHorizontalScrollbar() *Scrollbar

NewHorizontalScrollbar creates a new horizontal scrollbar.

func NewVerticalScrollbar added in v0.6.0

func NewVerticalScrollbar() *Scrollbar

NewVerticalScrollbar creates a new vertical scrollbar.

func (*Scrollbar) GetBox added in v0.23.0

func (this *Scrollbar) GetBox() tomo.Box

GetBox returns the underlying box.

func (this *Scrollbar) Link(box tomo.ContentObject) event.Cookie

Link assigns this scrollbar to a ContentObject. Closing the returned cookie will unlink it.

func (*Scrollbar) OnValueChange added in v0.6.0

func (this *Scrollbar) OnValueChange(callback func()) event.Cookie

OnValueChange specifies a function to be called when the user changes the position of the scrollbar.

func (*Scrollbar) PageSize added in v0.20.0

func (this *Scrollbar) PageSize() int

PageSize returns the scroll distance of a page.

func (*Scrollbar) SetValue added in v0.6.0

func (this *Scrollbar) SetValue(value float64)

SetValue sets the value of the scrollbar between 0 and 1, where 0 is scrolled all the way to the left/top, and 1 is scrolled all the way to the right/bottom.

func (*Scrollbar) StepSize added in v0.20.0

func (this *Scrollbar) StepSize() int

StepSize returns the scroll distance of a step.

func (*Scrollbar) Value added in v0.6.0

func (this *Scrollbar) Value() float64

Value returns the value of the scrollbar between 0 and 1 where 0 is scrolled all the way to the left/top, and 1 is scrolled all the way to the right/bottom.

type Segment added in v0.24.0

type Segment struct {
	// contains filtered or unexported fields
}

Segment is an object that can contain other objects, and provides a way to categorize the functionality of a window. Segments are typically laid out vertically in a window. There are several variants, the main one being the content segment. They can all be created using specialized constructors.

The following is a brief visual discription of how they are typically used, and in what order:

┌──────────────────────────┐
│ ┌──┐ ┌──┐ ┌────────────┐ ├─ command
│ │◄─│ │─►│ │/foo/bar/baz│ │
│ └──┘ └──┘ └────────────┘ │
├──────────────────────────┤
│ ┌───┐ ┌───┐ ┌───┐ ┌───┐  ├─ content
│ │   │ │   │ │   │ │   │  │
│ └───┘ └───┘ └───┘ └───┘  │
│ ┌───┐                    │
│ │   │                    │
│ └───┘                    │
├──────────────────────────┤
│ 5 items, 4KiB            ├─ status
└──────────────────────────┘
┌─────────────────┐
│ ┌───┐           │
│ │ ! │ Continue? │
│ └───┘           │
├─────────────────┤
│      ┌──┐ ┌───┐ ├────────── option
│      │No│ │Yes│ │
│      └──┘ └───┘ │
└─────────────────┘

Tags:

  • [command] The segment is a command segment.
  • [content] The segment is a content segment.
  • [status] The segment is a status segment.
  • [option] The segment is an option segment.

func NewCommandSegment added in v0.24.0

func NewCommandSegment(layout tomo.Layout, children ...tomo.Object) *Segment

NewCommandSegment creates a new segment intended to hold the window's navigational controls and command functionality. If the provided layout is nil, it will use a ContractHorizontal layout.

func NewContentSegment added in v0.24.0

func NewContentSegment(layout tomo.Layout, children ...tomo.Object) *Segment

NewContentSegment creates a new segment intended to hold the window's main content. If the provided layout is nil, it will use a ContractVertical layout.

func NewOptionSegment added in v0.24.0

func NewOptionSegment(layout tomo.Layout, children ...tomo.Object) *Segment

NewOptionSegment creates a new segment intended to hold the window's options. This is typically used for dialog boxes. If the provided layout is nil, it will use a ContractHorizontal layout. By default, it is end-aligned.

func NewStatusSegment added in v0.24.0

func NewStatusSegment(layout tomo.Layout, children ...tomo.Object) *Segment

NewStatusSegment creates a new segment intended to display the window's status. If the provided layout is nil, it will use a ContractHorizontal layout.

func (*Segment) Add added in v0.24.0

func (this *Segment) Add(object tomo.Object)

Add appends a child object. If the object is already a child of another object, it will be removed from that object first.

func (*Segment) At added in v0.24.0

func (this *Segment) At(index int) tomo.Object

At returns the child object at the specified index.

func (*Segment) Clear added in v0.24.0

func (this *Segment) Clear()

Clear removes all child objects.

func (*Segment) ContentBounds added in v0.24.0

func (this *Segment) ContentBounds() image.Rectangle

ContentBounds returns the bounds of the inner content of the container relative to the container's InnerBounds.

func (*Segment) GetBox added in v0.24.0

func (this *Segment) GetBox() tomo.Box

GetBox returns the underlying box.

func (*Segment) Insert added in v0.24.0

func (this *Segment) Insert(child tomo.Object, before tomo.Object)

Insert inserts a child object before a specified object. If the before object is nil or is not contained within this container, the inserted object is appended. If the inserted object is already a child of another object, it will be removed from that object first.

func (*Segment) Len added in v0.24.0

func (this *Segment) Len() int

Len returns hte amount of child objects.

func (*Segment) OnContentBoundsChange added in v0.24.0

func (this *Segment) OnContentBoundsChange(callback func()) event.Cookie

OnContentBoundsChange specifies a function to be called when the container's ContentBounds or InnerBounds changes.

func (*Segment) Remove added in v0.24.0

func (this *Segment) Remove(object tomo.Object)

Remove removes a child object, if it is a child of this container.

func (*Segment) ScrollTo added in v0.24.0

func (this *Segment) ScrollTo(position image.Point)

ScrollTo shifts the origin of the container's content to the origin of the container's InnerBounds, offset by the given point.

func (*Segment) SetAlign added in v0.24.0

func (this *Segment) SetAlign(x, y tomo.Align)

SetAlign sets the X and Y alignment of the container.

func (*Segment) SetLayout added in v0.24.0

func (this *Segment) SetLayout(layout tomo.Layout)

SetLayout sets the layout of the container.

func (*Segment) SetOverflow added in v0.24.0

func (this *Segment) SetOverflow(x, y bool)

SetOverflow sets the X and Y overflow of the container.

type Separator

type Separator struct {
	// contains filtered or unexported fields
}

Separator is a line for visually separating elements.

func NewSeparator

func NewSeparator() *Separator

NewSeparator creates a new separator line.

func (*Separator) GetBox added in v0.23.0

func (this *Separator) GetBox() tomo.Box

GetBox returns the underlying box.

type Slider

type Slider struct {
	// contains filtered or unexported fields
}

Slider is a control that selects a numeric value between 0 and 1.

Sub-components:

  • SliderHandle is the grabbable handle of the slider.

Tags:

  • [vertical] The slider is oriented vertically.
  • [horizontall] The slider is oriented horizontally.

SliderHandle tags:

  • [vertical] The handle is oriented vertically.
  • [horizontall] The handle is oriented horizontally.

func NewHorizontalSlider

func NewHorizontalSlider(value float64) *Slider

NewHorizontalSlider creates a new horizontal slider with the specified value.

func NewVerticalSlider

func NewVerticalSlider(value float64) *Slider

NewVerticalSlider creates a new vertical slider with the specified value.

func (*Slider) GetBox added in v0.23.0

func (this *Slider) GetBox() tomo.Box

GetBox returns the underlying box.

func (*Slider) OnConfirm added in v0.20.0

func (this *Slider) OnConfirm(callback func()) event.Cookie

OnConfirm specifies a function to be called when the user stops moving the slider.

func (*Slider) OnValueChange

func (this *Slider) OnValueChange(callback func()) event.Cookie

OnValueChange specifies a function to be called when the user moves the slider.

func (*Slider) SetFocused added in v0.23.0

func (this *Slider) SetFocused(focused bool)

SetFocused sets whether or not this slider has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (*Slider) SetValue

func (this *Slider) SetValue(value float64)

SetValue sets the value of the slider between 0 and 1.

func (*Slider) Value

func (this *Slider) Value() float64

Value returns the value of the slider between 0 and 1.

type Swatch added in v0.20.0

type Swatch struct {
	// contains filtered or unexported fields
}

Swatch displays a color, allowing the user to edit it by clicking on it.

func NewSwatch added in v0.20.0

func NewSwatch(value color.Color) *Swatch

NewSwatch creates a new swatch with the given color.

func (*Swatch) Choose added in v0.20.0

func (this *Swatch) Choose()

Choose creates a modal that allows the user to edit the color of the swatch.

func (*Swatch) Draw added in v0.20.0

func (this *Swatch) Draw(can canvas.Canvas)

func (*Swatch) GetBox added in v0.23.0

func (this *Swatch) GetBox() tomo.Box

GetBox returns the underlying box.

func (*Swatch) OnConfirm added in v0.20.0

func (this *Swatch) OnConfirm(callback func()) event.Cookie

OnConfirm specifies a function to be called when the user selects "OK" in the color picker.

func (*Swatch) OnValueChange added in v0.20.0

func (this *Swatch) OnValueChange(callback func()) event.Cookie

OnValueChange specifies a function to be called when the swatch's color is changed by the user.

func (*Swatch) RGBA added in v0.20.0

func (this *Swatch) RGBA() (r, g, b, a uint32)

RGBA satisfies the color.Color interface

func (*Swatch) SetFocused added in v0.23.0

func (this *Swatch) SetFocused(focused bool)

SetFocused sets whether or not this swatch has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (*Swatch) SetValue added in v0.20.0

func (this *Swatch) SetValue(value color.Color)

SetValue sets the color of the swatch.

func (*Swatch) Value added in v0.20.0

func (this *Swatch) Value() color.Color

Value returns the color of the swatch.

type TextInput

type TextInput struct {
	// contains filtered or unexported fields
}

TextInput is a single-line editable text box.

func NewMultilineTextInput added in v0.23.0

func NewMultilineTextInput(text string) *TextInput

NewMultilineTextInput creates a new multiline text input containing the specified text.

func NewTextInput

func NewTextInput(text string) *TextInput

NewTextInput creates a new text input containing the specified text.

func (*TextInput) ContentBounds added in v0.23.0

func (this *TextInput) ContentBounds() image.Rectangle

ContentBounds returns the bounds of the inner content of the text input relative to the input's InnerBounds.

func (*TextInput) Dot added in v0.23.0

func (this *TextInput) Dot() text.Dot

Dot returns the text cursor or selection.

func (*TextInput) GetBox added in v0.23.0

func (this *TextInput) GetBox() tomo.Box

GetBox returns the underlying box.

func (*TextInput) OnConfirm added in v0.20.0

func (this *TextInput) OnConfirm(callback func()) event.Cookie

OnConfirm specifies a function to be called when the user presses enter within the text input.

func (*TextInput) OnContentBoundsChange added in v0.23.0

func (this *TextInput) OnContentBoundsChange(callback func()) event.Cookie

OnContentBoundsChange specifies a function to be called when the text input's ContentBounds or InnerBounds changes.

func (*TextInput) OnDotChange added in v0.23.0

func (this *TextInput) OnDotChange(callback func()) event.Cookie

OnDotChange specifies a function to be called when the text cursor or selection changes.

func (*TextInput) OnValueChange added in v0.20.0

func (this *TextInput) OnValueChange(callback func()) event.Cookie

OnValueChange specifies a function to be called when the user edits the input text.

func (*TextInput) Redo added in v0.24.0

func (this *TextInput) Redo()

Redo redoes the last previously undone action.

func (*TextInput) ScrollTo added in v0.23.0

func (this *TextInput) ScrollTo(position image.Point)

ScrollTo shifts the origin of the text input's content to the origin of the inputs's InnerBounds, offset by the given point.

func (*TextInput) Select added in v0.23.0

func (this *TextInput) Select(dot text.Dot)

Select sets the text cursor or selection.

func (*TextInput) SetAlign added in v0.23.0

func (this *TextInput) SetAlign(x, y tomo.Align)

SetAlign sets the X and Y alignment of the text input.

func (*TextInput) SetFocused added in v0.23.0

func (this *TextInput) SetFocused(focused bool)

SetFocused sets whether or not this text input has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (*TextInput) SetValue added in v0.22.0

func (this *TextInput) SetValue(text string)

SetValue sets the text content of the input.

func (*TextInput) Type added in v0.14.0

func (this *TextInput) Type(char rune)

Type types a character at the current dot position.

func (*TextInput) Undo added in v0.24.0

func (this *TextInput) Undo()

Undo undoes the last action.

func (*TextInput) Value added in v0.22.0

func (this *TextInput) Value() string

Value returns the text content of the input.

type TextView added in v0.7.0

type TextView struct {
	// contains filtered or unexported fields
}

TextView is an area for displaying a large amount of multi-line text.

func NewTextView added in v0.7.0

func NewTextView(text string) *TextView

NewTextView creates a new text view.

func (*TextView) ContentBounds added in v0.23.0

func (this *TextView) ContentBounds() image.Rectangle

ContentBounds returns the bounds of the inner content of the text view relative to the text view's InnerBounds.

func (*TextView) Dot added in v0.23.0

func (this *TextView) Dot() text.Dot

Dot returns the text cursor or selection.

func (*TextView) GetBox added in v0.23.0

func (this *TextView) GetBox() tomo.Box

GetBox returns the underlying box.

func (*TextView) OnContentBoundsChange added in v0.23.0

func (this *TextView) OnContentBoundsChange(callback func()) event.Cookie

OnContentBoundsChange specifies a function to be called when the text view's ContentBounds or InnerBounds changes.

func (*TextView) OnDotChange added in v0.23.0

func (this *TextView) OnDotChange(callback func()) event.Cookie

OnDotChange specifies a function to be called when the text cursor or selection changes.

func (*TextView) ScrollTo added in v0.23.0

func (this *TextView) ScrollTo(position image.Point)

ScrollTo shifts the origin of the text view's content to the origin of the text view's InnerBounds, offset by the given point.

func (*TextView) Select added in v0.23.0

func (this *TextView) Select(dot text.Dot)

Select sets the text cursor or selection.

func (*TextView) SetAlign added in v0.23.0

func (this *TextView) SetAlign(x, y tomo.Align)

SetAlign sets the X and Y alignment of the text view.

func (*TextView) SetFocused added in v0.23.0

func (this *TextView) SetFocused(focused bool)

SetFocused sets whether or not this text view has keyboard focus. If set to true, this method will steal focus away from whichever object currently has focus.

func (*TextView) SetText added in v0.23.0

func (this *TextView) SetText(text string)

SetText sets the text content of the view.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL