Did a lot of work off-repo, basically init

This commit is contained in:
Luke I. Wilson
2021-03-11 13:27:35 -06:00
parent 2e9b2ad2b1
commit d0bb43cc8f
16 changed files with 1788 additions and 0 deletions

39
ui/component.go Normal file
View File

@@ -0,0 +1,39 @@
package ui
import (
"github.com/gdamore/tcell/v2"
)
// A Component refers generally to the behavior of a UI "component". Components
// include buttons, input fields, and labels. It is expected that after constructing
// a component, to call the SetPos() function, and possibly SetSize() as well.
//
// Many components implement their own `New...()` function. In those constructor
// functions, it is good practice for that component to set its size to be its
// minimum size. TODO: implement that behavior
type Component interface {
// A component knows its position and size, which is used to draw itself in
// its bounding rectangle.
Draw(tcell.Screen)
// Components can be focused, which may affect how it handles events. For
// example, when a button is focused, the Return key may be pressed to
// activate the button.
SetFocused(bool)
// Applies the theme to the component and all of its children.
SetTheme(*Theme)
// Get position of the Component.
GetPos() (int, int)
// Set position of the Component.
SetPos(int, int)
// Returns the smallest size the Component can be.
GetMinSize() (int, int)
// Get size of the Component.
GetSize() (int, int)
// Set size of the component. If size is smaller than minimum, minimum is
// used, instead.
SetSize(int, int)
tcell.EventHandler // A Component can handle events
}