From 30d4e208b1d16aee805ce7b3e504fb5b7e0f270b Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 25 Aug 2024 02:36:05 -0400 Subject: [PATCH] Document all tags and named sub-components Closes #9 --- button.go | 3 +++ calendar.go | 10 ++++++++++ checkbox.go | 4 ++++ colorpicker.go | 4 ++++ container.go | 11 ++++++++--- heading.go | 7 ++++++- icon.go | 5 +++++ menu.go | 4 ++++ scrollbar.go | 11 +++++++++++ slider.go | 11 +++++++++++ tabbedcontainer.go | 15 ++++++++++++++- 11 files changed, 80 insertions(+), 5 deletions(-) diff --git a/button.go b/button.go index 3ed6655..94aec44 100644 --- a/button.go +++ b/button.go @@ -12,6 +12,9 @@ var iconButtonLayout = layouts.Row { true } var bothButtonLayout = layouts.Row { false, true } // Button is a clickable button. +// +// Tags: +// - [icon] The button has an icon. type Button struct { box tomo.ContainerBox diff --git a/calendar.go b/calendar.go index a6739ee..f5ebda0 100644 --- a/calendar.go +++ b/calendar.go @@ -10,6 +10,16 @@ var _ tomo.Object = new(Calendar) // Calendar is an object that can display a date and allow the user to change // 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 { box tomo.ContainerBox diff --git a/checkbox.go b/checkbox.go index e8ffacd..47b9725 100644 --- a/checkbox.go +++ b/checkbox.go @@ -7,6 +7,10 @@ import "git.tebibyte.media/tomo/tomo/event" var _ tomo.Object = new(Checkbox) // 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 { box tomo.Box value bool diff --git a/colorpicker.go b/colorpicker.go index fc452ee..a848e3d 100644 --- a/colorpicker.go +++ b/colorpicker.go @@ -12,6 +12,10 @@ var _ tomo.Object = new(HSVAColorPicker) // HSVAColorPicker allows the user to pick a color by controlling its HSVA // parameters. +// +// Sub-components: +// - ColorPickerMap is a recangular control where the X axis controls +// saturation and the Y axis controls value. type HSVAColorPicker struct { box tomo.ContainerBox value internal.HSVA diff --git a/container.go b/container.go index 93dadc5..5b75025 100644 --- a/container.go +++ b/container.go @@ -10,9 +10,14 @@ var _ tomo.ContentObject = new(Container) // primitive for building more complex layouts. It has two main variants: an // outer container, and an inner container. The outer container has padding // 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 -// will have a corresponding object role variation of either "outer", "inner", -// or "sunken". +// "sunken" variation designed to hold a scrolled list of items. +// +// 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 { box tomo.ContainerBox } diff --git a/heading.go b/heading.go index 6610027..3b42784 100644 --- a/heading.go +++ b/heading.go @@ -9,7 +9,12 @@ var _ tomo.Object = new(Heading) // 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. +// 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 { box tomo.TextBox } diff --git a/icon.go b/icon.go index c3a2a70..aa152bf 100644 --- a/icon.go +++ b/icon.go @@ -6,6 +6,11 @@ import "git.tebibyte.media/tomo/tomo/canvas" var _ tomo.Object = new(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 { box tomo.Box icon tomo.Icon diff --git a/menu.go b/menu.go index 19db5ce..09957e0 100644 --- a/menu.go +++ b/menu.go @@ -7,6 +7,10 @@ import "git.tebibyte.media/tomo/tomo/input" import "git.tebibyte.media/tomo/objects/layouts" // 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 { tomo.Window diff --git a/scrollbar.go b/scrollbar.go index 1a78742..2e6202d 100644 --- a/scrollbar.go +++ b/scrollbar.go @@ -9,6 +9,17 @@ var _ tomo.Object = new(Scrollbar) // Scrollbar is a special type of slider that can control the scroll of any // 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 { box tomo.ContainerBox handle *sliderHandle diff --git a/slider.go b/slider.go index 0723b49..24e15ff 100644 --- a/slider.go +++ b/slider.go @@ -9,6 +9,17 @@ import "git.tebibyte.media/tomo/tomo/event" var _ tomo.Object = new(Slider) // 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 { box tomo.ContainerBox handle *sliderHandle diff --git a/tabbedcontainer.go b/tabbedcontainer.go index a8df8b9..7ff95e7 100644 --- a/tabbedcontainer.go +++ b/tabbedcontainer.go @@ -8,6 +8,19 @@ var _ tomo.Object = new(TabbedContainer) // 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. +// +// 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 { box tomo.ContainerBox @@ -35,7 +48,7 @@ func NewTabbedContainer () *TabbedContainer { tabbedContainer.leftSpacer.SetTag("left", true) tabbedContainer.rightSpacer = tomo.NewBox() tabbedContainer.rightSpacer.SetRole(tomo.R("objects", "TabSpacer")) - tabbedContainer.rightSpacer.SetTag("left", true) + tabbedContainer.rightSpacer.SetTag("left", true) // FIXME tabbedContainer.ClearTabs() tabbedContainer.setTabRowLayout()