widgets

package
v0.0.0-...-328342c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2016 License: BSD-2-Clause Imports: 16 Imported by: 0

Documentation

Overview

Copyright (c) 2016, redstarcoder

Copyright (c) 2016, redstarcoder

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Button

type Button struct {
	// contains filtered or unexported fields
}

func NewButton

func NewButton(gc *draw2d.GraphicContext, window, offscreen *glfw.Window, x, y float64, text string) *Button

func (*Button) CharPress

func (btn *Button) CharPress(char rune) draw2dui.Event

CharPress returns draw2dui.EventNone

func (*Button) Draw

func (btn *Button) Draw(selected, forceRedraw bool)

Draw draws the widget, selected determines if the widget displays as selected or not, and forceRedraw forces a full redraw of the widget. TODO draw dotted border if selected

func (*Button) GetData

func (btn *Button) GetData() interface{}

GetData returns nil

func (*Button) GetDimensions

func (btn *Button) GetDimensions() (float64, float64)

GetDimensions returns btn's drawn width and height

func (*Button) GetEnabled

func (btn *Button) GetEnabled() bool

GetEnabled returns whether the widget is enabled or not

func (*Button) GetInt

func (btn *Button) GetInt() int

GetInt returns -1

func (*Button) GetPos

func (btn *Button) GetPos() (float64, float64)

GetPos retrieves the widget's x, y coordinates

func (*Button) GetString

func (btn *Button) GetString() string

GetString returns btn's text

func (*Button) Handle

func (btn *Button) Handle(selected bool) bool

Handle returns false

func (*Button) IsInside

func (btn *Button) IsInside(x, y float64) bool

IsInside checks if point x, y is inside of the widget's boundaries. It uses btn.offscreen as a pallet

func (*Button) KeyPress

func (btn *Button) KeyPress(key glfw.Key, action glfw.Action, mods glfw.ModifierKey) draw2dui.Event

KeyPress has the widget process a KeyPress event

func (*Button) MClick

func (btn *Button) MClick(xpos, ypos float64, button glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey) draw2dui.Event

MClick has the widget process a MouseClick event

func (*Button) MMove

func (btn *Button) MMove(xpos, ypos float64) draw2dui.Event

MMove has the widget process a MouseMove event

func (*Button) Name

func (btn *Button) Name() string

Name returns btn's name

func (*Button) SetData

func (btn *Button) SetData(d interface{})

SetData does nothing

func (*Button) SetDimensions

func (btn *Button) SetDimensions(w, h float64)

SetDimensions sets btn's drawn width and height

func (*Button) SetEnabled

func (btn *Button) SetEnabled(enabled bool)

SetEnabled enables or disables the widget

func (*Button) SetInt

func (btn *Button) SetInt(i int)

SetInt does nothing

func (*Button) SetPos

func (btn *Button) SetPos(x, y float64)

SetPos changes the widget's x, y coordinates

func (*Button) SetString

func (btn *Button) SetString(s string)

SetString sets btn's text, using btn.maxlen as the max length

type Cursor

type Cursor struct {
	// contains filtered or unexported fields
}

TODO calculate iEdge & iOffset using something like MoveToX

func (*Cursor) Backspace

func (c *Cursor) Backspace() bool
func (c *Cursor) Blink() (redraw bool)

func (*Cursor) GenLines

func (c *Cursor) GenLines(_gc draw2d.GraphicContext, width float64)

func (*Cursor) Insert

func (c *Cursor) Insert(s string)

func (*Cursor) InsertLine

func (c *Cursor) InsertLine(s string)

GenLines must be called after

func (*Cursor) MoveLeft

func (c *Cursor) MoveLeft() bool

TODO Make MoveLeft and MoveRight take a parameter

func (*Cursor) MoveRight

func (c *Cursor) MoveRight() bool

func (*Cursor) MoveTo

func (c *Cursor) MoveTo(i int) bool

func (*Cursor) MoveToX

func (c *Cursor) MoveToX(_gc draw2d.GraphicContext, x, mx, width float64)

type Label

type Label struct {
	// contains filtered or unexported fields
}

func NewLabel

func NewLabel(gc *draw2d.GraphicContext, window, offscreen *glfw.Window, x, y float64, text string) *Label

func (*Label) CharPress

func (lbl *Label) CharPress(char rune) draw2dui.Event

CharPress returns draw2dui.EventNone

func (*Label) Draw

func (lbl *Label) Draw(selected, forceRedraw bool)

Draw draws the widget, selected determines if the widget displays as selected or not, and forceRedraw forces a full redraw of the widget.

func (*Label) GetData

func (lbl *Label) GetData() interface{}

GetData returns nil

func (*Label) GetDimensions

func (lbl *Label) GetDimensions() (float64, float64)

GetDimensions returns lbl's drawn width and height

func (*Label) GetEnabled

func (lbl *Label) GetEnabled() bool

GetEnabled returns true

func (*Label) GetInt

func (lbl *Label) GetInt() int

GetInt returns -1

func (*Label) GetPos

func (lbl *Label) GetPos() (float64, float64)

GetPos retrieves the widget's x, y coordinates

func (*Label) GetString

func (lbl *Label) GetString() string

GetString returns lbl's text

func (*Label) Handle

func (lbl *Label) Handle(selected bool) bool

Handle returns false

func (*Label) IsInside

func (lbl *Label) IsInside(x, y float64) bool

IsInside checks if point x, y is inside of the widget's boundaries. It uses lbl.offscreen as a pallet

func (*Label) KeyPress

func (lbl *Label) KeyPress(key glfw.Key, action glfw.Action, mods glfw.ModifierKey) draw2dui.Event

KeyPress returns draw2dui.EventNone

func (*Label) MClick

func (lbl *Label) MClick(xpos, ypos float64, button glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey) draw2dui.Event

MClick returns draw2dui.EventNone

func (*Label) MMove

func (lbl *Label) MMove(xpos, ypos float64) draw2dui.Event

MMove returns draw2dui.EventNone

func (*Label) Name

func (lbl *Label) Name() string

Name returns lbl's name

func (*Label) SetData

func (lbl *Label) SetData(d interface{})

SetData does nothing

func (*Label) SetDimensions

func (lbl *Label) SetDimensions(w, h float64)

SetDimensions sets lbl's drawn width and height

func (*Label) SetEnabled

func (lbl *Label) SetEnabled(enabled bool)

SetEnabled does nothing

func (*Label) SetInt

func (lbl *Label) SetInt(i int)

SetInt does nothing

func (*Label) SetPos

func (lbl *Label) SetPos(x, y float64)

SetPos changes the widget's x, y coordinates

func (*Label) SetString

func (lbl *Label) SetString(s string)

SetString sets lbl's text

type TextBox

type TextBox struct {
	// contains filtered or unexported fields
}

TODO text highlighting

func NewTextBox

func NewTextBox(gc *draw2d.GraphicContext, window, offscreen *glfw.Window, x, y, width, height float64, text string) *TextBox

NewTextBox creates a new TextBox widget BUG(x) TextBox does not support enabled state BUG(x) TextBox default is disabled, should be enabled BUG(x) TextBox should have a scrollbar BUG(x) TextBox text wrapping should be optional

func (*TextBox) CharPress

func (tb *TextBox) CharPress(char rune) draw2dui.Event

CharPress adds a character to the TextBox

func (*TextBox) Draw

func (tb *TextBox) Draw(selected, forceRedraw bool)

Draw draws the widget, selected determines if the widget displays as selected or not, and forceRedraw forces a full redraw of the widget.

func (*TextBox) GetData

func (tb *TextBox) GetData() interface{}

GetData returns nil

func (*TextBox) GetDimensions

func (tb *TextBox) GetDimensions() (float64, float64)

GetDimensions returns tf's drawn width and height

func (*TextBox) GetEnabled

func (tb *TextBox) GetEnabled() bool

GetEnabled returns whether the widget is enabled or not

func (*TextBox) GetInt

func (tb *TextBox) GetInt() int

GetInt returns tf's text cursor's position

func (*TextBox) GetPos

func (tb *TextBox) GetPos() (float64, float64)

GetPos retrieves the widget's x, y coordinates

func (*TextBox) GetString

func (tb *TextBox) GetString() string

GetString returns tf's text BUG(x) needs to rebuild cursor.text from cursor.textLines

func (*TextBox) Handle

func (tb *TextBox) Handle(selected bool) bool

Handle processes tf's cursor

func (*TextBox) InsertLine

func (tb *TextBox) InsertLine(s string)

func (*TextBox) IsInside

func (tb *TextBox) IsInside(x, y float64) bool

IsInside checks if point x, y is inside of the widget's boundaries. It uses tb.offscreen as a pallet

func (*TextBox) KeyPress

func (tb *TextBox) KeyPress(key glfw.Key, action glfw.Action, mods glfw.ModifierKey) draw2dui.Event

KeyPress has the widget process a KeyPress event

func (*TextBox) MClick

func (tb *TextBox) MClick(xpos, ypos float64, button glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey) draw2dui.Event

MClick has the widget process a MouseClick event

func (*TextBox) MMove

func (tb *TextBox) MMove(xpos, ypos float64) draw2dui.Event

MMove has the widget process a MouseMove event

func (*TextBox) Name

func (tb *TextBox) Name() string

Name returns tf's name

func (*TextBox) SetData

func (tb *TextBox) SetData(d interface{})

SetData does nothing

func (*TextBox) SetDimensions

func (tb *TextBox) SetDimensions(w, h float64)

SetDimensions sets tf's drawn width and height

func (*TextBox) SetEnabled

func (tb *TextBox) SetEnabled(enabled bool)

SetEnabled enables or disables the widget

func (*TextBox) SetInt

func (tb *TextBox) SetInt(i int)

SetInt moves tf's text cursor

func (*TextBox) SetPos

func (tb *TextBox) SetPos(x, y float64)

SetPos changes the widget's x, y coordinates

func (*TextBox) SetString

func (tb *TextBox) SetString(s string)

SetString sets tf's text, using tb.maxlen as the max length

type TextField

type TextField struct {
	// contains filtered or unexported fields
}

TODO text highlighting

func NewTextField

func NewTextField(gc *draw2d.GraphicContext, window, offscreen *glfw.Window, x, y, width float64, text string, maxlen int) *TextField

NewTextField creates a new TextField widget

func (*TextField) CharPress

func (tf *TextField) CharPress(char rune) draw2dui.Event

CharPress adds a character to the textfield

func (*TextField) Draw

func (tf *TextField) Draw(selected, forceRedraw bool)

Draw draws the widget, selected determines if the widget displays as selected or not, and forceRedraw forces a full redraw of the widget.

func (*TextField) GetData

func (tf *TextField) GetData() interface{}

GetData returns nil

func (*TextField) GetDimensions

func (tf *TextField) GetDimensions() (float64, float64)

GetDimensions returns tf's drawn width and height

func (*TextField) GetEnabled

func (tf *TextField) GetEnabled() bool

GetEnabled returns whether the widget is enabled or not

func (*TextField) GetInt

func (tf *TextField) GetInt() int

GetInt returns tf's text cursor's position

func (*TextField) GetPos

func (tf *TextField) GetPos() (float64, float64)

GetPos retrieves the widget's x, y coordinates

func (*TextField) GetString

func (tf *TextField) GetString() string

GetString returns tf's text

func (*TextField) Handle

func (tf *TextField) Handle(selected bool) bool

Handle processes tf's cursor

func (*TextField) IsInside

func (tf *TextField) IsInside(x, y float64) bool

IsInside checks if point x, y is inside of the widget's boundaries. It uses tf.offscreen as a pallet

func (*TextField) KeyPress

func (tf *TextField) KeyPress(key glfw.Key, action glfw.Action, mods glfw.ModifierKey) draw2dui.Event

KeyPress has the widget process a KeyPress event

func (*TextField) MClick

func (tf *TextField) MClick(xpos, ypos float64, button glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey) draw2dui.Event

MClick has the widget process a MouseClick event

func (*TextField) MMove

func (tf *TextField) MMove(xpos, ypos float64) draw2dui.Event

MMove has the widget process a MouseMove event

func (*TextField) Name

func (tf *TextField) Name() string

Name returns tf's name

func (*TextField) SetData

func (tf *TextField) SetData(d interface{})

SetData does nothing

func (*TextField) SetDimensions

func (tf *TextField) SetDimensions(w, h float64)

SetDimensions sets tf's drawn width and height

func (*TextField) SetEnabled

func (tf *TextField) SetEnabled(enabled bool)

SetEnabled enables or disables the widget

func (*TextField) SetInt

func (tf *TextField) SetInt(i int)

SetInt moves tf's text cursor

func (*TextField) SetPos

func (tf *TextField) SetPos(x, y float64)

SetPos changes the widget's x, y coordinates

func (*TextField) SetString

func (tf *TextField) SetString(s string)

SetString sets tf's text, using tf.maxlen as the max length

Notes

Bugs

  • loadCurrentFont should take a GraphicContext interface

  • TextBox does not support enabled state

  • TextBox default is disabled, should be enabled

  • TextBox should have a scrollbar

  • TextBox text wrapping should be optional

  • needs to rebuild cursor.text from cursor.textLines

  • shortening strings can end up with bad iOffset / iEdge

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL