An easy way to write applications with Tomo.
Go to file
2024-08-24 14:43:48 -04:00
assets
config Move config spec into a README.md file for the config package. 2024-08-23 01:50:30 -04:00
internal Update styles in response to new focus method for MenuItem 2024-08-24 14:43:48 -04:00
.editorconfig Add editorconfig 2024-04-29 16:24:04 -04:00
application.go Improve doc comment for GlobalConfig 2024-08-23 01:14:08 -04:00
go.mod Update backend 2024-08-23 17:27:08 -04:00
go.sum Update backend 2024-08-23 17:27:08 -04:00
LICENSE
manager.go Windows must be manually managed through the WaitFor function 2024-08-20 23:20:30 -04:00
path_unix.go Add system dirs to path.go 2024-08-22 13:37:38 -04:00
path.go Improve doc comments for ApplicationSystem*Dirs 2024-08-23 02:27:49 -04:00
README.md Improve README.md 2024-08-23 02:23:04 -04:00

nasin

Go Reference

Nasin builds an application framework on top of Tomo to ease and encourage the development of consistent and stable application software. It has these wonderful features, and more:

  • Use the Application interface to create applications with relatively low boilerplate
  • CLI argument parsing and URI opening
  • Automatic setup/teardown of the backend
  • Advanced configuration system that can watch config files for changes
  • Default style and icon set, as well as a fully featured stylesheet language for creating custom styles, and support for XDG icon themes

Getting Started

Here is a basic "hello world" application, with explanations as comments:

package main

import "image"
import "git.tebibyte.media/tomo/nasin"
import "git.tebibyte.media/tomo/objects"
import "git.tebibyte.media/tomo/objects/layouts"

func main () {
	nasin.RunApplication(new(Application))
}

type Application struct { }

// Describe returns the application's name and ID, and optionally what type of
// application it is.
func (this *Application) Describe () nasin.ApplicationDescription {
	return nasin.ApplicationDescription {
		// This is the name of the application. New application windows
		// will have this as their title by default.
		Name: "Example",
		// This is a "well-known" name, which typically is a domain name
		// owned by the application author.
		ID: "com.example.Example",
	}
}

// Init performs initial setup of the application. Since this is a single-window
// application that doesn't open any files, we create the window here.
func (this *Application) Init () error {
	// Passing an empty rectangle when creating a new window will cause it
	// to auto-expand to fit the minimum size of its contents.
	window, err := nasin.NewApplicationWindow(this, image.Rectangle { })
	if err != nil { return err }
	// Here we create a new container with a basic vertical layout, place a
	// text label that says "Hello world!" in it, and set it as the root
	// object of the window.
	window.SetRoot(objects.NewOuterContainer (
		layouts.ContractVertical,
		objects.NewLabel("Hello world!")))
	window.SetVisible(true)
	// Nasin will not exit until all windows it is "waiting for" have
	// been closed.
	nasin.WaitFor(window)
	return nil
}

// Stop cleanly closes things like system resources or background tasks. We do
// not have any here, so nothing is done.
func (this *Application) Stop () { }

To learn more, take a look at the examples directory and the online documentation.

  • Tomo API: The API that all other parts of the toolkit agree on
  • Objects: A standard collection of re-usable objects and other GUI components
  • Backend: The software responsible for managing and rendering things behind the scenes