MeshLib C++ Docs
Loading...
Searching...
No Matches
MR::UI::TestEngine Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  ButtonEntry
 
struct  Entry
 
struct  GroupEntry
 
struct  ValueEntry
 For sliders, drags, etc. More...
 

Concepts

concept  AllowedValueType
 

Functions

MRVIEWER_API bool createButton (std::string_view name)
 
template<AllowedValueType T>
requires std::is_arithmetic_v<T>
std::optional< T > createValue (std::string_view name, T value, T min, T max, bool consumeValueOverride=true)
 
MRVIEWER_API std::optional< std::string > createValue (std::string_view name, std::string value, bool consumeValueOverride=true, std::optional< std::vector< std::string > > allowedValues=std::nullopt)
 This overload is for strings.
 
template<AllowedValueType T>
std::optional< T > createValueTentative (std::string_view name, bool consumeValueOverride=true)
 
MRVIEWER_API void pushTree (std::string_view name)
 Use those to group buttons into named groups.
 
MRVIEWER_API void popTree ()
 
MRVIEWER_API const GroupEntrygetRootEntry ()
 Returns the current entry tree.
 

Detailed Description

This is a low-level header for implementing GUIs that can be interacted with programmatically. Most likely you don't need to touch this, just use widgets from MRUIStyle.h.

Function Documentation

◆ createButton()

MRVIEWER_API bool MR::UI::TestEngine::createButton ( std::string_view name)
nodiscard

Call this every frame when drawing a button you want to track (regardless of whether it returns true of false). If this returns true, simulate a button click.

◆ createValue() [1/2]

MRVIEWER_API std::optional< std::string > MR::UI::TestEngine::createValue ( std::string_view name,
std::string value,
bool consumeValueOverride = true,
std::optional< std::vector< std::string > > allowedValues = std::nullopt )
nodiscard

This overload is for strings.

◆ createValue() [2/2]

template<AllowedValueType T>
requires std::is_arithmetic_v<T>
std::optional< T > MR::UI::TestEngine::createValue ( std::string_view name,
T value,
T min,
T max,
bool consumeValueOverride = true )
nodiscard

Create a "value" (slider/drag/...). T must be a scalar; vector support must be implemented manually. Pass min >= max to disable the range checks. If this returns true, use the new value in place of the current one.

Parameters
consumeValueOverrideIf true - retrieves (deletes) a value from storage. If false - copies the value from the storage (saves the original to the storage to be retrieved again, for example, in the next frame)

◆ createValueTentative()

template<AllowedValueType T>
std::optional< T > MR::UI::TestEngine::createValueTentative ( std::string_view name,
bool consumeValueOverride = true )
nodiscard

Usually you don't need this function. This is for widgets that require you to specify the value override before drawing it, such as ImGui::CollapsingHeader(). For those, call this version first to read the value override, then draw the widget, then call the normal CreateValue() with the same name and with the new value, and discard its return value.

◆ getRootEntry()

MRVIEWER_API const GroupEntry & MR::UI::TestEngine::getRootEntry ( )
nodiscard

Returns the current entry tree.

◆ popTree()

MRVIEWER_API void MR::UI::TestEngine::popTree ( )

◆ pushTree()

MRVIEWER_API void MR::UI::TestEngine::pushTree ( std::string_view name)

Use those to group buttons into named groups.