![]() |
Divide Framework 0.1
A free and open-source 3D Framework under heavy development
|
Graphical User Interface. More...
#include <GUI.h>
Public Types | |
using | GUIMapPerScene = hashMap< I64, SceneGUIElements * > |
![]() | |
using | GUIMap = hashMap< U64, std::pair< GUIElement *, bool > > |
using | ButtonCallback = DELEGATE< void, I64 > |
Public Member Functions | |
GUI (Kernel &parent) | |
~GUI () override | |
ErrorCode | init (PlatformContext &context) |
Create the GUI. | |
void | destroy () |
void | preDraw (GFXDevice &context, const Rect< I32 > &viewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut) |
Render all elements that need their own internal render targets (e.g. CEGUI) | |
void | draw (GFXDevice &context, const Rect< I32 > &viewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut) |
Go through all of the registered scene gui elements and gather all of the render commands. | |
void | drawText (const TextElementBatch &batch, const Rect< I32 > &targetViewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut, bool pushCamera=true) |
Text rendering is handled exclusively by Mikko Mononen's FontStash library (https://github.com/memononen/fontstash) | |
void | onResolutionChange (const SizeChangeParams ¶ms) |
Mostly used by CEGUI to keep track of screen dimensions. | |
void | onChangeScene (Scene *newScene) |
When we change a scene, we want to toggle our current scene GUI elements off and toggle the new scene's elements on. | |
void | onUnloadScene (Scene *scene) |
When we unload a scene, we unload all of its GUI elements. ToDo: Scene should own these and scene should submit to GUI for rendering. Current logic is backwards -Ionut. | |
void | update (U64 deltaTimeUS) |
Main update call. Used to tick gui elements (cursors, animations, etc) | |
template<typename T > requires std::is_base_of_v<GUIElement, T> | |
T * | getSceneGUIElementImpl (const I64 sceneID, const U64 elementName) |
Find a return a gui element by name. | |
template<typename T > requires std::is_base_of_v<GUIElement, T> | |
T * | getSceneGUIElementImpl (const I64 sceneID, const I64 elementID) |
Find a return a gui element by ID. | |
GUIConsole & | getConsole () noexcept |
Get a reference to our console window. | |
const GUIConsole & | getConsole () const noexcept |
Get a const reference to our console window. | |
CEGUI::Window * | rootSheet () const noexcept |
Get a pointer to the root sheet that CEGUI renders into. | |
GUIMessageBox * | getDefaultMessageBox () const noexcept |
Return a pointer to the default, general purpose message box. | |
void | setCursorPosition (I32 x, I32 y) |
Mouse cursor forced to a certain position. | |
CEGUI::GUIContext * | getCEGUIContext () noexcept |
Provides direct access to the CEGUI context. Used by plugins (e.g. GUIConsole, GUIInput, etc) | |
void | showDebugCursor (bool state) |
Toggle debug cursor rendering on or off. | |
PROPERTY_R (bool, showDebugCursor, false) | |
Debug cursor state. The debug cursor is a the cursor as it's know internally to CEGUI (based on its internal position and state) | |
PROPERTY_R (string, defaultGUIScheme, "GWEN") | |
The "skin" used by CEGUI. | |
PROPERTY_RW (U64, textRenderInterval, Time::MillisecondsToMicroseconds(10)) | |
We should avoid rendering text as fast as possible. | |
![]() | |
GUIInterface (GUI &context) | |
virtual | ~GUIInterface () |
void | onLanguageChange (std::string_view newLanguage) |
GUI & | getParentContext () noexcept |
const GUI & | getParentContext () const noexcept |
template<typename T > requires std::is_base_of_v<GUIElement, T> | |
T * | getGUIElement (const U64 elementName) const |
Get a pointer to an element by name/id. | |
template<typename T > requires std::is_base_of_v<GUIElement, T> | |
T * | getGUIElement (const I64 elementID) const |
virtual GUIText * | addText (const char *name, const RelativePosition2D &position, const string &font, const UColour4 &colour, const string &text, bool multiLine=false, U8 fontSize=16u) |
virtual GUIText * | modifyText (const char *name, const string &text, bool multiLine) |
virtual GUIMessageBox * | addMsgBox (const char *name, const string &title, const string &message, vec2< I32 > offsetFromCentre=vec2< I32 >(0)) |
virtual GUIButton * | addButton (const char *name, const string &text, const RelativePosition2D &offset, const RelativeScale2D &size, const string &rootSheetID="") |
virtual GUIFlash * | addFlash (const char *name, const RelativePosition2D &position, const RelativeScale2D &size) |
virtual CEGUI::Window * | createWindow (const CEGUI::String &type, const CEGUI::String &name) |
virtual CEGUI::Window * | loadWindowFromLayoutFile (const char *layoutFileName) |
virtual bool | unloadWindow (CEGUI::Window *&window) |
![]() | |
KernelComponent (Kernel &parent) noexcept | |
virtual | ~KernelComponent ()=default |
Kernel & | parent () noexcept |
const Kernel & | parent () const noexcept |
![]() | |
NonCopyable (const NonCopyable &)=delete | |
NonCopyable & | operator= (const NonCopyable &)=delete |
NonCopyable (NonCopyable &&)=default | |
NonCopyable & | operator= (NonCopyable &&)=default |
![]() | |
FrameListener (const Str< 64 > &name, FrameListenerManager &parent, U32 callOrder) | |
Either give it a name. | |
virtual | ~FrameListener () override |
bool | operator< (FrameListener &that) const noexcept |
![]() | |
GUIDWrapper () noexcept | |
GUIDWrapper (const GUIDWrapper &old) noexcept | |
GUIDWrapper (GUIDWrapper &&old) noexcept | |
virtual | ~GUIDWrapper ()=default |
FORCE_INLINE I64 | getGUID () const noexcept |
GUIDWrapper & | operator= (const GUIDWrapper &old)=delete |
GUIDWrapper & | operator= (GUIDWrapper &&other)=delete |
![]() | |
virtual | ~InputAggregatorInterface ()=default |
virtual bool | onKeyDown (const KeyEvent &arg)=0 |
Keyboard: return true if input was consumed. | |
virtual bool | onKeyUp (const KeyEvent &arg)=0 |
virtual bool | mouseMoved (const MouseMoveEvent &arg)=0 |
Mouse: return true if input was consumed. | |
virtual bool | mouseButtonPressed (const MouseButtonEvent &arg)=0 |
virtual bool | mouseButtonReleased (const MouseButtonEvent &arg)=0 |
virtual bool | joystickButtonPressed (const JoystickEvent &arg)=0 |
Joystick or Gamepad: return true if input was consumed. | |
virtual bool | joystickButtonReleased (const JoystickEvent &arg)=0 |
virtual bool | joystickAxisMoved (const JoystickEvent &arg)=0 |
virtual bool | joystickPovMoved (const JoystickEvent &arg)=0 |
virtual bool | joystickBallMoved (const JoystickEvent &arg)=0 |
virtual bool | joystickAddRemove (const JoystickEvent &arg)=0 |
virtual bool | joystickRemap (const JoystickEvent &arg)=0 |
virtual bool | onTextEvent (const TextEvent &arg)=0 |
Protected Member Functions | |
bool | frameStarted (const FrameEvent &evt) override |
bool | onKeyDown (const Input::KeyEvent &key) override |
Key pressed: return true if input was consumed. | |
bool | onKeyUp (const Input::KeyEvent &key) override |
Key released: return true if input was consumed. | |
bool | joystickAxisMoved (const Input::JoystickEvent &arg) override |
Joystick axis change: return true if input was consumed. | |
bool | joystickPovMoved (const Input::JoystickEvent &arg) override |
Joystick direction change: return true if input was consumed. | |
bool | joystickButtonPressed (const Input::JoystickEvent &arg) override |
Joystick button pressed: return true if input was consumed. | |
bool | joystickButtonReleased (const Input::JoystickEvent &arg) override |
Joystick button released: return true if input was consumed. | |
bool | joystickBallMoved (const Input::JoystickEvent &arg) override |
bool | joystickAddRemove (const Input::JoystickEvent &arg) override |
bool | joystickRemap (const Input::JoystickEvent &arg) override |
bool | mouseMoved (const Input::MouseMoveEvent &arg) override |
Mouse moved: return true if input was consumed. | |
bool | mouseButtonPressed (const Input::MouseButtonEvent &arg) override |
Mouse button pressed: return true if input was consumed. | |
bool | mouseButtonReleased (const Input::MouseButtonEvent &arg) override |
Mouse button released: return true if input was consumed. | |
bool | onTextEvent (const Input::TextEvent &arg) noexcept override |
Called when text input was detected. | |
![]() | |
void | addElement (U64 id, GUIElement *element) |
virtual GUIElement * | getGUIElementImpl (U64 elementName, GUIType type) const |
virtual GUIElement * | getGUIElementImpl (I64 elementID, GUIType type) const |
![]() | |
NonCopyable ()=default | |
~NonCopyable ()=default | |
![]() | |
void | setCallOrder (const U32 order) noexcept |
virtual bool | frameStarted (const FrameEvent &evt) |
virtual bool | framePreRender (const FrameEvent &evt) |
framePreRenderStarted is called when we need to start processing the visual aspect of a scene | |
virtual bool | frameSceneRenderStarted (const FrameEvent &evt) |
frameSceneRenderStarted is called right before rendering the scene for the current player starts | |
virtual bool | frameSceneRenderEnded (const FrameEvent &evt) |
frameSceneRenderEnded is called immediately after scene rendering for the current player has ended but before any blitting operations | |
virtual bool | frameRenderingQueued (const FrameEvent &evt) |
virtual bool | framePostRender (const FrameEvent &evt) |
virtual bool | frameEnded (const FrameEvent &evt) |
frameEnded is called after the buffers have been swapped | |
PROPERTY_R_IW (bool, enabled, false) | |
PROPERTY_RW (Str< 64 >, name) | |
Protected Attributes | |
CEGUI::Window * | _rootSheet {nullptr} |
The root window into which CEGUI anchors all of its elements. | |
CEGUI::GUIContext * | _ceguiContext {nullptr} |
The CEGUI context as returned by the library upon creation. | |
![]() | |
GUI * | _context |
std::array< GUIMap, to_base(GUIType::COUNT)> | _guiElements |
![]() | |
Kernel & | _parent |
![]() | |
const I64 | _guid |
Private Member Functions | |
I32 | getFont (const Str< 64 > &fontName) |
Try to find the requested font in the font cache. Load on cache miss. | |
GUIElement * | getSceneGUIElementImpl (I64 sceneID, U64 elementName, GUIType type) const |
Internal lookup of a GUIElement by name. | |
GUIElement * | getSceneGUIElementImpl (I64 sceneID, I64 elementID, GUIType type) const |
Internal lookup of a GUIElement by ID. | |
void | recreateDefaultMessageBox () |
Used to recreate and re-register the default message box if needed (usually on scene change) | |
Private Attributes | |
bool | _init {false} |
Set to true when the GUI has finished loading. | |
CEGUIInput | _ceguiInput |
Used to implement key repeat. | |
CEGUI::CEGUIRenderer * | _ceguiRenderer { nullptr } |
Used to render CEGUI to a texture; We want to port this to the Divide::GFX interface. | |
CEGUI::DVDTextureTarget * | _renderTextureTarget {nullptr} |
Used to render CEGUI elements into. We blit this on top of our scene target. | |
std::unique_ptr< GUIConsole > | _console |
Our custom in-game console (for logs and commands. A la Quake's ~-console) | |
std::unique_ptr< GUIMessageBox > | _defaultMsgBox |
Pointer to a default message box used for general purpose messages. | |
Scene * | _activeScene {nullptr} |
Each scene has its own gui elements! (0 = global). We keep a pointer to the scene but we really shouldn't. Scene should feed itself into GUI. | |
GUIMapPerScene | _guiStack {} |
All the GUI elements created per scene. | |
SharedMutex | _guiStackLock {} |
A lock to protect access to _guiStack. | |
DVDFONSContext_uptr | _fonsContext |
We use Font Stash (https://github.com/memononen/fontstash) for rendering basic text on the screen. This is our own Divide::GFX based context object used for rendering. | |
hashMap< U64, I32 > | _fonts |
A cache of all font IDs used by Font Stash stored by name ID. | |
hashAlg::pair< Str< 64 >, I32 > | _fontCache = { "", -1 } |
A cache of the last requested font by name to avoid a lookup in the fonts map. | |
Pipeline * | _textRenderPipeline {nullptr} |
The text rendering pipeline we used to draw Font Stash text. | |
Handle< ShaderProgram > | _textRenderShader = INVALID_HANDLE<ShaderProgram> |
The text rendering shaderProgram we used to draw Font Stash text. | |
Handle< ShaderProgram > | _ceguiRenderShader = INVALID_HANDLE<ShaderProgram> |
Friends | |
class | SceneGUIElements |
Additional Inherited Members | |
![]() | |
static I64 | generateGUID () noexcept |
using Divide::GUI::GUIMapPerScene = hashMap<I64, SceneGUIElements*> |
void Divide::GUI::draw | ( | GFXDevice & | context, |
const Rect< I32 > & | viewport, | ||
GFX::CommandBuffer & | bufferInOut, | ||
GFX::MemoryBarrierCommand & | memCmdInOut | ||
) |
void Divide::GUI::drawText | ( | const TextElementBatch & | batch, |
const Rect< I32 > & | targetViewport, | ||
GFX::CommandBuffer & | bufferInOut, | ||
GFX::MemoryBarrierCommand & | memCmdInOut, | ||
bool | pushCamera = true |
||
) |
Text rendering is handled exclusively by Mikko Mononen's FontStash library (https://github.com/memononen/fontstash)
|
overrideprotectedvirtual |
Adapter patern instead of pure interface for the same reason as the Ogre boys pointed out: Implement what you need without filling classes with dummy functions frameStarted is calld at the beggining of a new frame before processing the logic aspect of a scene
Reimplemented from Divide::FrameListener.
|
noexcept |
Provides direct access to the CEGUI context. Used by plugins (e.g. GUIConsole, GUIInput, etc)
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
private |
Internal lookup of a GUIElement by ID.
|
private |
Internal lookup of a GUIElement by name.
ErrorCode Divide::GUI::init | ( | PlatformContext & | context | ) |
|
overrideprotectedvirtual |
Implements Divide::Input::InputAggregatorInterface.
|
overrideprotectedvirtual |
Joystick axis change: return true if input was consumed.
Implements Divide::Input::InputAggregatorInterface.
|
overrideprotectedvirtual |
Implements Divide::Input::InputAggregatorInterface.
|
overrideprotectedvirtual |
Joystick button pressed: return true if input was consumed.
Implements Divide::Input::InputAggregatorInterface.
|
overrideprotectedvirtual |
Joystick button released: return true if input was consumed.
Implements Divide::Input::InputAggregatorInterface.
|
overrideprotectedvirtual |
Joystick direction change: return true if input was consumed.
Implements Divide::Input::InputAggregatorInterface.
|
overrideprotectedvirtual |
Implements Divide::Input::InputAggregatorInterface.
|
overrideprotectedvirtual |
Mouse button pressed: return true if input was consumed.
Implements Divide::Input::InputAggregatorInterface.
|
overrideprotectedvirtual |
Mouse button released: return true if input was consumed.
Implements Divide::Input::InputAggregatorInterface.
|
overrideprotectedvirtual |
Mouse moved: return true if input was consumed.
Implements Divide::Input::InputAggregatorInterface.
void Divide::GUI::onChangeScene | ( | Scene * | newScene | ) |
|
overrideprotectedvirtual |
Key pressed: return true if input was consumed.
Implements Divide::Input::InputAggregatorInterface.
|
overrideprotectedvirtual |
Key released: return true if input was consumed.
Implements Divide::Input::InputAggregatorInterface.
void Divide::GUI::onResolutionChange | ( | const SizeChangeParams & | params | ) |
|
overrideprotectedvirtualnoexcept |
Called when text input was detected.
Implements Divide::Input::InputAggregatorInterface.
void Divide::GUI::onUnloadScene | ( | Scene * | scene | ) |
void Divide::GUI::preDraw | ( | GFXDevice & | context, |
const Rect< I32 > & | viewport, | ||
GFX::CommandBuffer & | bufferInOut, | ||
GFX::MemoryBarrierCommand & | memCmdInOut | ||
) |
Divide::GUI::PROPERTY_R | ( | bool | , |
showDebugCursor | , | ||
false | |||
) |
Divide::GUI::PROPERTY_RW | ( | U64 | , |
textRenderInterval | , | ||
Time::MillisecondsToMicroseconds(10) | |||
) |
We should avoid rendering text as fast as possible.
|
private |
|
inlinenoexcept |
void Divide::GUI::showDebugCursor | ( | bool | state | ) |
void Divide::GUI::update | ( | U64 | deltaTimeUS | ) |
|
friend |
|
private |
|
protected |
|
private |
|
private |
Used to render CEGUI to a texture; We want to port this to the Divide::GFX interface.
|
private |
|
private |
|
private |
|
private |
We use Font Stash (https://github.com/memononen/fontstash) for rendering basic text on the screen. This is our own Divide::GFX based context object used for rendering.
|
private |
|
mutableprivate |
|
private |
|
private |
|
protected |
|
private |
|
private |