Documentation ¶
Index ¶
- func PaintSolidColor[T pixel.Color](s *Screen[T], color T, x, y, width, height int)
- type Displayer
- type Event
- type EventBox
- type Image
- type ListBox
- func (box *ListBox[T]) HandleEvent(event Event, x, y int)
- func (box *ListBox[T]) Layout(width, height int)
- func (box *ListBox[T]) Len() int
- func (box *ListBox[T]) MarkUpdated()
- func (box *ListBox[T]) MinSize() (width, height int)
- func (box *ListBox[T]) RequestUpdate()
- func (box *ListBox[T]) Select(index int)
- func (box *ListBox[T]) Selected() int
- func (box *ListBox[T]) SetAlign(align TextAlign)
- func (box *ListBox[T]) SetColumns(columns int)
- func (box *ListBox[T]) SetEventHandler(eventHandler func(event Event, index int))
- func (box *ListBox[T]) SetPadding(horizontal, vertical int)
- func (box *ListBox[T]) Update(screen *Screen[T], displayX, displayY, displayWidth, displayHeight, x, y int)
- type Object
- type Rect
- func (r *Rect[T]) Background() T
- func (r *Rect[T]) HandleEvent(event Event, x, y int)
- func (r *Rect[T]) MarkUpdated()
- func (r *Rect[T]) NeedsLayout() (needsLayout bool)
- func (r *Rect[T]) NeedsUpdate() (this, child bool)
- func (r *Rect[T]) Parent() Object[T]
- func (r *Rect[T]) RequestLayout()
- func (r *Rect[T]) RequestUpdate()
- func (r *Rect[T]) ScrollIntoViewVertical(top, bottom int, child Object[T])
- func (r *Rect[T]) SetGrowable(horizontal, vertical int)
- func (r *Rect[T]) SetParent(parent Object[T])
- type Screen
- func (s *Screen[T]) Buffer() pixel.Image[T]
- func (s *Screen[T]) Layout()
- func (s *Screen[T]) Send(x, y int, buffer pixel.Image[T])
- func (s *Screen[T]) SetChild(child Object[T])
- func (s *Screen[T]) SetTouchState(x, y int16)
- func (s *Screen[T]) Size() (width, height int)
- func (s *Screen[T]) Update() error
- type ScrollBox
- func (b *ScrollBox[T]) HandleEvent(event Event, x, y int)
- func (b *ScrollBox[T]) Layout(width, height int)
- func (b *ScrollBox[T]) MarkUpdated()
- func (b *ScrollBox[T]) MinSize() (width, height int)
- func (b *ScrollBox[T]) RequestUpdate()
- func (b *ScrollBox[T]) ScrollIntoViewVertical(top, bottom int, child Object[T])
- func (b *ScrollBox[T]) SetGrowable(horizontal, vertical int)
- func (b *ScrollBox[T]) Update(screen *Screen[T], displayX, displayY, displayWidth, displayHeight, x, y int)
- type ScrollableDisplay
- type Text
- func (t *Text[T]) Layout(width, height int)
- func (t *Text[T]) MinSize() (width, height int)
- func (t *Text[T]) SetAlign(align TextAlign)
- func (t *Text[T]) SetBackground(background T)
- func (t *Text[T]) SetColor(color T)
- func (t *Text[T]) SetPadding(horizontal, vertical int)
- func (t *Text[T]) SetText(text string)
- func (t *Text[T]) Update(screen *Screen[T], displayX, displayY, displayWidth, displayHeight, x, y int)
- type TextAlign
- type VBox
- func (b *VBox[T]) HandleEvent(event Event, x, y int)
- func (b *VBox[T]) Layout(width, height int)
- func (b *VBox[T]) MarkUpdated()
- func (b *VBox[T]) MinSize() (width, height int)
- func (b *VBox[T]) RequestUpdate()
- func (b *VBox[T]) Update(screen *Screen[T], displayX, displayY, displayWidth, displayHeight, x, y int)
- type VerticalScrollBox
- func (b *VerticalScrollBox[T]) HandleEvent(event Event, x, y int)
- func (b *VerticalScrollBox[T]) Layout(width, height int)
- func (b *VerticalScrollBox[T]) MarkUpdated()
- func (b *VerticalScrollBox[T]) MinSize() (width, height int)
- func (b *VerticalScrollBox[T]) RequestUpdate()
- func (b *VerticalScrollBox[T]) ScrollIntoViewVertical(top, bottom int, child Object[T])
- func (b *VerticalScrollBox[T]) SetGrowable(horizontal, vertical int)
- func (b *VerticalScrollBox[T]) Update(screen *Screen[T], displayX, displayY, displayWidth, displayHeight, x, y int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Displayer ¶
type Displayer[T pixel.Color] interface { Size() (int16, int16) DrawBitmap(x, y int16, bitmap pixel.Image[T]) error Display() error Rotation() drivers.Rotation }
The Displayer that is drawn to.
type EventBox ¶
EventBox wraps an object and handles events for it.
func NewEventBox ¶
Create a new wrapper container that handles events.
func (*EventBox[T]) HandleEvent ¶
func (*EventBox[T]) SetEventHandler ¶
SetEventHandler sets the event callback for this object.
type Image ¶
func NewImage ¶
NewImage creates a new image object that will display the given image. By default, the image is centered in the available space, with a black background.
func (*Image[T]) SetBackground ¶
func (obj *Image[T]) SetBackground(color T)
SetBackground sets the background color for the image.
type ListBox ¶
A scrollable list of strings, of which one is currently selected.
func NewListBox ¶
func NewListBox[T pixel.Color](font font.Font, foreground, background, tint T, elements []string) *ListBox[T]
Create a new listbox with the given elements. The elements (and number of elements) cannot be changed after creation.
func (*ListBox[T]) HandleEvent ¶
HandleEvent handles events such as touch events and calls the event handler with the given child as a parameter.
func (*ListBox[T]) MarkUpdated ¶
func (box *ListBox[T]) MarkUpdated()
func (*ListBox[T]) MinSize ¶
MinSize returns the height of all the list items combined. The minimal width is always zero (it is expected to set to expand).
func (*ListBox[T]) RequestUpdate ¶
func (box *ListBox[T]) RequestUpdate()
RequestUpdate will request an update for this object and all of its children.
func (*ListBox[T]) Selected ¶
Selected returns the index of the currently selected element, or -1 if no element is selected.
func (*ListBox[T]) SetColumns ¶
SetColumns splits the view into multiple columns, so that elements can also display horizontally.
func (*ListBox[T]) SetEventHandler ¶
SetEventHandler sets the callback when one of the elements in the list gets selected.
func (*ListBox[T]) SetPadding ¶
Set padding for each text child.
type Object ¶
type Object[T pixel.Color] interface { // Request an update to this object (that doesn't change the layout). RequestUpdate() // Request a re-layout of this object. RequestLayout() // Layout the object in the provided area. The object will take up all the // given area (if needed, by filling in the rest with its background color). Layout(width, height int) // Update the screen if needed. It recurses into children, if the object has // any. It does not change any state: this is done separately in // MarkUpdated. // The displayX, displayY, displayWidth, and displayHeight parameters are // the area of the display that needs to be updated. The width and height // must never be zero. // The x and y parameter are the offset from the start of the object, which // can be zero or positive. They can be positive when the parent is a scroll // container, for example. Update(screen *Screen[T], displayX, displayY, displayWidth, displayHeight, x, y int) // MarkUpdated clears any 'needs update' flags that may be present on this // object, including its children if any. MarkUpdated() // Handle some event (usually, touch events). HandleEvent(event Event, x, y int) // Called when adding a child to a parent. Should only ever be called during // the construction of a container object. SetParent(object Object[T]) // Minimal width and height of an object. MinSize() (width, height int) // SetGrowable sets the grow factor in the horizontal and vertical // direction. SetGrowable(horizontal, vertical int) // If possible, scroll the parent (or parent-of-parent, recursively) scroll // container so that the given area moves into view. The top line is the // topmost pixel that should become visible, while the bottom offset is one // pixel past the area that should become visible (so that bottom-top is the // height of the area to make visible). ScrollIntoViewVertical(top, bottom int, object Object[T]) // contains filtered or unexported methods }
type Rect ¶
func MakeRect ¶
MakeRect returns a new initialized Rect object. This is mostly useful to initialize an embedded Rect struct in a custom object.
func (*Rect[T]) Background ¶
func (r *Rect[T]) Background() T
Background returns the current background for this object.
func (*Rect[T]) HandleEvent ¶
HandleEvent handles input events like touch taps.
func (*Rect[T]) MarkUpdated ¶
func (r *Rect[T]) MarkUpdated()
MarkUpdated clears the 'update' flags for this object.
func (*Rect[T]) NeedsLayout ¶
NeedsLayout returns whether this object needs to be re-layout, and clears the layout flag at the same time.
func (*Rect[T]) NeedsUpdate ¶
NeedsUpdate returns whether this object and/or a child object needs an update, and clears the update flag at the same time.
func (*Rect[T]) RequestLayout ¶
func (r *Rect[T]) RequestLayout()
func (*Rect[T]) RequestUpdate ¶
func (r *Rect[T]) RequestUpdate()
func (*Rect[T]) ScrollIntoViewVertical ¶
func (*Rect[T]) SetGrowable ¶
SetGrowable sets the grow factor in the horizontal and vertical direction. This means, for example, if one object has a factor of 1 and another of 2, the first object will get ⅓ and the second object will get ⅔ of the remaining space in the container after the minimal space has been given to all children.
type Screen ¶
func NewScreen ¶
NewScreen creates a new screen to fill the whole display. The buffer needs to be big enough to fill at least horizontal row of pixels, but should preferably be bigger (10% of the screen for example). The ppi parameter is the number of pixels per inch, which is important for touch events.
func (*Screen[T]) Buffer ¶
Buffer returns the pixel buffer used for sending data to the screen. It can be used inside an Update call.
func (*Screen[T]) Layout ¶
func (s *Screen[T]) Layout()
Layout determines the size for all objects in the screen. This is called from Update() so it normally doesn't need to be called manually, but it can sometimes be helpful to know the size of objects before doing further initialization, for example when drawing on a canvas.
func (*Screen[T]) Send ¶
Send an image buffer to the given coordinates.
This function is used internally, and should only be used to implement custom widgets.
func (*Screen[T]) SetChild ¶
SetChild sets the root child. This will typically be a container of some sort.
func (*Screen[T]) SetTouchState ¶
Set the position of the current touch point, or (-1, -1) if nothing currently touching the screen.
TODO: handle multitouch. This will require an API change. In other words, this API is going to change at some point in the future.
type ScrollBox ¶
ScrollBox is a scrollable wrapper of an object. It is growable and reports a minimal size of (0, 0) to the parent, so that it will take up the remaining space in the parent box.
func NewScrollBox ¶
NewScrollBox returns an initialized scroll box with the given child. If you want to scroll multiple children (vertically, for example), you can use a VBox instead.
func (*ScrollBox[T]) HandleEvent ¶
func (*ScrollBox[T]) MarkUpdated ¶
func (b *ScrollBox[T]) MarkUpdated()
func (*ScrollBox[T]) RequestUpdate ¶
func (b *ScrollBox[T]) RequestUpdate()
func (*ScrollBox[T]) ScrollIntoViewVertical ¶
func (*ScrollBox[T]) SetGrowable ¶
type ScrollableDisplay ¶
type ScrollableDisplay[T pixel.Color] interface { Displayer[T] SetScrollArea(topFixedArea, bottomFixedArea int16) SetScroll(line int16) StopScroll() }
ScrollableDisplay is a display that supports hardware scrolling. A display doesn't have to support it, but if it does, scrolling can become a lot more smooth.
type Text ¶
func MakeText ¶
MakeText returns a new initialized Rect object. This is mostly useful to initialize an embedded Text struct in a custom object. If you want a standalone text object, use NewText.
func (*Text[T]) SetBackground ¶
func (t *Text[T]) SetBackground(background T)
SetBackground changes the background color of the text.
func (*Text[T]) SetPadding ¶
Set horizontal and vertical padding in screen pixels. The padding must be a positive integer that is less than 128.
type VBox ¶
func (*VBox[T]) HandleEvent ¶
HandleEvent propagates an event to its children.
func (*VBox[T]) MarkUpdated ¶
func (b *VBox[T]) MarkUpdated()
func (*VBox[T]) MinSize ¶
MinSize returns the minimal size to fit around all the elements in this container.
func (*VBox[T]) RequestUpdate ¶
func (b *VBox[T]) RequestUpdate()
RequestUpdate will request an update for this object and all of its children.
type VerticalScrollBox ¶
VerticalScrollBox is a scrollable wrapper of an object that will use hardware acceleration when available. It is growable and reports a minimal size of (0, 0) to the parent, so that it will take up the remaining space in the parent box.
func NewVerticalScrollBox ¶
func NewVerticalScrollBox[T pixel.Color](top, child, bottom Object[T]) *VerticalScrollBox[T]
NewVerticalScrollBox returns an initialized scroll box with the given child. If you want to scroll multiple children (vertically, for example), you can use a VBox to wrap these children.
func (*VerticalScrollBox[T]) HandleEvent ¶
func (b *VerticalScrollBox[T]) HandleEvent(event Event, x, y int)
func (*VerticalScrollBox[T]) Layout ¶
func (b *VerticalScrollBox[T]) Layout(width, height int)
func (*VerticalScrollBox[T]) MarkUpdated ¶
func (b *VerticalScrollBox[T]) MarkUpdated()
func (*VerticalScrollBox[T]) MinSize ¶
func (b *VerticalScrollBox[T]) MinSize() (width, height int)
func (*VerticalScrollBox[T]) RequestUpdate ¶
func (b *VerticalScrollBox[T]) RequestUpdate()
func (*VerticalScrollBox[T]) ScrollIntoViewVertical ¶
func (b *VerticalScrollBox[T]) ScrollIntoViewVertical(top, bottom int, child Object[T])
func (*VerticalScrollBox[T]) SetGrowable ¶
func (b *VerticalScrollBox[T]) SetGrowable(horizontal, vertical int)
func (*VerticalScrollBox[T]) Update ¶
func (b *VerticalScrollBox[T]) Update(screen *Screen[T], displayX, displayY, displayWidth, displayHeight, x, y int)