Documentation ¶
Overview ¶
Referenced code: https://github.com/golang/exp/blob/master/shiny/widget/flex/flex.go
Index ¶
- Variables
- func Float(f float64) *float64
- 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 float64)
- func (v *View) SetDirection(direction Direction)
- func (v *View) SetDisplay(display Display)
- func (v *View) SetGrow(grow float64)
- func (v *View) SetHeight(height float64)
- func (v *View) SetHidden(hidden bool)
- func (v *View) SetJustify(justify Justify)
- func (v *View) SetLeft(left float64)
- func (v *View) SetMarginBottom(marginBottom float64)
- func (v *View) SetMarginLeft(marginLeft float64)
- func (v *View) SetMarginRight(marginRight float64)
- func (v *View) SetMarginTop(marginTop float64)
- func (v *View) SetPosition(position Position)
- func (v *View) SetRight(right float64)
- func (v *View) SetShrink(shrink float64)
- func (v *View) SetTop(top float64)
- func (v *View) SetWidth(width float64)
- func (v *View) SetWrap(wrap FlexWrap)
- func (v *View) Update()
- func (v *View) UpdateWithSize(width, height float64)
- type ViewConfig
Constants ¶
This section is empty.
Variables ¶
var (
Debug = false
)
Functions ¶
func RegisterComponents ¶
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 ¶
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 ¶
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 ¶
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 geo.Rectangle) }
DrawHandler represents a component that can be added to a container. Deprectead: use Drawer instead
type Drawer ¶
type Drawer interface { // Draw function draws the content of the component inside the frame. Draw(screen *ebiten.Image, frame geo.Rectangle, v *View) }
Drawer represents a component that can be added to a container.
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 ¶
type Handler interface{}
Handler represents a component that can be added to a container.
type HandlerOpts ¶
type HandlerOpts struct { Update func(v *View) Draw func(screen *ebiten.Image, frame geo.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 ¶
type MouseEnterLeaveHandler interface { // HandleMouseEnter handles the mouse enter. HandleMouseEnter(x, y int) bool // HandleMouseLeave handles the mouse leave. HandleMouseLeave() }
MouseEnterLeaveHandler represets a component that handle mouse enter.
type MouseHandler ¶
type MouseHandler interface { // HandleMouse handles the much move and returns true if it handles 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 // HandleJustReleasedMouseButtonLeft 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 ¶
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 ¶
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 float64 Height float64 // Handler is the handler for the root view. Handler Handler }
ParseOptions represents options for parsing HTML.
type SwipeDirection ¶
type SwipeDirection int
SwipeDirection represents different swipe directions.
const ( SwipeDirectionLeft SwipeDirection = iota SwipeDirectionRight SwipeDirectionUp SwipeDirectionDown )
type SwipeHandler ¶
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 ¶
type Updater interface { // Update updates the state of the component by one tick. Update(frame geo.Rectangle, v *View) }
Updater represents a component that updates by one tick.
type View ¶
type View struct { // TODO: Remove these fields in the future. Left float64 Right *float64 Top float64 Bottom *float64 Width float64 WidthInPct float64 Height float64 HeightInPct float64 MarginLeft float64 MarginTop float64 MarginRight float64 MarginBottom float64 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 ¶
func Parse(input string, opts *ParseOptions) *View
func (*View) Config ¶
func (v *View) Config() ViewConfig
func (*View) HandleJustPressedTouchID ¶
func (*View) HandleJustReleasedTouchID ¶
func (ct *View) HandleJustReleasedTouchID(touchID ebiten.TouchID, x, y int)
func (*View) MustGetByID ¶
MustGetByID returns the view with the specified id. It panics if not found.
func (*View) RemoveChild ¶
RemoveChild removes a specified view
func (*View) SetAlignContent ¶
func (v *View) SetAlignContent(alignContent AlignContent)
SetAlignContent sets the align content property of the view.
func (*View) SetAlignItems ¶
SetAlignItems sets the align items property of the view.
func (*View) SetDirection ¶
SetDirection sets the direction of the view.
func (*View) SetDisplay ¶
SetDisplay sets the display property of the view.
func (*View) SetJustify ¶
SetJustify sets the justify property of the view.
func (*View) SetMarginBottom ¶
SetMarginBottom sets the bottom margin of the view.
func (*View) SetMarginLeft ¶
SetMarginLeft sets the left margin of the view.
func (*View) SetMarginRight ¶
SetMarginRight sets the right margin of the view.
func (*View) SetMarginTop ¶
SetMarginTop sets the top margin of the view.
func (*View) SetPosition ¶
SetPosition sets the position of the view.
func (*View) UpdateWithSize ¶
UpdateWithSize the view with modified height and width
type ViewConfig ¶
type ViewConfig struct { TagName string ID string Left float64 Right *float64 Top float64 Bottom *float64 Width float64 Height float64 MarginLeft float64 MarginTop float64 MarginRight float64 MarginBottom float64 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 ¶
func (cfg ViewConfig) Tree() string