MeshLib C++ Docs
Loading...
Searching...
No Matches

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

#include <MRViewer/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 ()
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.
void update (bool force=false) const
DrawResult draw (ImDrawList &list, ImVec2 pos, const TextColor &defaultTextColor={}) const

Static Public Member Functions

static const FontFuncgetStaticDefaultFontFunc ()
 Get the default value for .defaultFont. This can be null to default to null, which means the current font.
static 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

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()

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

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

◆ draw()

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()

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()

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

◆ update()

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: