Documentation ¶
Index ¶
- Constants
- Variables
- func Color(r, g, b, a int) mgl32.Vec4
- func Construct()
- func DelContainer(ptr *Container)
- func GetFirstCmd(z uint8) *cmdList
- func GetLastCmd(z uint8) *cmdList
- func Init(glfwWindow *glfw.Window, graphProv graphics.GraphicsProvider) error
- func ParseSize(val string) (i float32, percent bool)
- type Callback
- type Container
- func (c *Container) Close()
- func (c *Container) NewButton(text string, f Callback) *Widget
- func (c *Container) NewCheckbox(value *bool, f Callback) *Widget
- func (c *Container) NewImg(img *Texture, x, y, w, h string) *Widget
- func (c *Container) NewInput(id string, text *string, f Callback) *Widget
- func (c *Container) NewProgressBar(value *float32, min, max float32, f Callback) *Widget
- func (c *Container) NewRow() *Widget
- func (c *Container) NewSlot(group *DADGroup, id string, x, y, w, h string, f DADCallback) *DADSlot
- func (c *Container) NewText(text string) *Widget
- type Cursor
- type DADCallback
- type DADGroup
- type DADItem
- type DADSlot
- type Font
- func (f *Font) CreateText(pos mgl.Vec2, color mgl.Vec4, msg string) *RenderData
- func (f *Font) CreateTextAdv(pos mgl.Vec2, color mgl.Vec4, maxWidth float32, charOffset int, ...) *RenderData
- func (f *Font) Destroy()
- func (f *Font) GetCurrentScale() float32
- func (f *Font) GetRenderSize(s string) (float32, float32, float32)
- func (f *Font) OffsetFloor(msg string, offset float32) float32
- func (f *Font) OffsetForIndex(msg string, stopIndex int) float32
- func (f *Font) OffsetForIndexAdv(msg string, charStartIndex int, stopIndex int) float32
- type HAlign
- type KeyEvent
- type Layout
- func (l *Layout) AddOffsets(w, h float32) (float32, float32)
- func (l *Layout) ContainsPoint(x, y float32) bool
- func (l *Layout) GetBackgroundRect() (r Rect)
- func (l *Layout) GetContentRect() (r Rect)
- func (l *Layout) GetTextPosCenter(w, h float32) (textPos mgl32.Vec2)
- func (l *Layout) GetTextPosLeft(h float32) (textPos mgl32.Vec2)
- func (l *Layout) GetTextPosRight(w, h float32) (textPos mgl32.Vec2)
- func (l *Layout) SetCursor(cursor *Cursor)
- func (l *Layout) SetHeight(val string)
- func (l *Layout) SetMaxSize(w, h float32)
- func (l *Layout) SetMinSize(w, h float32)
- func (l *Layout) SetWidth(val string)
- func (l *Layout) SetX(val string)
- func (l *Layout) SetY(val string)
- func (l *Layout) SummOffsets() (o Offset)
- func (l *Layout) Update()
- type Offset
- type Rect
- type RenderData
- type STATE
- type Size
- type Style
- type TALIGN
- type Texture
- type TexturePack
- type VAlign
- type Widget
- type WidgetConstructor
Constants ¶
const ( HAlignLeft = iota HAlignCenter HAlignRight )
const ( VAlignTop = iota VAlignMiddle VAlignBottom )
const ( MouseDown = iota MouseUp MouseClick MouseDoubleClick )
constants used for polling the state of a mouse button
Variables ¶
var ( ActiveWidget *Widget HoverWidget *Widget HoverContainer *Container )
var ( BGColorContainer = mgl32.Vec4{0.15, 0.15, 0.15, 0.75} BGColor = mgl32.Vec4{0.3, 0.3, 0.3, 1} BGColorHover = mgl32.Vec4{0.4, 0.4, 0.4, 1} BGColorSelected = mgl32.Vec4{0.5, 0.5, 0.5, 1} BGColorBtn = mgl32.Vec4{0.18, 0.18, 0.18, 1} BGColorBtnHover = mgl32.Vec4{0.28, 0.28, 0.28, 1} BGColorHighlight = mgl32.Vec4{0.17, 0.4, 0.63, 1} TextColor = mgl32.Vec4{0.8, 0.8, 0.8, 1} TextColorSelected = mgl32.Vec4{0.9, 0.9, 0.9, 1} TextColorHiglight = mgl32.Vec4{0.17, 0.4, 0.63, 1} BorderColor = mgl32.Vec4{0.15, 0.15, 0.15, 1} BorderColorHiglight = mgl32.Vec4{0.17, 0.4, 0.63, 1} BGColorImage = mgl32.Vec4{0.9, 0.9, 0.9, 1} BGColorImageHover = mgl32.Vec4{1, 1, 1, 1} )
Default colors
var DefaultMargin = Offset{4, 4, 4, 4}
var DefaultPadding = Offset{4, 4, 4, 4}
var FontGlyphs = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.,:[]{}\\|<>;\"'~`?/-+_=()*&^%$#@! "
var Keys *keyboard
var Mouse *mouse
var ShaderF = `` /* 830-byte string literal not displayed */
var ShaderV = `` /* 236-byte string literal not displayed */
Functions ¶
func Construct ¶
func Construct()
Construct loops through all of the Windows in the Manager and creates all of the widgets and their data. This function does not buffer the result to VBO or do the actual rendering -- call Draw() for that.
func DelContainer ¶
func DelContainer(ptr *Container)
func GetFirstCmd ¶
func GetFirstCmd(z uint8) *cmdList
GetFirstCmd create new cmd and insert in to first element
func GetLastCmd ¶
func GetLastCmd(z uint8) *cmdList
GetLastCmd will return the last non-custom cmdList
Types ¶
type Container ¶
type Container struct { ID string Hidden bool AutoAdjustHeight bool //not yet ready ShowScrollBar bool IsScrollable bool ScrollBarWidth float32 ScrollOffset float32 FontName string Style Style Layout *Layout Zorder uint8 Widgets []*Widget }
Container represents a collection of widgets in the user interface.
func NewContainer ¶
NewContainer creates new container for widgets x,y,w,h is string size ex: "80%", "200px"...
func (*Container) Close ¶
func (c *Container) Close()
Close function remove this window from window slice
func (*Container) NewProgressBar ¶
type DADCallback ¶
DADCallback call when item place to slot, in argument: item, slot and item value, boolean returned value allows place item to this slot or not
type DADGroup ¶
type DADGroup struct { *Container ID string Slots []*DADSlot Items []*DADItem // contains filtered or unexported fields }
DADGroup compound slot and items
func NewDragAndDropGroup ¶
NewDragAndDropGroup create new drag and drop group
type DADSlot ¶
type DADSlot struct { *Widget Item *DADItem Group *DADGroup // contains filtered or unexported fields }
DADSlot is slot for place drag and drop item
type Font ¶
type Font struct { Texture graphics.Texture TextureSize int Glyphs string GlyphHeight float32 GlyphWidth float32 // contains filtered or unexported fields }
Font contains data regarding a font and the texture that was created with the specified set of glyphs. It can then be used to create renderable string objects.
func GetFont ¶
GetFont attempts to get the font by name from the Manager's collection It returns the font on success or nil on failure.
func (*Font) CreateText ¶
CreateText makes a new renderable object from the supplied string using the data in the font. The data is returned as a RenderData object.
func (*Font) CreateTextAdv ¶
func (f *Font) CreateTextAdv(pos mgl.Vec2, color mgl.Vec4, maxWidth float32, charOffset int, cursorPosition int, s string) *RenderData
CreateText makes a new renderable object from the supplied string using the data in the font. The string returned will be the maximum amount of the msg that fits the specified maxWidth (if greater than 0.0) starting at the charOffset specified. The data is returned as a RenderData object.
func (*Font) GetCurrentScale ¶
GetCurrentScale returns the scale value for the font based on the current Manager's resolution vs the resolution the UI was designed for.
func (*Font) GetRenderSize ¶
GetRenderSize returns the width and height necessary in pixels for the font to display a string. The third return value is the advance height the string.
func (*Font) OffsetFloor ¶
OffsetFloor returns the maximum width offset that will fit between characters that is still smaller than the offset passed in.
func (*Font) OffsetForIndex ¶
OffsetForIndex returns the width offset that will fit just before the `stopIndex` number character in the msg.
type Layout ¶
type Layout struct { HAlign HAlign VAlign VAlign PositionFixed bool Square bool //value fot position content into this layout X float32 //content X Y float32 //content Y W float32 //max content width H float32 //max content height Padding Offset Margin Offset // contains filtered or unexported fields }
Layout is reresentation of object size position and other options
func NewLayoutZero ¶
func (*Layout) ContainsPoint ¶
func (*Layout) GetBackgroundRect ¶
func (*Layout) GetContentRect ¶
func (*Layout) GetTextPosCenter ¶
func (*Layout) GetTextPosRight ¶
func (*Layout) SetMaxSize ¶
func (*Layout) SetMinSize ¶
SetMinSize it`s width and height if incoming value more then exists
func (*Layout) SummOffsets ¶
type RenderData ¶
type RenderData struct { ComboBuffer []float32 // the combo VBO data (vert/uv/color) IndexBuffer []uint32 // the element index VBO data Faces uint32 // the number of faces in the text string Width float32 // the width in pixels of the text string Height float32 // the height in pixels of the text string AdvanceHeight float32 // the amount of pixels to move the pen in the verticle direction CursorOverflowRight bool // whether or not the cursor was too far to the right for string width }
RenderData is a structure containing the raw OpenGL VBO data needed to render a text string for a given texture.
type Size ¶
type Size struct {
// contains filtered or unexported fields
}
Size contains universial reresentation for fixed and percent sizes
type Style ¶
type Style struct { TextColor mgl32.Vec4 BackgroundColor mgl32.Vec4 BorderColor mgl32.Vec4 BorderWidth float32 Texture *Texture // contains filtered or unexported fields }
var ( DefaultContainerStyle Style DefaultTextStyle Style DefaultBtnStyle Style DefaultBtnStyleHover Style DefaultBtnStyleActive Style DefaultInputStyle Style DefaultInputStyleActive Style DefaultDaDItemStyle Style DefaultDaDItemStyleHover Style )
Default styles
type Texture ¶
type Texture struct { Tex graphicsprovider.Texture Offset mgl32.Vec4 }
func NewTextureImg ¶
type TexturePack ¶
type TexturePack struct {
Width, Height float32
Tex graphicsprovider.Texture
}
func NewTexturePack ¶
func NewTexturePack(img string) (*TexturePack, error)
func (*TexturePack) NewChunk ¶
func (tp *TexturePack) NewChunk(x0, y0, x1, y1 float32) *Texture
type Widget ¶
type Widget struct { ID string Hidden bool Text string TextAlign TALIGN Font *Font Texture *Texture //Global widget texture Style Style StyleHover Style StyleActive Style State STATE Zorder uint8 //initial value Z uint8 //current working value Layout *Layout Container *Container OnActive Callback OnKeyEnter Callback ConstructorData interface{} Constructor WidgetConstructor UserData interface{} // contains filtered or unexported fields }
func (*Widget) IsMouseDown ¶
type WidgetConstructor ¶
type WidgetConstructor func() Style