Documentation ¶
Overview ¶
Referenced code: https://github.com/golang/exp/blob/master/shiny/widget/flex/flex.go
Index ¶
- Variables
- func Int(i int) *int
- func RegisterComponents(cs ComponentsMap)
- type AlignContent
- type AlignItem
- type ButtonHandler
- type Component
- type ComponentsMap
- type Direction
- type Display
- type DrawHandler
- type Drawer
- type ErrorList
- type FlexAlign
- type FlexWrap
- type Handler
- type HandlerOpts
- type Justify
- type MouseEnterLeaveHandler
- type MouseHandler
- type MouseLeftButtonHandler
- type NotButton
- type ParseOptions
- type Position
- type SwipeDirection
- type SwipeHandler
- type TouchHandler
- type UpdateHandler
- type Updater
- type View
- func (v *View) AddChild(views ...*View) *View
- func (v *View) AddTo(parent *View) *View
- func (v *View) Config() ViewConfig
- func (v *View) Draw(screen *ebiten.Image)
- func (v *View) GetByID(id string) (*View, bool)
- func (ct *View) HandleJustPressedTouchID(touchID ebiten.TouchID, x, y int) bool
- func (ct *View) HandleJustReleasedTouchID(touchID ebiten.TouchID, x, y int)
- func (v *View) Layout()
- func (v *View) MustGetByID(id string) *View
- func (v *View) PopChild() *View
- func (v *View) RemoveAll()
- func (v *View) RemoveChild(cv *View) bool
- func (v *View) SetAlignContent(alignContent AlignContent)
- func (v *View) SetAlignItems(alignItems AlignItem)
- func (v *View) SetBottom(bottom int)
- func (v *View) SetDirection(direction Direction)
- func (v *View) SetDisplay(display Display)
- func (v *View) SetGrow(grow float64)
- func (v *View) SetHeight(height int)
- func (v *View) SetHidden(hidden bool)
- func (v *View) SetJustify(justify Justify)
- func (v *View) SetLeft(left int)
- func (v *View) SetMarginBottom(marginBottom int)
- func (v *View) SetMarginLeft(marginLeft int)
- func (v *View) SetMarginRight(marginRight int)
- func (v *View) SetMarginTop(marginTop int)
- func (v *View) SetPosition(position Position)
- func (v *View) SetRight(right int)
- func (v *View) SetShrink(shrink float64)
- func (v *View) SetTop(top int)
- func (v *View) SetWidth(width int)
- func (v *View) SetWrap(wrap FlexWrap)
- func (v *View) Update()
- func (v *View) UpdateWithSize(width, height int)
- type ViewConfig
Constants ¶
This section is empty.
Variables ¶
var (
Debug = false
)
Functions ¶
func RegisterComponents ¶ added in v2.3.6
func RegisterComponents(cs ComponentsMap)
Types ¶
type AlignContent ¶
type AlignContent uint8
AlignContent is the 'align-content' property. It aligns container lines when there is extra space on the cross-axis.
const ( AlignContentStart AlignContent = iota AlignContentEnd AlignContentCenter AlignContentSpaceBetween AlignContentSpaceAround AlignContentStretch )
func (AlignContent) String ¶ added in v2.3.4
func (f AlignContent) String() string
type ButtonHandler ¶
type ButtonHandler interface { // HandlePress handle the event when user just started pressing the button // The parameter (x, y) is the location relative to the window (0,0). // touchID is the unique ID of the touch. // If the button is pressed by a mouse, touchID is -1. HandlePress(x, y int, t ebiten.TouchID) // HandleRelease handle the event when user just released the button. // The parameter (x, y) is the location relative to the window (0,0). // The parameter isCancel is true when the touch/left click is released outside of the button. HandleRelease(x, y int, isCancel bool) }
ButtonHandler represents a button component.
type Component ¶ added in v2.3.0
type Component interface{}
The Component can be either a handler instance (e.g., DrawHandler), a factory function func() furex.Handler, or a function component func() *furex.View. This allows flexibility in usage: If you want to reuse the same handler instance for multiple HTML tags, pass the instance; otherwise, pass the factory function to create separate handler instances for each tag.
type ComponentsMap ¶ added in v2.3.0
ComponentsMap is a type alias for a dictionary that associates custom HTML tags with their respective components. This enables a convenient way to manage and reference components based on their corresponding HTML tags.
type DrawHandler ¶
type DrawHandler interface { // HandleDraw function draws the content of the component inside the frame. // The frame parameter represents the location (x,y) and size (width,height) relative to the window (0,0). HandleDraw(screen *ebiten.Image, frame image.Rectangle) }
DrawHandler represents a component that can be added to a container. Deprectead: use Drawer instead
type Drawer ¶ added in v2.4.0
type Drawer interface { // Draw function draws the content of the component inside the frame. Draw(screen *ebiten.Image, frame image.Rectangle, v *View) }
Drawer represents a component that can be added to a container.
type ErrorList ¶ added in v2.3.0
type ErrorList struct {
// contains filtered or unexported fields
}
type FlexWrap ¶
type FlexWrap uint8
FlexWrap controls whether the container is single- or multi-line, and the direction in which the lines are laid out.
type Handler ¶ added in v2.3.0
type Handler interface{}
Handler represents a component that can be added to a container.
func NewHandler ¶ added in v2.4.2
func NewHandler(opts HandlerOpts) Handler
NewHandler creates a new handler.
type HandlerOpts ¶ added in v2.4.2
type HandlerOpts struct { Update func(v *View) Draw func(screen *ebiten.Image, frame image.Rectangle, v *View) HandlePress func(x, y int, t ebiten.TouchID) HandleRelease func(x, y int, isCancel bool) }
HandlerOpts represents the options for a handler.
type MouseEnterLeaveHandler ¶ added in v2.2.0
type MouseEnterLeaveHandler interface { // HandleMouseEnter handles the mouse enter. HandleMouseEnter(x, y int) bool // HandleMouseLeave handles the mouse leave. HandleMouseLeave() }
MouseEnterHandler represets a component that handle mouse enter.
type MouseHandler ¶
type MouseHandler interface { // HandleMouse handles the mouch move and returns true if it handle the mouse move. // The parameter (x, y) is the location relative to the window (0,0). HandleMouse(x, y int) bool }
MouseHandler represents a component that handle mouse move.
type MouseLeftButtonHandler ¶
type MouseLeftButtonHandler interface { // HandleJustPressedMouseButtonLeft handle left mouse button click just pressed. // The parameter (x, y) is the location relative to the window (0,0). // It returns true if it handles the mouse move. HandleJustPressedMouseButtonLeft(x, y int) bool // HandleJustReleasedTouchID handles the touchID just released. // The parameter (x, y) is the location relative to the window (0,0). HandleJustReleasedMouseButtonLeft(x, y int) }
MouseLeftButtonHandler represents a component that handle mouse button left click.
type NotButton ¶ added in v2.2.3
type NotButton interface { // IsButton returns true if the handler is a button. IsButton() bool }
NotButton represents a component that is not a button. TODO: update HandlePress to return bool in the next major version.
type ParseOptions ¶ added in v2.3.0
type ParseOptions struct { // Components is a map of component name and handler. // For example, if you have a component named "start-button", you can define a handler // for it like this: // opts.Components := map[string]Handler{ // "start-button": <your handler>, // } // The component name must be in kebab-case. // You can use the component in your HTML like this: // <start-button></start-button> // Note: self closing tag is not supported. Components ComponentsMap // Width and Height is the size of the root view. // This is useful when you want to specify the width and height // outside of the HTML. Width int Height int // Handler is the handler for the root view. Handler Handler }
ParseOptions represents options for parsing HTML.
type SwipeDirection ¶ added in v2.1.4
type SwipeDirection int
SwipeHandler represents different swipe directions.
const ( SwipeDirectionLeft SwipeDirection = iota SwipeDirectionRight SwipeDirectionUp SwipeDirectionDown )
type SwipeHandler ¶ added in v2.1.4
type SwipeHandler interface { // HandleSwipe handles swipes. HandleSwipe(dir SwipeDirection) }
SwipeHandler represents a component that handle swipe.
type TouchHandler ¶
type TouchHandler interface { // HandleJustPressedTouchID handles the touchID just pressed and returns true if it handles the TouchID HandleJustPressedTouchID(touch ebiten.TouchID, x, y int) bool // HandleJustReleasedTouchID handles the touchID just released // Should be called only when it handled the TouchID when pressed HandleJustReleasedTouchID(touch ebiten.TouchID, x, y int) }
TouchHandler represents a component that handle touches.
type UpdateHandler ¶
type UpdateHandler interface {
// Updater updates the state of the component by one tick.
HandleUpdate()
}
UpdateHandler represents a component that updates by one tick. Deprectead: use Updater instead
type Updater ¶ added in v2.4.0
type Updater interface { // Update updates the state of the component by one tick. Update(v *View) }
Updater represents a component that updates by one tick.
type View ¶
type View struct { // TODO: Remove these fields in the future. Left int Right *int Top int Bottom *int Width int WidthInPct float64 Height int HeightInPct float64 MarginLeft int MarginTop int MarginRight int MarginBottom int Position Position Direction Direction Wrap FlexWrap Justify Justify AlignItems AlignItem AlignContent AlignContent Grow float64 Shrink float64 Display Display ID string Raw string TagName string Text string Attrs map[string]string Hidden bool Handler Handler // contains filtered or unexported fields }
View represents a UI element. You can set flex options, size, position and so on. Handlers can be set to create custom component such as button or list.
func Parse ¶ added in v2.3.0
func Parse(input string, opts *ParseOptions) *View
func (*View) Config ¶ added in v2.3.0
func (v *View) Config() ViewConfig
func (*View) GetByID ¶ added in v2.3.3
GetByID returns the view with the specified id. It returns nil if not found.
func (*View) HandleJustPressedTouchID ¶
func (*View) HandleJustReleasedTouchID ¶
func (ct *View) HandleJustReleasedTouchID(touchID ebiten.TouchID, x, y int)
func (*View) MustGetByID ¶ added in v2.3.3
MustGetByID returns the view with the specified id. It panics if not found.
func (*View) RemoveAll ¶ added in v2.1.1
func (v *View) RemoveAll()
RemoveAll removes all children view
func (*View) RemoveChild ¶
RemoveChild removes a specified view
func (*View) SetAlignContent ¶ added in v2.3.4
func (v *View) SetAlignContent(alignContent AlignContent)
SetAlignContent sets the align content property of the view.
func (*View) SetAlignItems ¶ added in v2.3.4
SetAlignItems sets the align items property of the view.
func (*View) SetDirection ¶ added in v2.3.4
SetDirection sets the direction of the view.
func (*View) SetDisplay ¶ added in v2.3.4
SetDisplay sets the display property of the view.
func (*View) SetJustify ¶ added in v2.3.4
SetJustify sets the justify property of the view.
func (*View) SetMarginBottom ¶ added in v2.3.4
SetMarginBottom sets the bottom margin of the view.
func (*View) SetMarginLeft ¶ added in v2.3.4
SetMarginLeft sets the left margin of the view.
func (*View) SetMarginRight ¶ added in v2.3.4
SetMarginRight sets the right margin of the view.
func (*View) SetMarginTop ¶ added in v2.3.4
SetMarginTop sets the top margin of the view.
func (*View) SetPosition ¶ added in v2.3.4
SetPosition sets the position of the view.
func (*View) UpdateWithSize ¶ added in v2.1.6
UpdateWithSize the view with modified height and width
type ViewConfig ¶ added in v2.3.0
type ViewConfig struct { TagName string ID string Left int Right *int Top int Bottom *int Width int Height int MarginLeft int MarginTop int MarginRight int MarginBottom int Position Position Direction Direction Wrap FlexWrap Justify Justify AlignItems AlignItem AlignContent AlignContent Grow float64 Shrink float64 // contains filtered or unexported fields }
This is for debugging and testing.
func (ViewConfig) Tree ¶ added in v2.3.4
func (cfg ViewConfig) Tree() string