MeshLib C++ Docs
Loading...
Searching...
No Matches
ImGui Namespace Reference

Classes

struct  CustomStatePluginWindowParameters
 Structure that contains parameters for State plugin window with custom style. More...
struct  HistogramGridLine
 helper structure for PlotCustomHistogram describing background grid line and label More...
struct  MultiDragRes
struct  SavedWindowPosParams
 Parameters drawing classic ImGui::Begin with loading / saving window position. More...

Enumerations

enum class  PaletteChanges {
  None = 0 , Reset = 1 , Texture = 2 , Ranges = 4 ,
  All = Texture | Ranges | Reset
}
enum class  PlaneWidgetFlags { None = 0 , DisableVisibility = 1 }
 Parameters for the Plane( MR::PlaneWidget& ... ) function. More...

Functions

bool Combo (const char *label, int *idx, const std::vector< std::string > &values)
bool Combo (const char *label, int *idx, std::function< const char *(int)> getter, int itemsCount)
bool ListBox (const char *label, int *idx, const std::vector< std::string > &values)
bool InputText (const char *label, std::string &str, ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=NULL, void *user_data=NULL)
bool DragFloatValid (const char *label, float *value, float speed=1.0f, float min=std::numeric_limits< float >::lowest(), float max=std::numeric_limits< float >::max(), const char *format="%.3f", ImGuiSliderFlags flags=0)
bool DragFloatValidLineWidth (const char *label, float *value)
 similar to ImGui::DragFloatValid but use available line width range
MultiDragRes DragFloatValid2 (const char *label, float v[2], float v_speed=1.0f, float min=std::numeric_limits< float >::lowest(), float max=std::numeric_limits< float >::max(), const char *format="%.3f", ImGuiSliderFlags flags=0, const char *(*tooltips)[2]=nullptr)
MultiDragRes DragFloatValid3 (const char *label, float v[3], float v_speed=1.0f, float min=std::numeric_limits< float >::lowest(), float max=std::numeric_limits< float >::max(), const char *format="%.3f", ImGuiSliderFlags flags=0, const char *(*tooltips)[3]=nullptr)
bool DragIntValid (const char *label, int *value, float speed=1, int min=std::numeric_limits< int >::lowest(), int max=std::numeric_limits< int >::max(), const char *format="%d")
MultiDragRes DragIntValid3 (const char *label, int v[3], float speed=1, int min=std::numeric_limits< int >::lowest(), int max=std::numeric_limits< int >::max(), const char *format="%d", const char *(*tooltips)[3]=nullptr)
bool InputIntValid (const char *label, int *value, int min, int max, int step=1, int step_fast=100, ImGuiInputTextFlags flags=0)
template<typename GetValueFunc, typename SetValueFunc>
bool Checkbox (const char *label, GetValueFunc getValue, SetValueFunc setValue)
 draw check-box that takes initial value from Getter and then saves the final value in Setter
void PlotCustomHistogram (const char *str_id, std::function< float(int idx)> values_getter, std::function< void(int idx)> tooltip, std::function< void(int idx)> on_click, int values_count, int values_offset=0, float scale_min=FLT_MAX, float scale_max=FLT_MAX, ImVec2 frame_size=ImVec2(0, 0), int selectedBarId=-1, int hoveredBarId=-1, const std::vector< HistogramGridLine > &gridIndexes={}, const std::vector< HistogramGridLine > &gridValues={})
bool BeginStatePlugin (const char *label, bool *open, float width)
 begin typical state plugin window
ImVec2 GetDownPosition (const float width)
float GetTitleBarHeght ()
 Calculate and return the height of the window title.
std::pair< ImVec2, bool > LoadSavedWindowPos (const char *label, ImGuiWindow *window, float width, const ImVec2 *position=nullptr)
std::pair< ImVec2, bool > LoadSavedWindowPos (const char *label, float width, const ImVec2 *position=nullptr)
void SaveWindowPosition (const char *label, ImGuiWindow *window)
void SaveWindowPosition (const char *label)
bool BeginSavedWindowPos (const std::string &name, bool *open, const SavedWindowPosParams &params)
bool BeginCustomStatePlugin (const char *label, bool *open, const CustomStatePluginWindowParameters &params={})
void EndCustomStatePlugin ()
 end state plugin window with custom style
bool BeginModalNoAnimation (const char *label, bool *open=nullptr, ImGuiWindowFlags flags=0)
 starts modal window with no animation for background
bool InputIntBitSet (const char *label, int *v, const MR::BitSet &bs, int step=1, int step_fast=100, ImGuiInputTextFlags flags=0)
 same as ImGui::InputInt
bool DragInputInt (const char *label, int *value, float speed=1, int min=std::numeric_limits< int >::lowest(), int max=std::numeric_limits< int >::max(), const char *format="%d", ImGuiSliderFlags flags=ImGuiSliderFlags_None)
 Combine of ImGui::DragInt and ImGui::InputInt.
bool Link (const char *label, uint32_t color=MR::Color(60, 120, 255).getUInt32())
 Draw text as link, calls callback on click.
PaletteChanges Palette (const char *label, MR::Palette &palette, std::string &presetName, float width, bool *fixZero=nullptr, float speed=1.0f, float min=std::numeric_limits< float >::lowest(), float max=std::numeric_limits< float >::max())
void Plane (MR::PlaneWidget &planeWidget, PlaneWidgetFlags flags={})
bool Direction (MR::DirectionWidget &dirWidget, bool &editDragging, const std::string &historyName)
void Image (const MR::ImGuiImage &image, const ImVec2 &size, const MR::Color &multColor)
 draw image with Y-direction inversed up-down
void Image (const MR::ImGuiImage &image, const ImVec2 &size, const ImVec4 &multColor={ 1, 1, 1, 1 })
MR::Vector2i GetImagePointerCoord (const MR::ImGuiImage &image, const ImVec2 &size, const ImVec2 &imagePos)
 get image coordinates under cursor considering Y-direction flipping
void Spinner (float radius)
 draw spinner in given place, radius with respect to scaling
bool ModalBigTitle (const char *title)
 draw big title with close cross (i.e. for settings modal popup )
bool ModalExitButton ()
 draw exit button with close cross (i.e. for settings modal popup )
float getExpSpeed (float val, float frac=0.01f, float min=1e-5f)
 get exponential speed for this value
float getLuminance (const ImVec4 &col)
 A crude conversion to grayscale. Good enough for our purposes.
bool isMultiViewportEnabled ()
 return true if ImGui Multi Viewport enabled

Detailed Description

Extend ImGui by populating its namespace directly

Code snippets taken from there: https:/// eliasdaler.github.io/using-imgui-with-sfml-pt2/

Enumeration Type Documentation

◆ PaletteChanges

enum class ImGui::PaletteChanges
strong

return struct of ImGui::Palette
values are bits

Enumerator
None 
Reset 
Texture 

reset palette

Ranges 

texture and legend must be updated

All 

uv-coordinates must be recomputed for the same values

◆ PlaneWidgetFlags

enum class ImGui::PlaneWidgetFlags
strong

Parameters for the Plane( MR::PlaneWidget& ... ) function.

Enumerator
None 
DisableVisibility 

Default setup.

Function Documentation

◆ BeginCustomStatePlugin()

bool ImGui::BeginCustomStatePlugin ( const char * label,
bool * open,
const CustomStatePluginWindowParameters & params = {} )

begin state plugin window with custom style. if you use this function, you must call EndCustomStatePlugin to close the plugin correctly. the flags ImGuiWindowFlags_NoScrollbar and ImGuiWindow_NoScrollingWithMouse are forced in the function.

◆ BeginModalNoAnimation()

bool ImGui::BeginModalNoAnimation ( const char * label,
bool * open = nullptr,
ImGuiWindowFlags flags = 0 )

starts modal window with no animation for background

◆ BeginSavedWindowPos()

bool ImGui::BeginSavedWindowPos ( const std::string & name,
bool * open,
const SavedWindowPosParams & params )

Same as ImGui::Begin, but with loading and saving the window position

see also LoadSavedWindowPos and SaveWindowPosition

◆ BeginStatePlugin()

bool ImGui::BeginStatePlugin ( const char * label,
bool * open,
float width )

begin typical state plugin window

◆ Checkbox()

template<typename GetValueFunc, typename SetValueFunc>
bool ImGui::Checkbox ( const char * label,
GetValueFunc getValue,
SetValueFunc setValue )
inline

draw check-box that takes initial value from Getter and then saves the final value in Setter

◆ Combo() [1/2]

bool ImGui::Combo ( const char * label,
int * idx,
const std::vector< std::string > & values )
inline

◆ Combo() [2/2]

bool ImGui::Combo ( const char * label,
int * idx,
std::function< const char *(int)> getter,
int itemsCount )
inline

◆ Direction()

bool ImGui::Direction ( MR::DirectionWidget & dirWidget,
bool & editDragging,
const std::string & historyName )

Shows 3 edit boxes for editing of world direction coordinates;

Parameters
editDraggingmust be initialized with zero, used to append only one history action on start dragging;
historyNamethe name of history action created on start dragging;
Returns
true if the direction was changed inside

◆ DragFloatValid()

bool ImGui::DragFloatValid ( const char * label,
float * value,
float speed = 1.0f,
float min = std::numeric_limits< float >::lowest(),
float max = std::numeric_limits< float >::max(),
const char * format = "%.3f",
ImGuiSliderFlags flags = 0 )

similar to ImGui::DragFloat but 1) value on output is forced to be in [min,max] range; 2) tooltip about Shift/Alt is shown when the item is active, and the valid range

◆ DragFloatValid2()

MultiDragRes ImGui::DragFloatValid2 ( const char * label,
float v[2],
float v_speed = 1.0f,
float min = std::numeric_limits< float >::lowest(),
float max = std::numeric_limits< float >::max(),
const char * format = "%.3f",
ImGuiSliderFlags flags = 0,
const char *(*) tooltips[2] = nullptr )

similar to ImGui::DragFloat2 - two drag-float controls in a row, but 1) returns information whether an item was deactivated; 2) calls DragFloatValid inside instead of DragFloat; 3) permits showing tooltip for each item

◆ DragFloatValid3()

MultiDragRes ImGui::DragFloatValid3 ( const char * label,
float v[3],
float v_speed = 1.0f,
float min = std::numeric_limits< float >::lowest(),
float max = std::numeric_limits< float >::max(),
const char * format = "%.3f",
ImGuiSliderFlags flags = 0,
const char *(*) tooltips[3] = nullptr )

similar to ImGui::DragFloat3 - three drag-float controls in a row, but 1) returns information whether an item was deactivated; 2) calls DragFloatValid inside instead of DragFloat; 3) permits showing tooltip for each item

◆ DragFloatValidLineWidth()

bool ImGui::DragFloatValidLineWidth ( const char * label,
float * value )

similar to ImGui::DragFloatValid but use available line width range

◆ DragInputInt()

bool ImGui::DragInputInt ( const char * label,
int * value,
float speed = 1,
int min = std::numeric_limits< int >::lowest(),
int max = std::numeric_limits< int >::max(),
const char * format = "%d",
ImGuiSliderFlags flags = ImGuiSliderFlags_None )

Combine of ImGui::DragInt and ImGui::InputInt.

Value can be changed by drag or "+"/"-" buttons

Note
used new visual style

◆ DragIntValid()

bool ImGui::DragIntValid ( const char * label,
int * value,
float speed = 1,
int min = std::numeric_limits< int >::lowest(),
int max = std::numeric_limits< int >::max(),
const char * format = "%d" )

similar to ImGui::DragInt but 1) value on output is forced to be in [min,max] range; 2) tooltip about Shift/Alt is shown when the item is active, and the valid range

◆ DragIntValid3()

MultiDragRes ImGui::DragIntValid3 ( const char * label,
int v[3],
float speed = 1,
int min = std::numeric_limits< int >::lowest(),
int max = std::numeric_limits< int >::max(),
const char * format = "%d",
const char *(*) tooltips[3] = nullptr )

similar to ImGui::DragInt3 - three drag-int controls in a row, but 1) returns information whether an item was deactivated; 2) calls DragIntValid inside instead of DragInt; 3) permits showing tooltip for each item

◆ EndCustomStatePlugin()

void ImGui::EndCustomStatePlugin ( )

end state plugin window with custom style

◆ GetDownPosition()

ImVec2 ImGui::GetDownPosition ( const float width)

returns the position of the window that will be located at the bottom of the viewport for a value pivot = ( 0.0f, 1.0f )

◆ getExpSpeed()

float ImGui::getExpSpeed ( float val,
float frac = 0.01f,
float min = 1e-5f )
inline

get exponential speed for this value

◆ GetImagePointerCoord()

MR::Vector2i ImGui::GetImagePointerCoord ( const MR::ImGuiImage & image,
const ImVec2 & size,
const ImVec2 & imagePos )

get image coordinates under cursor considering Y-direction flipping

◆ getLuminance()

float ImGui::getLuminance ( const ImVec4 & col)
inline

A crude conversion to grayscale. Good enough for our purposes.

◆ GetTitleBarHeght()

float ImGui::GetTitleBarHeght ( )

Calculate and return the height of the window title.

◆ Image() [1/2]

void ImGui::Image ( const MR::ImGuiImage & image,
const ImVec2 & size,
const ImVec4 & multColor = { 1, 1, 1, 1 } )

◆ Image() [2/2]

void ImGui::Image ( const MR::ImGuiImage & image,
const ImVec2 & size,
const MR::Color & multColor )

draw image with Y-direction inversed up-down

◆ InputIntBitSet()

bool ImGui::InputIntBitSet ( const char * label,
int * v,
const MR::BitSet & bs,
int step = 1,
int step_fast = 100,
ImGuiInputTextFlags flags = 0 )

same as ImGui::InputInt

Input int according valid from BitSet

Returns
true if value was changed and valid
Note
if inputted invalid value, it will be changed to first upper valid value (or find_last)
value can't be changed if bs has no any valid value

◆ InputIntValid()

bool ImGui::InputIntValid ( const char * label,
int * value,
int min,
int max,
int step = 1,
int step_fast = 100,
ImGuiInputTextFlags flags = 0 )

similar to ImGui::InputInt but 1) value on output is forced to be in [min,max] range; 2) tooltip about valid range is shown when the item is active

◆ InputText()

bool ImGui::InputText ( const char * label,
std::string & str,
ImGuiInputTextFlags flags = 0,
ImGuiInputTextCallback callback = NULL,
void * user_data = NULL )
inline

◆ isMultiViewportEnabled()

bool ImGui::isMultiViewportEnabled ( )

return true if ImGui Multi Viewport enabled

◆ Link()

bool ImGui::Link ( const char * label,
uint32_t color = MR::Color(60, 120, 255).getUInt32() )

Draw text as link, calls callback on click.

Draw text as link, colored with blue, calls callback on click

◆ ListBox()

bool ImGui::ListBox ( const char * label,
int * idx,
const std::vector< std::string > & values )
inline

◆ LoadSavedWindowPos() [1/2]

std::pair< ImVec2, bool > ImGui::LoadSavedWindowPos ( const char * label,
float width,
const ImVec2 * position = nullptr )

◆ LoadSavedWindowPos() [2/2]

std::pair< ImVec2, bool > ImGui::LoadSavedWindowPos ( const char * label,
ImGuiWindow * window,
float width,
const ImVec2 * position = nullptr )

Load saved window position, if possible

if can't load - get position (if setted) or default (upper-right viewport corner) see also SaveWindowPosition

Parameters
labelwindow label
widthwindow width
position(optional) preliminary window position
Returns
pair of the final position of the window and flag whether the position was loaded

◆ ModalBigTitle()

bool ImGui::ModalBigTitle ( const char * title)

draw big title with close cross (i.e. for settings modal popup )

◆ ModalExitButton()

bool ImGui::ModalExitButton ( )

draw exit button with close cross (i.e. for settings modal popup )

◆ Palette()

PaletteChanges ImGui::Palette ( const char * label,
MR::Palette & palette,
std::string & presetName,
float width,
bool * fixZero = nullptr,
float speed = 1.0f,
float min = std::numeric_limits< float >::lowest(),
float max = std::numeric_limits< float >::max() )

Helper palette widget, allows to change palette ranges and filter type
can load and save palette preset.

Parameters
presetNamestores the currently selected palette's preset name or empty string if the palette was edited by user
fixZeroif present shows checkbox to fix zero symmetrical palette
Returns
mask of changes, if it has PaletteChanges::Texture bit - object requires texture update, if it has PaletteChanges::Ranges uv coordinates should be recalculated and updated in object

◆ Plane()

void ImGui::Plane ( MR::PlaneWidget & planeWidget,
PlaneWidgetFlags flags = {} )

Helper plane widget, allows to draw specified plain in the scene
can import plane from the scene, draw it with mouse or adjust with controls planeWidget stores the plane widget params

◆ PlotCustomHistogram()

void ImGui::PlotCustomHistogram ( const char * str_id,
std::function< float(int idx)> values_getter,
std::function< void(int idx)> tooltip,
std::function< void(int idx)> on_click,
int values_count,
int values_offset = 0,
float scale_min = FLT_MAX,
float scale_max = FLT_MAX,
ImVec2 frame_size = ImVec2(0, 0),
int selectedBarId = -1,
int hoveredBarId = -1,
const std::vector< HistogramGridLine > & gridIndexes = {},
const std::vector< HistogramGridLine > & gridValues = {} )

draws a histogram

Parameters
selectedBarId(if not negative) the bar to highlight as selected
hoveredBarId(if not negative) the bar to highlight as hovered

◆ SaveWindowPosition() [1/2]

void ImGui::SaveWindowPosition ( const char * label)

◆ SaveWindowPosition() [2/2]

void ImGui::SaveWindowPosition ( const char * label,
ImGuiWindow * window )

Save window position

saved only if window exist see also LoadSavedWindowPos

◆ Spinner()

void ImGui::Spinner ( float radius)

draw spinner in given place, radius with respect to scaling