Documentation
¶
Overview ¶
Package fyneextensions provides additional utilities and helpers to extend the functionality of the Fyne toolkit (https://fyne.io/). These extensions offer extended layouts, custom widgets and additional conveniences to simplify the creation of user interfaces.
The package includes: - Fyne compatible layouts to be used with container.New():
- PaddedBox, MaxMinBox,
- EquallySpacedUnpaddedVBox, EquallySpacedUnpaddedHBox, EquallySpacedPaddedVBox, EquallySpacedPaddedHBox,
- ExpandingLastUnpaddedVBox, ExpandingFirstUnpaddedVBox, ExpandingLastPaddedVBox, ExpandingFirstPaddedVBox, ExpandingFirstUnpaddedHBox, ExpandingLastUnpaddedHBox, ExpandingFirstPaddedHBox, ExpandingAllProportionallyPaddedHBox,
- GiveUpLastExpandingUnpaddedVBox, GiveUpLastExpandingUnpaddedHBox
- ShadowedLayout,
- StackFixedRatioUnpadded, StackFixedRatioPadded, StackPadded
- Fyne compatible widgets:
SizableLabel, MiniWidget, FlexButton, ListableSearchableWidget, MainRibbon, SideBar
Utilities:
FormGenUtility,
ActionItem, ActionableMenu
Example:
Index ¶
- Constants
- func DarkTheme(fallback fyne.Theme) fyne.Theme
- func LightTheme(fallback fyne.Theme) fyne.Theme
- func NewExpandingFirstVBox(objects ...fyne.CanvasObject) *fyne.Container
- func NewExpandingLastVBox(objects ...fyne.CanvasObject) *fyne.Container
- func ParseDurationExtended(s string) (time.Duration, error)
- func ToNRGBA(c color.Color) (r, g, b, a int)
- type ActionItem
- type Actionable
- type ActionableMenu
- type ActionableMenuItem
- type EquallySpacedPaddedHBox
- type EquallySpacedPaddedVBox
- type EquallySpacedUnpaddedHBox
- type EquallySpacedUnpaddedVBox
- type ExpandingAllProportionallyPaddedHBox
- type ExpandingFirstPaddedHBox
- type ExpandingFirstPaddedVBox
- type ExpandingFirstUnpaddedHBox
- type ExpandingFirstUnpaddedVBox
- type ExpandingLastPaddedVBox
- type ExpandingLastUnpaddedHBox
- type ExpandingLastUnpaddedVBox
- type FlexButton
- func (t *FlexButton) CreateRenderer() fyne.WidgetRenderer
- func (t *FlexButton) DataChanged()
- func (t *FlexButton) MinSize() fyne.Size
- func (t *FlexButton) MouseIn(*desktop.MouseEvent)
- func (t *FlexButton) MouseMoved(me *desktop.MouseEvent)
- func (t *FlexButton) MouseOut()
- func (t *FlexButton) Refresh()
- func (t *FlexButton) SetMinSize(size fyne.Size)
- func (t *FlexButton) Tapped(*fyne.PointEvent)
- type FormGenKeepValueOption
- type FormGenUtility
- func (fgu *FormGenUtility) DisableEntry(fieldName string)
- func (fgu *FormGenUtility) EnableEntry(fieldName string)
- func (fgu *FormGenUtility) FocusOnFirstEntry()
- func (fgu *FormGenUtility) GetDialog(keepStructValues FormGenKeepValueOption) *dialog.FormDialog
- func (fgu *FormGenUtility) GetWidget(keepStructValues FormGenKeepValueOption) *widget.Form
- func (fgu *FormGenUtility) OverrideEntry(fieldName string)
- func (fgu *FormGenUtility) OverrideField(fieldName string)
- func (fgu *FormGenUtility) ShowDialog(keepStructValues FormGenKeepValueOption)
- type GiveUpLastExpandingUnpaddedHBox
- type GiveUpLastExpandingUnpaddedVBox
- type ListableSearchable
- type ListableSearchableWidget
- type MainRibbon
- type MaxMinBox
- type MiniWidget
- type PaddedBox
- type ShadowedLayout
- type ShadowedWidget
- type SideBar
- type SizableLabel
- type StackFixedRatioPadded
- type StackFixedRatioUnpadded
- type StackPadded
Constants ¶
const MaxMenuItems int = 100
Variables ¶
This section is empty.
Functions ¶
func LightTheme ¶
func LightTheme(fallback fyne.Theme) fyne.Theme
func NewExpandingFirstVBox ¶
func NewExpandingFirstVBox(objects ...fyne.CanvasObject) *fyne.Container
func NewExpandingLastVBox ¶
func NewExpandingLastVBox(objects ...fyne.CanvasObject) *fyne.Container
func ParseDurationExtended ¶
ParseDurationExtended parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
Types ¶
type ActionItem ¶
type ActionItem struct { Name binding.String CriticalName bool AlwaysShowAsContainer bool Resources []fyne.Resource Triggered func(int) SubActions []*ActionItem HasDynamicStates bool Disabler binding.Bool Hider binding.Bool Stater binding.Int }
ActionItem is a struct that represents an action. An action typically has a name, a state resources associated with it (icons), an action function to trigger and some binding states. Instead of a function to trigger, it could have sub-actions to create complex "menu" systems
The fields are as follows: - Name is a binding.String which provides a way to display a name for an action and observe changes to this name. - CriticalName is a bool that determines if the name is critical and should always be rendered. - AlwaysShowAsContainer is a bool that defines if the action should always be represented as a container even if there are no sub-actions. - Resources is a slice of fyne.Resource which can be used for representing the action in UI, like using an icon. The state of the item will force the related resource to be shown - Triggered is a function that will be invoked when the action is triggered. - SubActions are nested actions. - HasDynamicStates is a bool that defines if the action has dynamic states that can change. - Disabler, Hider, and Stater are binding variables which provide a way to control the disabled, hidden, and state properties of an action and observe changes to these properties.
The `Actionable` interface and its related items aim to provide a structured way to represent and manipulate actions in a Fyne application.
func NewActionItem ¶
func NewActionItem(name string, isNameCritical, alwaysShowAsContainer bool, resources []fyne.Resource, disabled bool, hidden bool, dynamicStates bool, state int, triggered func(int), subActions []*ActionItem) (action *ActionItem)
NewActionItem function is a factory function for creating new action items.
func (*ActionItem) AppendActions ¶
func (ai *ActionItem) AppendActions(subActions ...*ActionItem)
AppendActions method is to append sub actions to an existing ActionItem.
type Actionable ¶
type Actionable interface { GetActions() *ActionItem GetCanvas() fyne.Canvas }
The Actionable interface has two methods:
- GetActions() *ActionItem - GetCanvas() Fyne.Canvas
These are implemented by types that have actions and operate on a Fyne canvas.
type ActionableMenu ¶
type ActionableMenu struct { // Menu represents the actual fyne menu Menu *fyne.Menu // contains filtered or unexported fields }
ActionableMenu represents a Menu that has actions associated with it. Implements data binding listener interfaces to enable reactive behaviours to configuration changes such as name, being disabled, state changes and visibility.
func NewActionableMenu ¶
func NewActionableMenu(item *ActionItem) *ActionableMenu
NewActionableMenu creates a new ActionableMenu from a given ActionItem. It initializes a new Fyne menu and an actionable MenuItem for the provided Action. If any of the listener interfaces (Name, Disabler, Stater, Hider) for the associated ActionItem are non-nil, the newly created ActionableMenu is added as a listener to these. It returns a pointer to the constructed ActionableMenu. Input: an ActionItem to be associated with the new ActionableMenu. Output: a pointer to the newly created ActionableMenu.
func NewActionableMenu2 ¶
func NewActionableMenu2(items ...*ActionItem) *ActionableMenu
NewActionableMenu2 creates a new ActionableMenu from a given slice of ActionItem.
func (*ActionableMenu) DataChanged ¶
func (am *ActionableMenu) DataChanged()
type ActionableMenuItem ¶
type ActionableMenuItem struct {
// contains filtered or unexported fields
}
func NewActionableMenuItem ¶
func NewActionableMenuItem(item *ActionItem, parentItem binding.DataListener, rootItem binding.DataListener) *ActionableMenuItem
NewActionableMenuItem is a constructor function that takes an `*ActionItem`, a `parentItem` and a `rootItem` both as `binding.DataListener` and produces an `*ActionableMenuItem`. ParentItem and RootItem are typically nil.
In a nutshell, NewActionableMenuItem provides a way to create a MenuItem which is actionable, and is associated with other data listeners to react to changes. This allows for dynamically adjusting menu items based on the program state
func (*ActionableMenuItem) DataChanged ¶
func (ami *ActionableMenuItem) DataChanged()
func (*ActionableMenuItem) GetMenu ¶
func (ami *ActionableMenuItem) GetMenu() *fyne.Menu
The GetMenu method is a part of the `ActionableMenuItem` struct and it returns a pointer to a `fyne.Menu` or `nil`.
This function would be called when you want to obtain the associated menu of an ActionableMenuItem, if it exists, updating its data if there have been changes to the associated ActionItem.
type EquallySpacedPaddedHBox ¶
type EquallySpacedPaddedHBox struct{}
EquallySpacedPaddedHBox is a fyne compatible layout. It defines horizontal box without padding, where all object have the same width. Height is the container height
func (*EquallySpacedPaddedHBox) Layout ¶
func (d *EquallySpacedPaddedHBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*EquallySpacedPaddedHBox) MinSize ¶
func (d *EquallySpacedPaddedHBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type EquallySpacedPaddedVBox ¶
type EquallySpacedPaddedVBox struct{}
EquallySpacedPaddedVBox is a fyne compatible layout. It defines vertical box with padding, where all object have the same height. Width is the container width
func (*EquallySpacedPaddedVBox) Layout ¶
func (d *EquallySpacedPaddedVBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*EquallySpacedPaddedVBox) MinSize ¶
func (d *EquallySpacedPaddedVBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type EquallySpacedUnpaddedHBox ¶
type EquallySpacedUnpaddedHBox struct{}
EquallySpacedUnpaddedHBox is a fyne compatible layout. It defines horizontal box without padding, where all object have the same width. Height is the container height
func (*EquallySpacedUnpaddedHBox) Layout ¶
func (d *EquallySpacedUnpaddedHBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*EquallySpacedUnpaddedHBox) MinSize ¶
func (d *EquallySpacedUnpaddedHBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type EquallySpacedUnpaddedVBox ¶
type EquallySpacedUnpaddedVBox struct{}
EquallySpacedUnpaddedVBox is a fyne compatible layout. It defines vertical box without padding, where all object have the same height. Width is the container width
func (*EquallySpacedUnpaddedVBox) Layout ¶
func (d *EquallySpacedUnpaddedVBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*EquallySpacedUnpaddedVBox) MinSize ¶
func (d *EquallySpacedUnpaddedVBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type ExpandingAllProportionallyPaddedHBox ¶
type ExpandingAllProportionallyPaddedHBox struct{}
ExpandingAllProportionallyPaddedHBox is a Fyne compatible layout. It defines a horizontal box with padding, height of all elements is the container height, width of each element is calculated to keep the same ratio between width and height as from their MinSize()
func (*ExpandingAllProportionallyPaddedHBox) Layout ¶
func (d *ExpandingAllProportionallyPaddedHBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*ExpandingAllProportionallyPaddedHBox) MinSize ¶
func (d *ExpandingAllProportionallyPaddedHBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type ExpandingFirstPaddedHBox ¶
type ExpandingFirstPaddedHBox struct { }
ExpandingFirstPaddedHBox is a Fyne compatible layout. It defines a horizontal box with padding, which keeps the width of all objects except the last at their MinSize(), and expands the last element width to fill the container height. Height of all objects is the container height.
func (*ExpandingFirstPaddedHBox) Layout ¶
func (d *ExpandingFirstPaddedHBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*ExpandingFirstPaddedHBox) MinSize ¶
func (d *ExpandingFirstPaddedHBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type ExpandingFirstPaddedVBox ¶
type ExpandingFirstPaddedVBox struct { }
ExpandingFirstPaddedVBox is a Fyne compatible layout. It defines a vertical box with padding, which keeps the height of all objects except the first at their MinSize(), and expands the first element height to fill the container height. Width of all objects is the container width.
func (*ExpandingFirstPaddedVBox) Layout ¶
func (d *ExpandingFirstPaddedVBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*ExpandingFirstPaddedVBox) MinSize ¶
func (d *ExpandingFirstPaddedVBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type ExpandingFirstUnpaddedHBox ¶
type ExpandingFirstUnpaddedHBox struct { }
ExpandingFirstUnpaddedHBox is a Fyne compatible layout. It defines a horizontal box without padding, which keeps the width of all objects except the first at their MinSize(), and expands the first element width to fill the container height. Height of all objects is the container height.
func (*ExpandingFirstUnpaddedHBox) Layout ¶
func (d *ExpandingFirstUnpaddedHBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*ExpandingFirstUnpaddedHBox) MinSize ¶
func (d *ExpandingFirstUnpaddedHBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type ExpandingFirstUnpaddedVBox ¶
type ExpandingFirstUnpaddedVBox struct { }
ExpandingFirstUnpaddedVBox is a Fyne compatible layout. It defines a vertical box without any padding, which keeps the height of all objects except the first at their MinSize(), and expands the first element height to fill the container height. Width of all objects is the container width.
func (*ExpandingFirstUnpaddedVBox) Layout ¶
func (d *ExpandingFirstUnpaddedVBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*ExpandingFirstUnpaddedVBox) MinSize ¶
func (d *ExpandingFirstUnpaddedVBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type ExpandingLastPaddedVBox ¶
type ExpandingLastPaddedVBox struct { }
ExpandingLastPaddedVBox is a Fyne compatible layout. It defines a vertical box with padding, which keeps the height of all objects except the last at their MinSize(), and expands the last element height to fill the container height. Width of all objects is the container width.
func (*ExpandingLastPaddedVBox) Layout ¶
func (d *ExpandingLastPaddedVBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*ExpandingLastPaddedVBox) MinSize ¶
func (d *ExpandingLastPaddedVBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type ExpandingLastUnpaddedHBox ¶
type ExpandingLastUnpaddedHBox struct { }
ExpandingLastUnpaddedHBox is a Fyne compatible layout. It defines a horizontal box without padding, which keeps the width of all objects except the last at their MinSize(), and expands the last element width to fill the container height. Height of all objects is the container height.
func (*ExpandingLastUnpaddedHBox) Layout ¶
func (d *ExpandingLastUnpaddedHBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*ExpandingLastUnpaddedHBox) MinSize ¶
func (d *ExpandingLastUnpaddedHBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type ExpandingLastUnpaddedVBox ¶
type ExpandingLastUnpaddedVBox struct { }
ExpandingLastUnpaddedVBox is a Fyne compatible layout. It defines a vertical box without any padding, which keeps the height of all objects except the last at their MinSize(), and expands the last element height to fill the container height. Width of all objects is the container width.
func (*ExpandingLastUnpaddedVBox) Layout ¶
func (d *ExpandingLastUnpaddedVBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*ExpandingLastUnpaddedVBox) MinSize ¶
func (d *ExpandingLastUnpaddedVBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type FlexButton ¶
type FlexButton struct { widget.DisableableWidget OnTapped func(int) Texter binding.String Disabler binding.Bool Hider binding.Bool Stater binding.Int ToolTipper binding.String // contains filtered or unexported fields }
FlexButton is a fyne compatible widget which defines a flexible and customizable button widget. It provides a consistent look and feel across different parts of our app, and encapsulates styles and behaviors that are commonly associated with button elements.
the NewFlexButton factory function should be used to create an instance of FlexButton
The main additional functionalities over the standard widget.Button object are the following: - image and text management: it is possible to define one or more image, and dynamic text via binding.String - dynamic layout: it is possible to define if text must be visible, and how to layout image and text. - sizable: it is possible to define image size, text will be displayed or not depending on container size - encapsulates state: the object can hold an int state value, based on binding.Int object, depending on which it will display different image - can be hidden or disabled via binding.Bool objects - when binding.String tool tip is defined, it will push its text to the binding object when mouse is over. If not, the text will be displayed on a tooltip popup - it can include a side image when the button triggers a sub-menu
It is the basic object for the MainRibbon widget
func NewFlexButton ¶
func NewFlexButton(text string, images []fyne.Resource, isTextAndIconLaidHorizontal bool, compressText bool, isImagePadded bool, hasMoreIcon bool, isMoreIconBelow bool, fullHeight float32, textHeight float32, mCanvas fyne.Canvas, onTapped func(int), texter binding.String, disabler binding.Bool, hider binding.Bool, stater binding.Int, toolTipper binding.String) *FlexButton
NewFlexButton is the factory function for FlexButton object
it requires the following inputs: - text: The button text. - images: An array of images to be displayed on the button. Each image is specified as an object that satisfies the fyne.Resource interface. - isTextAndIconLaidHorizontal: A boolean to determine whether the text and the image are laid out horizontally. If true, the text and image are placed side by side; otherwise, they are stacked vertically. - compressText: A boolean to determine whether the text must be displayed. If true and FlexButton container size is not big enough, text is omitted. This implies that MinSize() of the FlexButton is the size of the image only - isImagePadded: A boolean to determine whether the image is padded. If true, padding is added around the image within the button's bounds. - hasMoreIcon: A boolean to determine whether the button has a "more" icon. If true, a "more" icon is displayed side or below the button to indicate the presence of additional functionality or content. - isMoreIconBelow: A boolean to determine the placement of the "more" icon. If true, the "more" icon is placed below the button content. - fullHeight: The full height of the button. For text and image laid out vertically with compressText=false, this is the image height + text height. On other cases it is the image height only - textHeight: The height of the button text. The combination of fullHeight, textHeight and compressText define the FlexButton MinSize() and layout - mCanvas: The fyne.Canvas where the button is rendered. - onTapped: The function to be called when the button is tapped. OnTapped requires an int as input, which is the state of the button when OnTapped is called - texter: A binding that determines the text displayed on the button. - disabler: A binding that determines whether the button is disabled. - hider: A binding that determines whether the button is visible. - stater: A binding that determines the state of the button. - toolTipper: A binding that determines the tooltip text for the button. Returns: - A pointer to the created FlexButton instance.
func (*FlexButton) CreateRenderer ¶
func (t *FlexButton) CreateRenderer() fyne.WidgetRenderer
func (*FlexButton) DataChanged ¶
func (t *FlexButton) DataChanged()
func (*FlexButton) MinSize ¶
func (t *FlexButton) MinSize() fyne.Size
func (*FlexButton) MouseIn ¶
func (t *FlexButton) MouseIn(*desktop.MouseEvent)
func (*FlexButton) MouseMoved ¶
func (t *FlexButton) MouseMoved(me *desktop.MouseEvent)
func (*FlexButton) MouseOut ¶
func (t *FlexButton) MouseOut()
func (*FlexButton) Refresh ¶
func (t *FlexButton) Refresh()
func (*FlexButton) SetMinSize ¶
func (t *FlexButton) SetMinSize(size fyne.Size)
func (*FlexButton) Tapped ¶
func (t *FlexButton) Tapped(*fyne.PointEvent)
type FormGenKeepValueOption ¶ added in v0.0.13
type FormGenKeepValueOption int
const ( KeepStructExceptOnFirstShow FormGenKeepValueOption = iota KeepStruct KeepEntry ResetStruct )
type FormGenUtility ¶
type FormGenUtility struct { OnSubmit func(bool) // contains filtered or unexported fields }
FormGenUtility is a struct that allows you to automatically generate a form based on the fields of any given struct. It utilizes the Fyne library to create these forms, efficiently creating a user interface for data input.
This utility is beneficial for rapidly constructing forms, providing flexibility and consistent structuring to your applications.
Currently supported types are:
- string
- int, int8, int16, int32, int64
- float32 and float64
- bool
- time.Time and time.Duration
- slice of string []string
- int alias for dropdown select entry only, e.g. type weekday int
Mainly, the Fyne form inputs are configured via the struct fields' tags. Here are the tags available for customization:
`formGenInclude`: This tag determines whether a particular struct field should be included in the form. The value should be "true" if you want to include the field from the form. Skip it otherwise. only exported fields are allowed
`formGenDescription`: This tag provides a descriptive label to a form field. This will be shown side of the entry on the form
`formGenLabel`: This tag provides a descriptive label to a form field. This will be shown side of the check or radio items
`formGenMaxVal` and `formGenMinVal`: These tags determine the maximum and minimum values for numeric form fields. If out of range, it causes a validation error.
`formGenIsRequired`: This tag determines if a field is required. If a required field is left empty, it causes a validation error.
`formGenDefaultValue`: This tag defines a default value for a form field. For required fields ('formGenIsRequired=true'), this value will be used if entry is left empty.
`formGenOnEntryChange`: This tag allows defining a callback function that is triggered when the value of this form field changes. The function must be exported with struct receiver (not pointer receiver!) and must have as argument a value of same type of the field and an error. For float64, as example, callback should be: func (myStruct MyStruct) OnFloatChange(float64, error) Notice that there is no check at compile about validity of callback function: errors (e.g. spelling of the function) will result in panic
`formGenOptions`: This tag is used to define dropdown options for dropdown form fields. Options are applied only on custom struct derived from int, e.g. type MySelection int The MySelection values can be as defined with a const, e.g. const ( Selection1 MySelection = iota, Selection2, ... ) Options as should be shown in the dropdown select entry are defined as options in this tag. Each option should be separated by "|||" for example `formGenOptions` "Selection 1|||Selection 2|||Selection 3"
`formGenRadioGroup`, 'formGenCheckGroup': This tag allows defining a group of check or radio buttons (on a single line). The tag value should be a unique string which defines the group.
Each field of the struct corresponds to a field on the form, and the types, labels, and other behaviors of the form fields are mapped from the types, names, and tags of the struct fields.
The method ShowDialog will generate a dialog.Form and show it on the passed canvas ¶
Them method GetWidget will generate a new fyne.Widget to be shown in a custom CanvasObject
func NewFormGenDialog ¶
func NewFormGenDialog(s interface{}, title, confirm, dismiss string, onSubmit func(bool), w fyne.Window, minSize fyne.Size) *FormGenUtility
NewFormGenDialog is a utility function for dynamically generating form dialog. It takes in a struct and creates a form dialog based on the struct's exported fields that are flagged with a `formGenInclude` tag.
Parameters:
- s (interface{}): The struct based on which the form dialog will be created. - title (string): The title of the form dialog. - confirm (string): The label for the confirm button in the form dialog. - dismiss (string): The label for the cancel/dismiss button in the form dialog. - onSubmit (func(bool)): A callback function that will be called when form is submitted. The function takes a boolean parameter which is true if form submission was successful and false otherwise. - w (fyne.Window): The parent window for the form dialog. - minSize (fyne.Size): The minimum size of the form dialog.
Returns:
- *FormGenUtility: A pointer to the FormGenUtility instance, which includes the generated form dialog and its associated elements.
Example Usage:
type User struct { Name string `formGenInclude:"true"` Age int `formGenInclude:"true"` } user := User{Name: "John", Age: 25} fgu := NewFormGenDialog(user, "User Form", "OK", "Cancel", func(b bool) { if b { fmt.Println("Form Submitted") } else { fmt.Println("Form Dismissed") } }, window, fyne.NewSize(300, 200))
In this example, a new form dialog is generated based on the `User` struct. The form will have two fields, "Name" and "Age". Both fields are included because they have `formGenInclude` tag set to "true". Upon form submission or cancellation, respective messages will be printed on the console.
The `NewFormGenDialog` function allows for the dynamic creation of forms without having to manually create each form field, making code cleaner and facilitating use of forms in larger projects.
func (*FormGenUtility) DisableEntry ¶
func (fgu *FormGenUtility) DisableEntry(fieldName string)
DisableEntry disables the entry in the form Field name must mach the field as typed in the struct passed to the FormGenUtility.
func (*FormGenUtility) EnableEntry ¶
func (fgu *FormGenUtility) EnableEntry(fieldName string)
EnableEntry enables the entry in the form. Field name must mach the field as typed in the struct passed to the FormGenUtility.
func (*FormGenUtility) FocusOnFirstEntry ¶
func (fgu *FormGenUtility) FocusOnFirstEntry()
FocusOnFirstEntry is a method of the FormGenUtility type that performs the action of focussing on the first entry field of the form.
Example Usage:
fgu := NewFormGenDialog(user, "User Form", "OK", "Cancel", onSubmitFunc, window, fyne.NewSize(300, 200)) // Focus on the first entry field of the form fgu.FocusOnFirstEntry()
The FocusOnFirstEntry method does not have any parameters and does not return any value.
This method checks if there is at least one entry in the form, selects the first and then sets the focus to this field. This action is especially useful after the form dialog is shown to the user, to immediately allow the user to start entering data into the form without having to manually click on the first entry field.
func (*FormGenUtility) GetDialog ¶
func (fgu *FormGenUtility) GetDialog(keepStructValues FormGenKeepValueOption) *dialog.FormDialog
GetDialog is a method of the FormGenUtility type that returns the generated form dialog.
Parameters:
- keepStructValues (FormGenKeepValueOption): A flag to indicate whether to keep or discard the values in the form entries.
Returns:
- *dialog.FormDialog: The form dialog generated by the NewFormGenDialog function.
Example Usage:
fgu := NewFormGenDialog(user, "User Form", "OK", "Cancel", onSubmitFunc, window, fyne.NewSize(300, 200)) // Save current values and get the form dialog dialog := fgu.GetDialog(true)
func (*FormGenUtility) GetWidget ¶
func (fgu *FormGenUtility) GetWidget(keepStructValues FormGenKeepValueOption) *widget.Form
GetWidget is a method of the FormGenUtility type that returns the generated form widget. Differently from dialog.Form (GetDialog), the widget can be added to a custom CanvasObject and further customized where necessary. It does not include ok and cancel buttons, which need to be created manually and call the OnSubmit (or OnCancel) functions
Parameters:
- keepStructValues (FormGenKeepValueOption): A flag to indicate whether to keep or discard the values in the form entries.
Returns: - *widget.Form: The form widget generated by the NewFormGenDialog function.
Example Usage:
fgu := NewFormGenDialog(user, "User Form", "OK", "Cancel", onSubmitFunc, window, fyne.NewSize(300, 200)) // Retrieve the form widget with current values widget := fgu.GetWidget(true)
func (*FormGenUtility) OverrideEntry ¶
func (fgu *FormGenUtility) OverrideEntry(fieldName string)
OverrideEntry overrides the content of the entry from the value stored in the specified field. Field name must mach the field as typed in the struct passed to the FormGenUtility. Use to update the entry in the form if the struct is altered, while the form is open
func (*FormGenUtility) OverrideField ¶ added in v0.0.8
func (fgu *FormGenUtility) OverrideField(fieldName string)
OverrideField overrides the value stored in the struct from the value in the dedicated entry. Field name must mach the field as typed in the struct passed to the FormGenUtility. Use to update the struct from the entry before the Confirm button is pressed in the form
func (*FormGenUtility) ShowDialog ¶
func (fgu *FormGenUtility) ShowDialog(keepStructValues FormGenKeepValueOption)
ShowDialog is a method of the FormGenUtility type that shows the generated form dialog.
Parameters:
- keepStructValues (FormGenKeepValueOption): A flag to indicate whether to keep or discard the values in the form entries.
Example Usage:
fgu := NewFormGenDialog(user, "User Form", "OK", "Cancel", onSubmitFunc, window, fyne.NewSize(300, 200)) // Show dialog with current values fgu.ShowDialog(true)
type GiveUpLastExpandingUnpaddedHBox ¶
type GiveUpLastExpandingUnpaddedHBox struct { }
GiveUpLastExpandingUnpaddedHBox is a Fyne compatible layout. It defines a horizontal layout of maximum 2 objects, without padding, that does not show the last element if container width is not sufficient. Its MinSize() is the MinSize() of the first element. The last element, if visible, is always kept at its MinSize() width. The first element is expanded to fill the container width. Height is the container width for all elements.
func (*GiveUpLastExpandingUnpaddedHBox) Layout ¶
func (d *GiveUpLastExpandingUnpaddedHBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*GiveUpLastExpandingUnpaddedHBox) MinSize ¶
func (d *GiveUpLastExpandingUnpaddedHBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type GiveUpLastExpandingUnpaddedVBox ¶
type GiveUpLastExpandingUnpaddedVBox struct { }
GiveUpLastExpandingUnpaddedVBox is a Fyne compatible layout. It defines a vertical layout of maximum 2 objects, without padding, that does not show the last element if container height is not sufficient. Its MinSize() is the MinSize() of the first element. The last element, if visible, is always kept at its MinSize() height. The first element is expanded to fill the container height. Width is the container width for all elements.
func (*GiveUpLastExpandingUnpaddedVBox) Layout ¶
func (d *GiveUpLastExpandingUnpaddedVBox) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*GiveUpLastExpandingUnpaddedVBox) MinSize ¶
func (d *GiveUpLastExpandingUnpaddedVBox) MinSize(objects []fyne.CanvasObject) fyne.Size
type ListableSearchable ¶
type ListableSearchable interface { ListLen() int CreateListItem() fyne.CanvasObject UpdateListItem(int, fyne.CanvasObject) GetSelected() int OnSelectedItem(int) GetListableSearchableActions() *ActionItem GetCanvas() fyne.Canvas ClearSearch() StartSearch(string) }
ListableSearchable defines the basic operations and behavior required for a ListableSearchableWidget.
Methods: - ListLen() int: This method returns the length of the list. - CreateListItem() fyne.CanvasObject: This method creates a list item and returns a fyne.CanvasObject. The concrete implementation of this object can vary. Note that this constructor does not need actual data to be displayed, but only the constructors fof the CanvasObjects which will hold the data - UpdateListItem(int, fyne.CanvasObject): This method updates a list item at a given index position with a fyne.CanvasObject. This will introduce actual data into the list - GetSelected() int: This method returns the index position of the currently selected item in the list. - OnSelectedItem(int): This method defines what to do when an item in the list is selected. The specific action is determined by the integer parameter, which represents the index of the item. - GetListableSearchableActions() *ActionItem: This method returns the actions related to ListableSearchable widget. If the returned *ActionItem is not nil, the widget will display a customized menu - GetCanvas() fyne.Canvas: This method must return the canvas object where the ListableSearchableWidget will be displayed. - ClearSearch(): Clears the current search results. - StartSearch(string): This method starts a search operation on the list using the input string as the query.
type ListableSearchableWidget ¶
type ListableSearchableWidget struct { widget.BaseWidget // contains filtered or unexported fields }
The ListableSearchableWidget struct is a Fyne compatible widget. The widget can display a list of items with a search bar with a default Search and Clear button. The search bar can also include a customized menu.
it is possible to associate to a ListableSearchableWidget any object which implements ListableSearchable interface
Constructor: - NewListableSearchableWidget: Returns a new instance of the ListableSearchableWidget struct.
func NewListableSearchableWidget ¶
func NewListableSearchableWidget(iList ListableSearchable) *ListableSearchableWidget
func (*ListableSearchableWidget) CreateRenderer ¶
func (t *ListableSearchableWidget) CreateRenderer() fyne.WidgetRenderer
func (*ListableSearchableWidget) DataChanged ¶
func (t *ListableSearchableWidget) DataChanged()
func (*ListableSearchableWidget) ResetListableSearchableAndRefresh ¶
func (t *ListableSearchableWidget) ResetListableSearchableAndRefresh(mList ListableSearchable)
type MainRibbon ¶
type MainRibbon struct { widget.BaseWidget // contains filtered or unexported fields }
The MainRibbon struct is a fyne.Widget. Its main purpose is to provide a user interface element that organizes other widgets into a ribbon-like structure.
It should be added to a container.AppTabs widget. The BuildTabItemRibbon function is a factory function for creating new container.TabItem to be added to the container.AppTabs in Fyne.
It is based on ActionItem, which dictates the ribbon layout. Items can be laid out horizontally or vertically, or in context menus, depending on ActionItem depth and length
func BuildTabItemRibbon ¶
func BuildTabItemRibbon(act Actionable, maxSize, blockSize float32, toolTipper binding.String) (*container.TabItem, *MainRibbon)
BuildTabItemRibbon is a function that constructs a `container.TabItem` and a `MainRibbon` from an actionable item, dimensions (maxSize and blockSize), and a string for tooltips.
The function signature is: - act is the object implementing Actionable interface which will indicate all ribbon functionalities. - maxSize and blockSize are the maximum size and block size. These are used for laying out vertically components within the MainRibbon. For example, a maxSize of 90 and blockSize of 30 will allow up to 3 lines of objects in the ribbon - toolTipper is a binding.String that serves for adding tooltips to components. This is optional. if set to nil, the tip will be displayed on a context popup instead when passing over a button with the mouse
func (*MainRibbon) AddItems ¶ added in v0.0.10
func (mr *MainRibbon) AddItems(items ...*ActionItem)
func (*MainRibbon) CreateRenderer ¶
func (mr *MainRibbon) CreateRenderer() fyne.WidgetRenderer
func (*MainRibbon) DataChanged ¶
func (mr *MainRibbon) DataChanged()
func (*MainRibbon) MinSize ¶
func (mr *MainRibbon) MinSize() fyne.Size
type MaxMinBox ¶
type MaxMinBox struct{}
MaxMinBox is a fyne compatible layout. It must have 2 fyne.CanvasObjects and will lay them out filling the container size for the first one, and centered at its MinSize() the second one
type MiniWidget ¶
type MiniWidget struct { widget.DisableableWidget // contains filtered or unexported fields }
MiniWidget is a Fyne compatible widget. It represents a miniaturized widget structure in the GUI which can be adapted to multiple usages, such as menu ribbons, sidebars, etc. It's ideal for use-cases like notifications, small data charts, or compact control elements. It can be configured with a header or footer area, with close, minimize, move up and move down buttons An instance of a MiniWidget can be created with the factory NewMiniWidget
func NewMiniWidget ¶
func NewMiniWidget(header string, headerOnTop bool, headerSize float32, content fyne.CanvasObject, shadowed bool, showMinimize bool, onMinimize func(bool), showClose bool, onClose func(), showMove bool, onMoveUp func(miniWidget *MiniWidget), onMoveDown func(miniWidget *MiniWidget), showMore bool, onMore func(fyne.CanvasObject), texter binding.String, disabler binding.Bool, closer binding.Bool, minimizer binding.Int, mCanvas fyne.Canvas) *MiniWidget
NewMiniWidget is a factory function that creates and initializes a new MiniWidget.
The function accepts the following parameters:
header: a string that sets the header of the MiniWidget. headerOnTop: a bool that determines if the header should be on top or bottom of the MiniWidget. headerSize: a float32 that sets the size of the header. content: a fyne.CanvasObject which represents the content of the MiniWidget. shadowed: a bool to enable or disable shadow for the MiniWidget. showMinimize: a bool to show or hide minimize functionality for the MiniWidget. onMinimize: a callback function that gets executed when the MiniWidget is minimized. showClose: a bool to show or hide close functionality for the MiniWidget. onClose: a callback function that gets executed when the MiniWidget is closed. showMove: a bool to enable or disable movement functionality for the MiniWidget. onMoveUp: a callback function that gets executed when the MiniWidget is moved upwards. onMoveDown: a callback function that gets executed when the MiniWidget is moved downwards. showMore: a bool to enable or disable more functionality for the MiniWidget. onMore: a callback function that gets executed when the more button on the MiniWidget is clicked. texter: a binding.String instance to bind header text to the MiniWidget. disabler: a binding.Bool instance to disable the MiniWidget. closer: a binding.Bool instance to bind custom close function to the MiniWidget. minimizer: a binding.Int instance to bind custom minimize function to the MiniWidget. mCanvas: a fyne.Canvas instance where the MiniWidget will be drawn.
This function returns a pointer to a fully initialized MiniWidget.
func (*MiniWidget) CreateRenderer ¶
func (t *MiniWidget) CreateRenderer() fyne.WidgetRenderer
func (*MiniWidget) DataChanged ¶
func (t *MiniWidget) DataChanged()
func (*MiniWidget) MinSize ¶
func (t *MiniWidget) MinSize() fyne.Size
func (*MiniWidget) Minimize ¶
func (t *MiniWidget) Minimize(state int)
func (*MiniWidget) Refresh ¶
func (t *MiniWidget) Refresh()
type PaddedBox ¶
type PaddedBox struct{}
PaddedBox is a fyne compatible layout. It must have 2 fyne.CanvasObjects and will lay them out filling the container size for the first one, and centered with a theme.Padding() border the second one
type ShadowedLayout ¶
type ShadowedLayout struct{}
ShadowedLayout is a Fyne compatible layout. It defines a tiled layout of maximum 2 objects, where the first element is in the top-left corner and the second in the bottom-right. Its MinSize() is the MinSize() of the first element + one theme.Padding() for both width and height. It is the typical layout of a shadowed content where the first element is the content and the second a rectangle for the shadow.
func (*ShadowedLayout) Layout ¶
func (d *ShadowedLayout) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*ShadowedLayout) MinSize ¶
func (d *ShadowedLayout) MinSize(objects []fyne.CanvasObject) fyne.Size
type ShadowedWidget ¶
type ShadowedWidget struct { widget.BaseWidget // contains filtered or unexported fields }
ShadowedWidget is a Fyne compatible fine.Widget. It just shows a user defined content, adding a backround rectangle as shadow. It uses ShadowedLayout layout
func NewShadowedWidget ¶ added in v0.0.2
func NewShadowedWidget(obj fyne.CanvasObject) *ShadowedWidget
NewShadowedWidget is a factory function for a ShadowedWidget. Requires a fyne.CanvasObject as input, to which it will apply a shadow
func (*ShadowedWidget) CreateRenderer ¶
func (t *ShadowedWidget) CreateRenderer() fyne.WidgetRenderer
func (*ShadowedWidget) MinSize ¶
func (t *ShadowedWidget) MinSize() fyne.Size
func (*ShadowedWidget) Refresh ¶
func (t *ShadowedWidget) Refresh()
type SideBar ¶
type SideBar struct { widget.BaseWidget // contains filtered or unexported fields }
SideBar is a Fyne compatible widget which acts as a container for MiniWidget components. It can manage basic functionalities such as adding content to the sidebar and moving child objects up and down
func NewSideBar ¶
func NewSideBar(widgets ...*MiniWidget) *SideBar
func (*SideBar) AddWidget ¶
func (sb *SideBar) AddWidget(widgets ...*MiniWidget)
func (*SideBar) CreateRenderer ¶
func (sb *SideBar) CreateRenderer() fyne.WidgetRenderer
func (*SideBar) DataChanged ¶
func (sb *SideBar) DataChanged()
type SizableLabel ¶
type SizableLabel struct { widget.BaseWidget // contains filtered or unexported fields }
SizableLabel is a Fyne compatible widget. It is to all extents a simple label. The only difference with the built-in widget.Label is that the SizableLabel is configured by the CanvasObject size instead of the font size. This comes useful when you need to ensure certain proportions between your GUI components although readability of your text is at your risk.
func NewSizableLabel ¶
func (*SizableLabel) CreateRenderer ¶
func (t *SizableLabel) CreateRenderer() fyne.WidgetRenderer
func (*SizableLabel) GetFontSize ¶
func (t *SizableLabel) GetFontSize() float32
func (*SizableLabel) MinSize ¶
func (t *SizableLabel) MinSize() fyne.Size
func (*SizableLabel) Refresh ¶
func (t *SizableLabel) Refresh()
func (*SizableLabel) SetTextSize ¶
func (t *SizableLabel) SetTextSize(size float32)
type StackFixedRatioPadded ¶
type StackFixedRatioPadded struct{}
StackFixedRatioPadded is a Fyne compatible layout. It defines a stack-like layout where elements are tiled one on top of the other filling the container size, but with the difference that it keeps the ratio between width and height as from each object MinSize() constant. It also adds an empty border around each object of 1 theme.Padding() size
func (*StackFixedRatioPadded) Layout ¶
func (d *StackFixedRatioPadded) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*StackFixedRatioPadded) MinSize ¶
func (d *StackFixedRatioPadded) MinSize(objects []fyne.CanvasObject) fyne.Size
type StackFixedRatioUnpadded ¶
type StackFixedRatioUnpadded struct{}
StackFixedRatioUnpadded is a Fyne compatible layout. It defines a stack-like layout where elements are tiled one on top of the other filling the container size, but with the difference that it keeps the ratio between width and height as from each object MinSize() constant.
func (*StackFixedRatioUnpadded) Layout ¶
func (d *StackFixedRatioUnpadded) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*StackFixedRatioUnpadded) MinSize ¶
func (d *StackFixedRatioUnpadded) MinSize(objects []fyne.CanvasObject) fyne.Size
type StackPadded ¶
type StackPadded struct{}
StackPadded is a Fyne compatible layout. It behaves like container.NewStack() but adds an empty border around each object of 1 theme.Padding() size
func (*StackPadded) Layout ¶
func (d *StackPadded) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)
func (*StackPadded) MinSize ¶
func (d *StackPadded) MinSize(objects []fyne.CanvasObject) fyne.Size
Source Files
¶
- doc.go
- interface_actionable.go
- layout_boxed.go
- layout_equallyspaced.go
- layout_expandingbox.go
- layout_giveupbox.go
- layout_shadowed.go
- layout_stackkeepratio.go
- utilitiy_miscellanea.go
- utility_formgen.go
- utility_menu.go
- utility_menu2.go
- widget_flexbutton.go
- widget_listablesearchable.go
- widget_miniwidget.go
- widget_ribbon.go
- widget_sidebar.go
- widget_sizablelabel.go