count

command
v0.0.0-...-b8644d8 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: Unlicense Imports: 6 Imported by: 0

README

Count – a simple Counter

UI for a simple counter

This little example is mainly about exploring a way of expressing the visual representation in a more concise way.

Building the View Tree

Gio is very flexible and it is possible to do anything related to UI graphics with it. However, building the visual tree assembles nested objects and function calls (often closures), which quickly becomes tedious.

One way of simplifying nested function calls is to make is possible to chain them. So instead of

    var my DomainObject

    Layout(context) dimensions {
        property1 := …
        container{axis: V}.Layout(context, property1) {
            widget1(context, &my),
            func(context) dimensions {
                property2 := …
                text := "…"
                return widget2(context, property2, text)
            }
        }
    }

we may prefer typing something like this:

    var my DomainObject

    layout().Content(
        container().Axis(V).Prop(…).Content(
            widget1().Bind(&my),
            widget2().Prop(…).Text("…")
        )
    )

(Both snippets in pseudo-code.)

Making it easier for users to create the widget tree requires reducing complexity by reducing options. It is necessary to strike a balance between flexibility and expressiveness. The HTML/CSS model is widely used and may be an adequate set of functionality. A requirement is, however, to always make it easy to opt out and fall back to Gio's full capacity.

Encapsulation

The counter box is a user-level component. It encapsulates widget behaviour and visuals in one place. Its interface is provided by a UI delegate binding to the domain object (a simple int in this case).

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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