uif2

package module
v2.0.0-...-c676ffa Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

README

UI Framework 2

STATUS: This is a early pre-alpha that I am still activily working on. Expect breaking API changes.

A thin client solution for building UIs.

Motivation

Writing a user interface in modern languages is kind of annoying. Hence there are 100s of UI libraries. UIF2 is my attempt to add to that with a UI library that I enjoy using.

UIF2 is a "thin client". As I was looking at different UI libraries there's an abundance of good solutions but each is focused on a single language.

  • In C++ you have plenty of choice. GTK+ and QT are the obvious cross-platform choices there. ImGUI is a little less obvious but it's a great solution for smaller experimental applications and development UIs.
  • In C# you have Windows Forms and WPF.
  • In Java you have Swing and JavaFX among others.
  • In Swift you have SwiftUI, Cocoa, and UIKit.
  • In Rust you have eGUI.

As soon as you move of that language the developer experience working with the UI library starts to fall down.

The goal of UIF2 is to take these UI libraries and make them available to everyone over a simple network boundary.

UIF was an earlier project of mine using Direct2D and gRPC. It was handy for prototyping until I started wanting more mature UI controls.

UIF2 solves that by switching to a cross-platform library (eGUI) with mature UI controls.

Architecture

UIF2 internally represents the UI as a element tree (like HTML and most other UIs). This element tree can be effectively manipulated by another process with a simple JSON based API.

Documentation

Index

Constants

View Source
const ROOT = 0xff_ff_ff_ff

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Root *Node
	// contains filtered or unexported fields
}

func Dial

func Dial() (*Client, error)

func (*Client) Flush

func (c *Client) Flush() error

type CmdAppendChild

type CmdAppendChild struct {
	ParentId uint32 `json:"parent_id"`
	ObjectId uint32 `json:"object_id"`
	Node     *Node  `json:"node"`
}

type CmdReplaceNode

type CmdReplaceNode struct {
	ObjectId uint32 `json:"object_id"`
	Node     *Node  `json:"node"`
}

type ComboBox

type ComboBox struct {
	Label     string   `json:"label"`
	Selected  string   `json:"selected"`
	Options   []string `json:"options"`
	OnChanged string   `json:"on_changed"`
	// contains filtered or unexported fields
}

func (*ComboBox) Append

func (n *ComboBox) Append(node NodeFuncs)

implements NodeFuncs

func (*ComboBox) Node

func (n *ComboBox) Node() *Node

func (*ComboBox) SetClient

func (n *ComboBox) SetClient(client *Client)

type EditCommand

type EditCommand struct {
	AppendChild *CmdAppendChild `json:",omitempty"`
	ReplaceNode *CmdReplaceNode `json:",omitempty"`
}

type EvClicked

type EvClicked struct {
	Id string `json:"id"`
}

type EvUpdate

type EvUpdate struct {
	Id       string `json:"id"`
	ObjectId uint32 `json:"object_id"`
	Node     Node   `json:"node"`
}

type Event

type Event struct {
	Update  *EvUpdate  `json:",omitempty"`
	Clicked *EvClicked `json:",omitempty"`
}

type Label

type Label struct {
	Text string `json:"text"`
	// contains filtered or unexported fields
}

func NewLabel

func NewLabel(text string) *Label

func (*Label) Append

func (n *Label) Append(node NodeFuncs)

implements NodeFuncs

func (*Label) Node

func (n *Label) Node() *Node

func (*Label) SetClient

func (n *Label) SetClient(client *Client)

func (*Label) SetText

func (n *Label) SetText(t string)

type Node

type Node struct {
	Label     *Label     `json:",omitempty"`
	TextInput *TextInput `json:",omitempty"`
	ComboBox  *ComboBox  `json:",omitempty"`
	// contains filtered or unexported fields
}

func (*Node) AddUpdateListener

func (n *Node) AddUpdateListener(evId string, cb func())

func (*Node) Append

func (n *Node) Append(node NodeFuncs)

func (*Node) Node

func (n *Node) Node() *Node

func (*Node) Replace

func (n *Node) Replace()

func (*Node) SetClient

func (n *Node) SetClient(client *Client)

type NodeFuncs

type NodeFuncs interface {
	SetClient(client *Client)
	Append(node NodeFuncs)
	Node() *Node
}

type TextInput

type TextInput struct {
	Text      string `json:"text"`
	OnChanged string `json:"on_changed"`
	// contains filtered or unexported fields
}

func NewTextInput

func NewTextInput() *TextInput

func (*TextInput) AddOnChanged

func (n *TextInput) AddOnChanged(cb func())

func (*TextInput) Append

func (n *TextInput) Append(node NodeFuncs)

implements NodeFuncs

func (*TextInput) Node

func (n *TextInput) Node() *Node

func (*TextInput) SetClient

func (n *TextInput) SetClient(client *Client)

type Transaction

type Transaction struct {
	ClientId string        `json:"client_id"`
	Edits    []EditCommand `json:"edits"`
}

Directories

Path Synopsis
samples
sink command

Jump to

Keyboard shortcuts

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