widget

package
v5.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SheetDockableKind    = "sheet"
	TemplateDockableKind = "template"
	ListDockableKind     = "list"
)

Known dockable kinds

View Source
const DefaultMarkdownWidth = 8 * 100

DefaultMarkdownWidth is the default maximum width to use, roughly equivalent to a page at 100dpi.

Variables

This section is empty.

Functions

func AddHelpToInfoPop added in v5.3.0

func AddHelpToInfoPop(target unison.Paneler, text string)

AddHelpToInfoPop adds one or more lines of help text to an InfoPop.

func AddKeyBindingInfoToInfoPop added in v5.3.0

func AddKeyBindingInfoToInfoPop(target unison.Paneler, keyBinding unison.KeyBinding, text string)

AddKeyBindingInfoToInfoPop adds information about a key binding to an InfoPop.

func AddScalingHelpToInfoPop added in v5.3.0

func AddScalingHelpToInfoPop(target unison.Paneler)

AddScalingHelpToInfoPop adds the help info about scaling to an InfoPop.

func ClearInfoPop added in v5.3.0

func ClearInfoPop(target unison.Paneler)

ClearInfoPop clears the InfoPop data.

func DeepSync

func DeepSync(panel unison.Paneler)

DeepSync does a depth-first traversal of the panel and all of its descendents and calls Sync() on any Syncer objects it finds.

func FocusFirstContent

func FocusFirstContent(toolbar, content unison.Paneler)

FocusFirstContent attempts to focus the first non-button widget in the content. Failing that, tries to focus the first focusable widget in the content. Failing that, tries to focus the first focusable widget in the toolbar.

func MarkForLayoutWithinDockable

func MarkForLayoutWithinDockable(panel unison.Paneler)

MarkForLayoutWithinDockable sets the NeedsLayout flag on the provided panel and all of its parents up to the first Dockable.

func MarkModified

func MarkModified(panel unison.Paneler)

MarkModified looks for a ModifiableRoot, starting at the panel. If found, it then called MarkModified() on it.

func NewDefaultInfoPop added in v5.3.0

func NewDefaultInfoPop() *unison.Button

NewDefaultInfoPop creates a new InfoPop with the message about mouse wheel scaling.

func NewFieldInteriorLeadingLabel

func NewFieldInteriorLeadingLabel(text string) *unison.Label

NewFieldInteriorLeadingLabel creates a new label appropriate for the label in the interior of a row before a field.

func NewFieldLeadingLabel

func NewFieldLeadingLabel(text string) *unison.Label

NewFieldLeadingLabel creates a new label appropriate for the first label in a row before a field.

func NewFieldTrailingLabel

func NewFieldTrailingLabel(text string) *unison.Label

NewFieldTrailingLabel creates a new label appropriate for after a field.

func NewInfoPop added in v5.3.0

func NewInfoPop() *unison.Button

NewInfoPop creates a new InfoPop.

func NewInteriorSeparator added in v5.3.0

func NewInteriorSeparator() *unison.Separator

NewInteriorSeparator creates a new interior vertical separator.

func NewPageHeader

func NewPageHeader(title string, hSpan int) *unison.Label

NewPageHeader creates a new center-aligned header for a sheet page.

func NewPageInternalHeader

func NewPageInternalHeader(title string, span int) unison.Paneler

NewPageInternalHeader creates a new center-aligned internal header for a sheet page.

func NewPageLabel

func NewPageLabel(title string) *unison.Label

NewPageLabel creates a new start-aligned field label for a sheet page.

func NewPageLabelCenter

func NewPageLabelCenter(title string) *unison.Label

NewPageLabelCenter creates a new center-aligned field label for a sheet page.

func NewPageLabelEnd

func NewPageLabelEnd(title string) *unison.Label

NewPageLabelEnd creates a new end-aligned field label for a sheet page.

func NewPageLabelWithRandomizer

func NewPageLabelWithRandomizer(title, tooltip string, clickCallback func()) *unison.Panel

NewPageLabelWithRandomizer creates a new end-aligned field label for a sheet page that includes a randomization button.

func NewSearchField

func NewSearchField() *unison.Field

NewSearchField creates a new search widget.

func NewToolbarSeparator

func NewToolbarSeparator() *unison.Separator

NewToolbarSeparator creates a new vertical separator for the toolbar.

func SetCheckBoxState

func SetCheckBoxState(checkbox *CheckBox, checked bool)

SetCheckBoxState sets the checkbox state based on the value of checked.

func SetFieldValue

func SetFieldValue(field *unison.Field, value string)

SetFieldValue sets the value of this field, marking the field and all of its parents as needing to be laid out again if the value is not what is currently in the field.

func WrapWithSpan

func WrapWithSpan(span int, children ...unison.Paneler) *unison.Panel

WrapWithSpan wraps a number of children with a single panel that request to fill in span number of columns.

Types

type CheckBox

type CheckBox struct {
	*unison.CheckBox
	// contains filtered or unexported fields
}

CheckBox provides a checkbox that works with undo.

func NewCheckBox

func NewCheckBox(targetMgr *TargetMgr, targetKey, title string, get func() unison.CheckState, set func(unison.CheckState)) *CheckBox

NewCheckBox creates a new check box.

func (*CheckBox) Sync

func (c *CheckBox) Sync()

Sync the checkbox to the current value.

type DecimalField

type DecimalField = NumericField[fxp.Int]

DecimalField is field that holds a decimal (fixed-point) number.

func NewDecimalField

func NewDecimalField(targetMgr *TargetMgr, targetKey, undoTitle string, get func() fxp.Int, set func(fxp.Int), min, max fxp.Int, forceSign, noMinWidth bool) *DecimalField

NewDecimalField creates a new field that holds a fixed-point number.

func NewDecimalPageField

func NewDecimalPageField(targetMgr *TargetMgr, targetKey, undoTitle string, get func() fxp.Int, set func(fxp.Int), min, max fxp.Int, noMinWidth bool) *DecimalField

NewDecimalPageField creates a new numeric text entry field for a sheet page.

type DockableKind

type DockableKind interface {
	DockableKind() string
}

DockableKind defines the method required DockableKinds.

type DragHandle

type DragHandle struct {
	unison.Panel
	// contains filtered or unexported fields
}

DragHandle provides a simple draggable handle.

func NewDragHandle

func NewDragHandle(data map[string]any) *DragHandle

NewDragHandle creates a new draggable handle widget.

type DrawableSVGPair

type DrawableSVGPair struct {
	Left  *unison.SVG
	Right *unison.SVG
	Size  unison.Size
}

DrawableSVGPair draws two SVG's side-by-side.

func (*DrawableSVGPair) DrawInRect

func (s *DrawableSVGPair) DrawInRect(canvas *unison.Canvas, rect unison.Rect, _ *unison.SamplingOptions, paint *unison.Paint)

DrawInRect implements the Drawable interface.

func (*DrawableSVGPair) LogicalSize

func (s *DrawableSVGPair) LogicalSize() unison.Size

LogicalSize implements the Drawable interface.

type EntityPanel

type EntityPanel interface {
	unison.Paneler
	Entity() *gurps.Entity
}

EntityPanel defines methods for a panel that can hold an entity.

type FocusRef

type FocusRef struct {
	Key        string
	SelStart   int
	SelEnd     int
	Selectable bool
}

FocusRef holds a focus reference.

type GroupedCloser

type GroupedCloser interface {
	unison.TabCloser
	CloseWithGroup(other unison.Paneler) bool
}

GroupedCloser defines the methods required of a tab that wishes to be closed when another tab is closed.

type IntegerField

type IntegerField = NumericField[int]

IntegerField is field that holds an integer.

func NewIntegerField

func NewIntegerField(targetMgr *TargetMgr, targetKey, undoTitle string, get func() int, set func(int), min, max int, forceSign, noMinWidth bool) *IntegerField

NewIntegerField creates a new field that holds an int.

func NewIntegerPageField

func NewIntegerPageField(targetMgr *TargetMgr, targetKey, undoTitle string, get func() int, set func(int), min, max int, showSign bool) *IntegerField

NewIntegerPageField creates a new integer entry field for a sheet page.

type LengthField

type LengthField = NumericField[measure.Length]

LengthField is field that holds a length value.

func NewHeightPageField

func NewHeightPageField(targetMgr *TargetMgr, targetKey, undoTitle string, entity *gurps.Entity, get func() measure.Length, set func(measure.Length), min, max measure.Length, noMinWidth bool) *LengthField

NewHeightPageField creates a new height entry field for a sheet page.

func NewLengthField

func NewLengthField(targetMgr *TargetMgr, targetKey, undoTitle string, entity *gurps.Entity, get func() measure.Length, set func(measure.Length), min, max measure.Length, noMinWidth bool) *LengthField

NewLengthField creates a new field that holds a fixed-point number.

type Markdown

type Markdown struct {
	unison.Panel
	// contains filtered or unexported fields
}

Markdown provides a simple markdown display widget. It is currently *very* limited in what it can display.

func NewMarkdown

func NewMarkdown() *Markdown

NewMarkdown creates a new markdown widget.

func (*Markdown) SetContent

func (m *Markdown) SetContent(content string, maxWidth int)

SetContent replaces the current markdown content.

type ModifiableRoot

type ModifiableRoot interface {
	MarkModified(src unison.Paneler)
}

ModifiableRoot marks the root of a modifable tree of components, typically a Dockable.

type NonEditableField

type NonEditableField struct {
	*unison.Label
	// contains filtered or unexported fields
}

NonEditableField holds the data for a non-editable field.

func NewNonEditableField

func NewNonEditableField(syncer func(*NonEditableField)) *NonEditableField

NewNonEditableField creates a new start-aligned non-editable field that uses the same font and size as the field.

func NewNonEditableFieldCenter

func NewNonEditableFieldCenter(syncer func(*NonEditableField)) *NonEditableField

NewNonEditableFieldCenter creates a new center-aligned non-editable field that uses the same font and size as the field.

func NewNonEditableFieldEnd

func NewNonEditableFieldEnd(syncer func(*NonEditableField)) *NonEditableField

NewNonEditableFieldEnd creates a new end-aligned non-editable field that uses the same font and size as the field.

func (*NonEditableField) Sync

func (f *NonEditableField) Sync()

Sync the field to the current value.

type NonEditablePageField

type NonEditablePageField struct {
	*unison.Label
	// contains filtered or unexported fields
}

NonEditablePageField holds the data for a non-editable page field.

func NewNonEditablePageField

func NewNonEditablePageField(syncer func(*NonEditablePageField)) *NonEditablePageField

NewNonEditablePageField creates a new start-aligned non-editable field that uses the same font and size as the page field.

func NewNonEditablePageFieldCenter

func NewNonEditablePageFieldCenter(syncer func(*NonEditablePageField)) *NonEditablePageField

NewNonEditablePageFieldCenter creates a new center-aligned non-editable field that uses the same font and size as the page field.

func NewNonEditablePageFieldEnd

func NewNonEditablePageFieldEnd(syncer func(*NonEditablePageField)) *NonEditablePageField

NewNonEditablePageFieldEnd creates a new end-aligned non-editable field that uses the same font and size as the page field.

func (*NonEditablePageField) Sync

func (f *NonEditablePageField) Sync()

Sync the field to the current value.

type NumericField

type NumericField[T xmath.Numeric] struct {
	*unison.Field

	Format func(T) string
	// contains filtered or unexported fields
}

NumericField holds a numeric value that can be edited.

func NewNumericField

func NewNumericField[T xmath.Numeric](targetMgr *TargetMgr, targetKey, undoTitle string, getPrototypes func(min, max T) []T, get func() T, set func(T), format func(T) string, extract func(s string) (T, error), min, max T) *NumericField[T]

NewNumericField creates a new field that formats its content.

func (*NumericField[T]) Max

func (f *NumericField[T]) Max() T

Max returns the maximum value allowed.

func (*NumericField[T]) Min

func (f *NumericField[T]) Min() T

Min returns the minimum value allowed.

func (*NumericField[T]) SetMarksModified

func (f *NumericField[T]) SetMarksModified(marksModified bool)

SetMarksModified sets whether this field will attempt to mark its ModifiableRoot as modified. Default is true.

func (*NumericField[T]) SetMinMax

func (f *NumericField[T]) SetMinMax(min, max T)

SetMinMax sets the minimum and maximum values and then adjusts the minimum text width, if a prototype function has been set.

func (*NumericField[T]) Sync

func (f *NumericField[T]) Sync()

Sync the field to the current value.

type PercentageField

type PercentageField = NumericField[int]

PercentageField is field that holds a percentage.

func NewPercentageField

func NewPercentageField(targetMgr *TargetMgr, targetKey, undoTitle string, get func() int, set func(int), min, max int, forceSign, noMinWidth bool) *PercentageField

NewPercentageField creates a new field that holds a percentage.

func NewScaleField added in v5.3.0

func NewScaleField(min, max int, def, get func() int, set func(int), scroller *unison.ScrollPanel, afterApply func(), attemptCenter bool) *PercentageField

NewScaleField creates a new scale field and hooks it into the target.

type Popup[T comparable] struct {
	*unison.PopupMenu[T]
	// contains filtered or unexported fields
}

Popup provides a popup menu that works with undo.

func NewPopup

func NewPopup[T comparable](targetMgr *TargetMgr, targetKey, undoTitle string, get func() T, set func(T), items ...T) *Popup[T]

NewPopup creates a new popup menu.

func (*Popup[T]) Sync

func (p *Popup[T]) Sync()

Sync the popup to the current value.

type Rebuildable

type Rebuildable interface {
	unison.Paneler
	fmt.Stringer
	Rebuild(full bool)
}

Rebuildable defines the methods a rebuildable panel should provide.

type Selectable

type Selectable interface {
	Selection() (start, end int)
	SetSelection(start, end int)
}

Selectable panels can have their selection queried and set.

type StringField

type StringField struct {
	*unison.Field
	// contains filtered or unexported fields
}

StringField holds the value for a string field.

func NewMultiLineStringField

func NewMultiLineStringField(targetMgr *TargetMgr, targetKey, undoTitle string, get func() string, set func(string)) *StringField

NewMultiLineStringField creates a new field for editing a string.

func NewStringField

func NewStringField(targetMgr *TargetMgr, targetKey, undoTitle string, get func() string, set func(string)) *StringField

NewStringField creates a new field for editing a string.

func NewStringPageField

func NewStringPageField(targetMgr *TargetMgr, targetKey, undoTitle string, get func() string, set func(string)) *StringField

NewStringPageField creates a new text entry field for a sheet page.

func NewStringPageFieldNoGrab

func NewStringPageFieldNoGrab(targetMgr *TargetMgr, targetKey, undoTitle string, get func() string, set func(string)) *StringField

NewStringPageFieldNoGrab creates a new text entry field for a sheet page, but with HGrab set to false.

func (*StringField) Sync

func (f *StringField) Sync()

Sync the field to the current value.

type Syncer

type Syncer interface {
	Sync()
}

Syncer should be called to sync an object's UI state to its model.

type TargetMgr

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

TargetMgr provides management of target panels.

func NewTargetMgr

func NewTargetMgr(root unison.Paneler) *TargetMgr

NewTargetMgr creates a new TargetMgr with the given root.

func (*TargetMgr) CurrentFocusRef

func (t *TargetMgr) CurrentFocusRef() *FocusRef

CurrentFocusRef returns the current FocusRef, if any.

func (*TargetMgr) Find

func (t *TargetMgr) Find(refKey string) *unison.Panel

Find searches the tree of panels starting at the root, looking for a specific refKey.

func (*TargetMgr) NextPrefix

func (t *TargetMgr) NextPrefix() string

NextPrefix returns the next unique prefix to use.

func (*TargetMgr) ReacquireFocus

func (t *TargetMgr) ReacquireFocus(ref *FocusRef, toolbar, content unison.Paneler)

ReacquireFocus attempts to restore the focus previously obtained by a call to CurrentFocusRef().

type TargetUndo

type TargetUndo[T any] struct {
	unison.UndoEdit[T]
	// contains filtered or unexported fields
}

TargetUndo provides undo support for fields that may be swapped out during updates by using a TargetMgr to locate the real target.

func NewTargetUndo

func NewTargetUndo[T any](targetMgr *TargetMgr, targetKey, title string, undoID int64, applyCallback func(target *unison.Panel, data T), beforeData T) *TargetUndo[T]

NewTargetUndo creates a new undo that supports having a revisable target.

type TitledBorder

type TitledBorder struct {
	Title string
	Font  unison.Font
}

TitledBorder provides a titled line border.

func (*TitledBorder) Draw

func (t *TitledBorder) Draw(gc *unison.Canvas, rect unison.Rect)

Draw implements unison.Border

func (*TitledBorder) Insets

func (t *TitledBorder) Insets() unison.Insets

Insets implements unison.Border

type WeightField

type WeightField = NumericField[measure.Weight]

WeightField is field that holds a weight value.

func NewWeightField

func NewWeightField(targetMgr *TargetMgr, targetKey, undoTitle string, entity *gurps.Entity, get func() measure.Weight, set func(measure.Weight), min, max measure.Weight, noMinWidth bool) *WeightField

NewWeightField creates a new field that holds a fixed-point number.

func NewWeightPageField

func NewWeightPageField(targetMgr *TargetMgr, targetKey, undoTitle string, entity *gurps.Entity, get func() measure.Weight, set func(measure.Weight), min, max measure.Weight, noMinWidth bool) *WeightField

NewWeightPageField creates a new weight entry field for a sheet page.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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