objects/heading.go

32 lines
911 B
Go
Raw Normal View History

2023-08-10 15:52:01 -06:00
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 {
2023-08-10 15:52:01 -06:00
if level < 0 { level = 0 }
if level > 2 { level = 2 }
this := &Heading { TextBox: tomo.NewTextBox() }
2024-07-21 09:48:28 -06:00
this.SetRole(tomo.R("objects", "Heading"))
this.SetTag(fmt.Sprint(level), true)
2023-08-10 15:52:01 -06:00
this.SetText(text)
2024-07-26 19:00:53 -06:00
this.SetSelectable(true)
this.SetFocusable(true)
2023-08-10 15:52:01 -06:00
return this
}
2024-08-14 09:45:10 -06:00
// NewMenuHeading creatss a new heading for use in menus.
func NewMenuHeading (text string) *Heading {
heading := NewHeading(0, text)
heading.SetTag("menu", true)
return heading
}