objects/heading.go
2024-08-14 11:45:10 -04:00

32 lines
911 B
Go

package objects
import "fmt"
import "git.tebibyte.media/tomo/tomo"
// Heading is a label that denotes the start of some section of content. It can
// have a level from 0 to 2, with 0 being the most prominent and 2 being the
// most subtle. The level is described in the role variation.
type Heading struct {
tomo.TextBox
}
// NewHeading creates a new section heading. The level can be from 0 to 2.
func NewHeading (level int, text string) *Heading {
if level < 0 { level = 0 }
if level > 2 { level = 2 }
this := &Heading { TextBox: tomo.NewTextBox() }
this.SetRole(tomo.R("objects", "Heading"))
this.SetTag(fmt.Sprint(level), true)
this.SetText(text)
this.SetSelectable(true)
this.SetFocusable(true)
return this
}
// NewMenuHeading creatss a new heading for use in menus.
func NewMenuHeading (text string) *Heading {
heading := NewHeading(0, text)
heading.SetTag("menu", true)
return heading
}