eweygewey

package module
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2017 License: BSD-2-Clause Imports: 14 Imported by: 5

README

EweyGewey v0.3.2

EweyGewey is an OpenGL immediate-mode GUI library written in the Go programming language that is designed to be integrated easily into an OpenGL application.

The design of the library is heavily inspired by imgui.

UNDER CONSTRUCTION

At present, it is very much in an alpha stage with new development adding in features, widgets and possibly API breaks. Any API break should increment the minor version number and any patch release tags should remain compatible even in development 0.x versions.

Screenshots

Here's some of what's available right now in the basic example:

basic_ss

Requirements

  • Mathgl - for 3d math
  • Freetype - for dynamic font texture generation
  • Fizzle - provides an OpenGL 3/es2/es3 abstraction
  • GLFW (v3.1) - currently GLFW is the only 'host' support for input

Additionally, a backend graphics provider needs to be used. At present, fizzle supports the following:

  • Go GL - pre-generated OpenGL bindings using their glow project
  • opengles2 - Go bindings to the OpenGL ES 2.0 library

These are included when the graphicsprovider subpackage is used and direct importing is not required.

Installation

The dependency Go libraries can be installed with the following commands.

go get github.com/go-gl/glfw/v3.1/glfw
go get github.com/go-gl/mathgl/mgl32
go get github.com/golang/freetype
go get github.com/tbogdala/fizzle

An OpenGL library will also be required for desktop applications; install the OpenGL 3.3 library with the following command:

go get github.com/go-gl/gl/v3.3-core/gl

If you're compiling for Android/iOS, then you will need an OpenGL ES library, and that can be installed with the following command instead:

go get github.com/remogatto/opengles2

This does assume that you have the native GLFW 3.1 library installed already accessible to Go tools. This should be the only native library needed.

Current Features

  • Basic windowing system
  • Basic theming support
  • Basic input support that detects mouse clicks and double-clicks
  • Basic scaling for larger resolutions
  • Widgets:
    • Text
    • Buttons
    • Sliders for integers and floats with ranges and without
    • Scroll bars
    • Images
    • Editbox
    • Checkbox
    • Separator
    • Custom drawn 3d widgets

TODO

The following need to be addressed in order to start releases:

  • more widgets:
    • text wrapping
    • multi-line text editors
    • combobox
    • image buttons
  • detailed theming (e.g. custom drawing of slider cursor)
  • texture atlas creation
  • z-ordering for windows
  • scroll bars don't scroll on mouse drag
  • editbox cursor doesn't start where mouse was clicked
  • text overflow on editboxes isn't handled well
  • better OpenGL flag management
  • documentation
  • samples

LICENSE

EweyGewey is released under the BSD license. See the LICENSE file for more details.

Fonts in the examples/assets directory are licensed under the SIL OFL open font license.

Documentation

Index

Constants

View Source
const (
	MouseDown        = 0
	MouseUp          = 1
	MouseClick       = 2
	MouseDoubleClick = 4
)

constants used for polling the state of a mouse button

View Source
const (
	EweyKeyUnknown = iota
	EweyKeyWorld1
	EweyKeyWorld2
	EweyKeyEscape
	EweyKeyEnter
	EweyKeyTab
	EweyKeyBackspace
	EweyKeyInsert
	EweyKeyDelete
	EweyKeyRight
	EweyKeyLeft
	EweyKeyDown
	EweyKeyUp
	EweyKeyPageUp
	EweyKeyPageDown
	EweyKeyHome
	EweyKeyEnd
	EweyKeyCapsLock
	EweyKeyScrollLock
	EweyKeyNumLock
	EweyKeyPrintScreen
	EweyKeyPause
	EweyKeyF1
	EweyKeyF2
	EweyKeyF3
	EweyKeyF4
	EweyKeyF5
	EweyKeyF6
	EweyKeyF7
	EweyKeyF8
	EweyKeyF9
	EweyKeyF10
	EweyKeyF11
	EweyKeyF12
	EweyKeyF13
	EweyKeyF14
	EweyKeyF15
	EweyKeyF16
	EweyKeyF17
	EweyKeyF18
	EweyKeyF19
	EweyKeyF20
	EweyKeyF21
	EweyKeyF22
	EweyKeyF23
	EweyKeyF24
	EweyKeyF25
	EweyKeyLeftShift
	EweyKeyLeftControl
	EweyKeyLeftAlt
	EweyKeyLeftSuper
	EweyKeyRightShift
	EweyKeyRightControl
	EweyKeyRightAlt
	EweyKeyRightSuper
)

Variables

View Source
var (
	// VertShader330 is the GLSL vertex shader program for the user interface.
	VertShader330 = `` /* 376-byte string literal not displayed */

	// FragShader330 is the GLSL fragment shader program for the user interface.
	// NOTE: 4 samplers is a hardcoded value now, but there's no reason it has to be that specifically.
	FragShader330 = `` /* 517-byte string literal not displayed */

	// DefaultStyle is the default style to use for drawing widgets
	DefaultStyle = Style{
		ButtonColor:          ColorIToV(171, 102, 102, 153),
		ButtonActiveColor:    ColorIToV(204, 128, 120, 255),
		ButtonHoverColor:     ColorIToV(171, 102, 102, 255),
		ButtonTextColor:      ColorIToV(230, 230, 230, 255),
		ButtonMargin:         mgl.Vec4{2, 2, 2, 2},
		ButtonPadding:        mgl.Vec4{2, 2, 4, 4},
		CheckboxColor:        ColorIToV(128, 128, 128, 179),
		CheckboxCheckColor:   ColorIToV(204, 128, 120, 255),
		CheckboxCursorWidth:  15.0,
		CheckboxMargin:       mgl.Vec4{2, 2, 2, 2},
		CheckboxPadding:      mgl.Vec4{4, 4, 4, 4},
		EditboxBgColor:       ColorIToV(128, 128, 128, 179),
		EditboxActiveColor:   ColorIToV(204, 128, 120, 255),
		EditboxCursorColor:   ColorIToV(230, 230, 230, 255),
		EditboxCursorWidth:   3.0,
		EditboxBlinkDuration: 0.25,
		EditboxBlinkInterval: 1.0,
		EditboxTextColor:     ColorIToV(230, 230, 230, 255),
		EditboxMargin:        mgl.Vec4{2, 2, 2, 2},
		EditboxPadding:       mgl.Vec4{2, 2, 4, 4},
		FontName:             "Default",
		ImageMargin:          mgl.Vec4{0, 0, 0, 0},
		IndentSpacing:        26.0,
		ScrollBarCursorColor: ColorIToV(102, 102, 204, 77),
		ScrollBarBgColor:     ColorIToV(51, 64, 77, 153),
		ScrollBarWidth:       16.0,
		ScrollBarCursorWidth: 10.0,
		SeparatorColor:       ColorIToV(230, 230, 230, 255),
		SeparatorHeight:      1.0,
		SeparatorMargin:      mgl.Vec4{4, 4, 8, 8},
		SliderBgColor:        ColorIToV(128, 128, 128, 179),
		SliderCursorColor:    ColorIToV(179, 179, 179, 179),
		SliderFloatFormat:    "%0.3f",
		SliderIntFormat:      "%d",
		SliderMargin:         mgl.Vec4{2, 2, 2, 2},
		SliderPadding:        mgl.Vec4{2, 2, 4, 4},
		SliderTextColor:      ColorIToV(230, 230, 230, 255),
		SliderCursorWidth:    15.0,
		TextMargin:           mgl.Vec4{4, 4, 6, 6},
		TextColor:            ColorIToV(230, 230, 230, 255),
		TitleBarPadding:      mgl.Vec4{2, 2, 6, 6},
		TitleBarTextColor:    ColorIToV(230, 230, 230, 255),
		TitleBarBgColor:      ColorIToV(69, 69, 138, 255),
		TreeNodeMargin:       mgl.Vec4{2, 2, 2, 2},
		TreeNodePadding:      mgl.Vec4{2, 2, 4, 4},
		TreeNodeTextColor:    ColorIToV(230, 230, 230, 255),
		WindowBgColor:        ColorIToV(0, 0, 0, 179),
		WindowPadding:        mgl.Vec4{4, 4, 4, 4},
	}
)

Functions

func ClipF32

func ClipF32(min, max, value float32) float32

ClipF32 returns a value that is between the closed interval of [min .. max].

func ColorIToV

func ColorIToV(r, g, b, a int) mgl.Vec4

ColorIToV takes the color parameters as integers and returns them as a float vector.

Types

type BuildCallback

type BuildCallback func(window *Window)

BuildCallback is a type for the function that builds the widgets for the window.

type Font

type Font struct {
	Texture     graphics.Texture
	TextureSize int
	Glyphs      string
	GlyphHeight float32
	GlyphWidth  float32
	Owner       *Manager
	// 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 (*Font) CreateText

func (f *Font) CreateText(pos mgl.Vec3, color mgl.Vec4, msg string) TextRenderData

CreateText makes a new renderable object from the supplied string using the data in the font. The data is returned as a TextRenderData object.

func (*Font) CreateTextAdv added in v0.2.0

func (f *Font) CreateTextAdv(pos mgl.Vec3, color mgl.Vec4, maxWidth float32, charOffset int, cursorPosition int, msg string) TextRenderData

CreateTextAdv 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 TextRenderData object.

func (*Font) Destroy

func (f *Font) Destroy()

Destroy releases the OpenGL texture for the font.

func (*Font) GetCurrentScale

func (f *Font) GetCurrentScale() float32

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

func (f *Font) GetRenderSize(msg string) (float32, float32, float32)

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

func (f *Font) OffsetFloor(msg string, offset float32) float32

OffsetFloor returns the maximum width offset that will fit between characters that is still smaller than the offset passed in.

func (*Font) OffsetForIndex

func (f *Font) OffsetForIndex(msg string, stopIndex int) float32

OffsetForIndex returns the width offset that will fit just before the `stopIndex` number character in the msg.

func (*Font) OffsetForIndexAdv added in v0.2.0

func (f *Font) OffsetForIndexAdv(msg string, charStartIndex int, stopIndex int) float32

OffsetForIndexAdv returns the width offset that will fit just before the `stopIndex` number character in the msg, starting at charStartIndex.

type FrameStartFunc

type FrameStartFunc func(startTime time.Time)

FrameStartFunc is the type of function to be called when the manager is starting a new frame to construct and draw.

type KeyPressEvent

type KeyPressEvent struct {
	// the key that was hit if it is alpha-numeric or otherwise able to be
	// stored as a character
	Rune rune

	// if the key was not something that can be stored as a rune, then
	// use the corresponding key enum value here (e.g. eweyKeyF1)
	KeyCode int

	// IsRune indicates if the event for a rune or non-rune key
	IsRune bool

	// ShiftDown indicates if the shift key was down at time of key press
	ShiftDown bool

	// CtrlDown indicates if the ctrl key was down at time of key press
	CtrlDown bool

	// AltDown indicates if the alt key was down at time of key press
	AltDown bool

	// SuperDown indicates if the super key was down at time of key press
	SuperDown bool
}

KeyPressEvent represents the data associated with a single key-press event from whatever input library is used in conjunction with this package.

type Manager

type Manager struct {
	// GetMousePosition should be a function that returns the current mouse
	// position for the application.
	GetMousePosition func() (float32, float32)

	// GetMouseDownPosition should be a function that returns the mouse position
	// stored for when the button made the transition from UP->DOWN.
	GetMouseDownPosition func(buttonNumber int) (float32, float32)

	// GetMousePositionDelta should be a function that returns the amount
	// of change in the mouse position.
	GetMousePositionDelta func() (float32, float32)

	// GetMouseButtonAction should be a function that returns the state
	// of a mouse button: MouseUp | MouseDown | MouseRepeat.
	GetMouseButtonAction func(buttonNumber int) int

	// ClearMouseButtonAction should be a function that clears any tracked
	// action data for a mouse button
	ClearMouseButtonAction func(buttonNumber int)

	// GetScrollWheelDelta should be a function that returns the amount of
	// change to the scroll wheel position that has happened since last check.
	GetScrollWheelDelta func(bool) float32

	// GetKeyEvents is the function to be called to get the slice of
	// currently buffered key press events
	GetKeyEvents func() []KeyPressEvent

	// ClearKeyEvents is the function to be called to clear out the key press event buffer
	ClearKeyEvents func()

	// GetClipboardString returns a possible string from the clipboarnd and
	// possibly an error.
	GetClipboardString func() (string, error)

	// SetClipboardString sets a string in the system clipboard.
	SetClipboardString func(string)

	// FrameStart is the time the UI manager's Construct() was called.
	FrameStart time.Time

	// FrameDelta is the time between frames as given to Construct().
	FrameDelta float64

	// ScrollSpeed is how much each move of the scroll wheel should be magnified
	ScrollSpeed float32
	// contains filtered or unexported fields
}

Manager holds all of the widgets and knows how to draw the UI.

func NewManager

func NewManager(gfx graphics.GraphicsProvider) *Manager

NewManager is the constructor for the Manager type that will create a new object and sets sane defaults.

func (*Manager) AddConstructionStartCallback

func (ui *Manager) AddConstructionStartCallback(cb FrameStartFunc)

AddConstructionStartCallback adds a new callback to the slice of callbacks that will be called when the manager is starting construction of a new frame to draw.

func (*Manager) AddTextureToStack

func (ui *Manager) AddTextureToStack(texID graphics.Texture) uint32

AddTextureToStack adds a texture ID to the stack of textures the manager maintains and returns it's index in the stack +1. In other words, this is a one-based number scheme because 0 is reserved for the font.

func (*Manager) AdviseResolution

func (ui *Manager) AdviseResolution(w int32, h int32)

AdviseResolution will change the resolution the Manager uses to draw widgets.

func (*Manager) ClearActiveInputID

func (ui *Manager) ClearActiveInputID()

ClearActiveInputID clears any focus claims.

func (*Manager) Construct

func (ui *Manager) Construct(frameDelta float64)

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 (*Manager) DisplayToScreen

func (ui *Manager) DisplayToScreen(xD, yD float32) (float32, float32)

DisplayToScreen converts a resolution-specific coordinate to screen-normalized space with the origin in the lower left corner. E.g. if the UI is 800x600, coalling with (400,300) returns (0.5, 0.5)

func (*Manager) Draw

func (ui *Manager) Draw()

Draw buffers the UI vertex data into the rendering pipeline and does the actual draw call.

func (*Manager) DrawRectFilled

func (ui *Manager) DrawRectFilled(cmd *cmdList, xS, yS, wS, hS float32, color mgl.Vec4, textureIndex uint32)

DrawRectFilled draws a rectangle in the user interface using a solid background. Coordinate parameters should be passed in screen-normalized space. This gets appended to the command list passed in.

func (*Manager) GetActiveInputID

func (ui *Manager) GetActiveInputID() string

GetActiveInputID returns the active input id which claimed input focus.

func (*Manager) GetDesignHeight

func (ui *Manager) GetDesignHeight() int32

GetDesignHeight returns the normalized height for the UI.

func (*Manager) GetFont

func (ui *Manager) GetFont(name string) *Font

GetFont attempts to get the font by name from the Manager's collection. It returns the font on success or nil on failure.

func (*Manager) GetResolution

func (ui *Manager) GetResolution() (int32, int32)

GetResolution returns the width and height of the user interface.

func (*Manager) GetWindow

func (ui *Manager) GetWindow(id string) *Window

GetWindow returns a window based on the id string passed in

func (*Manager) GetWindowsByFilter added in v0.2.0

func (ui *Manager) GetWindowsByFilter(filter func(w *Window) bool) []*Window

GetWindowsByFilter returns a slice of *Window which is populated by filtering the internal window list with the function provided. If the function returns true the window will get included in the results.

func (*Manager) Initialize

func (ui *Manager) Initialize(vertShader, fragShader string, w, h, designH int32) error

Initialize does the setup required for the user interface to draw. This includes heavier operations like compiling shaders.

func (*Manager) NewFont

func (ui *Manager) NewFont(name string, fontFilepath string, scaleInt int, glyphs string) (*Font, error)

NewFont loads the font from a file and 'registers' it with the UI manager.

func (*Manager) NewFontBytes added in v0.3.2

func (ui *Manager) NewFontBytes(name string, fontBytes []byte, scaleInt int, glyphs string) (*Font, error)

NewFontBytes loads the font from a byte slice and 'registers' it with the UI manager.

func (*Manager) NewWindow

func (ui *Manager) NewWindow(id string, x, y, w, h float32, constructor BuildCallback) *Window

NewWindow creates a new window and adds it to the collection of windows to draw.

func (*Manager) RemoveWindow

func (ui *Manager) RemoveWindow(wndToRemove *Window)

RemoveWindow will remove the window from the user interface.

func (*Manager) ScreenToDisplay

func (ui *Manager) ScreenToDisplay(xS, yS float32) (float32, float32)

ScreenToDisplay converts screen-normalized point to resolution-specific coordinates with the origin in the lower left corner. E.g. if the UI is 800x600, calling with (0.5, 0.5) returns (400, 300)

func (*Manager) SetActiveInputID

func (ui *Manager) SetActiveInputID(id string) bool

SetActiveInputID sets the active input id which tells the user interface which widget is currently claiming 'focus' for input. Returns a bool indicating if the focus claim was successful because the input can be claimed only once per UP->DOWN mouse transition.

type Style

type Style struct {
	ButtonColor          mgl.Vec4 // button background color
	ButtonHoverColor     mgl.Vec4 // button background color with mouse hovering
	ButtonActiveColor    mgl.Vec4 // button background color when clicked
	ButtonTextColor      mgl.Vec4 // button text color
	ButtonMargin         mgl.Vec4 // [left,right,top,bottom] margin values for buttons
	ButtonPadding        mgl.Vec4 // [left,right,top,bottom] padding values for buttons
	CheckboxColor        mgl.Vec4 // checkbox background color
	CheckboxCheckColor   mgl.Vec4 // checkbox cursor color when clicked
	CheckboxCursorWidth  float32  // checkbox inner check cursor size
	CheckboxMargin       mgl.Vec4 // [left,right,top,bottom] margin values for checkbox
	CheckboxPadding      mgl.Vec4 // [left,right,top,bottom] padding values for checkbox
	EditboxBgColor       mgl.Vec4 // Editbox background color
	EditboxActiveColor   mgl.Vec4 // Editbox background color when clicked
	EditboxCursorColor   mgl.Vec4 // color for the editbox cursor
	EditboxCursorWidth   float32  // width of the editbox cursor in pixels
	EditboxBlinkDuration float32  // how long the cursor is visible during a blink (in seconds)
	EditboxBlinkInterval float32  // how many seconds between the start of the cursor blink (in seconds)
	EditboxTextColor     mgl.Vec4 // Editbox text color
	EditboxMargin        mgl.Vec4 // [left,right,top,bottom] margin values for Editbox
	EditboxPadding       mgl.Vec4 // [left,right,top,bottom] padding values for Editbox
	FontName             string   // font name to use by default
	ImageMargin          mgl.Vec4 // margin for the image widgets
	IndentSpacing        float32  // the amount of pixels to indent
	ScrollBarCursorColor mgl.Vec4 // the color of the cursor of the scroll bar
	ScrollBarBgColor     mgl.Vec4 // the color of the background of the scroll bar
	ScrollBarWidth       float32  // the width of the scroll bar
	ScrollBarCursorWidth float32  // the width of the scroll bar cursor
	SeparatorColor       mgl.Vec4 // the color of the separator bar
	SeparatorHeight      float32  // the height of the separator rectangle
	SeparatorMargin      mgl.Vec4 // the margin for the separator rectangle
	SliderBgColor        mgl.Vec4 // slider background color
	SliderCursorColor    mgl.Vec4 // slider cursor color
	SliderFloatFormat    string   // formatting string for the float value in a slider
	SliderIntFormat      string   // formatting string for the int value in a slider
	SliderMargin         mgl.Vec4 // margin for the slider text strings
	SliderPadding        mgl.Vec4 // padding for the slider text strings
	SliderTextColor      mgl.Vec4 // slider text color
	SliderCursorWidth    float32  // slider cursor width
	TextColor            mgl.Vec4 // text color
	TextMargin           mgl.Vec4 // margin for text widgets
	TitleBarPadding      mgl.Vec4 // padding for the title bar of the window
	TitleBarTextColor    mgl.Vec4 // text color
	TitleBarBgColor      mgl.Vec4 // window background color
	TreeNodeTextColor    mgl.Vec4 // text color for tree nodes
	TreeNodeMargin       mgl.Vec4 // [left,right,top,bottom] margin values for tree nodes
	TreeNodePadding      mgl.Vec4 // [left,right,top,bottom] padding values for tree nodes
	WindowBgColor        mgl.Vec4 // window background color
	WindowPadding        mgl.Vec4 // [left,right,top,bottom] padding values for windows
}

Style defines parameters to the drawing functions that control the way the widgets are organized and drawn.

type TextRenderData

type TextRenderData 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
}

TextRenderData is a structure containing the raw OpenGL VBO data needed to render a text string for a given texture.

type Window

type Window struct {
	// ID is the widget id string for the window for claiming focus.
	ID string

	// Location is the location of the upper left hand corner of the window.
	// The X and Y axis should be specified screen-normalized coordinates.
	Location mgl.Vec3

	// Width is how wide the window is in screen-normalized space.
	Width float32

	// Height is how tall the window is in screen-normalized space.
	Height float32

	// ShowScrollBar indicates if the scroll bar should be attached to the side
	// of the window
	ShowScrollBar bool

	// ShowTitleBar indicates if the title bar should be drawn or not
	ShowTitleBar bool

	// IsMoveable indicates if the window should be moveable by LMB drags
	IsMoveable bool

	// IsScrollable indicates if the window should scroll the contents based
	// on mouse scroll wheel input.
	IsScrollable bool

	// AutoAdjustHeight indicates if the window's height should be automatically
	// adjusted to accommodate all of the widgets.
	AutoAdjustHeight bool

	// Title is the string to display in the title bar if it is visible
	Title string

	// OnBuild gets called by the UI Manager when the UI is getting built.
	// This should be a function that makes all of the calls necessary
	// to build the window's widgets.
	OnBuild BuildCallback

	// Owner is the owning UI Manager object.
	Owner *Manager

	// ScrollOffset is essentially the scrollbar *position* which tells the
	// window hot to offset the controlls to give the scrolling effect.
	ScrollOffset float32

	// Style is the set of visual parameters to use when drawing this window.
	Style
	// contains filtered or unexported fields
}

Window represents a collection of widgets in the user interface.

func (*Window) Button

func (wnd *Window) Button(id string, text string) (bool, error)

Button draws the button widget on screen with the given text.

func (*Window) Checkbox

func (wnd *Window) Checkbox(id string, value *bool) (bool, error)

Checkbox draws the checkbox widget on screen.

func (*Window) ContainsPosition

func (wnd *Window) ContainsPosition(x, y float32) bool

ContainsPosition returns true if the position passed in is contained within the window's space.

func (*Window) Custom

func (wnd *Window) Custom(widthS, heightS float32, margin mgl.Vec4, customDraw func())

Custom inserts a new cmdList and sets it up for custom rendering.

func (*Window) DragSliderFloat

func (wnd *Window) DragSliderFloat(id string, speed float32, value *float32) error

DragSliderFloat creates a slider widget that alters a value based on mouse movement only.

func (*Window) DragSliderFloat64

func (wnd *Window) DragSliderFloat64(id string, speed float64, value *float64) error

DragSliderFloat64 creates a slider widget that alters a value based on mouse movement only.

func (*Window) DragSliderInt

func (wnd *Window) DragSliderInt(id string, speed float32, value *int) error

DragSliderInt creates a slider widget that alters a value based on mouse movement only.

func (*Window) DragSliderUFloat

func (wnd *Window) DragSliderUFloat(id string, speed float32, value *float32) error

DragSliderUFloat creates a slider widget that alters a value based on mouse movement only.

func (*Window) DragSliderUFloat64

func (wnd *Window) DragSliderUFloat64(id string, speed float64, value *float64) error

DragSliderUFloat64 creates a slider widget that alters a value based on mouse movement only.

func (*Window) DragSliderUInt

func (wnd *Window) DragSliderUInt(id string, speed float32, value *uint) error

DragSliderUInt creates a slider widget that alters a value based on mouse movement only.

func (*Window) Editbox

func (wnd *Window) Editbox(id string, value *string) (bool, error)

Editbox creates an editbox control that changes the value string.

func (*Window) GetAspectRatio

func (wnd *Window) GetAspectRatio() float32

GetAspectRatio returns the aspect ratio of the window (width / height)

func (*Window) GetDisplaySize

func (wnd *Window) GetDisplaySize() (float32, float32, float32, float32)

GetDisplaySize returns four values: the x and y positions of the window on the screen in display-space and then the width and height of the window in display-space values. This does not include space for the scroll bars.

func (*Window) GetFrameSize

func (wnd *Window) GetFrameSize() (float32, float32, float32, float32)

GetFrameSize returns the (x,y) top-left corner of the window in display-space coordinates and the width and height of the total window frame as well, including the space window decorations take up like titlebar and scrollbar.

func (*Window) GetTitleString

func (wnd *Window) GetTitleString() string

GetTitleString will return a string with one space in it or the Title property if the Title is not an empty string.

func (*Window) Image

func (wnd *Window) Image(id string, widthS, heightS float32, color mgl.Vec4, textureIndex uint32, uvPair mgl.Vec4) error

Image draws the image widget on screen.

func (*Window) Indent

func (wnd *Window) Indent()

Indent increases the indent level in the window, which also immediately changes the widgetCursorDC value.

func (*Window) RequestItemWidthMax

func (wnd *Window) RequestItemWidthMax(nextMaxWS float32)

RequestItemWidthMax will request the window to draw the next widget with at most the specified window-normalized size (e.g. if Window's width is 500 px, then passing 0.25 here translates to 125 px).

func (*Window) RequestItemWidthMin

func (wnd *Window) RequestItemWidthMin(nextMinWS float32)

RequestItemWidthMin will request the window to draw the next widget with the specified window-normalized size (e.g. if Window's width is 500 px, then passing 0.25 here translates to 125 px).

func (*Window) Separator

func (wnd *Window) Separator()

Separator draws a separator rectangle and advances the cursor to a new row automatically.

func (*Window) SliderFloat

func (wnd *Window) SliderFloat(id string, value *float32, min, max float32) error

SliderFloat creates a slider widget that alters a value based on the min/max values provided.

func (*Window) SliderInt

func (wnd *Window) SliderInt(id string, value *int, min, max int) error

SliderInt creates a slider widget that alters a value based on the min/max values provided.

func (*Window) Space

func (wnd *Window) Space(spaceS float32)

Space adds some horizontal space based on the relative width of the window. For example: a window width of 800, passing 0.1 adds a space of 80

func (*Window) StartRow

func (wnd *Window) StartRow()

StartRow starts a new row of widgets in the window.

func (*Window) Text

func (wnd *Window) Text(msg string) error

Text renders a text widget

func (*Window) TreeNode

func (wnd *Window) TreeNode(id string, text string) (bool, error)

TreeNode draws the tree node widget on screen with the given text. Returns a bool indicating if the tree node is considered to be 'open'.

func (*Window) Unindent

func (wnd *Window) Unindent()

Unindent decreases the indent level in the window, which also immediately changes the widgetCursorDC value.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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