MeshLib C++ Docs
Loading...
Searching...
No Matches
MR::ImGuiMeasurementIndicators::Text Struct Reference

Represents an arbitrary block of text, possibly with icons, colors, etc. More...

#include <MRImGuiMeasurementIndicators.h>

Classes

struct  DrawResult
 
struct  Elem
 
struct  Line
 

Public Types

using ElemVar = std::variant<std::string, TextIcon, TextColor, TextFont>
 
using FontFunc = std::function<FontAndSize()>
 

Public Member Functions

 Text ()
 
 Text (const std::string &text)
 
 Text (std::string_view text)
 
 Text (const char *text)
 
bool isEmpty () const
 
void addLine ()
 
MRVIEWER_API void addText (std::string_view text)
 Adds some string to the text. Automatically splits by newlines.
 
void addElem (Elem elem)
 
void add (auto &&elem)
 Adds any element type of ElemVar.
 
MRVIEWER_API void update (bool force=false) const
 
MRVIEWER_API DrawResult draw (ImDrawList &list, ImVec2 pos, const TextColor &defaultTextColor={}) const
 

Static Public Member Functions

static MRVIEWER_API const FontFuncgetStaticDefaultFontFunc ()
 Get the default value for .defaultFont. This can be null to default to null, which means the current font.
 
static MRVIEWER_API void setStaticDefaultFontFunc (FontFunc func)
 

Public Attributes

std::vector< Linelines
 
ImVec2 size
 
ImVec2 align
 Alignment. [0,0] = top-left, [1,1] = bottom-right.
 
FontAndSize defaultFont = getStaticDefaultFontFunc()()
 
ImVec2 computedSize
 The computed content size. Read-only. Don't set manually, update() sets this.
 
bool dirty = false
 No computedSizeWithPadding, because for the entire Text we use size exactly, without max( size, computedSize ).
 

Detailed Description

Represents an arbitrary block of text, possibly with icons, colors, etc.

Member Typedef Documentation

◆ ElemVar

◆ FontFunc

using MR::ImGuiMeasurementIndicators::Text::FontFunc = std::function<FontAndSize()>

Constructor & Destructor Documentation

◆ Text() [1/4]

MR::ImGuiMeasurementIndicators::Text::Text ( )
inline

◆ Text() [2/4]

MR::ImGuiMeasurementIndicators::Text::Text ( const std::string & text)
inline

◆ Text() [3/4]

MR::ImGuiMeasurementIndicators::Text::Text ( std::string_view text)
inline

◆ Text() [4/4]

MR::ImGuiMeasurementIndicators::Text::Text ( const char * text)
inline

Member Function Documentation

◆ add()

void MR::ImGuiMeasurementIndicators::Text::add ( auto && elem)
inline

Adds any element type of ElemVar.

◆ addElem()

void MR::ImGuiMeasurementIndicators::Text::addElem ( Elem elem)
inline

A low-level function for adding layout elements. For strings prefer addText(). This function doesn't automatically split them by newlines, and so on.

◆ addLine()

void MR::ImGuiMeasurementIndicators::Text::addLine ( )
inline

Add an empty string to force some vertical size on empty lines.

◆ addText()

MRVIEWER_API void MR::ImGuiMeasurementIndicators::Text::addText ( std::string_view text)

Adds some string to the text. Automatically splits by newlines.

◆ draw()

MRVIEWER_API DrawResult MR::ImGuiMeasurementIndicators::Text::draw ( ImDrawList & list,
ImVec2 pos,
const TextColor & defaultTextColor = {} ) const

Draws the text to the specified draw list. Automatically calls update(). If defaultTextColor is not specified, takes it from ImGui.

◆ getStaticDefaultFontFunc()

static MRVIEWER_API const FontFunc & MR::ImGuiMeasurementIndicators::Text::getStaticDefaultFontFunc ( )
staticnodiscard

Get the default value for .defaultFont. This can be null to default to null, which means the current font.

◆ isEmpty()

bool MR::ImGuiMeasurementIndicators::Text::isEmpty ( ) const
inlinenodiscard

◆ setStaticDefaultFontFunc()

static MRVIEWER_API void MR::ImGuiMeasurementIndicators::Text::setStaticDefaultFontFunc ( FontFunc func)
static

◆ update()

MRVIEWER_API void MR::ImGuiMeasurementIndicators::Text::update ( bool force = false) const

Recalculate computedSize in various places in this class. If force == false, only acts if dirty == true. In any case, resets the dirty flag.

Member Data Documentation

◆ align

ImVec2 MR::ImGuiMeasurementIndicators::Text::align

Alignment. [0,0] = top-left, [1,1] = bottom-right.

◆ computedSize

ImVec2 MR::ImGuiMeasurementIndicators::Text::computedSize
mutable

The computed content size. Read-only. Don't set manually, update() sets this.

◆ defaultFont

FontAndSize MR::ImGuiMeasurementIndicators::Text::defaultFont = getStaticDefaultFontFunc()()

If null, uses the current font. Currently this defaults to a monospaced font. This is here because update() needs to know the font too.

◆ dirty

bool MR::ImGuiMeasurementIndicators::Text::dirty = false
mutable

No computedSizeWithPadding, because for the entire Text we use size exactly, without max( size, computedSize ).

◆ lines

std::vector<Line> MR::ImGuiMeasurementIndicators::Text::lines

◆ size

ImVec2 MR::ImGuiMeasurementIndicators::Text::size

The text size for alignment. Unlike size in other elements below, this isn't the minimum size. If this is zero, align will pivot the text around a point, as opposed to in a box (the math for this just happens to work automatically).


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