qml

package
v0.5.58 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertPosition

func AssertPosition(registry *BoundWidgetRegistry, id string, expectedX, expectedY, expectedW, expectedH float32, tolerance float32) string

AssertPosition checks if a widget is at the expected position (for tests)

func Convert

func Convert(qml string) (meui.Widget, error)

func ConvertFile

func ConvertFile(path string) (meui.Widget, error)

func CreateWidget

func CreateWidget(name string) (meui.Widget, error)

func DumpWidgetTree

func DumpWidgetTree(widget meui.Widget) string

DumpWidgetTree returns JSON representation of the widget tree with coordinates

func GetRegisteredWidgets

func GetRegisteredWidgets() []string

func GetWidgetPosition

func GetWidgetPosition(registry *BoundWidgetRegistry, id string) (x, y, w, h float32, found bool)

GetWidgetPosition returns the frame rect of a widget by ID from the registry

func GetWidgetProperties

func GetWidgetProperties(name string) []string

func HandleProperty

func HandleProperty(w meui.Widget, propName string, value interface{}) bool

HandleProperty dispatches a property to its registered handler. Returns true if the property was handled.

func IsValidProperty

func IsValidProperty(widgetType, propName string) bool

func LoadAndConvert

func LoadAndConvert(path string) (meui.Widget, error)

func Parse

func Parse(qml string) (meui.Widget, error)

func RegisterFlowWidget

func RegisterFlowWidget(name string, factory WidgetFactory, flowWrapper func() interface{}, properties []string)

RegisterFlowWidget registers a widget with a flow wrapper for reflection-based property setting.

func RegisterWidget

func RegisterWidget(name string, factory WidgetFactory, properties []string)

func SetFlowWrapper

func SetFlowWrapper(name string, fw func() interface{})

SetFlowWrapper attaches a flow wrapper factory to an already-registered widget.

func ValidateQML

func ValidateQML(obj *Object) error

Types

type AnchorJSON

type AnchorJSON struct {
	Fill     string  `json:"fill,omitempty"`     // parent, or ""
	CenterIn string  `json:"centerIn,omitempty"` // parent, or ""
	Left     string  `json:"left,omitempty"`
	Right    string  `json:"right,omitempty"`
	Top      string  `json:"top,omitempty"`
	Bottom   string  `json:"bottom,omitempty"`
	Margins  float32 `json:"margins,omitempty"`
}

AnchorJSON represents anchor settings on a widget

type BindingContext

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

func NewBindingContext

func NewBindingContext() *BindingContext

func (*BindingContext) ApplyBindings

func (ctx *BindingContext) ApplyBindings()

func (*BindingContext) RegisterObject

func (ctx *BindingContext) RegisterObject(obj *Object)

func (*BindingContext) ResolveProperty

func (ctx *BindingContext) ResolveProperty(obj *Object, propName string, value interface{}) (interface{}, bool)

type BoundWidget

type BoundWidget interface {
	SetBoundProperty(name string, value interface{})
}

BoundWidget interface for widgets that support property bindings

type BoundWidgetRegistry

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

func LoadFileResult

func LoadFileResult(path string) (*meui.Panel, *BoundWidgetRegistry, error)

func NewBoundWidgetRegistry

func NewBoundWidgetRegistry() *BoundWidgetRegistry

func (*BoundWidgetRegistry) ApplyBindings

func (r *BoundWidgetRegistry) ApplyBindings(ctx *BindingContext)

func (*BoundWidgetRegistry) Err

func (r *BoundWidgetRegistry) Err() error

Err returns the first duplicate-ID error encountered during Register.

func (*BoundWidgetRegistry) Get

Get retrieves a widget by ID from the registry

func (*BoundWidgetRegistry) Inject

func (r *BoundWidgetRegistry) Inject(model interface{}) error

Inject reads qml:"id" struct tags from model and populates fields from the registry. Returns an error if any referenced ID is missing or if a type mismatch occurs.

func (*BoundWidgetRegistry) Register

func (r *BoundWidgetRegistry) Register(id string, widget interface{})

Register stores a widget by QML id. Returns silently on duplicate id but records the error — call Err() after loading to check.

func (*BoundWidgetRegistry) RegisterFlow

func (r *BoundWidgetRegistry) RegisterFlow(id string, fw interface{})

RegisterFlow stores a flow wrapper alongside its widget by the same QML id.

type Object

type Object struct {
	Type       string
	ID         string
	Properties []Property
	Children   []*Object
	Parent     *Object // QML parent in the document tree
	Line       int     // source line number (1-based)
	Column     int     // source column (0-based)
}

func ParseQML

func ParseQML(qml string) (*Object, error)

type PropHandler

type PropHandler func(w meui.Widget, propName string, value interface{})

PropHandler is a function that applies a QML property to a widget.

type Property

type Property struct {
	Name  string
	Value interface{}
	Line  int // source line number (1-based)
	Col   int // source column (0-based)
}

type QMLResult

type QMLResult struct {
	Widget  meui.Widget
	Context *BindingContext
	Widgets *BoundWidgetRegistry
}

func Load

func Load(path string) (*QMLResult, error)

func LoadBundle added in v0.1.3

func LoadBundle(bundle *resources.Bundle, uri string) (*QMLResult, error)

LoadBundle reads a scene from a resources bundle, e.g. res://scenes/main.qml. Asset and file references inside the scene stay resource URIs (res://, meui://) and are resolved by the widgets when they load them.

func LoadFS added in v0.1.3

func LoadFS(fsys fs.FS, path string) (*QMLResult, error)

LoadFS reads a scene from any fs.FS. It does not rewrite references, so a caller that also wants resource-scheme assets should use LoadBundle.

func ParseWithBindings

func ParseWithBindings(qml string) (*QMLResult, error)

func ParseWithBindingsFile

func ParseWithBindingsFile(path string) (*QMLResult, error)

ParseWithBindingsFile reads a QML file and returns the full result with registry.

type WidgetEntry

type WidgetEntry struct {
	Name        string
	Factory     WidgetFactory
	FlowWrapper func() interface{} // returns a flow wrapper struct pointer
	Properties  []string
}

func GetEntry

func GetEntry(name string) *WidgetEntry

GetEntry returns the WidgetEntry for a given type name.

type WidgetFactory

type WidgetFactory func() meui.Widget

type WidgetJSON

type WidgetJSON struct {
	ID       string       `json:"id,omitempty"`
	Type     string       `json:"type"`
	X        float32      `json:"x"`
	Y        float32      `json:"y"`
	Width    float32      `json:"width"`
	Height   float32      `json:"height"`
	Debug    string       `json:"debug,omitempty"`
	Anchors  *AnchorJSON  `json:"anchors,omitempty"`
	Children []WidgetJSON `json:"children,omitempty"`
}

WidgetJSON represents a widget in the JSON tree dump

func FindWidgetByID

func FindWidgetByID(tree WidgetJSON, id string) *WidgetJSON

FindWidgetByID searches the JSON tree for a widget by ID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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