Document all tags and named sub-components

Closes #9
This commit is contained in:
Sasha Koshka 2024-08-25 02:36:05 -04:00
parent a688e2dc24
commit 30d4e208b1
11 changed files with 80 additions and 5 deletions

View File

@ -12,6 +12,9 @@ var iconButtonLayout = layouts.Row { true }
var bothButtonLayout = layouts.Row { false, true } var bothButtonLayout = layouts.Row { false, true }
// Button is a clickable button. // Button is a clickable button.
//
// Tags:
// - [icon] The button has an icon.
type Button struct { type Button struct {
box tomo.ContainerBox box tomo.ContainerBox

View File

@ -10,6 +10,16 @@ var _ tomo.Object = new(Calendar)
// Calendar is an object that can display a date and allow the user to change // Calendar is an object that can display a date and allow the user to change
// it. It can display one month at a time. // it. It can display one month at a time.
//
// Sub-components:
// - CalendarGrid organizes the days into a grid.
// - CalendarWeekdayHeader appears at the top of each grid column, and shows
// the day of the week that column represents.
// - CalendarDay appears within the grid for each day of the current month.
//
// CalendarDay tags:
// - [weekend] The day is a weekend.
// - [weekday] The day is a weekday.
type Calendar struct { type Calendar struct {
box tomo.ContainerBox box tomo.ContainerBox

View File

@ -7,6 +7,10 @@ import "git.tebibyte.media/tomo/tomo/event"
var _ tomo.Object = new(Checkbox) var _ tomo.Object = new(Checkbox)
// Checkbox is a control that can be toggled. // Checkbox is a control that can be toggled.
//
// Tags:
// - [checked] The checkbox's value is true.
// - [unchecked] The checkbox's value is false.
type Checkbox struct { type Checkbox struct {
box tomo.Box box tomo.Box
value bool value bool

View File

@ -12,6 +12,10 @@ var _ tomo.Object = new(HSVAColorPicker)
// HSVAColorPicker allows the user to pick a color by controlling its HSVA // HSVAColorPicker allows the user to pick a color by controlling its HSVA
// parameters. // parameters.
//
// Sub-components:
// - ColorPickerMap is a recangular control where the X axis controls
// saturation and the Y axis controls value.
type HSVAColorPicker struct { type HSVAColorPicker struct {
box tomo.ContainerBox box tomo.ContainerBox
value internal.HSVA value internal.HSVA

View File

@ -10,9 +10,14 @@ var _ tomo.ContentObject = new(Container)
// primitive for building more complex layouts. It has two main variants: an // primitive for building more complex layouts. It has two main variants: an
// outer container, and an inner container. The outer container has padding // outer container, and an inner container. The outer container has padding
// around its edges, whereas the inner container does not. It also has a // around its edges, whereas the inner container does not. It also has a
// "sunken" variation designed to hold a scrolled list of items. The container // "sunken" variation designed to hold a scrolled list of items.
// will have a corresponding object role variation of either "outer", "inner", //
// or "sunken". // Tags:
// - [outer] The container is the root of a window.
// - [inner] The container is within another container, and is part of a
// larger layout.
// - [sunken] The container holds a visually grouped, usually scrolled, list
// of items.
type Container struct { type Container struct {
box tomo.ContainerBox box tomo.ContainerBox
} }

View File

@ -9,7 +9,12 @@ var _ tomo.Object = new(Heading)
// Heading is a label that denotes the start of some section of content. It can // 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 // 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. // most subtle.
//
// Tags:
// - [0] The heading has a level of 0 (most prominent).
// - [1] The heading has a level of 1.
// - [2] The heading has a level of 2 (least prominent).
type Heading struct { type Heading struct {
box tomo.TextBox box tomo.TextBox
} }

View File

@ -6,6 +6,11 @@ import "git.tebibyte.media/tomo/tomo/canvas"
var _ tomo.Object = new(Icon) var _ tomo.Object = new(Icon)
// Icon displays a single icon. // Icon displays a single icon.
//
// Tags:
// - [large] The icon is large sized.
// - [medium] The icon is medium sized.
// - [small] The icon is small sized.
type Icon struct { type Icon struct {
box tomo.Box box tomo.Box
icon tomo.Icon icon tomo.Icon

View File

@ -7,6 +7,10 @@ import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/objects/layouts" import "git.tebibyte.media/tomo/objects/layouts"
// Menu is a menu window. // Menu is a menu window.
//
// Sub-components:
// - TearLine is a horizontal line at the top of the menu that, when clicked,
// causes the menu to be "torn off" into a movable window.
type Menu struct { type Menu struct {
tomo.Window tomo.Window

View File

@ -9,6 +9,17 @@ var _ tomo.Object = new(Scrollbar)
// Scrollbar is a special type of slider that can control the scroll of any // Scrollbar is a special type of slider that can control the scroll of any
// overflowing ContainerObject. // overflowing ContainerObject.
//
// Sub-components:
// - ScrollbarHandle is the grabbable handle of the scrollbar.
//
// Tags:
// - [vertical] The scrollbar is oriented vertically.
// - [horizontall] The scrollbar is oriented horizontally.
//
// ScrollbarHandle tags:
// - [vertical] The handle is oriented vertically.
// - [horizontall] The handle is oriented horizontally.
type Scrollbar struct { type Scrollbar struct {
box tomo.ContainerBox box tomo.ContainerBox
handle *sliderHandle handle *sliderHandle

View File

@ -9,6 +9,17 @@ import "git.tebibyte.media/tomo/tomo/event"
var _ tomo.Object = new(Slider) var _ tomo.Object = new(Slider)
// Slider is a control that selects a numeric value between 0 and 1. // Slider is a control that selects a numeric value between 0 and 1.
//
// Sub-components:
// - SliderHandle is the grabbable handle of the slider.
//
// Tags:
// - [vertical] The slider is oriented vertically.
// - [horizontall] The slider is oriented horizontally.
//
// SliderHandle tags:
// - [vertical] The handle is oriented vertically.
// - [horizontall] The handle is oriented horizontally.
type Slider struct { type Slider struct {
box tomo.ContainerBox box tomo.ContainerBox
handle *sliderHandle handle *sliderHandle

View File

@ -8,6 +8,19 @@ var _ tomo.Object = new(TabbedContainer)
// TabbedContainer holds multiple objects, each in their own tab. The user can // TabbedContainer holds multiple objects, each in their own tab. The user can
// click the tab bar at the top to choose which one is activated. // click the tab bar at the top to choose which one is activated.
//
// Sub-components:
// - TabRow sits at the top of the container and contains a row of tabs.
// - TabSpacer sits at either end of the tab row, bookending the list of tabs.
// - Tab appears in the tab row for each tab in the container. The user can
// click on the tab to switch to it.
//
// TabSpacer tags:
// - [left] The spacer is on the left.
// - [right] The spacer is on the right.
//
// Tab tags:
// - [active] The tab is currently active and its contents are visible.
type TabbedContainer struct { type TabbedContainer struct {
box tomo.ContainerBox box tomo.ContainerBox
@ -35,7 +48,7 @@ func NewTabbedContainer () *TabbedContainer {
tabbedContainer.leftSpacer.SetTag("left", true) tabbedContainer.leftSpacer.SetTag("left", true)
tabbedContainer.rightSpacer = tomo.NewBox() tabbedContainer.rightSpacer = tomo.NewBox()
tabbedContainer.rightSpacer.SetRole(tomo.R("objects", "TabSpacer")) tabbedContainer.rightSpacer.SetRole(tomo.R("objects", "TabSpacer"))
tabbedContainer.rightSpacer.SetTag("left", true) tabbedContainer.rightSpacer.SetTag("left", true) // FIXME
tabbedContainer.ClearTabs() tabbedContainer.ClearTabs()
tabbedContainer.setTabRowLayout() tabbedContainer.setTabRowLayout()