RavEngine
Loading...
Searching...
No Matches
RavEngine::GUIComponent Class Reference

#include <GUI.hpp>

Inheritance diagram for RavEngine::GUIComponent:
[legend]
Collaboration diagram for RavEngine::GUIComponent:
[legend]

Classes

struct  GUIData
 

Public Types

enum class  RenderMode { Screenspace , Worldspace }
 

Public Member Functions

decltype(data) GetData () const
 
void MouseMove ()
 
 GUIComponent ()
 
 MOVE_NO_COPY (GUIComponent)
 
 GUIComponent (int width, int height, float DPI=1)
 
void SetDPIScale (float scale)
 
Rml::ElementDocument * AddDocument (const std::string &name)
 
void RemoveDocument (const std::string &name)
 
bool IsDocumentLoaded (const std::string &name) const
 
Rml::ElementDocument * GetDocument (const std::string &name) const
 
void SetDimensions (uint32_t width, uint32_t height)
 
void MouseX (float normalized_pos)
 
void MouseY (float normalized_pos)
 
void ScrollY (float amt)
 
template<typename T >
constexpr void ExclusiveAccess (const T &func)
 
template<typename T >
constexpr void EnqueueUIUpdate (const T &func)
 
void Debug ()
 
bool Update ()
 
bool Render ()
 

Static Public Member Functions

static bool LoadFont (const std::string &filename)
 

Public Attributes

enum RavEngine::GUIComponent::RenderMode Mode = RenderMode::Screenspace
 

Protected Attributes

Ref< GUIData > data = std::make_shared<GUIData>()
 

Friends

class RenderEngine
 

Detailed Description

For putting interactive UI in a scene.

Constructor & Destructor Documentation

◆ GUIComponent() [1/2]

GUIComponent::GUIComponent ( )

Construct a GUI document using the current screen size

◆ GUIComponent() [2/2]

GUIComponent::GUIComponent ( int  width,
int  height,
float  DPI = 1 
)

Construct a GUI renderer with user-supplied size

Parameters
widththe width in pixels of the context
heightthe height in pixels of the context

Member Function Documentation

◆ AddDocument()

ElementDocument * GUIComponent::AddDocument ( const std::string &  name)

Load a document from disk with a name

Parameters
namethe name of the RML file
Exceptions
ifthis document has already been loaded into this context

◆ Debug()

void GUIComponent::Debug ( )

Set the RML debugger to focus on this context

◆ EnqueueUIUpdate()

template<typename T >
constexpr void RavEngine::GUIComponent::EnqueueUIUpdate ( const T &  func)
inlineconstexpr

Schedule a UI update. Use this call whenever you are making changes to the UI, to avoid threading issues

Parameters
funca capturing lambda to execute. Be sure to capture by value! The passed function is executed on a different thread at a different time than the caller.

◆ ExclusiveAccess()

template<typename T >
constexpr void RavEngine::GUIComponent::ExclusiveAccess ( const T &  func)
inlineconstexpr

Execute code on this element with exclusive thread-safe access. For internal use only.

Parameters
funca lambda to execute.

◆ GetDocument()

Rml::ElementDocument * GUIComponent::GetDocument ( const std::string &  name) const

Get a pointer to a document, for performing queries or bindings.

Parameters
namethe name of the document.
Returns
a pointer to the RML ElementDocument. Use of this pointer is not safe outside of ExclusiveAccess.
Exceptions
ifthe document is not loaded.

◆ IsDocumentLoaded()

bool GUIComponent::IsDocumentLoaded ( const std::string &  name) const
Returns
true if a document with the passed name is currently loaded.
Parameters
namethe name of the RML file

◆ LoadFont()

bool GUIComponent::LoadFont ( const std::string &  filename)
static

Load a font globally

◆ MouseX()

void GUIComponent::MouseX ( float  normalized_pos)

Bind to your InputManager's mouse X axis mapping

Parameters
normalized_posthe position of the mouse, in [0,1)

◆ MouseY()

void GUIComponent::MouseY ( float  normalized_pos)

Bind to your InputManager's mouse Y axis mapping

Parameters
normalized_posthe position of the mouse, in [0,1)

◆ RemoveDocument()

void GUIComponent::RemoveDocument ( const std::string &  name)

Unload a document from disk with a name

Parameters
namethe name of the RML file
Exceptions
ifthis document is not loaded

◆ Render()

bool GUIComponent::Render ( )

Issue draw calls to render this element (internal use only)

◆ ScrollY()

void RavEngine::GUIComponent::ScrollY ( float  amt)
inline

Bind to your InputManager's scroll Y axis mapping

Parameters
normalized_posthe position of the mouse, in [0,1)

◆ SetDimensions()

void RavEngine::GUIComponent::SetDimensions ( uint32_t  width,
uint32_t  height 
)
inline

Change the size of the context.

Parameters
widththe new width of the context
heightthe new height of the context

◆ Update()

bool GUIComponent::Update ( )

Recalculate based on changes made (internal use only)


The documentation for this class was generated from the following files: