MeshLib C++ Docs
Loading...
Searching...
No Matches
MRUIStyle.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMesh/MRFinally.h"
5#include "exports.h"
6#include "MRUnits.h"
7#include "MRVectorTraits.h"
8#include "MRImGui.h"
9#include <span>
10#include <string>
11#include <optional>
12#include <filesystem>
13
14namespace MR
15{
18
19
20class ImGuiImage;
21
22namespace UI
23{
24
26[[nodiscard]] MRVIEWER_API float scale();
27
28namespace detail
29{
31 MRVIEWER_API void setScale( float newScale );
32}
33
35[[nodiscard]] MRVIEWER_API bool isItemActive( const char* name );
36
38namespace StateStorage
39{
40
41[[nodiscard]] MRVIEWER_API bool readBool( std::string_view key, bool defaultValue = false );
42MRVIEWER_API void writeBool( std::string_view key, bool value );
43
44}
45
57
59MRVIEWER_API std::unique_ptr<ImGuiImage>& getTexture( TextureType type );
60
62MRVIEWER_API void init();
63
66{
68 bool enabled = true;
69
71 ImGuiButtonFlags flags = ImGuiButtonFlags_None;
72
77
80
82 bool forceImguiTextColor = false;
84 bool border = false;
85
88
90 bool enableTestEngine = true;
91
93 std::string testEngineName;
94};
95
104
106{
109
111 float size = 100.f;
113 float optimalLenth = 10.0f;
115 float minValue = 0.0f;
117 float maxValue = 1.0f;
120
122 float lenDash = 8.0f;
124 float lenDashWithText = 12.0f;
126 float textPadding = 3.0f;
129};
130
132MRVIEWER_API ImGuiKey getImGuiModPrimaryCtrl();
133
135MRVIEWER_API const char* getImGuiPrimaryCtrlName();
136
138MRVIEWER_API bool checkKey( ImGuiKey passedKey );
139
141[[deprecated( "Use UI::buttonEx( label, size, params ) instead" )]]
142MRVIEWER_API bool buttonEx( const char* label,bool active, const Vector2f& size = Vector2f( 0, 0 ),
143 ImGuiButtonFlags flags = ImGuiButtonFlags_None, const ButtonCustomizationParams& customParams = {} );
144
146MRVIEWER_API bool buttonEx( const char* label, const Vector2f& size = Vector2f( 0, 0 ), const ButtonCustomizationParams& customParams = {} );
149MRVIEWER_API bool button( const char* label, bool active, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None );
152inline bool button( const char* label, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None )
153{
154 return button( label, true, size, key );
155}
156
158MRVIEWER_API bool buttonCommonSize( const char* label, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None );
160MRVIEWER_API bool buttonUnique( const char* label, int* value, int ownValue, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None );
161
163MRVIEWER_API void drawPoltHorizontalAxis( const PlotAxis& plotAxis );
165MRVIEWER_API void drawPoltVerticalAxis( const PlotAxis& plotAxis );
166
168MRVIEWER_API bool buttonIconEx(
169 const std::string& name,
170 const Vector2f& iconSize,
171 const std::string& text,
172 const ImVec2& buttonSize,
173 const ButtonIconCustomizationParams& params = {} );
174
176inline bool buttonIcon( const std::string& name, const Vector2f& iconSize, const std::string& text, const ImVec2& buttonSize )
177{
178 return buttonIconEx( name, iconSize, text, buttonSize );
179}
180
182 const std::string& name,
183 const Vector2f& iconSize,
184 const std::string& text,
185 const ImVec2& buttonSize,
186 bool textUnderIcon = true,
187 ImGuiKey key = ImGuiKey_None )
188{
190 params.baseParams.forceImGuiBackground = true;
191 params.baseParams.forceImguiTextColor = true;
192 params.textUnderImage = textUnderIcon;
193 params.baseParams.underlineFirstLetter = std::string_view( ImGui::GetKeyName( key ) ) == std::string_view( text.c_str(), 1 );
194 return buttonIconEx( name, iconSize, text, buttonSize, params ) || checkKey( key );
195}
196
198MRVIEWER_API bool buttonUniqueIcon(
199 const std::string& iconName,
200 const Vector2f& iconSize,
201 const std::string& text,
202 const ImVec2& buttonSize,
203 int* value,
204 int ownValue,
205 bool textUnderIcon = true,
206 ImGuiKey key = ImGuiKey_None );
207
208
210MRVIEWER_API bool toggle( const char* label, bool* value );
212MRVIEWER_API bool checkbox( const char* label, bool* value );
214MRVIEWER_API bool checkboxOrFixedValue( const char* label, bool* value, std::optional<bool> valueOverride );
216MRVIEWER_API bool checkboxValid( const char* label, bool* value, bool valid );
218MRVIEWER_API bool checkboxMixed( const char* label, bool* value, bool mixed );
220template <typename Getter, typename Setter>
221bool checkbox( const char* label, Getter get, Setter set )
222{
223 bool value = get();
224 bool ret = checkbox( label, &value );
225 set( value );
226 return ret;
227}
228template <typename Getter, typename Setter>
229bool checkboxValid( const char* label, Getter get, Setter set, bool valid )
230{
231 bool value = get();
232 bool ret = checkboxValid( label, &value, valid );
233 set( value );
234 return ret;
235}
236
238template <typename T>
239bool checkboxFlags( const char* label, T& target, T flags )
240{
241 bool value = bool( target & flags );
242 bool mixed = value && ( target & flags ) != flags;
243 if ( checkboxMixed( label, &value, mixed ) )
244 {
245 if ( value )
246 target |= flags;
247 else
248 target &= ~flags;
249 return true;
250 }
251 return false;
252}
253
255{
257 bool baseValue = false;
259 bool modifierHeld = false;
260
262
264
267 [[nodiscard]] explicit operator bool() const { return baseValue != modifierHeld; }
268};
269
279MRVIEWER_API bool checkboxOrModifier( const char* label, CheckboxOrModifierState& value, int modifiers, int respectedModifiers = -1, std::optional<bool> valueOverride = {} );
280
281
283MRVIEWER_API bool radioButton( const char* label, int* value, int valButton );
285MRVIEWER_API bool radioButtonOrFixedValue( const char* label, int* value, int valButton, std::optional<int> valueOverride );
286
288{
290 int value{};
293
295 [[nodiscard]] explicit operator int() const
296 {
297 return effectiveValue;
298 }
299};
300
307MRVIEWER_API bool radioButtonOrModifier( const char* label, RadioButtonOrModifierState& value, int valButton, int modifiers, int respectedModifiers = -1, std::optional<int> valueOverride = {} );
308
310MRVIEWER_API bool colorEdit4( const char* label, Vector4f& color, ImGuiColorEditFlags flags = ImGuiColorEditFlags_None );
311MRVIEWER_API bool colorEdit4( const char* label, Color& color, ImGuiColorEditFlags flags = ImGuiColorEditFlags_None );
312
314MRVIEWER_API bool combo( const char* label, int* v, const std::vector<std::string>& options,
315 bool showPreview = true, const std::vector<std::string>& tooltips = {}, const std::string& defaultText = "Not selected" );
316
321MRVIEWER_API bool beginCombo( const char* label, const std::string& text, bool enableTestEngine = true );
323MRVIEWER_API void endCombo();
324
326MRVIEWER_API bool comboElem( const char* label, bool selected );
327
329MRVIEWER_API bool inputText( const char* label, std::string& str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
331MRVIEWER_API bool inputTextIntoArray( const char* label, char* array, std::size_t size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
332
334MRVIEWER_API bool inputTextMultiline( const char* label, std::string& str, const ImVec2& size = ImVec2(), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
336MRVIEWER_API bool inputTextIntoArrayMultiline( const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
337
339{
340 std::optional<ImVec2> cachedSize;
341};
342
343MRVIEWER_API bool inputTextMultilineFullyScrollable( CachedTextSize& cache, const char* label, std::string& str, const ImVec2& size = ImVec2(), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
344MRVIEWER_API bool inputTextIntoArrayMultilineFullyScrollable( CachedTextSize& cache, const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
345
347MRVIEWER_API bool inputTextCentered( const char* label, std::string& str, float width = 0.0f, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
348
350MRVIEWER_API void inputTextCenteredReadOnly( const char* label, const std::string& str, float width = 0.0f, const std::optional<ImVec4>& textColor = {}, const std::optional<ImVec4>& labelColor = {} );
351
352
353namespace detail
354{
356 MRVIEWER_API bool genericSlider( const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags );
357
359 template <typename T>
360 concept Scalar = std::is_arithmetic_v<T> && !std::is_same_v<T, bool>;
361
363 template <typename T>
365
368 template <typename Bound, typename Target>
370 std::same_as<Bound, Target> ||
371 ( VectorTraits<Bound>::size == 1 && std::same_as<typename VectorTraits<Bound>::BaseType, typename VectorTraits<Target>::BaseType> );
372
375 template <typename Speed, typename Target>
377 std::same_as<Speed, typename VectorTraits<Target>::BaseType> || std::same_as<Speed, float> ||
378 std::same_as<Speed, Target> || std::same_as<Speed, typename VectorTraits<Target>::template ChangeBase<float>>;
379
390 template <UnitEnum E, VectorOrScalar T, typename F>
391 [[nodiscard]] bool unitWidget( const char* label, T& v, UnitToStringParams<E>& unitParams, F&& func );
392
393}
394
396inline constexpr int defaultSliderFlags = ImGuiSliderFlags_AlwaysClamp;
397
399template <UnitEnum E, detail::VectorOrScalar T>
400requires ( VectorTraits<T>::size == 1 )
401[[nodiscard]] float getDefaultDragSpeed();
402
404template <UnitEnum E, detail::VectorOrScalar T, detail::VectorOrScalar TargetType>
405[[nodiscard]] T getDefaultStep( bool fast );
406
411template <UnitEnum E, detail::VectorOrScalar T, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
412bool slider( const char* label, T& v, const U& vMin, const U& vMax, UnitToStringParams<E> unitParams = {}, ImGuiSliderFlags flags = defaultSliderFlags );
413
419template <UnitEnum E, detail::VectorOrScalar T, detail::ValidDragSpeedForTargetType<T> SpeedType = float, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
420bool drag( const char* label, T& v, SpeedType vSpeed = getDefaultDragSpeed<E, SpeedType>(), const U& vMin = std::numeric_limits<U>::lowest(), const U& vMax = std::numeric_limits<U>::max(), UnitToStringParams<E> unitParams = {}, ImGuiSliderFlags flags = defaultSliderFlags, const U& step = getDefaultStep<E, U, T>( false ), const U& stepFast = getDefaultStep<E, U, T>( true ) );
421
423template <UnitEnum E, detail::VectorOrScalar T, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
424bool input( const char* label, T& v, const U& vMin = std::numeric_limits<U>::lowest(), const U& vMax = std::numeric_limits<U>::max(), UnitToStringParams<E> unitParams = {}, ImGuiSliderFlags flags = defaultSliderFlags );
425
430template <UnitEnum E, detail::VectorOrScalar T>
431void readOnlyValue( const char* label, const T& v, std::optional<ImVec4> textColor = {}, UnitToStringParams<E> unitParams = {}, std::optional<ImVec4> labelColor = {} );
432
433
438template <UnitEnum E, detail::Scalar T, typename F>
439bool plusMinusGeneric( const char* label, T& plus, T& minus, UnitToStringParams<E> unitToStringParams, F&& func );
440
445template <UnitEnum E, detail::Scalar T, detail::ValidDragSpeedForTargetType<T> SpeedType = float, typename F = std::nullptr_t>
446bool dragPlusMinus( const char* label, T& plus, T& minus, SpeedType speed = getDefaultDragSpeed<E, SpeedType>(), T plusMin = T{}, T plusMax = std::numeric_limits<T>::max(), UnitToStringParams<E> unitParams = {}, ImGuiSliderFlags flags = defaultSliderFlags, F&& wrapFunc = nullptr );
447
451template <UnitEnum E, detail::Scalar T, typename F = std::nullptr_t>
452bool inputPlusMinus( const char* label, T& plus, T& minus, T plusMin = T{}, T plusMax = std::numeric_limits<T>::max(), UnitToStringParams<E> unitParams = {}, ImGuiSliderFlags flags = defaultSliderFlags, F&& wrapFunc = nullptr );
453
454
456MRVIEWER_API const std::pair<const char*, ImU32>& notificationChar( NotificationType type );
457
459MRVIEWER_API void mouseControlHint( ImGuiMouseButton btn, const std::string& hint );
460
462MRVIEWER_API void transparentText( const char* fmt, ... );
464MRVIEWER_API void transparentTextWrapped( const char* fmt, ... );
466MRVIEWER_API void notificationFrame( NotificationType type, const std::string& str );
467
469MRVIEWER_API void setTooltipIfHovered( const std::string& text );
470
473{
475 const ImGuiImage* icon{ nullptr };
476
478 Vector2f iconSize;
479
481 std::string label;
482
484 std::string suffix;
485
487 std::optional<Color> suffixFrameColor;
488
491 bool forceImGuiSpacing = false;
492
494 float extraScale = 1;
495};
496
498MRVIEWER_API void separator( const SeparatorParams& params );
499
504MRVIEWER_API void separator( const std::string& text = "", int issueCount = -1 );
505MRVIEWER_API void separator(
506 const std::string& text,
507 const ImVec4& color,
508 const std::string& issueCount );
511MRVIEWER_API void separator( const ImGuiImage& icon, const std::string& text, const Vector2f& iconSize = { 24.f, 24.f } );
512MRVIEWER_API void separator( const std::string& iconName, const std::string& text, const Vector2f& iconSize = { 24.f, 24.f } );
513
518MRVIEWER_API void progressBar( float fraction, const Vector2f& size = Vector2f( -1, 0 ) );
519
521MRVIEWER_API bool beginTabBar( const char* str_id, ImGuiTabBarFlags flags = 0 );
522MRVIEWER_API void endTabBar();
523MRVIEWER_API bool beginTabItem( const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0 );
524MRVIEWER_API void endTabItem();
525
535MRVIEWER_API void alignTextToFramePadding( float padding );
539MRVIEWER_API void alignTextToControl( float controlHeight );
541MRVIEWER_API void alignTextToRadioButton();
543MRVIEWER_API void alignTextToCheckBox();
545MRVIEWER_API void alignTextToButton();
546
550MRVIEWER_API void highlightWindowArea( const ImVec2& min = {-1.0f, -1.0f}, const ImVec2& max = { -1.0f, -1.0f } );
551
554{
556 std::string configName;
558 std::string imGuiIdKey;
560 std::filesystem::path configDirectory;
562 std::string* inputName{ nullptr };
564 bool inputNameDialog = true;
566 bool triggerSave = false;
568 bool warnExisting = true;
570 std::function<bool( const std::string& name )> onSave;
571
573 MRVIEWER_API std::string popupName() const;
574};
575
577MRVIEWER_API void saveCustomConfigModal(const CustomConfigModalSettings& settings );
578
581{
582 ImDrawList& list;
583 ImDrawFlags oldFlags{};
584
585public:
586 Disabler( ImDrawList& list, ImDrawFlags mask )
587 : list( list ), oldFlags( list.Flags )
588 {
589 list.Flags &= mask;
590 }
591
592 Disabler( const Disabler& ) = delete;
593 Disabler& operator=( const Disabler& ) = delete;
594
596 {
597 list.Flags = oldFlags;
598 }
599};
600
603{
604public:
605 LineAntialiasingDisabler( ImDrawList& list ) : Disabler( list, ~ImDrawListFlags_AntiAliasedLines )
606 {
607 }
608};
609
610}
611
612}
613
614#include "MRUIStyle.ipp"
Definition MRImGuiImage.h:18
Whether T is a scalar type that we can use with our widgets.
Definition MRUIStyle.h:360
Definition MRUIStyle.h:369
Whether T is a scalar or vector that we can use with our widgets.
Definition MRUIStyle.h:364
auto width(const Box< V > &box)
returns size along x axis
Definition MRBox.h:354
constexpr const V & get(const Box< V > &box) noexcept
get<0> returns min, get<1> returns max
Definition MRBox.h:400
bool buttonEx(const char *label, bool active, const Vector2f &size=Vector2f(0, 0), ImGuiButtonFlags flags=ImGuiButtonFlags_None, const ButtonCustomizationParams &customParams={})
draw gradient button, which can be disabled (active = false)
const char * getImGuiPrimaryCtrlName()
returns "Ctrl" by default or "Command" if ImGui has changed it internally for macos
void progressBar(float fraction, const Vector2f &size=Vector2f(-1, 0))
float size
size plot by axis
Definition MRUIStyle.h:111
TextureType
enumeration texture types
Definition MRUIStyle.h:48
Disabler(const Disabler &)=delete
void saveCustomConfigModal(const CustomConfigModalSettings &settings)
Draw modal window to save user configs (for example Palettes)
VarUnitToStringParams labelFormatParams
the format of the text for labels
Definition MRUIStyle.h:128
void separator(const SeparatorParams &params)
separator line with customizations
bool inputTextIntoArrayMultilineFullyScrollable(CachedTextSize &cache, const char *label, char *buf, size_t buf_size, const ImVec2 &size=ImVec2(), ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=nullptr, void *user_data=nullptr)
bool genericSlider(const char *label, ImGuiDataType data_type, void *p_data, const void *p_min, const void *p_max, const char *format, ImGuiSliderFlags flags)
A type-erased slider.
bool modifierHeld
Whether the setting is currently inverted because the modifier is held.
Definition MRUIStyle.h:259
float scale()
Returns the global UI scale. Use this instead of passing around the scale in parameters.
bool beginCombo(const char *label, const std::string &text, bool enableTestEngine=true)
bool radioButtonOrFixedValue(const char *label, int *value, int valButton, std::optional< int > valueOverride)
If valueOverride is specified, then the radio button is disabled and that value is displayed instead ...
bool forceImguiTextColor
force use if ImGuiCol_Text for text
Definition MRUIStyle.h:82
void notificationFrame(NotificationType type, const std::string &str)
similar to ImGui::TextWrapped but also have styled background and notification type indicator
bool inputText(const char *label, std::string &str, ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=nullptr, void *user_data=nullptr)
Draws text input, should be used instead of ImGui::InputText().
CheckboxOrModifierState()
Definition MRUIStyle.h:261
bool inputPlusMinus(const char *label, T &plus, T &minus, T plusMin=T{}, T plusMax=std::numeric_limits< T >::max(), UnitToStringParams< E > unitParams={}, ImGuiSliderFlags flags=defaultSliderFlags, F &&wrapFunc=nullptr)
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:32
bool buttonIcon(const std::string &name, const Vector2f &iconSize, const std::string &text, const ImVec2 &buttonSize)
button with a gradient, always active
Definition MRUIStyle.h:176
T getDefaultStep(bool fast)
Default step speed for UI::input().
void drawPoltVerticalAxis(const PlotAxis &plotAxis)
draw dash with text along the vertical axis
void mouseControlHint(ImGuiMouseButton btn, const std::string &hint)
draws hint with corresponding mouse btn icon
ImGuiImage * customTexture
Definition MRUIStyle.h:76
Disabler(ImDrawList &list, ImDrawFlags mask)
Definition MRUIStyle.h:586
NotificationType
Definition MRNotificationType.h:10
LineAntialiasingDisabler(ImDrawList &list)
Definition MRUIStyle.h:605
void setScale(float newScale)
Strictly for internal use. Updates the value that scale() returns.
bool checkboxOrFixedValue(const char *label, bool *value, std::optional< bool > valueOverride)
If valueOverride is specified, then the checkbox is disabled and that value is displayed instead of v...
bool border
show border or not
Definition MRUIStyle.h:84
std::string suffix
framed text after label (might be used for some indications)
Definition MRUIStyle.h:484
std::string imGuiIdKey
Optional string added at the end of popup name to have unique names.
Definition MRUIStyle.h:558
std::optional< Color > suffixFrameColor
color of background frame behind suffix (if not present default ImGuiCol_FrameBg is used)
Definition MRUIStyle.h:487
bool buttonIconFlatBG(const std::string &name, const Vector2f &iconSize, const std::string &text, const ImVec2 &buttonSize, bool textUnderIcon=true, ImGuiKey key=ImGuiKey_None)
button without a gradient, always active, configurable by an external style
Definition MRUIStyle.h:181
ImGuiButtonFlags flags
imgui flags for this button
Definition MRUIStyle.h:71
float lenDash
length dash without text
Definition MRUIStyle.h:122
void endTabBar()
bool button(const char *label, bool active, const Vector2f &size=Vector2f(0, 0), ImGuiKey key=ImGuiKey_None)
bool enabled
If false, the button is grayed out and can't be clicked.
Definition MRUIStyle.h:68
const ImGuiImage * icon
optional icon in the left part of separator
Definition MRUIStyle.h:475
bool buttonUniqueIcon(const std::string &iconName, const Vector2f &iconSize, const std::string &text, const ImVec2 &buttonSize, int *value, int ownValue, bool textUnderIcon=true, ImGuiKey key=ImGuiKey_None)
bool dragPlusMinus(const char *label, T &plus, T &minus, SpeedType speed=getDefaultDragSpeed< E, SpeedType >(), T plusMin=T{}, T plusMax=std::numeric_limits< T >::max(), UnitToStringParams< E > unitParams={}, ImGuiSliderFlags flags=defaultSliderFlags, F &&wrapFunc=nullptr)
bool isItemActive(const char *name)
Checks if the item with this name in the current window is active.
bool checkbox(const char *label, bool *value)
draw gradient checkbox
std::unique_ptr< ImGuiImage > & getTexture(TextureType type)
get texture by type
void transparentTextWrapped(const char *fmt,...)
similar to ImGui::TextWrapped but use current text color with alpha channel = 0.5
size_t textDashIndicesStep
sign every nth dash
Definition MRUIStyle.h:119
void highlightWindowArea(const ImVec2 &min={-1.0f, -1.0f}, const ImVec2 &max={ -1.0f, -1.0f })
static constexpr int size
Definition MRVectorTraits.h:22
CheckboxOrModifierState(bool baseValue)
Definition MRUIStyle.h:263
void drawPoltHorizontalAxis(const PlotAxis &plotAxis)
draw dash with text along the horizontal axis
Disabler & operator=(const Disabler &)=delete
float minValue
the minimum value of the axis
Definition MRUIStyle.h:115
bool combo(const char *label, int *v, const std::vector< std::string > &options, bool showPreview=true, const std::vector< std::string > &tooltips={}, const std::string &defaultText="Not selected")
draw combo box
float lenDashWithText
length dash with text
Definition MRUIStyle.h:124
int value
The permanent value of this setting, as set by the user by clicking the radio button.
Definition MRUIStyle.h:290
std::filesystem::path configDirectory
Directory where to save config.
Definition MRUIStyle.h:560
bool drag(const char *label, T &v, SpeedType vSpeed=getDefaultDragSpeed< E, SpeedType >(), const U &vMin=std::numeric_limits< U >::lowest(), const U &vMax=std::numeric_limits< U >::max(), UnitToStringParams< E > unitParams={}, ImGuiSliderFlags flags=defaultSliderFlags, const U &step=getDefaultStep< E, U, T >(false), const U &stepFast=getDefaultStep< E, U, T >(true))
void setTooltipIfHovered(const std::string &text)
draw tooltip only if current item is hovered
bool inputTextMultilineFullyScrollable(CachedTextSize &cache, const char *label, std::string &str, const ImVec2 &size=ImVec2(), ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=nullptr, void *user_data=nullptr)
This version adds a horizontal scrollbar. Also it never draws the label, and uses full window width b...
float getDefaultDragSpeed()
Default drag speed for UI::drag().
bool radioButton(const char *label, int *value, int valButton)
draw gradient radio button
constexpr int defaultSliderFlags
Default flags for slider() and drag() below.
Definition MRUIStyle.h:396
void endCombo()
Only call this if beginCombo() returned true!
bool plusMinusGeneric(const char *label, T &plus, T &minus, UnitToStringParams< E > unitToStringParams, F &&func)
bool slider(const char *label, T &v, const U &vMin, const U &vMax, UnitToStringParams< E > unitParams={}, ImGuiSliderFlags flags=defaultSliderFlags)
std::string configName
Name of desired config type.
Definition MRUIStyle.h:556
bool checkboxOrModifier(const char *label, CheckboxOrModifierState &value, int modifiers, int respectedModifiers=-1, std::optional< bool > valueOverride={})
bool readBool(std::string_view key, bool defaultValue=false)
bool comboElem(const char *label, bool selected)
A replacement for ImGui::Selectable() that should be used with beginCombo() and endCombo() to be able...
Vector2f iconSize
size of icon
Definition MRUIStyle.h:478
std::string testEngineName
if not empty, force use this string as name in TestEngine
Definition MRUIStyle.h:93
bool triggerSave
if true - opens modal in this frame, or saves if (!inputNameDialog && inputName)
Definition MRUIStyle.h:566
bool forceImGuiSpacing
Definition MRUIStyle.h:491
bool colorEdit4(const char *label, Vector4f &color, ImGuiColorEditFlags flags=ImGuiColorEditFlags_None)
draw gradient color edit 4
int effectiveValue
The value that is displayed, and to be used - can differ from value if modifiers are pressed.
Definition MRUIStyle.h:292
bool underlineFirstLetter
draw line under first letter of label
Definition MRUIStyle.h:87
bool forceImGuiBackground
force use imgui background if !customTexture
Definition MRUIStyle.h:79
void readOnlyValue(const char *label, const T &v, std::optional< ImVec4 > textColor={}, UnitToStringParams< E > unitParams={}, std::optional< ImVec4 > labelColor={})
void alignTextToButton()
Specialization of alignTextToFramePadding for UI::button with default height.
bool beginTabItem(const char *label, bool *p_open=NULL, ImGuiTabItemFlags flags=0)
bool textUnderImage
if false - text is to the right
Definition MRUIStyle.h:102
T mixed(const Vector3< T > &a, const Vector3< T > &b, const Vector3< T > &c)
mixed product
Definition MRVector3.h:208
void alignTextToRadioButton()
Specialization of alignTextToFramePadding for UI::radioButton.
bool inputTextMultiline(const char *label, std::string &str, const ImVec2 &size=ImVec2(), ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=nullptr, void *user_data=nullptr)
Draws multiline text input, should be used instead of ImGui::InputTextMultiline().
void writeBool(std::string_view key, bool value)
bool buttonIconEx(const std::string &name, const Vector2f &iconSize, const std::string &text, const ImVec2 &buttonSize, const ButtonIconCustomizationParams &params={})
draw a button with an icon and text under it
bool unitWidget(const char *label, T &v, UnitToStringParams< E > &unitParams, F &&func)
const std::pair< const char *, ImU32 > & notificationChar(NotificationType type)
returns icons font character for given notification type, and its color
float extraScale
The spacing is multiplied by this.
Definition MRUIStyle.h:494
std::string label
label at the left part of separator (drawn after icon if present)
Definition MRUIStyle.h:481
bool checkboxFlags(const char *label, T &target, T flags)
Draw a checkbox toggling one or more bits in the mask.
Definition MRUIStyle.h:239
ImVec2 startAxisPoint
the point from which the axes will be drawn
Definition MRUIStyle.h:108
bool input(const char *label, T &v, const U &vMin=std::numeric_limits< U >::lowest(), const U &vMax=std::numeric_limits< U >::max(), UnitToStringParams< E > unitParams={}, ImGuiSliderFlags flags=defaultSliderFlags)
Like drag(), but clicking it immediately activates text input, so it's not actually draggable.
bool checkKey(ImGuiKey passedKey)
returns true if button is pressed in this frame, preserve its further processing in viewer keyboard e...
bool inputNameDialog
If false, inputName is used (if inputName is nullptr this option is not used)
Definition MRUIStyle.h:564
bool warnExisting
If true - warns user before overriding existing file, otherwise override without warning.
Definition MRUIStyle.h:568
float optimalLenth
optimal length between dashes
Definition MRUIStyle.h:113
bool inputTextIntoArray(const char *label, char *array, std::size_t size, ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=nullptr, void *user_data=nullptr)
This overload is for arrays, as opposed to std::strings.
bool inputTextCentered(const char *label, std::string &str, float width=0.0f, ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=nullptr, void *user_data=nullptr)
draw input text box with text aligned by center
std::function< bool(const std::string &name)> onSave
Callback that is called when save is requested->returns true if file saved successfully (to close mod...
Definition MRUIStyle.h:570
std::string * inputName
String used by input.
Definition MRUIStyle.h:562
void endTabItem()
ImGuiKey getImGuiModPrimaryCtrl()
returns imgui modifier Id based on current environment
void alignTextToFramePadding(float padding)
bool enableTestEngine
Allow interacting with this button from UI::TestEngine.
Definition MRUIStyle.h:90
bool toggle(const char *label, bool *value)
draws checkbox-like toggle (enabled/disabled states)(O=)/(=O)
void alignTextToControl(float controlHeight)
std::optional< ImVec2 > cachedSize
Definition MRUIStyle.h:340
bool inputTextIntoArrayMultiline(const char *label, char *buf, size_t buf_size, const ImVec2 &size=ImVec2(), ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=nullptr, void *user_data=nullptr)
This overload is for arrays, as opposed to std::strings.
std::string popupName() const
returns accumulated name of the popup
bool beginTabBar(const char *str_id, ImGuiTabBarFlags flags=0)
create and append items into a TabBar: see corresponding ImGui:: functions
void inputTextCenteredReadOnly(const char *label, const std::string &str, float width=0.0f, const std::optional< ImVec4 > &textColor={}, const std::optional< ImVec4 > &labelColor={})
draw read-only text box with text aligned by center
T BaseType
The base template handles scalars (or just non-vectors).
Definition MRVectorTraits.h:21
bool baseValue
The persistent value of this setting, as set by the user by clicking the checkbox.
Definition MRUIStyle.h:257
bool checkboxValid(const char *label, bool *value, bool valid)
If valid is false checkbox is disabled. Same as checkboxOrFixedValue( ..., valid ?...
float maxValue
the maximal value of the axis
Definition MRUIStyle.h:117
void init()
init internal parameters
bool radioButtonOrModifier(const char *label, RadioButtonOrModifierState &value, int valButton, int modifiers, int respectedModifiers=-1, std::optional< int > valueOverride={})
void alignTextToCheckBox()
Specialization of alignTextToFramePadding for UI::checkbox.
void transparentText(const char *fmt,...)
similar to ImGui::Text but use current text color with alpha channel = 0.5
ButtonCustomizationParams baseParams
basic customization parameters
Definition MRUIStyle.h:99
bool buttonUnique(const char *label, int *value, int ownValue, const Vector2f &size=Vector2f(0, 0), ImGuiKey key=ImGuiKey_None)
draw button with same logic as radioButton
bool buttonCommonSize(const char *label, const Vector2f &size=Vector2f(0, 0), ImGuiKey key=ImGuiKey_None)
float textPadding
text offset from dash
Definition MRUIStyle.h:126
bool checkboxMixed(const char *label, bool *value, bool mixed)
draw gradient checkbox with mixed state
std::variant< > VarUnitToStringParams
The std::variant of UnitToStringParams<E> for all known Es (unit kinds).
Definition MRUnits.h:125
~Disabler()
Definition MRUIStyle.h:595
@ Mono
Definition MRUIStyle.h:49
@ Gradient
Definition MRUIStyle.h:50
@ RainbowRect
Definition MRUIStyle.h:54
@ GradientBtnSecond
Definition MRUIStyle.h:52
@ GradientBtnGray
Definition MRUIStyle.h:53
@ Count
Definition MRUIStyle.h:55
@ GradientBtn
Definition MRUIStyle.h:51
Use this to store state across frames. Like what CollapsingHeader() uses to store it's open/close sta...
Definition MRUIStyle.h:39
Definition MRUIStyle.h:29
Definition MRUINonOverlappingLabels.h:10
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRColor.h:12
parameters to customize buttonEx
Definition MRUIStyle.h:66
Definition MRUIStyle.h:97
Definition MRUIStyle.h:339
Definition MRUIStyle.h:255
Settings required for UI::saveCustomConfigModal
Definition MRUIStyle.h:554
Definition MRUIStyle.h:106
Definition MRUIStyle.h:288
Parameters for drawing custom separator.
Definition MRUIStyle.h:473
Controls how a value with a unit is converted to a string.
Definition MRUnits.h:71