gui

package
v0.0.0-...-86d339c Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: GPL-3.0 Imports: 16 Imported by: 1

Documentation

Overview

Package gui implements the GUI infraestructure and several widgets.

Index

Constants

View Source
const (
	AlignNone   = Align(iota) // No alignment
	AlignLeft                 // Align horizontally at left
	AlignRight                // Align horizontally at right
	AlignWidth                // Align horizontally using all width
	AlignTop                  // Align vertically at the top
	AlignBottom               // Align vertically at the cnter
	AlignHeight               // Align vertically using all height
	AlignCenter               // Align horizontally/vertically at the center
)

The various types of alignment.

View Source
const (
	OnClick       = "gui.OnClick"       // Widget clicked by mouse left button or key
	OnCursorEnter = "gui.OnCursorEnter" // cursor enters the panel area
	OnCursorLeave = "gui.OnCursorLeave" // cursor leaves the panel area
	OnMouseOut    = "gui.OnMouseOut"    // mouse button pressed outside of the panel
	OnResize      = "gui.OnResize"      // panel size changed (no parameters)
	OnEnable      = "gui.OnEnable"      // panel enabled state changed (no parameters)
	OnChange      = "gui.OnChange"      // onChange is emitted by List, DropDownList, CheckBox and Edit
	OnChild       = "gui.OnChild"       // child added to or removed from panel
	OnRadioGroup  = "gui.OnRadioGroup"  // radio button from a group changed state
	OnRightClick  = "gui.OnRightClick"  // Widget clicked by mouse right button
)

Consolidate window events plus GUI events

View Source
const (
	StopGUI = 0x01             // Stop event propagation to GUI
	Stop3D  = 0x02             // Stop event propagation to 3D
	StopAll = StopGUI | Stop3D // Stop event propagation
)

Types of event propagation stopping.

View Source
const (
	StyleOver = iota + 1
	StyleFocus
	StyleDisabled
	StyleNormal
	StyleDef
)

States that a GUI element can be in

Variables

This section is empty.

Functions

func SetStyleDefault

func SetStyleDefault(s *Style)

SetStyleDefault sets the default style

Types

type Align

type Align int

Align specifies the alignment of an object inside another.

type BasicStyle

type BasicStyle struct {
	PanelStyle
	FgColor math32.Color4
}

BasicStyle extends PanelStyle by adding a foreground color. Many GUI components can be styled using BasicStyle or redeclared versions thereof (e.g. ButtonStyle)

type ButtonState

type ButtonState int

ButtonState specifies a button state.

const (
	ButtonNormal ButtonState = iota
	ButtonOver
	ButtonPressed
	ButtonDisabled
)

The possible button states.

type ColorStyle

type ColorStyle struct {
	BgDark    math32.Color4
	BgMed     math32.Color4
	BgNormal  math32.Color4
	BgOver    math32.Color4
	Highlight math32.Color4
	Select    math32.Color4
	Text      math32.Color4
	TextDis   math32.Color4
}

ColorStyle defines the main colors used.

type FillLayout

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

FillLayout is the simple layout where the assigned panel "fills" its parent in the specified dimension(s)

func NewFillLayout

func NewFillLayout(width, height bool) *FillLayout

NewFillLayout creates and returns a pointer of a new fill layout

func (*FillLayout) Recalc

func (f *FillLayout) Recalc(ipan IPanel)

Recalc is called by the panel which has this layout

type GridLayout

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

GridLayout is a panel layout which arranges its children in a rectangular grid. It is necessary to set the number of columns of the grid when the layout is created. The panel's child elements are positioned in the grid cells accordingly to the order they were added to the panel. The height of each row is determined by the height of the heightest child in the row. The width of each column is determined by the width of the widest child in the column

func NewGridLayout

func NewGridLayout(ncols int) *GridLayout

NewGridLayout creates and returns a pointer of a new grid layout

func (*GridLayout) Recalc

func (g *GridLayout) Recalc(ipan IPanel)

Recalc sets the position and sizes of all of the panel's children. It is normally called by the parent panel when its size changes or a child is added or removed.

func (*GridLayout) SetAlignH

func (g *GridLayout) SetAlignH(align Align)

SetAlignH sets the horizontal alignment for all the grid cells The alignment of an individual cell can be set by settings its layout parameters.

func (*GridLayout) SetAlignV

func (g *GridLayout) SetAlignV(align Align)

SetAlignV sets the vertical alignment for all the grid cells The alignment of an individual cell can be set by settings its layout parameters.

func (*GridLayout) SetColAlignH

func (g *GridLayout) SetColAlignH(col int, align Align)

SetColAlignH sets the horizontal alignment for all the cells of the specified column. The function panics if the supplied column is invalid.

func (*GridLayout) SetColAlignV

func (g *GridLayout) SetColAlignV(col int, align Align)

SetColAlignV sets the vertical alignment for all the cells of the specified column. The function panics if the supplied column is invalid

func (*GridLayout) SetExpandH

func (g *GridLayout) SetExpandH(expand bool)

SetExpandH sets it the columns should expand horizontally if possible

func (*GridLayout) SetExpandV

func (g *GridLayout) SetExpandV(expand bool)

SetExpandV sets it the rowss should expand vertically if possible

type GridLayoutParams

type GridLayoutParams struct {
	ColSpan int   // Number of additional columns to ocuppy to the right
	AlignH  Align // Vertical alignment
	AlignV  Align // Horizontal alignment
}

GridLayoutParams describes layout parameter for an specific child

type HBoxLayout

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

HBoxLayout implements a panel layout which arranges the panel children horizontally. The children can be separated by a space in pixels set by SetSpacing(). The whole group of children can be aligned horizontally by SetAlignH() which can accept the following types of alignment:

AlignLeft: Try to align the group of children to the left if the panel width is
greater the the sum of the children widths + spacing.

AlignRight: Try to align the group of children to the right if the panel width is
greater the the sum of the children widths + spacing.

AlignCenter: Try to align the group of children in the center if the panel width is
greater the the sum of the children widths + spacing.

AlignWidth - Try to align the individual children with the same same space between each other.
Each individual child can be aligned vertically by SetLayoutParameters()

If the layout method SetAutoHeight(true) is called, the panel minimum content height will be the height of the child with the largest height.

If the layout method SetAutoWidth(true) is called, the panel minimum content width will be the sum of its children's widths plus the spacing.

func NewHBoxLayout

func NewHBoxLayout() *HBoxLayout

NewHBoxLayout creates and returns a pointer to a new horizontal box layout

func (*HBoxLayout) Recalc

func (bl *HBoxLayout) Recalc(ipan IPanel)

Recalc recalculates and sets the position and sizes of all children

func (*HBoxLayout) SetAlignH

func (bl *HBoxLayout) SetAlignH(align Align)

SetAlignH sets the horizontal alignment of the whole group of items inside the parent panel and updates the layout. This only has any effect if there are no expanded items.

func (*HBoxLayout) SetAutoHeight

func (bl *HBoxLayout) SetAutoHeight(state bool)

SetAutoHeight sets if the panel minimum height should be the height of the largest of its children's height.

func (*HBoxLayout) SetAutoWidth

func (bl *HBoxLayout) SetAutoWidth(state bool)

SetAutoWidth sets if the panel minimum width should be sum of its children's width plus the spacing

func (*HBoxLayout) SetSpacing

func (bl *HBoxLayout) SetSpacing(spacing float32)

SetSpacing sets the horizontal spacing between the items in pixels and updates the layout if possible

type HBoxLayoutParams

type HBoxLayoutParams struct {
	Expand float32 // item expand horizontally factor (0 - no expand)
	AlignV Align   // item vertical alignment
}

HBoxLayoutParams specify the vertical alignment of each individual child.

type ILayout

type ILayout interface {
	Recalc(ipan IPanel)
}

ILayout is the interface for layouts

type IPanel

type IPanel interface {
	graphic.IGraphic
	GetPanel() *Panel
	SetRoot(*Root)
	Root() *Root
	LostKeyFocus()
	TotalHeight() float32
	TotalWidth() float32
	SetLayout(ILayout)
	SetPosition(x, y float32)
	SetPositionX(x float32)
	SetPositionY(y float32)
}

IPanel is the interface for all panel types

type Image

type Image struct {
	Panel // Embedded panel
	// contains filtered or unexported fields
}

Image is a Panel which contains a single Image

func NewImage

func NewImage(imgfile string) (image *Image, err error)

NewImage creates and returns an image panel with the image from the specified image used as a texture. Initially the size of the panel content area is the exact size of the image.

func NewImageFromRGBA

func NewImageFromRGBA(rgba *image.RGBA) *Image

NewImageFromRGBA creates and returns an image panel from the specified image

func NewImageFromTex

func NewImageFromTex(tex *texture.Texture2D) *Image

NewImageFromTex creates and returns an image panel from the specified texture2D

func (*Image) SetImage

func (i *Image) SetImage(imgfile string) error

SetImage sets the image from the specified image file

func (*Image) SetTexture

func (i *Image) SetTexture(tex *texture.Texture2D) *texture.Texture2D

SetTexture changes the image texture to the specified texture2D. It returns a pointer to the previous texture.

type ImageButton

type ImageButton struct {
	*Panel // Embedded Panel
	// contains filtered or unexported fields
}

ImageButton represents an image button GUI element

func NewImageButton

func NewImageButton(normalImgPath string) (*ImageButton, error)

NewImageButton creates and returns a pointer to a new ImageButton widget with the specified image.

func (*ImageButton) Dispose

func (b *ImageButton) Dispose()

Dispose releases resources used by this widget

func (*ImageButton) SetFontSize

func (b *ImageButton) SetFontSize(size float64)

SetFontSize sets the font size of the label/icon

func (*ImageButton) SetIcon

func (b *ImageButton) SetIcon(icode string)

SetIcon sets the icon

func (*ImageButton) SetImage

func (b *ImageButton) SetImage(state ButtonState, imgfile string) error

SetImage sets the button left image from the specified filename If there is currently a selected icon, it is removed

func (*ImageButton) SetStyles

func (b *ImageButton) SetStyles(bs *ImageButtonStyles)

SetStyles set the button styles overriding the default style

func (*ImageButton) SetText

func (b *ImageButton) SetText(text string)

SetText sets the text of the label

type ImageButtonStyle

type ImageButtonStyle BasicStyle

ImageButtonStyle contains the styling of an ImageButton.

type ImageButtonStyles

type ImageButtonStyles struct {
	Normal   ImageButtonStyle
	Over     ImageButtonStyle
	Focus    ImageButtonStyle
	Pressed  ImageButtonStyle
	Disabled ImageButtonStyle
}

ImageButtonStyles contains one ImageButtonStyle for each possible ImageButton state.

type ImageLabel

type ImageLabel struct {
	Panel // Embedded panel
	// contains filtered or unexported fields
}

ImageLabel is a panel which can contain an Image or Icon plus a Label side by side.

func NewImageLabel

func NewImageLabel(text string) *ImageLabel

NewImageLabel creates and returns a pointer to a new image label widget with the specified text for the label and no image/icon

func (*ImageLabel) CopyFields

func (il *ImageLabel) CopyFields(other *ImageLabel)

CopyFields copies another image label icon/image and text to this one

func (*ImageLabel) ImageVisible

func (il *ImageLabel) ImageVisible() bool

ImageVisible returns the image visibility

func (*ImageLabel) SetBgColor

func (il *ImageLabel) SetBgColor(color *math32.Color)

SetBgColor sets the color of the image label background The color alpha is set to 1.0

func (*ImageLabel) SetBgColor4

func (il *ImageLabel) SetBgColor4(color *math32.Color4)

SetBgColor4 sets the color4 of the image label background

func (*ImageLabel) SetColor

func (il *ImageLabel) SetColor(color *math32.Color)

SetColor sets the color of the label and icon text

func (*ImageLabel) SetColor4

func (il *ImageLabel) SetColor4(color *math32.Color4)

SetColor4 sets the color4 of the label and icon

func (*ImageLabel) SetFontSize

func (il *ImageLabel) SetFontSize(size float64)

SetFontSize sets the size of the image label font size

func (*ImageLabel) SetIcon

func (il *ImageLabel) SetIcon(icon string)

SetIcon sets the image label icon from the default Icon font. If there is currently a selected image, it is removed

func (*ImageLabel) SetImage

func (il *ImageLabel) SetImage(img *Image)

SetImage sets the image label image

func (*ImageLabel) SetImageFromFile

func (il *ImageLabel) SetImageFromFile(imgfile string) error

SetImageFromFile sets the image label image from the specified filename If there is currently a selected icon, it is removed

func (*ImageLabel) SetImageVisible

func (il *ImageLabel) SetImageVisible(vis bool)

SetImageVisible sets the image visibility

func (*ImageLabel) SetText

func (il *ImageLabel) SetText(text string)

SetText sets the text of the image label

func (*ImageLabel) Text

func (il *ImageLabel) Text() string

Text returns the current label text

type ImageLabelStyle

type ImageLabelStyle BasicStyle

ImageLabelStyle contains the styling of an ImageLabel.

type Label

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

Label is a panel which contains a texture with text. The content size of the label panel is the exact size of the texture.

func NewIcon

func NewIcon(icon string) *Label

NewIcon creates and returns a label panel with the specified text drawn using the default icon font.

func NewLabel

func NewLabel(text string) *Label

NewLabel creates and returns a label panel with the specified text drawn using the default text font.

func NewLabelWithFont

func NewLabelWithFont(msg string, font *text.Font) *Label

NewLabelWithFont creates and returns a label panel with the specified text drawn using the specified font.

func (*Label) BgColor

func (l *Label) BgColor() math32.Color4

BgColor returns returns the background color.

func (*Label) Color

func (l *Label) Color() math32.Color4

Color returns the text color.

func (*Label) Font

func (l *Label) Font() *text.Font

Font returns the font.

func (*Label) FontDPI

func (l *Label) FontDPI() float64

FontDPI returns the resolution of the font in dots per inch (DPI).

func (*Label) FontSize

func (l *Label) FontSize() float64

FontSize returns the point size of the font.

func (*Label) LineSpacing

func (l *Label) LineSpacing() float64

LineSpacing returns the spacing between lines.

func (*Label) SetBgColor

func (l *Label) SetBgColor(color *math32.Color) *Label

SetBgColor sets the background color. The color alpha is set to 1.0

func (*Label) SetBgColor4

func (l *Label) SetBgColor4(color *math32.Color4) *Label

SetBgColor4 sets the background color.

func (*Label) SetColor

func (l *Label) SetColor(color *math32.Color) *Label

SetColor sets the text color. Alpha is set to 1 (opaque).

func (*Label) SetColor4

func (l *Label) SetColor4(color4 *math32.Color4) *Label

SetColor4 sets the text color.

func (*Label) SetFont

func (l *Label) SetFont(f *text.Font)

SetFont sets the font.

func (*Label) SetFontDPI

func (l *Label) SetFontDPI(dpi float64) *Label

SetFontDPI sets the resolution of the font in dots per inch (DPI).

func (*Label) SetFontSize

func (l *Label) SetFontSize(size float64) *Label

SetFontSize sets the point size of the font.

func (*Label) SetLineSpacing

func (l *Label) SetLineSpacing(spacing float64) *Label

SetLineSpacing sets the spacing between lines.

func (*Label) SetText

func (l *Label) SetText(text string)

SetText sets and draws the label text using the font.

func (*Label) Text

func (l *Label) Text() string

Text returns the label text.

type LabelStyle

type LabelStyle struct {
	PanelStyle
	text.FontAttributes
	FgColor math32.Color4
}

LabelStyle contains all the styling attributes of a Label. It's essentially a BasicStyle combined with FontAttributes.

type Panel

type Panel struct {
	*graphic.Graphic // Embedded graphic
	// contains filtered or unexported fields
}

Panel is 2D rectangular graphic which by default has a quad (2 triangles) geometry. When using the default geometry, a panel has margins, borders, paddings and a content area. The content area can be associated with a texture It is the building block of most GUI widgets.

func NewPanel

func NewPanel(width, height float32) *Panel

NewPanel creates and returns a pointer to a new panel with the specified dimensions in pixels and a default quad geometry

func (*Panel) Add

func (p *Panel) Add(ichild IPanel) *Panel

Add adds a child panel to this one

func (*Panel) ApplyStyle

func (p *Panel) ApplyStyle(ps *PanelStyle)

ApplyStyle applies the provided PanelStyle to the panel

func (*Panel) Borders

func (p *Panel) Borders() RectBounds

Borders returns this panel current border sizes

func (*Panel) BordersColor4

func (p *Panel) BordersColor4() math32.Color4

BordersColor4 returns current border color

func (*Panel) Bounded

func (p *Panel) Bounded() bool

Bounded returns this panel bounded state

func (*Panel) Color4

func (p *Panel) Color4() math32.Color4

Color4 returns the current color of the panel content area

func (*Panel) ContainsPosition

func (p *Panel) ContainsPosition(x, y float32) bool

ContainsPosition returns indication if this panel contains the specified screen position in pixels.

func (*Panel) ContentCoords

func (p *Panel) ContentCoords(wx, wy float32) (float32, float32)

ContentCoords converts the specified window absolute coordinates in pixels (as informed by OnMouse event) to this panel internal content area pixel coordinates

func (*Panel) ContentHeight

func (p *Panel) ContentHeight() float32

ContentHeight returns the current height of the content area in pixels

func (*Panel) ContentWidth

func (p *Panel) ContentWidth() float32

ContentWidth returns the current width of the content area in pixels

func (*Panel) Enabled

func (p *Panel) Enabled() bool

Enabled returns the current enabled state of this panel

func (*Panel) GetPanel

func (p *Panel) GetPanel() *Panel

GetPanel satisfies the IPanel interface and returns pointer to this panel

func (*Panel) Height

func (p *Panel) Height() float32

Height returns the current panel external height in pixels

func (*Panel) Initialize

func (p *Panel) Initialize(width, height float32)

Initialize initializes this panel and is normally used by other types which embed a panel.

func (*Panel) InitializeGraphic

func (p *Panel) InitializeGraphic(width, height float32, gr *graphic.Graphic)

InitializeGraphic initializes this panel with a different graphic

func (*Panel) InsideBorders

func (p *Panel) InsideBorders(x, y float32) bool

InsideBorders returns indication if the specified screen position in pixels is inside the panel borders, including the borders width. Unlike "ContainsPosition" is does not consider the panel margins.

func (*Panel) Intersects

func (p *Panel) Intersects(other *Panel) bool

Intersects returns if this panel intersects with the other panel

func (*Panel) Layout

func (p *Panel) Layout() ILayout

Layout returns this panel current layout

func (*Panel) LayoutParams

func (p *Panel) LayoutParams() interface{}

LayoutParams returns this panel current layout parameters

func (*Panel) LostKeyFocus

func (p *Panel) LostKeyFocus()

LostKeyFocus satisfies the IPanel interface and is called by gui root container when the panel loses the key focus

func (*Panel) Margins

func (p *Panel) Margins() RectBounds

Margins returns the current margin sizes in pixels

func (*Panel) Material

func (p *Panel) Material() *material.Material

Material returns a pointer for this panel core.Material

func (*Panel) MinHeight

func (p *Panel) MinHeight() float32

MinHeight returns the minimum height of this panel (ContentHeight = 0)

func (*Panel) MinWidth

func (p *Panel) MinWidth() float32

MinWidth returns the minimum width of this panel (ContentWidth = 0)

func (*Panel) NDC2Pix

func (p *Panel) NDC2Pix(nx, ny float32) (x, y float32)

NDC2Pix converts the specified NDC coordinates (-1,1) to relative pixel coordinates for this panel content area. 0,0 1,0 0,0 w,0 +--------+ +---------+ | | -------> | | +--------+ +---------+ 0,-1 1,-1 0,h w,h

func (*Panel) Paddings

func (p *Panel) Paddings() RectBounds

Paddings returns this panel padding sizes in pixels

func (*Panel) Pix2NDC

func (p *Panel) Pix2NDC(px, py float32) (nx, ny float32)

Pix2NDC converts the specified relative pixel coordinates to NDC coordinates for this panel content area 0,0 w,0 0,0 1,0 +---------+ +---------+ | | ------> | | +---------+ +---------+ 0,h w,h 0,-1 1,-1

func (*Panel) Pospix

func (p *Panel) Pospix() math32.Vector3

Pospix returns this panel absolute coordinate in pixels

func (*Panel) Remove

func (p *Panel) Remove(ichild IPanel) bool

Remove removes the specified child from this panel

func (*Panel) RenderSetup

func (p *Panel) RenderSetup(gs *gls.GLS, rinfo *core.RenderInfo)

RenderSetup is called by the Engine before drawing the object

func (*Panel) Root

func (p *Panel) Root() *Root

Root satisfies the IPanel interface Returns the pointer to the root panel for this panel's root.

func (*Panel) SetBorders

func (p *Panel) SetBorders(top, right, bottom, left float32)

SetBorders sets this panel border sizes in pixels and recalculates the panel external size

func (*Panel) SetBordersColor

func (p *Panel) SetBordersColor(color *math32.Color)

SetBordersColor sets the color of this panel borders The borders opacity is set to 1.0 (full opaque)

func (*Panel) SetBordersColor4

func (p *Panel) SetBordersColor4(color *math32.Color4)

SetBordersColor4 sets the color and opacity of this panel borders

func (*Panel) SetBordersFrom

func (p *Panel) SetBordersFrom(src *RectBounds)

SetBordersFrom sets this panel border sizes from the specified RectBounds pointer and recalculates the panel size

func (*Panel) SetBounded

func (p *Panel) SetBounded(bounded bool)

SetBounded sets this panel bounded state

func (*Panel) SetColor

func (p *Panel) SetColor(color *math32.Color) *Panel

SetColor sets the color of the panel paddings and content area

func (*Panel) SetColor4

func (p *Panel) SetColor4(color *math32.Color4) *Panel

SetColor4 sets the color of the panel paddings and content area

func (*Panel) SetContentAspectHeight

func (p *Panel) SetContentAspectHeight(height float32)

SetContentAspectHeight sets the height of the content area of the panel to the specified value and adjusts its width to keep the same aspect ratio.

func (*Panel) SetContentAspectWidth

func (p *Panel) SetContentAspectWidth(width float32)

SetContentAspectWidth sets the width of the content area of the panel to the specified value and adjusts its height to keep the same aspect radio.

func (*Panel) SetContentHeight

func (p *Panel) SetContentHeight(height float32)

SetContentHeight sets this panel content height to the specified dimension in pixels. The external size of the panel may increase or decrease to accommodate the new width

func (*Panel) SetContentSize

func (p *Panel) SetContentSize(width, height float32)

SetContentSize sets this panel content size to the specified dimensions. The external size of the panel may increase or decrease to acomodate the new content size.

func (*Panel) SetContentWidth

func (p *Panel) SetContentWidth(width float32)

SetContentWidth sets this panel content width to the specified dimension in pixels. The external size of the panel may increase or decrease to accommodate the new width

func (*Panel) SetEnabled

func (p *Panel) SetEnabled(state bool)

SetEnabled sets the panel enabled state A disabled panel do not process key or mouse events.

func (*Panel) SetHeight

func (p *Panel) SetHeight(height float32)

SetHeight sets this panel external height in pixels. The internal panel areas and positions are recalculated

func (*Panel) SetLayout

func (p *Panel) SetLayout(ilayout ILayout)

SetLayout sets the layout to use to position the children of this panel To remove the layout, call this function passing nil as parameter.

func (*Panel) SetLayoutParams

func (p *Panel) SetLayoutParams(params interface{})

SetLayoutParams sets the layout parameters for this panel

func (*Panel) SetMargins

func (p *Panel) SetMargins(top, right, bottom, left float32)

SetMargins set this panel margin sizes in pixels and recalculates the panel external size

func (*Panel) SetMarginsFrom

func (p *Panel) SetMarginsFrom(src *RectBounds)

SetMarginsFrom sets this panel margins sizes from the specified RectBounds pointer and recalculates the panel external size

func (*Panel) SetModelMatrix

func (p *Panel) SetModelMatrix(gl *gls.GLS, mm *math32.Matrix4)

SetModelMatrix calculates and sets the specified matrix with the model matrix for this panel

func (*Panel) SetPaddings

func (p *Panel) SetPaddings(top, right, bottom, left float32)

SetPaddings sets the panel padding sizes in pixels

func (*Panel) SetPaddingsColor

func (p *Panel) SetPaddingsColor(color *math32.Color)

SetPaddingsColor sets the color of this panel paddings.

func (*Panel) SetPaddingsFrom

func (p *Panel) SetPaddingsFrom(src *RectBounds)

SetPaddingsFrom sets this panel padding sizes from the specified RectBounds pointer and recalculates the panel size

func (*Panel) SetPosition

func (p *Panel) SetPosition(x, y float32)

SetPosition sets this panel absolute position in pixel coordinates from left to right and from top to bottom of the screen.

func (*Panel) SetRoot

func (p *Panel) SetRoot(root *Root)

SetRoot satisfies the IPanel interface. Sets the pointer to the root panel for this panel and all its children.

func (*Panel) SetSize

func (p *Panel) SetSize(width, height float32)

SetSize sets this panel external width and height in pixels.

func (*Panel) SetTopChild

func (p *Panel) SetTopChild(ipan IPanel)

SetTopChild sets the Z coordinate of the specified panel to be on top of all other children of this panel. The function does not check if the specified panel is a child of this one.

func (*Panel) SetWidth

func (p *Panel) SetWidth(width float32)

SetWidth sets this panel external width in pixels. The internal panel areas and positions are recalculated

func (*Panel) Size

func (p *Panel) Size() (float32, float32)

Size returns this panel current external width and height in pixels

func (*Panel) TotalHeight

func (p *Panel) TotalHeight() float32

TotalHeight satisfies the IPanel interface and returns the total height of this panel considering visible not bounded children

func (*Panel) TotalWidth

func (p *Panel) TotalWidth() float32

TotalWidth satisfies the IPanel interface and returns the total width of this panel considering visible not bounded children

func (*Panel) UpdateMatrixWorld

func (p *Panel) UpdateMatrixWorld()

UpdateMatrixWorld overrides the standard core.Node version which is called by the Engine before rendering the frame.

func (*Panel) Width

func (p *Panel) Width() float32

Width returns the current panel external width in pixels

type PanelStyle

type PanelStyle struct {
	Margin      RectBounds
	Border      RectBounds
	Padding     RectBounds
	BorderColor math32.Color4
	BgColor     math32.Color4
}

PanelStyle contains all the styling attributes of a Panel.

type Rect

type Rect struct {
	X      float32
	Y      float32
	Width  float32
	Height float32
}

Rect represents a rectangle.

func (*Rect) Contains

func (r *Rect) Contains(x, y float32) bool

Contains determines whether a 2D point is inside the Rect.

type RectBounds

type RectBounds struct {
	Top    float32
	Right  float32
	Bottom float32
	Left   float32
}

RectBounds specifies the size of the boundaries of a rectangle. It can represent the thickness of the borders, the margins, or the padding of a rectangle.

func (*RectBounds) Set

func (bs *RectBounds) Set(top, right, bottom, left float32)

Set sets the values of the RectBounds.

type Root

type Root struct {
	Panel             // embedded panel
	core.TimerManager // embedded TimerManager
	// contains filtered or unexported fields
}

Root is the container and dispatcher of panel events

func NewRoot

func NewRoot(m *moblie.Moblie) *Root

NewRoot creates and returns a pointer to a gui root panel for the specified window func NewRoot(gs *gls.GLS, win window.IWindow) *Root { func NewRoot(gs *gls.GLS, moblie *moblie.Moblie) *Root { func NewRoot(gs *gls.GLS, win window.IWindow) *Root {

func (*Root) Add

func (r *Root) Add(ipan IPanel)

Add adds the specified panel to the root container list of children Overrides the Panel version because it needs to set the root panel field

func (*Root) ClearKeyFocus

func (r *Root) ClearKeyFocus()

ClearKeyFocus clears the key focus panel (if any) without calling LostKeyFocus() for previous focused panel

func (*Root) GetWH

func (r *Root) GetWH() (float32, float32)

func (*Root) HasKeyFocus

func (r *Root) HasKeyFocus(ipan IPanel) bool

HasKeyFocus checks if the specified panel has the key focus

func (*Root) HasMouseFocus

func (r *Root) HasMouseFocus(ipan IPanel) bool

HasMouseFocus checks if the specified panel has the mouse focus

func (*Root) SetGs

func (r *Root) SetGs(gs *gls.GLS)

func (*Root) SetKeyFocus

func (r *Root) SetKeyFocus(ipan IPanel)

SetKeyFocus sets the panel which will receive all keyboard events Passing nil will remove the focus (if any)

func (*Root) SetModal

func (r *Root) SetModal(ipan IPanel)

SetModal sets the modal panel. If there is a modal panel, only events for this panel are dispatched To remove the modal panel call this function with a nil panel.

func (*Root) SetMouseFocus

func (r *Root) SetMouseFocus(ipan IPanel)

SetMouseFocus sets the panel which will receive all mouse events Passing nil will restore the default event processing

func (*Root) SetScrollFocus

func (r *Root) SetScrollFocus(ipan IPanel)

SetScrollFocus sets the panel which will receive all scroll events Passing nil will restore the default event processing

func (*Root) StopPropagation

func (r *Root) StopPropagation(events int)

StopPropagation stops the propagation of the current event to outside the root panel (for example the 3D camera)

func (*Root) SubscribeMoblie

func (r *Root) SubscribeMoblie()

SubscribeWin subscribes this root panel to window events

type Style

type Style struct {
	Color       ColorStyle
	Font        *text.Font
	FontIcon    *text.Font
	Label       LabelStyle
	ImageButton ImageButtonStyles
}

Style contains the styles for all GUI elements

func NewDarkStyle

func NewDarkStyle() *Style

NewDarkStyle creates and returns a pointer to the a new "dark" style

func NewLightStyle

func NewLightStyle() *Style

NewLightStyle creates and returns a pointer to the a new "light" style

func StyleDefault

func StyleDefault() *Style

StyleDefault returns a pointer to the current default style

type VBoxLayout

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

VBoxLayout implements a panel layout which arranges the panel children vertically. The children can be separated by a space in pixels set by SetSpacing(). The whole group of children can be aligned vertically by SetAlignV() which can accept the following types of alignment:

AlignTop: Try to align the group of children to the top if the panel height is
greater the the sum of the children heights + spacing.

AlignBottom: Try to align the group of children to the bottoom if the panel height is
greater the the sum of the children heights + spacing.

AlignCenter: Try to align the group of children in the center if the panel height is
greater the the sum of the children heights + spacing.

AlignHeight: Try to align the individual children vertically with the same same space between each other.
Each individual child can be aligned horizontally by SetLayoutParameters()

If the layout method SetAutoHeight(true) is called, the panel minimum content height will be the sum of its children's heights plus the spacing.

If the layout method SetAutoWidth(true) is called, the panel minimum content width will be the width of the widest child.

func NewVBoxLayout

func NewVBoxLayout() *VBoxLayout

NewVBoxLayout creates and returns a pointer to a new horizontal box layout

func (*VBoxLayout) Recalc

func (bl *VBoxLayout) Recalc(ipan IPanel)

Recalc recalculates and sets the position and sizes of all children

func (*VBoxLayout) SetAlignV

func (bl *VBoxLayout) SetAlignV(align Align)

SetAlignV sets the vertical alignment of the whole group of items inside the parent panel and updates the layout if possible. This only has any effect if there are no expanded items.

func (*VBoxLayout) SetAutoHeight

func (bl *VBoxLayout) SetAutoHeight(state bool)

SetAutoHeight sets if the panel minimum height should be the height of the largest of its children's height.

func (*VBoxLayout) SetAutoWidth

func (bl *VBoxLayout) SetAutoWidth(state bool)

SetAutoWidth sets if the panel minimum width should be sum of its children's width plus the spacing

func (*VBoxLayout) SetSpacing

func (bl *VBoxLayout) SetSpacing(spacing float32)

SetSpacing sets the horizontal spacing between the items in pixels and updates the layout if possible

type VBoxLayoutParams

type VBoxLayoutParams struct {
	Expand float32 // item expand vertically factor (0 - no expand)
	AlignH Align   // item horizontal alignment
}

VBoxLayoutParams specify the horizontal alignment of each individual child.

Directories

Path Synopsis
Code generated by go-bindata.
Code generated by go-bindata.

Jump to

Keyboard shortcuts

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