glacier

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 1 Imported by: 0

README

Simple Layout Library in Go

Why?

Layout is very overtly complicated. So why not make a layout calculation library that uses weights and ratios for things?

How it works

Pretty much check the example, but basically:

import (
	g "codeberg.org/pingwt/glacier"
)

func main() {
	// layout map is just a hashmap to look up your layouts
	lm := make(g.LayoutMap)

	// you can make a root as a Col layout to store things,
	// then here we have top (calculated first) and bottom (calculated second)
	root := g.NewLayout(lm, "root", g.Col, 0, 1)
	g.NewLayout(lm, "top", g.Row, 0, 1)
	g.NewLayout(lm, "bot", g.Row, 1, 1)


	// and we can add those into root and update it
	root.Children = g.Children{lm["top"], lm["bot"]}
	root.W = 800
	root.H = 600
	root.Update()

	// now you can query the outputs
	botW := lm["bot"].W //should return 800 still
	botH := lm["bot"].H //should return 300 as we split root into two equal weights
}

And then you can use the X,Y,W,H calculation in your favorite UI library.

Inspiration

Naming comes from Go+Layout so glay just like the clay C UI/Layout library but then it's extra play-on-word with glay-cier -> glacier

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Children

type Children []*Layout

A child of a layout will be sized depending on its parent

type Direction

type Direction int
const (
	// Horizontally, left->right
	Hr Direction = iota
	// Vertically, up->down
	Vt
)

type Layout

type Layout struct {
	ID                 string
	Direction          Direction
	Visible            bool
	Order              int
	Weight, X, Y, W, H float32
	Children           Children
}

The base struct for everything in glacier

func NewLayout

func NewLayout(lm LayoutMap, id string, d Direction, order int, weight float32) *Layout

func (*Layout) Update

func (l *Layout) Update()

Recalculates the sizing of a layout

type LayoutMap

type LayoutMap map[string]*Layout

A layout map contains pointers to all the layouts so that you can look them up easily

Directories

Path Synopsis
examples
basic command

Jump to

Keyboard shortcuts

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