Support Forum G3D Web Page |
Renders UI elements. More...
Inherits G3D::ReferenceCountedObject.
Classes | |
class | TextStyle |
Default style information for captions. More... | |
Public Member Functions | |
void | beginRendering (class RenderDevice *rd, float pixelScale) |
Call before all other render methods. More... | |
Vector2 | bounds (const GuiText &text) const |
Computes the rendered size of this text (max of enabled and disabled versions) More... | |
Rect2D | canvasToClickBounds (const Rect2D &bounds, float captionHeight) const |
Rect2D | canvasToClientBounds (const Rect2D &bounds, float captionHeight) const |
Given the full bounds around a canvas, returns the internal region for rendering in. More... | |
Rect2D | checkBoxToClickBounds (const Rect2D &bounds, const GuiText &caption) const |
Computes the bounds around the checkbox and caption. More... | |
Rect2D | clientToPaneBounds (const Rect2D &bounds, const GuiText &caption, PaneStyle paneStyle) const |
Rect2D | clientToWindowBounds (const Rect2D &bounds, WindowStyle frameStyle) const |
Given the area that controls should appear in for a window, returns the bounds that should be used to draw the window. More... | |
const TextStyle & | defaultStyle () const |
Return the default text style. More... | |
Rect2D | dropDownListToClickBounds (const Rect2D &bounds, float captionWidth) const |
Given the bounds of a full dropDownList and caption, returns the bounds around just the control itself. More... | |
void | endRendering () |
Call after all other render methods. More... | |
Rect2D | horizontalScrollBarToBarBounds (const Rect2D &bounds) const |
Rect2D | horizontalScrollBarToThumbBounds (const Rect2D &bounds, float pos, float scale) const |
Rect2D | horizontalSliderToThumbBounds (const Rect2D &bounds, float pos, float captionWidth) const |
Returns the position of the thumb button, which is needed for processing UI events for the slider. More... | |
Rect2D | horizontalSliderToTrackBounds (const Rect2D &bounds, float captionWidth) const |
Vector2 | minButtonSize (const GuiText &text, ButtonStyle buttonStyle) const |
Returns the size a button would have to be to enclose this caption. More... | |
Rect2D | paneToClientBounds (const Rect2D &bounds, const GuiText &caption, PaneStyle paneStyle) const |
void | pauseRendering () |
Invoke from a custom GuiControl::render to make arbitrary RenderDevice calls. More... | |
void | popClientRect () |
void | pushClientRect (const Rect2D &r) |
Offsets all subsequent rendering by r.x0y0() and sets the clipping region to r. More... | |
Rect2D | radioButtonToClickBounds (const Rect2D &bounds, const GuiText &caption) const |
Computes the bounds around the radio button and caption. More... | |
void | renderButton (const Rect2D &bounds, bool enabled, bool focused, bool pushed, const GuiText &text, ButtonStyle buttonStyle) |
Only call between beginRendering and endRendering. More... | |
void | renderButtonBorder (const Rect2D &bounds, bool focused, ButtonStyle buttonStyle) |
Only call between beginRendering and endRendering. More... | |
void | renderCanvas (const Rect2D &bounds, bool enabled, bool focused, const GuiText &caption, float captionHeight) |
Render a drawing area with borders that look like a text box. More... | |
void | renderCheckBox (const Rect2D &bounds, bool enabled, bool focused, bool checked, const GuiText &text) |
Only call between beginRendering and endRendering. More... | |
void | renderDropDownList (const Rect2D &bounds, bool enabled, bool focused, bool menuOpen, const GuiText &contentText, const GuiText &text, float captionWidth) |
void | renderHorizontalScrollBar (const Rect2D &bounds, float pos, float scale, bool focused) |
void | renderHorizontalSlider (const Rect2D &bounds, float pos, bool enabled, bool focused, const GuiText &text, float captionWidth) |
Only call between beginRendering and endRendering. More... | |
void | renderLabel (const Rect2D &bounds, const GuiText &text, GFont::XAlign xalign, GFont::YAlign yalign, bool enabled, bool wordWrap=false) const |
Only call between beginRendering and endRendering. More... | |
void | renderMultiLineTextBox (const Rect2D &bounds, bool enabled, bool focused, const GuiText &caption, float captionWidth, const GuiText &text, const GuiText &cursor, int cursorPosition, int highlightPosition, TextBoxStyle style) |
void | renderPane (const Rect2D &fullBounds, const GuiText &caption, PaneStyle paneStyle) |
void | renderRadioButton (const Rect2D &bounds, bool enabled, bool focused, bool checked, const GuiText &text) |
Only call between beginRendering and endRendering. More... | |
void | renderSelection (const Rect2D &bounds) |
Render the selection region for a menu or list. More... | |
void | renderTextBox (const Rect2D &bounds, bool enabled, bool focused, const GuiText &caption, float captionWidth, const GuiText &text, const GuiText &cursor, int cursorPosition, int highlightPosition, TextBoxStyle style) |
Render a single-line text box. More... | |
void | renderTextBoxBorder (const Rect2D &fullBounds, bool enabled, bool focused) |
Render the border that is used for a text box. More... | |
void | renderVerticalScrollBar (const Rect2D &bounds, float pos, float scale, bool focused) |
Only call between beginRendering and endRendering. More... | |
void | renderWindow (const Rect2D &bounds, bool focused, bool hasCloseButton, bool closeButtonIsDown, bool closeIsFocused, const GuiText &text, WindowStyle frameStyle) |
Only call between beginRendering and endRendering. More... | |
void | resumeRendering () |
float | scrollBarWidth () const |
float | textBoxBorderWidth () const |
Pad | textBoxPadding () const |
Rect2D | textBoxToClickBounds (const Rect2D &bounds, float captionWidth) const |
Rect2D | verticalScrollBarToBarBounds (const Rect2D &bounds) const |
Rect2D | verticalScrollBarToThumbBounds (const Rect2D &bounds, float pos, float scale) const |
Returns the position of the thumb button, which is needed for processing UI events for the scrollBar. More... | |
Rect2D | windowToClientBounds (const Rect2D &bounds, WindowStyle frameStyle) const |
Given the bounds on a window's borders, returns the bounds of the area inside the window where controls will appear. More... | |
Rect2D | windowToCloseButtonBounds (const Rect2D &bounds, WindowStyle frameStyle) const |
Rect2D | windowToTitleBounds (const Rect2D &bounds, WindowStyle frameStyle) const |
Static Public Member Functions | |
static shared_ptr< GuiTheme > | fromFile (const String &filename, shared_ptr< GFont > fallbackFont=shared_ptr< GFont >(), float fallbackSize=11, const Color4 &fallbackColor=Color3::black(), const Color4 &fallbackOutlineColor=Color4::clear()) |
May return a cached copy. More... | |
static void | makeThemeFromSourceFiles (const String &sourceDir, const String &whiteName, const String &blackName, const String &coordsFile, const String &destFile) |
Create a .gtm file from source files. More... | |
Static Public Attributes | |
static weak_ptr< GuiTheme > | lastThemeLoaded |
Static Protected Member Functions | |
template<class T , class ... ArgTypes> | |
static shared_ptr< T > | createShared (ArgTypes &&... args) |
Like std::make_shared, but works for protected constructors. More... | |
Friends | |
class | GuiThemeEditor |
class | GuiWindow |
Renders UI elements.
Loads and renders G3D GUI .gtm files, which can be used with G3D::Gui. .gtm files can be found in the data module data/gui directory.
Can also be used to explicitly render a UI without actual controls behind it, for example:
theme->beginRendering(rd); theme->renderWindow(Rect2D::xywh(80, 70, 550, 250), false, false, false, false, "Window", GuiTheme::NORMAL_WINDOW_STYLE); theme->renderWindow(Rect2D::xywh(500, 120, 50, 150), true, true, true, "Tools", GuiTheme::TOOL_WINDOW_STYLE); theme->renderCheckBox(Rect2D::xywh(100, 100, 20, 20), true, true, true, "Check box"); theme->renderRadioButton(Rect2D::xywh(100, 120, 20, 20), true, false, false, "Radio button"); theme->renderButton(Rect2D::xywh(100, 160, 80, 27), true, true, true, "Button"); theme->setFont(timesFont, 12, Color3::black(), Color4::clear()); theme->renderButton(Rect2D::xywh(200, 160, 80, 27), true, true, true, "New Font"); theme->setFont(arialFont, 10, Color3::black(), Color4::clear()); theme->renderHorizontalSlider(Rect2D::xywh(100, 200, 150, 27), 0.5f, true, false, "Slider");
int s = 30; theme->renderButton(Rect2D::xywh(100 + s * 0, 230, 30, 30), true, false, false, GuiText("7", iconFont)); theme->renderButton(Rect2D::xywh(100 + s * 1, 230, 30, 30), true, false, false, GuiText("4", iconFont)); theme->renderButton(Rect2D::xywh(100 + s * 2, 230, 30, 30), true, false, false, GuiText("=", iconFont)); theme->renderButton(Rect2D::xywh(100 + s * 3, 230, 30, 30), true, false, true, GuiText(";", iconFont)); theme->renderButton(Rect2D::xywh(100 + s * 4, 230, 30, 30), true, false, false, GuiText("<", iconFont)); theme->renderButton(Rect2D::xywh(100 + s * 5, 230, 30, 30), true, false, false, GuiText("8", iconFont)); theme->setFont(arialFont, 10, Color3::black(), Color4::clear()); theme->endRendering();
Controls the appearance of the window's borders and background.
void G3D::GuiTheme::beginRendering | ( | class RenderDevice * | rd, |
float | pixelScale | ||
) |
Call before all other render methods.
Computes the rendered size of this text (max of enabled and disabled versions)
Given the full bounds around a canvas, returns the internal region for rendering in.
Rect2D G3D::GuiTheme::checkBoxToClickBounds | ( | const Rect2D & | bounds, |
const GuiText & | caption | ||
) | const |
Computes the bounds around the checkbox and caption.
Rect2D G3D::GuiTheme::clientToPaneBounds | ( | const Rect2D & | bounds, |
const GuiText & | caption, | ||
PaneStyle | paneStyle | ||
) | const |
Rect2D G3D::GuiTheme::clientToWindowBounds | ( | const Rect2D & | bounds, |
WindowStyle | frameStyle | ||
) | const |
Given the area that controls should appear in for a window, returns the bounds that should be used to draw the window.
Note that the window's shadow or other effects may exceed these bounds when rendering.
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
|
inline |
Return the default text style.
Given the bounds of a full dropDownList and caption, returns the bounds around just the control itself.
void G3D::GuiTheme::endRendering | ( | ) |
Call after all other render methods.
|
static |
May return a cached copy.
filename | Name of the .gtm file. |
Rect2D G3D::GuiTheme::horizontalScrollBarToThumbBounds | ( | const Rect2D & | bounds, |
float | pos, | ||
float | scale | ||
) | const |
Rect2D G3D::GuiTheme::horizontalSliderToThumbBounds | ( | const Rect2D & | bounds, |
float | pos, | ||
float | captionWidth | ||
) | const |
Returns the position of the thumb button, which is needed for processing UI events for the slider.
Rect2D G3D::GuiTheme::horizontalSliderToTrackBounds | ( | const Rect2D & | bounds, |
float | captionWidth | ||
) | const |
|
static |
Create a .gtm file from source files.
Used as a preprocess when creating new themes. You probably don't need to call this because most people will want to use pre-existing skins (making a theme is a time-consuming artistic process!)
sourceDir | Directory containing the whiteName, blackName and coordsFile files. |
whiteName | Image of controls on a white background, must be in sourceDir |
blackName | Image of controls on a black background, must be in sourceDir |
coordsFile | Text file describing the location of controls |
destFile | Output filename for the built gui theme (should use .gtm extension) |
Vector2 G3D::GuiTheme::minButtonSize | ( | const GuiText & | text, |
ButtonStyle | buttonStyle | ||
) | const |
Returns the size a button would have to be to enclose this caption.
Rect2D G3D::GuiTheme::paneToClientBounds | ( | const Rect2D & | bounds, |
const GuiText & | caption, | ||
PaneStyle | paneStyle | ||
) | const |
void G3D::GuiTheme::pauseRendering | ( | ) |
Invoke from a custom GuiControl::render to make arbitrary RenderDevice calls.
Be sure to call resumeRendering() when done. Invokes RenderDevice::pushState automatically.
void G3D::GuiTheme::popClientRect | ( | ) |
void G3D::GuiTheme::pushClientRect | ( | const Rect2D & | r | ) |
Offsets all subsequent rendering by r.x0y0() and sets the clipping region to r.
Call only between beginRendering and endRendering.
Rect2D G3D::GuiTheme::radioButtonToClickBounds | ( | const Rect2D & | bounds, |
const GuiText & | caption | ||
) | const |
Computes the bounds around the radio button and caption.
void G3D::GuiTheme::renderButton | ( | const Rect2D & | bounds, |
bool | enabled, | ||
bool | focused, | ||
bool | pushed, | ||
const GuiText & | text, | ||
ButtonStyle | buttonStyle | ||
) |
Only call between beginRendering and endRendering.
void G3D::GuiTheme::renderButtonBorder | ( | const Rect2D & | bounds, |
bool | focused, | ||
ButtonStyle | buttonStyle | ||
) |
Only call between beginRendering and endRendering.
void G3D::GuiTheme::renderCanvas | ( | const Rect2D & | bounds, |
bool | enabled, | ||
bool | focused, | ||
const GuiText & | caption, | ||
float | captionHeight | ||
) |
Render a drawing area with borders that look like a text box.
The caption for a canvas is rendered above it and the canvas has the full width of its bounds.
void G3D::GuiTheme::renderCheckBox | ( | const Rect2D & | bounds, |
bool | enabled, | ||
bool | focused, | ||
bool | checked, | ||
const GuiText & | text | ||
) |
Only call between beginRendering and endRendering.
void G3D::GuiTheme::renderDropDownList | ( | const Rect2D & | bounds, |
bool | enabled, | ||
bool | focused, | ||
bool | menuOpen, | ||
const GuiText & | contentText, | ||
const GuiText & | text, | ||
float | captionWidth | ||
) |
void G3D::GuiTheme::renderHorizontalScrollBar | ( | const Rect2D & | bounds, |
float | pos, | ||
float | scale, | ||
bool | focused | ||
) |
void G3D::GuiTheme::renderHorizontalSlider | ( | const Rect2D & | bounds, |
float | pos, | ||
bool | enabled, | ||
bool | focused, | ||
const GuiText & | text, | ||
float | captionWidth | ||
) |
Only call between beginRendering and endRendering.
Label is on the right, slider is aligned with the left edge
pos | 0 = left edge, 1 = right edge |
void G3D::GuiTheme::renderLabel | ( | const Rect2D & | bounds, |
const GuiText & | text, | ||
GFont::XAlign | xalign, | ||
GFont::YAlign | yalign, | ||
bool | enabled, | ||
bool | wordWrap = false |
||
) | const |
Only call between beginRendering and endRendering.
void G3D::GuiTheme::renderMultiLineTextBox | ( | const Rect2D & | bounds, |
bool | enabled, | ||
bool | focused, | ||
const GuiText & | caption, | ||
float | captionWidth, | ||
const GuiText & | text, | ||
const GuiText & | cursor, | ||
int | cursorPosition, | ||
int | highlightPosition, | ||
TextBoxStyle | style | ||
) |
void G3D::GuiTheme::renderPane | ( | const Rect2D & | fullBounds, |
const GuiText & | caption, | ||
PaneStyle | paneStyle | ||
) |
void G3D::GuiTheme::renderRadioButton | ( | const Rect2D & | bounds, |
bool | enabled, | ||
bool | focused, | ||
bool | checked, | ||
const GuiText & | text | ||
) |
Only call between beginRendering and endRendering.
void G3D::GuiTheme::renderSelection | ( | const Rect2D & | bounds | ) |
Render the selection region for a menu or list.
void G3D::GuiTheme::renderTextBox | ( | const Rect2D & | bounds, |
bool | enabled, | ||
bool | focused, | ||
const GuiText & | caption, | ||
float | captionWidth, | ||
const GuiText & | text, | ||
const GuiText & | cursor, | ||
int | cursorPosition, | ||
int | highlightPosition, | ||
TextBoxStyle | style | ||
) |
Render a single-line text box.
Only call between beginRendering and endRendering. Automatically shifts text so that a cursor at character index given by cursorPosition is visible on screen.
void G3D::GuiTheme::renderTextBoxBorder | ( | const Rect2D & | fullBounds, |
bool | enabled, | ||
bool | focused | ||
) |
Render the border that is used for a text box.
Only call between beginRendering and endRendering. Used to render the border for scrollPane.
void G3D::GuiTheme::renderVerticalScrollBar | ( | const Rect2D & | bounds, |
float | pos, | ||
float | scale, | ||
bool | focused | ||
) |
Only call between beginRendering and endRendering.
pos | 0 when the thumb is at the top of the scroll bar and it is equal to the other param scale when it is at the bottom of the bar |
scale | is the maximum value that pos can be |
void G3D::GuiTheme::renderWindow | ( | const Rect2D & | bounds, |
bool | focused, | ||
bool | hasCloseButton, | ||
bool | closeButtonIsDown, | ||
bool | closeIsFocused, | ||
const GuiText & | text, | ||
WindowStyle | frameStyle | ||
) |
Only call between beginRendering and endRendering.
bounds | Corresponds to the footprint of the window; dropshadows and glows may still render outside this area. |
void G3D::GuiTheme::resumeRendering | ( | ) |
|
inline |
|
inline |
|
inline |
Rect2D G3D::GuiTheme::verticalScrollBarToThumbBounds | ( | const Rect2D & | bounds, |
float | pos, | ||
float | scale | ||
) | const |
Returns the position of the thumb button, which is needed for processing UI events for the scrollBar.
Rect2D G3D::GuiTheme::windowToClientBounds | ( | const Rect2D & | bounds, |
WindowStyle | frameStyle | ||
) | const |
Given the bounds on a window's borders, returns the bounds of the area inside the window where controls will appear.
Rect2D G3D::GuiTheme::windowToCloseButtonBounds | ( | const Rect2D & | bounds, |
WindowStyle | frameStyle | ||
) | const |
Rect2D G3D::GuiTheme::windowToTitleBounds | ( | const Rect2D & | bounds, |
WindowStyle | frameStyle | ||
) | const |
|
friend |
|
friend |
|
static |