nomlib
Loading...
Searching...
No Matches
nom::UIContext Class Reference

libRocket context abstraction More...

#include <UIContext.hpp>

Public Types

typedef UIContext self_type

Public Member Functions

 UIContext ()
 Default constructor; initialize the visual debugger state to boolean FALSE.
virtual ~UIContext ()
 Destructor.
void shutdown ()
 Free the resources (documents) used by the context followed by the context itself.
bool debugger_enabled () const
 Get the state of the visual debugger for the context.
void enable_debugger ()
 Enable libRocket's visual debugger tool.
void disable_debugger ()
 Disable libRocket's visual debugger tool.
Size2i debugger_size () const
 Get the visual debugger's dimensions.
void set_debugger_position (const Point2i &pos)
 Set the visual debugger's position.
Size2i beacon_size () const
 Get the visual error beacon dimensions.
void set_beacon_position (const Point2i &pos)
 Set the visual error beacon position.
void set_debugger_size (const Size2i &dims)
 Set the visual debugger's dimensions.
Rocket::Core::Context * context () const
 Get libRocket's context.
Size2i size () const
 Get the dimensions (width and height) of this context instance.
bool valid () const
 Get the validity status of this context instance.
bool create_context (const std::string &name, const Size2i &res, Rocket::Core::RenderInterface *interface=nullptr)
 Create a new element context used by libRocket.
Rocket::Core::ElementDocument * load_document_file (const std::string &filename)
Rocket::Core::ElementDocument * load_mouse_cursor_file (const std::string &filename)
void show_mouse_cursor (bool state)
bool load_font (const std::string &filename)
void set_size (const Size2i &dims)
 Resize the dimensions (width and height) of this context instance.
void set_event_handler (nom::EventHandler &evt_handler)
 Install the event handler used by the context.
void update ()
void draw ()

Private Member Functions

void initialize_debugger ()
 Initialize libRocket's visual debugger tool.
void process_event (const nom::Event &evt)
 Internal event processing loop for the context.

Private Attributes

bool debugger_
 Active state of libRocket's visual debugger.
Rocket::Core::Context * context_
 The implementation's element context (used by libRocket).
Rocket::Core::RenderInterface * renderer_
 Rendering bridge between libRocket and nomlib.
std::unique_ptr< IUIEventHandlerevt_
 The internal event handler for the context.
EventHandlerevent_handler_ = nullptr
Size2i res_
 The dimensions of the context.

Detailed Description

libRocket context abstraction

Todo
Consider inheriting off nom::IDrawable?

Definition at line 59 of file UIContext.hpp.

Member Typedef Documentation

◆ self_type

typedef UIContext nom::UIContext::self_type

Definition at line 62 of file UIContext.hpp.

Member Function Documentation

◆ beacon_size()

Size2i nom::UIContext::beacon_size ( ) const

Get the visual error beacon dimensions.

Returns
The size of the visual err beacon on success, or Size2i::null on failure, such as when the debugger has not been initialized.
Remarks
This method is provided for overriding the default RCSS as defined in libRocket's source and is generally not necessary unless you are dealing with especially small windows.
This method depends on the visual debugger being initialized within ::create.

◆ context()

Rocket::Core::Context * nom::UIContext::context ( ) const

Get libRocket's context.

Remarks
The returned pointer is managed by the engine, and must not be be freed by the end-user.
See also
UIContext::create_context.

◆ create_context()

bool nom::UIContext::create_context ( const std::string & name,
const Size2i & res,
Rocket::Core::RenderInterface * interface = nullptr )

Create a new element context used by libRocket.

\params interface The custom rendering interface to use, or NULL to use the default interface. The default interface must be provided by an explicit call to Rocket::Core::SetRenderInterface.

Remarks
libRocket must be initialized prior to making this call.
Note
The visual debugger must be explicitly enabled with a call to UIContext::enable_debugger.
See also
nom::init_librocket and nom::shutdown_librocket.
nom::RocketSDL2RenderInterface.

◆ debugger_size()

Size2i nom::UIContext::debugger_size ( ) const

Get the visual debugger's dimensions.

Returns
The size of the top-level debugger element on success, or Size2i::null on failure, such as when the debugger has not been initialized.
Remarks
This method depends on the visual debugger being initialized within ::create.

◆ draw()

void nom::UIContext::draw ( )
Remarks
The boolean return from the context's ::Render method is currently ignored.

◆ initialize_debugger()

void nom::UIContext::initialize_debugger ( )
private

Initialize libRocket's visual debugger tool.

Remarks
This method call is necessary to support SDL2's independent resolution scale.
Todo
Handle positioning of the event log window in regards to independent scale.

◆ set_beacon_position()

void nom::UIContext::set_beacon_position ( const Point2i & pos)

Set the visual error beacon position.

Parameters
posThe X, Y coordinates used for positioning; these will be relative to the context's dimensions.
Remarks
This method depends on the visual debugger being initialized within ::create.

◆ set_debugger_position()

void nom::UIContext::set_debugger_position ( const Point2i & pos)

Set the visual debugger's position.

Parameters
posThe X, Y coordinates used for positioning; these will be relative to the context's dimensions.
Remarks
This method is provided for overriding the default RCSS as defined in libRocket's source and is generally not necessary unless you are dealing with especially small windows.
This method depends on the visual debugger being initialized within ::create.

◆ set_debugger_size()

void nom::UIContext::set_debugger_size ( const Size2i & dims)

Set the visual debugger's dimensions.

Remarks
This method is provided for overriding the default RCSS as defined in libRocket's source and is generally not necessary unless you are dealing with especially small windows.
Note
This overwrites the minimum width, width and max-height of the Element Info window.

◆ set_event_handler()

void nom::UIContext::set_event_handler ( nom::EventHandler & evt_handler)

Install the event handler used by the context.

Remarks
The application's events will not be processed until a call is made to the event handler's ::poll_event method.
Note
The installed event handler must outlive the destruction of this interface!

◆ set_size()

void nom::UIContext::set_size ( const Size2i & dims)

Resize the dimensions (width and height) of this context instance.

Remarks
This method takes into account the current resolution scale as set with SDL2 (logical size).

◆ shutdown()

void nom::UIContext::shutdown ( )

Free the resources (documents) used by the context followed by the context itself.

Remarks
This must be explicitly called by the application to properly free the memory.

◆ size()

Size2i nom::UIContext::size ( ) const

Get the dimensions (width and height) of this context instance.

Returns
A nom::Size2i with a non-zero width and height in pixel units on success, or zero width and height on failure – such as if the context is invalid.

◆ update()

void nom::UIContext::update ( )
Remarks
The boolean return from the context's ::Update method is currently ignored.

Member Data Documentation

◆ context_

Rocket::Core::Context* nom::UIContext::context_
private

The implementation's element context (used by libRocket).

Remarks
This is a pointer managed by libRocket and must not be freed.

Definition at line 228 of file UIContext.hpp.

◆ debugger_

bool nom::UIContext::debugger_
private

Active state of libRocket's visual debugger.

Definition at line 223 of file UIContext.hpp.

◆ event_handler_

EventHandler* nom::UIContext::event_handler_ = nullptr
private

Definition at line 239 of file UIContext.hpp.

◆ evt_

std::unique_ptr<IUIEventHandler> nom::UIContext::evt_
private

The internal event handler for the context.

Definition at line 236 of file UIContext.hpp.

◆ renderer_

Rocket::Core::RenderInterface* nom::UIContext::renderer_
private

Rendering bridge between libRocket and nomlib.

Remarks
This is a pointer managed by libRocket and must not be freed.

Definition at line 233 of file UIContext.hpp.

◆ res_

Size2i nom::UIContext::res_
private

The dimensions of the context.

Definition at line 242 of file UIContext.hpp.


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