Support Forum       G3D Web Page     
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
G3D::GuiFunctionBox Class Reference

Displays a Spline<float> with editable control points. More...

Inherits G3D::GuiControl.

Public Member Functions

bool canChangeNumPoints () const
 
const GuiTextcaption () const
 
float captionHeight () const
 For controls that have a caption outside the bounds of the control on the top or bottom, this is the size reserved for the caption. More...
 
float captionWidth () const
 For controls that have a caption outside the bounds of the control on the left, this is the size reserved for the caption. More...
 
const Rect2DclickRect () const
 Used by GuiContainers. More...
 
virtual float defaultCaptionHeight () const override
 Default caption size for this control. More...
 
virtual float defaultCaptionWidth () const
 
bool enabled () const
 
virtual void findControlUnderMouse (Vector2 mouse, GuiControl *&control)
 Return the enabled, visible control containing the mouse. More...
 
bool focused () const
 
Vector2 fromOSWindowCoords (const Vector2 &v) const
 Transforms v from OS window coordinates to this control's coordinates. More...
 
bool mouseOver () const
 
void moveBy (const Vector2 &delta)
 
void moveBy (float dx, float dy)
 
void moveRightOf (const GuiControl *control, const Vector2 &offset)
 If these two controls have the same parent, move this one immediately to the right of the argument. More...
 
void moveRightOf (const GuiControl *control, float offsetX=0.0f)
 
const Rect2Drect () const
 
void setCanChangeNumPoints (bool b)
 
virtual void setCaption (const GuiText &caption)
 
virtual void setCaptionHeight (float c)
 
virtual void setCaptionWidth (float c)
 
void setControlPointColor (const Color4 &c)
 
void setCurveColor (const Color4 &c)
 
virtual void setEnabled (bool e)
 
void setEventSource (GuiControl *c)
 
void setFocused (bool b)
 Grab or release keyboard focus. More...
 
void setGridColor (const Color4 &c)
 
void setHeight (float h)
 
void setPosition (const Vector2 &v)
 
void setPosition (float x, float y)
 
virtual void setRect (const Rect2D &rect)
 If you explicitly change the rectangle of a control, the containing pane may clip its borders. More...
 
void setSize (const Vector2 &v)
 
void setSize (float x, float y)
 
void setTimeBounds (float minTime, float maxTime)
 Default to [0, 1]. More...
 
void setValueBounds (float minVal, float maxVal)
 Setting these automatically clamps all spline points to the legal range. More...
 
void setVisible (bool b)
 
void setWidth (float w)
 
shared_ptr< GuiThemetheme () const
 
virtual bool toolStyle () const
 Return true if this is in tool button style. More...
 
Vector2 toOSWindowCoords (const Vector2 &v) const
 Returns the coordinates of v, which is in the coordinate system of this object, relative to the OSWindow on which it will be rendered. More...
 
Rect2D toOSWindowCoords (const Rect2D &r) const
 
bool visible () const
 
GuiWindowwindow () const
 Get the window containing this control. More...
 

Protected Types

enum  {
  LEFT_CAPTION_WIDTH = 80,
  TOP_CAPTION_HEIGHT = 20
}
 
enum  { NONE = -1 }
 

Protected Member Functions

 GuiFunctionBox (GuiContainer *parent, const GuiText &text, Spline< float > *spline)
 
void clampTimes (int i=NONE)
 Ensures that all spline time samples are monotonically increasing and within bounds. More...
 
void clampValues ()
 Ensure that spline values fit the legal range. More...
 
Vector2 controlPointLocation (int i) const
 Returns the pixel position at which this control point will render. More...
 
void drawBackground (RenderDevice *rd, const shared_ptr< GuiTheme > &skin) const
 
void drawControlPoints (RenderDevice *rd, const shared_ptr< GuiTheme > &skin) const
 
void drawSpline (RenderDevice *rd, const shared_ptr< GuiTheme > &skin) const
 
void fireEvent (GEventType type)
 Fires an event. More...
 
int getNearestControlPoint (const Vector2 &pixelLoc)
 Returns the control point nearest this location, creating it if there is no nearby control point. More...
 
virtual bool onEvent (const GEvent &event) override
 Events are only delivered (by GuiWindow) to a GuiControl when the control has the key focus. More...
 
virtual void render (RenderDevice *rd, const shared_ptr< GuiTheme > &theme, bool ancestorsEnabled) const override
 
Only methods on theme may be called from this method by default. More...
 

Protected Attributes

Rect2D m_bounds
 Rendering client bounds updated by every render. More...
 
bool m_canChangeNumPoints
 
GuiText m_caption
 
float m_captionHeight
 
float m_captionWidth
 
Rect2D m_clickRect
 Rect bounds used for mouse actions. More...
 
Rect2D m_clipBounds
 Bounds for mouse clicks and scissor region, updated by every render. More...
 
Color4 m_controlColor
 
bool m_drag
 True if dragging m_selected. More...
 
bool m_enabled
 
GuiControlm_eventSource
 Sent events should appear to be from this object, which is usually "this". More...
 
Color4 m_gridColor
 
GuiWindowm_gui
 The window that ultimately contains this control. More...
 
float m_maxTime
 
float m_maxValue
 
float m_minTime
 
float m_minValue
 
Vector2 m_mouseStart
 Mouse position when drag began. More...
 
GuiContainerm_parent
 Parent pane. More...
 
Rect2D m_rect
 Rect bounds used for rendering and layout. More...
 
Vector2 m_scale
 Derivative of (time, control) per pixel, computed during rendering. More...
 
int m_selected
 Index of the currently selected control point, NONE if no selection. More...
 
Spline< float > * m_spline
 
Color4 m_splineColor
 
float m_timeStart
 m_spline->time[m_selected] when drag began More...
 
float m_valueStart
 m_spline->control[m_selected] when drag began More...
 
bool m_visible
 

Friends

class GuiPane
 

Detailed Description

Displays a Spline<float> with editable control points.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protectedinherited
Enumerator
LEFT_CAPTION_WIDTH 
TOP_CAPTION_HEIGHT 

◆ anonymous enum

anonymous enum
protected
Enumerator
NONE 

Constructor & Destructor Documentation

◆ GuiFunctionBox()

G3D::GuiFunctionBox::GuiFunctionBox ( GuiContainer parent,
const GuiText text,
Spline< float > *  spline 
)
protected

Member Function Documentation

◆ canChangeNumPoints()

bool G3D::GuiFunctionBox::canChangeNumPoints ( ) const
inline

◆ caption()

const GuiText& G3D::GuiControl::caption ( ) const
inherited

◆ captionHeight()

float G3D::GuiControl::captionHeight ( ) const
inherited

For controls that have a caption outside the bounds of the control on the top or bottom, this is the size reserved for the caption.

◆ captionWidth()

float G3D::GuiControl::captionWidth ( ) const
inherited

For controls that have a caption outside the bounds of the control on the left, this is the size reserved for the caption.

◆ clampTimes()

void G3D::GuiFunctionBox::clampTimes ( int  i = NONE)
protected

Ensures that all spline time samples are monotonically increasing and within bounds.

Works outwards from element i.

Referenced by setTimeBounds(), and setValueBounds().

◆ clampValues()

void G3D::GuiFunctionBox::clampValues ( )
protected

Ensure that spline values fit the legal range.

Referenced by setValueBounds().

◆ clickRect()

const Rect2D& G3D::GuiControl::clickRect ( ) const
inlineinherited

Used by GuiContainers.

◆ controlPointLocation()

Vector2 G3D::GuiFunctionBox::controlPointLocation ( int  i) const
protected

Returns the pixel position at which this control point will render.

◆ defaultCaptionHeight()

virtual float G3D::GuiFunctionBox::defaultCaptionHeight ( ) const
overridevirtual

Default caption size for this control.

Reimplemented from G3D::GuiControl.

◆ defaultCaptionWidth()

virtual float G3D::GuiControl::defaultCaptionWidth ( ) const
inlinevirtualinherited

◆ drawBackground()

void G3D::GuiFunctionBox::drawBackground ( RenderDevice rd,
const shared_ptr< GuiTheme > &  skin 
) const
protected

◆ drawControlPoints()

void G3D::GuiFunctionBox::drawControlPoints ( RenderDevice rd,
const shared_ptr< GuiTheme > &  skin 
) const
protected

◆ drawSpline()

void G3D::GuiFunctionBox::drawSpline ( RenderDevice rd,
const shared_ptr< GuiTheme > &  skin 
) const
protected

◆ enabled()

bool G3D::GuiControl::enabled ( ) const
inherited

◆ findControlUnderMouse()

virtual void G3D::GuiControl::findControlUnderMouse ( Vector2  mouse,
GuiControl *&  control 
)
inlinevirtualinherited

Return the enabled, visible control containing the mouse.

The default implementation returns itself if the mouse is within its bounds. GuiContainers should override this to iterate through children. Since only one (non-overlapping) child will write to control, it is sufficient to call this on all children without testing to see if one already wrote to control.

Reimplemented in G3D::GuiNumberBox< Value >, G3D::GuiNumberBox< float >, G3D::GuiNumberBox< int >, G3D::GuiTextureBox, G3D::GuiPane, G3D::GuiScrollPane, G3D::GuiFrameBox, and G3D::GuiTabPane.

Referenced by G3D::GuiNumberBox< int >::findControlUnderMouse().

◆ fireEvent()

void G3D::GuiControl::fireEvent ( GEventType  type)
protectedinherited

Fires an event.

◆ focused()

bool G3D::GuiControl::focused ( ) const
inherited

◆ fromOSWindowCoords()

Vector2 G3D::GuiControl::fromOSWindowCoords ( const Vector2 v) const
inherited

Transforms v from OS window coordinates to this control's coordinates.

◆ getNearestControlPoint()

int G3D::GuiFunctionBox::getNearestControlPoint ( const Vector2 pixelLoc)
protected

Returns the control point nearest this location, creating it if there is no nearby control point.

◆ mouseOver()

bool G3D::GuiControl::mouseOver ( ) const
inherited

◆ moveBy() [1/2]

void G3D::GuiControl::moveBy ( const Vector2 delta)
inherited

◆ moveBy() [2/2]

void G3D::GuiControl::moveBy ( float  dx,
float  dy 
)
inherited

◆ moveRightOf() [1/2]

void G3D::GuiControl::moveRightOf ( const GuiControl control,
const Vector2 offset 
)
inherited

If these two controls have the same parent, move this one immediately to the right of the argument.

Parameters
offsetMay be negative

Referenced by G3D::GuiControl::moveRightOf().

◆ moveRightOf() [2/2]

void G3D::GuiControl::moveRightOf ( const GuiControl control,
float  offsetX = 0.0f 
)
inlineinherited

◆ onEvent()

virtual bool G3D::GuiFunctionBox::onEvent ( const GEvent event)
overrideprotectedvirtual

Events are only delivered (by GuiWindow) to a GuiControl when the control has the key focus.

If the control does not consume the event, the event is delivered to each of its GUI parents in order, back to the window's root pane.

Key focus is transferred during a mouse down event.

Reimplemented from G3D::GuiControl.

◆ rect()

const Rect2D& G3D::GuiControl::rect ( ) const
inherited

◆ render()

virtual void G3D::GuiFunctionBox::render ( RenderDevice rd,
const shared_ptr< GuiTheme > &  theme,
bool  ancestorsEnabled 
) const
overrideprotectedvirtual


Only methods on theme may be called from this method by default.

To make arbitrary RenderDevice calls, wrap them in GuiTheme::pauseRendering ... GuiTheme::resumeRendering.

Parameters
ancestorsEnabledDraw as disabled if this is false or if enabled() is false.

Implements G3D::GuiControl.

◆ setCanChangeNumPoints()

void G3D::GuiFunctionBox::setCanChangeNumPoints ( bool  b)
inline

◆ setCaption()

virtual void G3D::GuiControl::setCaption ( const GuiText caption)
virtualinherited

◆ setCaptionHeight()

virtual void G3D::GuiControl::setCaptionHeight ( float  c)
virtualinherited

◆ setCaptionWidth()

virtual void G3D::GuiControl::setCaptionWidth ( float  c)
virtualinherited

◆ setControlPointColor()

void G3D::GuiFunctionBox::setControlPointColor ( const Color4 c)
inline

◆ setCurveColor()

void G3D::GuiFunctionBox::setCurveColor ( const Color4 c)
inline

◆ setEnabled()

virtual void G3D::GuiControl::setEnabled ( bool  e)
virtualinherited

◆ setEventSource()

void G3D::GuiControl::setEventSource ( GuiControl c)
inlineinherited

◆ setFocused()

void G3D::GuiControl::setFocused ( bool  b)
inherited

Grab or release keyboard focus.

◆ setGridColor()

void G3D::GuiFunctionBox::setGridColor ( const Color4 c)
inline

◆ setHeight()

void G3D::GuiControl::setHeight ( float  h)
inherited

◆ setPosition() [1/2]

void G3D::GuiControl::setPosition ( const Vector2 v)
inherited

◆ setPosition() [2/2]

void G3D::GuiControl::setPosition ( float  x,
float  y 
)
inherited

◆ setRect()

virtual void G3D::GuiControl::setRect ( const Rect2D rect)
virtualinherited

If you explicitly change the rectangle of a control, the containing pane may clip its borders.

Call pack() on the containing pane (or window) to resize that container appropriately.

Reimplemented in G3D::GuiNumberBox< Value >, G3D::GuiNumberBox< float >, G3D::GuiNumberBox< int >, G3D::GuiTextureBox, G3D::GuiPane, G3D::GuiTextBox, G3D::GuiDropDownList, G3D::GuiScrollPane, G3D::GuiTabPane, G3D::GuiContainer, G3D::GuiFrameBox, G3D::GuiRadioButton, and G3D::GuiCheckBox.

◆ setSize() [1/2]

void G3D::GuiControl::setSize ( const Vector2 v)
inherited

◆ setSize() [2/2]

void G3D::GuiControl::setSize ( float  x,
float  y 
)
inherited

◆ setTimeBounds()

void G3D::GuiFunctionBox::setTimeBounds ( float  minTime,
float  maxTime 
)
inline

Default to [0, 1].

◆ setValueBounds()

void G3D::GuiFunctionBox::setValueBounds ( float  minVal,
float  maxVal 
)
inline

Setting these automatically clamps all spline points to the legal range.

◆ setVisible()

void G3D::GuiControl::setVisible ( bool  b)
inherited

◆ setWidth()

void G3D::GuiControl::setWidth ( float  w)
inherited

◆ theme()

shared_ptr<GuiTheme> G3D::GuiControl::theme ( ) const
inherited

◆ toolStyle()

virtual bool G3D::GuiControl::toolStyle ( ) const
inlinevirtualinherited

Return true if this is in tool button style.

Reimplemented in G3D::GuiRadioButton, G3D::GuiButton, and G3D::GuiCheckBox.

◆ toOSWindowCoords() [1/2]

Vector2 G3D::GuiControl::toOSWindowCoords ( const Vector2 v) const
inherited

Returns the coordinates of v, which is in the coordinate system of this object, relative to the OSWindow on which it will be rendered.

Referenced by G3D::GuiControl::toOSWindowCoords().

◆ toOSWindowCoords() [2/2]

Rect2D G3D::GuiControl::toOSWindowCoords ( const Rect2D r) const
inlineinherited

◆ visible()

bool G3D::GuiControl::visible ( ) const
inherited

◆ window()

GuiWindow* G3D::GuiControl::window ( ) const
inherited

Get the window containing this control.

Friends And Related Function Documentation

◆ GuiPane

friend class GuiPane
friend

Member Data Documentation

◆ m_bounds

Rect2D G3D::GuiFunctionBox::m_bounds
protected

Rendering client bounds updated by every render.

◆ m_canChangeNumPoints

bool G3D::GuiFunctionBox::m_canChangeNumPoints
protected

◆ m_caption

GuiText G3D::GuiControl::m_caption
protectedinherited

◆ m_captionHeight

float G3D::GuiControl::m_captionHeight
protectedinherited

◆ m_captionWidth

float G3D::GuiControl::m_captionWidth
protectedinherited

◆ m_clickRect

Rect2D G3D::GuiControl::m_clickRect
protectedinherited

Rect bounds used for mouse actions.

Updated by setRect.

Referenced by G3D::GuiControl::clickRect().

◆ m_clipBounds

Rect2D G3D::GuiFunctionBox::m_clipBounds
protected

Bounds for mouse clicks and scissor region, updated by every render.

◆ m_controlColor

Color4 G3D::GuiFunctionBox::m_controlColor
protected

Referenced by setControlPointColor().

◆ m_drag

bool G3D::GuiFunctionBox::m_drag
protected

True if dragging m_selected.

◆ m_enabled

bool G3D::GuiControl::m_enabled
protectedinherited

◆ m_eventSource

GuiControl* G3D::GuiControl::m_eventSource
protectedinherited

Sent events should appear to be from this object, which is usually "this".

Other controls can set the event source to create compound controls that seem atomic from the outside.

Referenced by G3D::GuiSlider< int >::GuiSlider(), G3D::GuiNumberBox< Value >::MyTextBox::MyTextBox(), and G3D::GuiControl::setEventSource().

◆ m_gridColor

Color4 G3D::GuiFunctionBox::m_gridColor
protected

Referenced by setGridColor().

◆ m_gui

GuiWindow* G3D::GuiControl::m_gui
protectedinherited

The window that ultimately contains this control.

◆ m_maxTime

float G3D::GuiFunctionBox::m_maxTime
protected

Referenced by setTimeBounds().

◆ m_maxValue

float G3D::GuiFunctionBox::m_maxValue
protected

Referenced by setValueBounds().

◆ m_minTime

float G3D::GuiFunctionBox::m_minTime
protected

Referenced by setTimeBounds().

◆ m_minValue

float G3D::GuiFunctionBox::m_minValue
protected

Referenced by setValueBounds().

◆ m_mouseStart

Vector2 G3D::GuiFunctionBox::m_mouseStart
protected

Mouse position when drag began.

◆ m_parent

GuiContainer* G3D::GuiControl::m_parent
protectedinherited

Parent pane.

◆ m_rect

Rect2D G3D::GuiControl::m_rect
protectedinherited

Rect bounds used for rendering and layout.

Relative to the enclosing pane's clientRect.

Referenced by G3D::GuiControl::findControlUnderMouse(), G3D::GuiNumberBox< int >::render(), G3D::GuiNumberBox< int >::setCaption(), and G3D::GuiNumberBox< int >::setRect().

◆ m_scale

Vector2 G3D::GuiFunctionBox::m_scale
protected

Derivative of (time, control) per pixel, computed during rendering.

◆ m_selected

int G3D::GuiFunctionBox::m_selected
protected

Index of the currently selected control point, NONE if no selection.

Referenced by setTimeBounds().

◆ m_spline

Spline<float>* G3D::GuiFunctionBox::m_spline
protected

◆ m_splineColor

Color4 G3D::GuiFunctionBox::m_splineColor
protected

Referenced by setCurveColor().

◆ m_timeStart

float G3D::GuiFunctionBox::m_timeStart
protected

m_spline->time[m_selected] when drag began

◆ m_valueStart

float G3D::GuiFunctionBox::m_valueStart
protected

m_spline->control[m_selected] when drag began

◆ m_visible

bool G3D::GuiControl::m_visible
protectedinherited

documentation generated on Wed Nov 24 2021 08:01:56 using doxygen 1.8.15