Back to godoc.org
github.com/BigJk/ramen / components

Package components

v0.0.0-...-e4b01fe
Latest Go to latest

The latest major version is .

Published: Nov 12, 2019 | License: Apache-2.0 | Module: github.com/BigJk/ramen

Index

Constants

const (
	// ComponentIdle means the component is neither clicked not hovered over.
	ComponentIdle = ComponentState(0)
	// ComponentHovered means the component is hovered over
	ComponentHovered = ComponentState(1)
	// ComponentClicked means the component is hovered over and the left mouse button is currently pressed.
	ComponentClicked = ComponentState(2)
)

type Button

type Button struct {
	*console.ComponentBase
	// contains filtered or unexported fields
}

Button represents a button that you can click.

func NewButton

func NewButton(x, y, width, height int, text string, callback ClickedCallback) *Button

NewButton creates a new button at the given position, size and text.

func (*Button) Draw

func (b *Button) Draw(con *console.Console, timeElapsed float64)

Draw draws the button

func (*Button) FocusOnClick

func (b *Button) FocusOnClick() bool

FocusOnClick returns true if a click should focus the button

func (*Button) SetBackground

func (b *Button) SetBackground(bg, bgHover, bgClicked *consolecolor.Color)

SetBackground sets the background colors for the button states. Parameters that are nil will be ignored and not set.

func (*Button) SetForeground

func (b *Button) SetForeground(f, fHover, fClicked *consolecolor.Color)

SetForeground sets the foreground colors for the button states. Parameters that are nil will be ignored and not set.

func (*Button) Update

func (b *Button) Update(con *console.Console, timeElapsed float64) bool

Update updates the button

type ClickedCallback

type ClickedCallback func()

ClickedCallback will be called if a click on the component happened.

type ComponentState

type ComponentState int

ComponentState represents generic states that components can use to define logic.

func CalculateComponentState

func CalculateComponentState(con *console.Console, x, y, w, h int) ComponentState

CalculateComponentState is generic helper function to calculate the state of a given area in the console.

type EnterCallback

type EnterCallback func()

EnterCallback will be called if the enter key has been pressed.

type TextBox

type TextBox struct {
	*console.ComponentBase
	// contains filtered or unexported fields
}

TextBox represents a box that you can type in.

func NewTextbox

func NewTextbox(x, y, width, height int) *TextBox

NewTextbox creates a new textbox at the given position and size.

func (*TextBox) Draw

func (tb *TextBox) Draw(con *console.Console, timeElapsed float64)

Draw draws the textbox.

func (*TextBox) FocusOnClick

func (tb *TextBox) FocusOnClick() bool

FocusOnClick returns true if a click should focus the textbox

func (*TextBox) GetText

func (tb *TextBox) GetText() string

GetText returns the text of the textbox.

func (*TextBox) SetBackground

func (tb *TextBox) SetBackground(bg, bgHover, bgClicked *consolecolor.Color)

SetBackground sets the background colors for textbox. Parameters that are nil will be ignored and not set.

func (*TextBox) SetEnterCallback

func (tb *TextBox) SetEnterCallback(callback EnterCallback)

SetEnterCallback sets the enter callback.

func (*TextBox) SetForeground

func (tb *TextBox) SetForeground(f, fInactive *consolecolor.Color)

SetForeground sets the foreground colors for the textbox states. Parameters that are nil will be ignored and not set.

func (*TextBox) SetText

func (tb *TextBox) SetText(newText string)

SetText changes the text of the textbox.

func (*TextBox) SetTextChanged

func (tb *TextBox) SetTextChanged(callback TextChangeCallback)

SetTextChanged sets the text change callback.

func (*TextBox) Update

func (tb *TextBox) Update(con *console.Console, timeElapsed float64) bool

Update updates the textbox.

type TextChangeCallback

type TextChangeCallback func(text string)

TextChangeCallback will be called if a text of the component has been changed.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier