Support Forum       G3D Web Page     
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
G3D::GuiNumberBox< Value > Class Template Reference

Number editing textbox with associated slider. More...

Inherits G3D::GuiContainer.

Classes

class  MyTextBox
 Notifies the containing pane when the text is commited. More...
 

Public Types

enum  { CONTROL_HEIGHT = 25 }
 
enum  { CONTROL_WIDTH = 215 }
 
enum  { BUTTON_WIDTH = 80 }
 
enum  { TOOL_BUTTON_WIDTH = 50 }
 
enum  { CONTROL_PADDING = 4 }
 

Public Member Functions

 GuiNumberBox (GuiContainer *parent, const GuiText &caption, const Pointer< Value > &value, const GuiText &units, GuiTheme::SliderScale scale, Value minValue, Value maxValue, Value roundIncrement, GuiTheme::TextBoxStyle textBoxStyle, bool useLowerInf=false, bool useUpperInf=false)
 For use when building larger controls out of GuiNumberBox. More...
 
 ~GuiNumberBox ()
 
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...
 
const Rect2DclientRect () const
 Client rect bounds, relative to the parent (or window if there is no parent). More...
 
virtual float defaultCaptionHeight () const
 Default caption size for this control. More...
 
virtual float defaultCaptionWidth () const
 
bool enabled () const
 
virtual void findControlUnderMouse (Vector2 mouse, GuiControl *&control) override
 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...
 
virtual void increaseBounds (const Vector2 &extent)
 Updates this container to ensure that its client rect is least as wide and high as the specified extent, then recursively calls increaseBounds on its parent. More...
 
Value maxValue () const
 
Value minValue () const
 
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)
 
virtual bool onChildControlEvent (const GEvent &event)
 Invoked immediately (i.e., outside of the queue sequence) when a child fires an event through Widget::fireEvent. More...
 
const Rect2Drect () const
 
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...
 
virtual void setCaption (const GuiText &c) override
 
virtual void setCaptionHeight (float c)
 
virtual void setCaptionWidth (float c)
 
virtual void setEnabled (bool e) override
 
void setEventSource (GuiControl *c)
 
void setFocused (bool b)
 Grab or release keyboard focus. More...
 
void setHeight (float h)
 
void setPosition (const Vector2 &v)
 
void setPosition (float x, float y)
 
void setRange (Value lo, Value hi)
 
virtual void setRect (const Rect2D &rect) override
 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 setUnitsSize (float s)
 
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
 
float unitsSize () const
 The number of pixels between the text box and the slider. More...
 
bool visible () const
 
GuiWindowwindow () const
 Get the window containing this control. More...
 

Protected Types

enum  {
  LEFT_CAPTION_WIDTH = 80,
  TOP_CAPTION_HEIGHT = 20
}
 
enum  { textBoxWidth = 60 }
 

Protected Member Functions

void commit ()
 Called when the user commits the text box. More...
 
void fireEvent (GEventType type)
 Fires an event. More...
 
String formatString (double v, double roundIncrement)
 
virtual bool onEvent (const GEvent &event)
 Events are only delivered (by GuiWindow) to a GuiControl when the control has the key focus. More...
 
void roundAndClamp (Value &v) const
 
void updateText ()
 

Static Protected Member Functions

static String formatString (int v, int roundIncrement)
 
static String formatString (int64 v, int64 roundIncrement)
 
static String formatString (uint64 v, uint64 roundIncrement)
 
static String formatString (float v, float roundIncrement)
 
static String precision (double roundIncrement)
 Computes the format string for the precision specification needed to see the most significant digit of roundIncrement. More...
 

Protected Attributes

GuiText m_caption
 
float m_captionHeight
 
float m_captionWidth
 
Rect2D m_clickRect
 Rect bounds used for mouse actions. More...
 
Rect2D m_clientRect
 Position to which all child controls are relative. More...
 
bool m_enabled
 
GuiControlm_eventSource
 Sent events should appear to be from this object, which is usually "this". More...
 
String m_formatString
 
GuiWindowm_gui
 The window that ultimately contains this control. More...
 
bool m_lowerLimitInf
 
Value m_maxValue
 
Value m_minValue
 
Value m_oldValue
 Value represented by m_textValue. More...
 
GuiContainerm_parent
 Parent pane. More...
 
Rect2D m_rect
 Rect bounds used for rendering and layout. More...
 
Value m_roundIncrement
 Round to the nearest multiple of this value. More...
 
GuiSlider< Value > * m_slider
 nullptr if there is no slider More...
 
GuiTextBoxm_textBox
 
String m_textValue
 Text version of value. More...
 
GuiText m_units
 
float m_unitsSize
 
bool m_upperLimitInf
 
Pointer< Value > m_value
 Current value. More...
 
bool m_visible
 

Friends

class GuiPane
 
class GuiWindow
 

Detailed Description

template<class Value>
class G3D::GuiNumberBox< Value >

Number editing textbox with associated slider.

See GuiWindow for an example of creating a number box.

Events:

The min/mix/rounding values are enforced on the GUI, but not on the underlying value if it is changed programmatically.

"nan", "inf", and "-inf" are all parsed to the appropriate floating point values.

See also
G3D::GuiPane::addNumberBox

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited
Enumerator
CONTROL_HEIGHT 

◆ anonymous enum

anonymous enum
inherited
Enumerator
CONTROL_WIDTH 

◆ anonymous enum

anonymous enum
inherited
Enumerator
BUTTON_WIDTH 

◆ anonymous enum

anonymous enum
inherited
Enumerator
TOOL_BUTTON_WIDTH 

◆ anonymous enum

anonymous enum
inherited
Enumerator
CONTROL_PADDING 

◆ anonymous enum

anonymous enum
protectedinherited
Enumerator
LEFT_CAPTION_WIDTH 
TOP_CAPTION_HEIGHT 

◆ anonymous enum

template<class Value>
anonymous enum
protected
Enumerator
textBoxWidth 

Constructor & Destructor Documentation

◆ GuiNumberBox()

template<class Value>
G3D::GuiNumberBox< Value >::GuiNumberBox ( GuiContainer parent,
const GuiText caption,
const Pointer< Value > &  value,
const GuiText units,
GuiTheme::SliderScale  scale,
Value  minValue,
Value  maxValue,
Value  roundIncrement,
GuiTheme::TextBoxStyle  textBoxStyle,
bool  useLowerInf = false,
bool  useUpperInf = false 
)
inline

For use when building larger controls out of GuiNumberBox.

For making a regular GUI, use GuiPane::addNumberBox.

◆ ~GuiNumberBox()

template<class Value>
G3D::GuiNumberBox< Value >::~GuiNumberBox ( )
inline

Member Function Documentation

◆ 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.

◆ clickRect()

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

Used by GuiContainers.

◆ clientRect()

const Rect2D& G3D::GuiContainer::clientRect ( ) const
inlineinherited

Client rect bounds, relative to the parent (or window if there is no parent).

◆ commit()

template<class Value>
void G3D::GuiNumberBox< Value >::commit ( )
inlineprotected

Called when the user commits the text box.

◆ defaultCaptionHeight()

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

Default caption size for this control.

Reimplemented in G3D::GuiFunctionBox.

◆ defaultCaptionWidth()

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

◆ enabled()

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

◆ findControlUnderMouse()

template<class Value>
virtual void G3D::GuiNumberBox< Value >::findControlUnderMouse ( Vector2  mouse,
GuiControl *&  control 
)
inlineoverridevirtual

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 from G3D::GuiControl.

◆ fireEvent()

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

Fires an event.

◆ focused()

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

◆ formatString() [1/5]

template<class Value>
static String G3D::GuiNumberBox< Value >::formatString ( int  v,
int  roundIncrement 
)
inlinestaticprotected

◆ formatString() [2/5]

template<class Value>
static String G3D::GuiNumberBox< Value >::formatString ( int64  v,
int64  roundIncrement 
)
inlinestaticprotected

◆ formatString() [3/5]

template<class Value>
static String G3D::GuiNumberBox< Value >::formatString ( uint64  v,
uint64  roundIncrement 
)
inlinestaticprotected

◆ formatString() [4/5]

template<class Value>
static String G3D::GuiNumberBox< Value >::formatString ( float  v,
float  roundIncrement 
)
inlinestaticprotected

◆ formatString() [5/5]

template<class Value>
String G3D::GuiNumberBox< Value >::formatString ( double  v,
double  roundIncrement 
)
inlineprotected

◆ fromOSWindowCoords()

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

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

◆ increaseBounds()

virtual void G3D::GuiContainer::increaseBounds ( const Vector2 extent)
virtualinherited

Updates this container to ensure that its client rect is least as wide and high as the specified extent, then recursively calls increaseBounds on its parent.

Used during automatic layout sizing.

◆ maxValue()

template<class Value>
Value G3D::GuiNumberBox< Value >::maxValue ( ) const
inline

◆ minValue()

template<class Value>
Value G3D::GuiNumberBox< Value >::minValue ( ) const
inline

◆ 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

◆ onChildControlEvent()

virtual bool G3D::GuiContainer::onChildControlEvent ( const GEvent event)
virtualinherited

Invoked immediately (i.e., outside of the queue sequence) when a child fires an event through Widget::fireEvent.

If this method returns true, the event is never submitted to the event queue. The default implementation passes the event to the GUI parent of this GuiContainer.

This enables creation of new custom controls by embedding other controls inside a GuiContainer; the container can suppress or watch the child control events in order to present its own behavior to its parent and the GuiWindow.

◆ onEvent()

virtual bool G3D::GuiControl::onEvent ( const GEvent event)
inlineprotectedvirtualinherited

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 in G3D::GuiTextureBox, G3D::GuiTextBox, G3D::GuiFunctionBox, G3D::GuiScrollBar, G3D::GuiDropDownList, G3D::GuiButton, G3D::ProfilerWindow::ProfilerTreeDisplay, G3D::GuiRadioButton, G3D::_GuiSliderBase, G3D::GuiTabPane, G3D::GuiCheckBox, G3D::GuiScrollPane, and G3D::GuiMultiLineTextBox.

◆ precision()

template<class Value>
static String G3D::GuiNumberBox< Value >::precision ( double  roundIncrement)
inlinestaticprotected

Computes the format string for the precision specification needed to see the most significant digit of roundIncrement.

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

◆ rect()

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

◆ render()

template<class Value>
virtual void G3D::GuiNumberBox< Value >::render ( RenderDevice rd,
const shared_ptr< GuiTheme > &  theme,
bool  ancestorsEnabled 
) const
inlineoverridevirtual


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.

◆ roundAndClamp()

template<class Value>
void G3D::GuiNumberBox< Value >::roundAndClamp ( Value &  v) const
inlineprotected

◆ setCaption()

template<class Value>
virtual void G3D::GuiNumberBox< Value >::setCaption ( const GuiText c)
inlineoverridevirtual

Reimplemented from G3D::GuiControl.

◆ setCaptionHeight()

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

◆ setCaptionWidth()

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

◆ setEnabled()

template<class Value>
virtual void G3D::GuiNumberBox< Value >::setEnabled ( bool  e)
inlineoverridevirtual

Reimplemented from G3D::GuiControl.

◆ setEventSource()

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

◆ setFocused()

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

Grab or release keyboard focus.

◆ 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

◆ setRange()

template<class Value>
void G3D::GuiNumberBox< Value >::setRange ( Value  lo,
Value  hi 
)
inline

◆ setRect()

template<class Value>
virtual void G3D::GuiNumberBox< Value >::setRect ( const Rect2D rect)
inlineoverridevirtual

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 from G3D::GuiContainer.

Referenced by G3D::GuiNumberBox< int >::setCaption(), and G3D::GuiNumberBox< int >::setUnitsSize().

◆ setSize() [1/2]

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

◆ setSize() [2/2]

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

◆ setUnitsSize()

template<class Value>
void G3D::GuiNumberBox< Value >::setUnitsSize ( float  s)
inline

◆ 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

◆ unitsSize()

template<class Value>
float G3D::GuiNumberBox< Value >::unitsSize ( ) const
inline

The number of pixels between the text box and the slider.

◆ updateText()

template<class Value>
void G3D::GuiNumberBox< Value >::updateText ( )
inlineprotected

◆ 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

template<class Value>
friend class GuiPane
friend

◆ GuiWindow

template<class Value>
friend class GuiWindow
friend

Member Data Documentation

◆ 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_clientRect

Rect2D G3D::GuiContainer::m_clientRect
protectedinherited

Position to which all child controls are relative.

Referenced by G3D::GuiContainer::clientRect(), G3D::GuiNumberBox< int >::findControlUnderMouse(), and G3D::GuiNumberBox< int >::render().

◆ 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_formatString

template<class Value>
String G3D::GuiNumberBox< Value >::m_formatString
protected

◆ m_gui

GuiWindow* G3D::GuiControl::m_gui
protectedinherited

The window that ultimately contains this control.

◆ m_lowerLimitInf

template<class Value>
bool G3D::GuiNumberBox< Value >::m_lowerLimitInf
protected

◆ m_maxValue

template<class Value>
Value G3D::GuiNumberBox< Value >::m_maxValue
protected

◆ m_minValue

template<class Value>
Value G3D::GuiNumberBox< Value >::m_minValue
protected

◆ m_oldValue

template<class Value>
Value G3D::GuiNumberBox< Value >::m_oldValue
protected

◆ 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_roundIncrement

template<class Value>
Value G3D::GuiNumberBox< Value >::m_roundIncrement
protected

Round to the nearest multiple of this value.

Referenced by G3D::GuiNumberBox< int >::GuiNumberBox(), and G3D::GuiNumberBox< int >::roundAndClamp().

◆ m_slider

template<class Value>
GuiSlider<Value>* G3D::GuiNumberBox< Value >::m_slider
protected

◆ m_textBox

template<class Value>
GuiTextBox* G3D::GuiNumberBox< Value >::m_textBox
protected

◆ m_textValue

template<class Value>
String G3D::GuiNumberBox< Value >::m_textValue
protected

◆ m_units

template<class Value>
GuiText G3D::GuiNumberBox< Value >::m_units
protected

◆ m_unitsSize

template<class Value>
float G3D::GuiNumberBox< Value >::m_unitsSize
protected

◆ m_upperLimitInf

template<class Value>
bool G3D::GuiNumberBox< Value >::m_upperLimitInf
protected

◆ m_value

template<class Value>
Pointer<Value> G3D::GuiNumberBox< Value >::m_value
protected

◆ m_visible

bool G3D::GuiControl::m_visible
protectedinherited

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