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
107
109{
112
114 float size = 100.f;
116 float optimalLenth = 10.0f;
118 float minValue = 0.0f;
120 float maxValue = 1.0f;
123
125 float lenDash = 8.0f;
127 float lenDashWithText = 12.0f;
129 float textPadding = 3.0f;
132};
133
135MRVIEWER_API ImGuiKey getImGuiModPrimaryCtrl();
136
138MRVIEWER_API const char* getImGuiPrimaryCtrlName();
139
141MRVIEWER_API bool checkKey( ImGuiKey passedKey );
142
144[[deprecated( "Use UI::buttonEx( label, size, params ) instead" )]]
145MRVIEWER_API bool buttonEx( const char* label,bool active, const Vector2f& size = Vector2f( 0, 0 ),
146 ImGuiButtonFlags flags = ImGuiButtonFlags_None, const ButtonCustomizationParams& customParams = {} );
147
149MRVIEWER_API bool buttonEx( const char* label, const Vector2f& size = Vector2f( 0, 0 ), const ButtonCustomizationParams& customParams = {} );
152MRVIEWER_API bool button( const char* label, bool active, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None );
155inline bool button( const char* label, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None )
156{
157 return button( label, true, size, key );
158}
159
161MRVIEWER_API bool buttonCommonSize( const char* label, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None );
163MRVIEWER_API bool buttonUnique( const char* label, int* value, int ownValue, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None );
164
166MRVIEWER_API void drawPoltHorizontalAxis( const PlotAxis& plotAxis );
168MRVIEWER_API void drawPoltVerticalAxis( const PlotAxis& plotAxis );
169
171MRVIEWER_API bool buttonIconEx(
172 const std::string& name,
173 const Vector2f& iconSize,
174 const std::string& text,
175 const ImVec2& buttonSize,
176 const ButtonIconCustomizationParams& params = {} );
177
179inline bool buttonIcon( const std::string& name, const Vector2f& iconSize, const std::string& text, const ImVec2& buttonSize )
180{
181 return buttonIconEx( name, iconSize, text, buttonSize );
182}
183
185 const std::string& name,
186 const Vector2f& iconSize,
187 const std::string& text,
188 const ImVec2& buttonSize,
189 bool textUnderIcon = true,
190 ImGuiKey key = ImGuiKey_None )
191{
193 params.baseParams.forceImGuiBackground = true;
194 params.baseParams.forceImguiTextColor = true;
195 params.textUnderImage = textUnderIcon;
196 params.baseParams.underlineFirstLetter = std::string_view( ImGui::GetKeyName( key ) ) == std::string_view( text.c_str(), 1 );
197 return buttonIconEx( name, iconSize, text, buttonSize, params ) || checkKey( key );
198}
199
201MRVIEWER_API bool buttonUniqueIcon(
202 const std::string& iconName,
203 const Vector2f& iconSize,
204 const std::string& text,
205 const ImVec2& buttonSize,
206 int* value,
207 int ownValue,
208 bool textUnderIcon = true,
209 ImGuiKey key = ImGuiKey_None );
210
211
213MRVIEWER_API bool toggle( const char* label, bool* value );
215MRVIEWER_API bool checkbox( const char* label, bool* value );
217MRVIEWER_API bool checkboxOrFixedValue( const char* label, bool* value, std::optional<bool> valueOverride );
219MRVIEWER_API bool checkboxValid( const char* label, bool* value, bool valid );
221MRVIEWER_API bool checkboxMixed( const char* label, bool* value, bool mixed );
223template <typename Getter, typename Setter>
224bool checkbox( const char* label, Getter get, Setter set )
225{
226 bool value = get();
227 bool ret = checkbox( label, &value );
228 set( value );
229 return ret;
230}
231template <typename Getter, typename Setter>
232bool checkboxValid( const char* label, Getter get, Setter set, bool valid )
233{
234 bool value = get();
235 bool ret = checkboxValid( label, &value, valid );
236 set( value );
237 return ret;
238}
239
241template <typename T>
242bool checkboxFlags( const char* label, T& target, T flags )
243{
244 bool value = bool( target & flags );
245 bool mixed = value && ( target & flags ) != flags;
246 if ( checkboxMixed( label, &value, mixed ) )
247 {
248 if ( value )
249 target |= flags;
250 else
251 target &= ~flags;
252 return true;
253 }
254 return false;
255}
256
258{
260 bool baseValue = false;
262 bool modifierHeld = false;
263
265
267
270 [[nodiscard]] explicit operator bool() const { return baseValue != modifierHeld; }
271};
272
282MRVIEWER_API bool checkboxOrModifier( const char* label, CheckboxOrModifierState& value, int modifiers, int respectedModifiers = -1, std::optional<bool> valueOverride = {} );
283
284
286MRVIEWER_API bool radioButton( const char* label, int* value, int valButton );
288MRVIEWER_API bool radioButtonOrFixedValue( const char* label, int* value, int valButton, std::optional<int> valueOverride );
289
291{
293 int value{};
296
298 [[nodiscard]] explicit operator int() const
299 {
300 return effectiveValue;
301 }
302};
303
310MRVIEWER_API bool radioButtonOrModifier( const char* label, RadioButtonOrModifierState& value, int valButton, int modifiers, int respectedModifiers = -1, std::optional<int> valueOverride = {} );
311
313MRVIEWER_API bool colorEdit4( const char* label, Vector4f& color, ImGuiColorEditFlags flags = ImGuiColorEditFlags_None );
314MRVIEWER_API bool colorEdit4( const char* label, Color& color, ImGuiColorEditFlags flags = ImGuiColorEditFlags_None );
315
317MRVIEWER_API bool combo( const char* label, int* v, const std::vector<std::string>& options,
318 bool showPreview = true, const std::vector<std::string>& tooltips = {}, const std::string& defaultText = "Not selected" );
319
324MRVIEWER_API bool beginCombo( const char* label, const std::string& text, bool enableTestEngine = true );
326MRVIEWER_API void endCombo();
327
329MRVIEWER_API bool comboElem( const char* label, bool selected );
330
332MRVIEWER_API bool inputText( const char* label, std::string& str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
334MRVIEWER_API bool inputTextIntoArray( const char* label, char* array, std::size_t size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
335
337MRVIEWER_API bool inputTextMultiline( const char* label, std::string& str, const ImVec2& size = ImVec2(), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
339MRVIEWER_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 );
341MRVIEWER_API bool inputTextMultilineWithHint( const char* label, const char* hint, std::string& str, const ImVec2& size = ImVec2(), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
343MRVIEWER_API bool inputTextIntoArrayMultilineWithHint( const char* label, const char* hint, char* buf, size_t buf_size, const ImVec2& size = ImVec2(), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
344
346{
347 std::optional<ImVec2> cachedSize;
348};
349
350MRVIEWER_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 );
351MRVIEWER_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 );
352
354MRVIEWER_API bool inputTextCentered( const char* label, std::string& str, float width = 0.0f, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
355
359MRVIEWER_API void inputTextCenteredReadOnly( const char* label, const std::string& str, float width = 0.0f, const std::optional<ImVec4>& textColor = {}, const std::optional<ImVec4>& labelColor = {}, bool selectable = true );
360
361
362namespace detail
363{
365 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 );
366
368 template <typename T>
369 concept Scalar = std::is_arithmetic_v<T> && !std::is_same_v<T, bool>;
370
372 template <typename T>
374
377 template <typename Bound, typename Target>
379 std::same_as<Bound, Target> ||
380 ( VectorTraits<Bound>::size == 1 && std::same_as<typename VectorTraits<Bound>::BaseType, typename VectorTraits<Target>::BaseType> );
381
384 template <typename Speed, typename Target>
386 std::same_as<Speed, typename VectorTraits<Target>::BaseType> || std::same_as<Speed, float> ||
387 std::same_as<Speed, Target> || std::same_as<Speed, typename VectorTraits<Target>::template ChangeBase<float>>;
388
399 template <UnitEnum E, VectorOrScalar T, typename F>
400 [[nodiscard]] bool unitWidget( const char* label, T& v, UnitToStringParams<E>& unitParams, F&& func );
401
402}
403
405inline constexpr int defaultSliderFlags = ImGuiSliderFlags_AlwaysClamp;
406
408template <UnitEnum E, detail::VectorOrScalar T>
409requires ( VectorTraits<T>::size == 1 )
410[[nodiscard]] float getDefaultDragSpeed();
411
413template <UnitEnum E, detail::VectorOrScalar T, detail::VectorOrScalar TargetType>
414[[nodiscard]] T getDefaultStep( bool fast );
415
420template <UnitEnum E, detail::VectorOrScalar T, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
421bool slider( const char* label, T& v, const U& vMin, const U& vMax, UnitToStringParams<E> unitParams = {}, ImGuiSliderFlags flags = defaultSliderFlags );
422
428template <UnitEnum E, detail::VectorOrScalar T, detail::ValidDragSpeedForTargetType<T> SpeedType = float, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
429bool 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 ) );
430
432template <UnitEnum E, detail::VectorOrScalar T, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
433bool 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, const U& step = getDefaultStep<E, U, T>( false ), const U& stepFast = getDefaultStep<E, U, T>( true ) );
434
439template <UnitEnum E, detail::VectorOrScalar T>
440void readOnlyValue( const char* label, const T& v, std::optional<ImVec4> textColor = {}, UnitToStringParams<E> unitParams = {}, std::optional<ImVec4> labelColor = {} );
441
442
447template <UnitEnum E, detail::Scalar T, typename F>
448bool plusMinusGeneric( const char* label, T& plus, T& minus, UnitToStringParams<E> unitToStringParams, F&& func );
449
454template <UnitEnum E, detail::Scalar T, detail::ValidDragSpeedForTargetType<T> SpeedType = float, typename F = std::nullptr_t>
455bool 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 );
456
460template <UnitEnum E, detail::Scalar T, typename F = std::nullptr_t>
461bool 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 );
462
463
465MRVIEWER_API const std::pair<const char*, ImU32>& notificationChar( NotificationType type );
466
468MRVIEWER_API void mouseControlHint( ImGuiMouseButton btn, const std::string& hint );
469
471MRVIEWER_API void transparentText( const char* fmt, ... );
473MRVIEWER_API void transparentTextWrapped( const char* fmt, ... );
475MRVIEWER_API void notificationFrame( NotificationType type, const std::string& str );
476
478MRVIEWER_API void setTooltipIfHovered( const std::string& text );
479
482{
484 const ImGuiImage* icon{ nullptr };
485
487 Vector2f iconSize;
488
490 std::string label;
491
493 std::string suffix;
494
496 std::optional<Color> suffixFrameColor;
497
500 bool forceImGuiSpacing = false;
501
503 float extraScale = 1;
504};
505
507MRVIEWER_API void separator( const SeparatorParams& params );
508
513MRVIEWER_API void separator( const std::string& text = "", int issueCount = -1 );
514MRVIEWER_API void separator(
515 const std::string& text,
516 const ImVec4& color,
517 const std::string& issueCount );
520MRVIEWER_API void separator( const ImGuiImage& icon, const std::string& text, const Vector2f& iconSize = { 24.f, 24.f } );
521MRVIEWER_API void separator( const std::string& iconName, const std::string& text, const Vector2f& iconSize = { 24.f, 24.f } );
522
527MRVIEWER_API void progressBar( float fraction, const Vector2f& size = Vector2f( -1, 0 ) );
528
530MRVIEWER_API bool beginTabBar( const char* str_id, ImGuiTabBarFlags flags = 0 );
531MRVIEWER_API void endTabBar();
532MRVIEWER_API bool beginTabItem( const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0 );
533MRVIEWER_API void endTabItem();
534
544MRVIEWER_API void alignTextToFramePadding( float padding );
548MRVIEWER_API void alignTextToControl( float controlHeight );
550MRVIEWER_API void alignTextToRadioButton();
552MRVIEWER_API void alignTextToCheckBox();
554MRVIEWER_API void alignTextToButton();
555
559MRVIEWER_API void highlightWindowArea( const ImVec2& min = {-1.0f, -1.0f}, const ImVec2& max = { -1.0f, -1.0f } );
560
563{
565 std::string configName;
567 std::string imGuiIdKey;
569 std::filesystem::path configDirectory;
571 std::string* inputName{ nullptr };
573 bool inputNameDialog = true;
575 bool triggerSave = false;
577 bool warnExisting = true;
579 std::function<bool( const std::string& name )> onSave;
580
582 MRVIEWER_API std::string popupName() const;
583};
584
586MRVIEWER_API void saveCustomConfigModal(const CustomConfigModalSettings& settings );
587
590{
591 ImDrawList& list;
592 ImDrawFlags oldFlags{};
593
594public:
595 Disabler( ImDrawList& list, ImDrawFlags mask )
596 : list( list ), oldFlags( list.Flags )
597 {
598 list.Flags &= mask;
599 }
600
601 Disabler( const Disabler& ) = delete;
602 Disabler& operator=( const Disabler& ) = delete;
603
605 {
606 list.Flags = oldFlags;
607 }
608};
609
612{
613public:
614 LineAntialiasingDisabler( ImDrawList& list ) : Disabler( list, ~ImDrawListFlags_AntiAliasedLines )
615 {
616 }
617};
618
623#define MR_X( E ) \
624 extern template MRVIEWER_API bool drag<E, float, float, float>( const char*, float&, float, const float&, const float&, UnitToStringParams<E>, ImGuiSliderFlags, const float&, const float& ); \
625 extern template MRVIEWER_API bool drag<E, int, int, int>( const char*, int&, int, const int&, const int&, UnitToStringParams<E>, ImGuiSliderFlags, const int&, const int& ); \
626 extern template MRVIEWER_API bool drag<E, int, float, int>( const char*, int&, float, const int&, const int&, UnitToStringParams<E>, ImGuiSliderFlags, const int&, const int& );
628#undef MR_X
629
630}
631
632}
633
634#include "MRUIStyle.ipp"
Definition MRImGuiImage.h:18
Whether T is a scalar type that we can use with our widgets.
Definition MRUIStyle.h:369
Definition MRUIStyle.h:378
Whether T is a scalar or vector that we can use with our widgets.
Definition MRUIStyle.h:373
auto width(const Box< V > &box)
returns size along x axis
Definition MRBox.h:386
constexpr const V & get(const Box< V > &box) noexcept
get<0> returns min, get<1> returns max
Definition MRBox.h:432
bool inputTextIntoArrayMultilineWithHint(const char *label, const char *hint, 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.
auto mixed(const Vector3< T > &a, const Vector3< U > &b, const Vector3< U > &c) -> decltype(dot(a, cross(b, c)))
mixed product
Definition MRVector3.h:207
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:114
TextureType
enumeration texture types
Definition MRUIStyle.h:48
#define MR_X(E)
ignore for bindings to prevent GCC14 error: undefined symbol: ZN2MR11getUnitInfoITkNS_8UnitEnumENS_8T...
Definition MRUnitInfo.h:153
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:131
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:262
float scale()
Returns the global UI scale. Use this instead of passing around the scale in parameters.
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, const U &step=getDefaultStep< E, U, T >(false), const U &stepFast=getDefaultStep< E, U, T >(true))
Like drag(), but clicking it immediately activates text input, so it's not actually draggable.
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:264
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:59
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:179
T getDefaultStep(bool fast)
Default step speed for UI::input().
void drawPoltVerticalAxis(const PlotAxis &plotAxis)
draw dash with text along the vertical axis
std::optional< ImVec4 > iconColor
if set, the icon is drawn in this color, otherwise in the color of the text
Definition MRUIStyle.h:105
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:595
NotificationType
Definition MRNotificationType.h:10
LineAntialiasingDisabler(ImDrawList &list)
Definition MRUIStyle.h:614
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:493
std::string imGuiIdKey
Optional string added at the end of popup name to have unique names.
Definition MRUIStyle.h:567
std::optional< Color > suffixFrameColor
color of background frame behind suffix (if not present default ImGuiCol_FrameBg is used)
Definition MRUIStyle.h:496
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:184
ImGuiButtonFlags flags
imgui flags for this button
Definition MRUIStyle.h:71
float lenDash
length dash without text
Definition MRUIStyle.h:125
void endTabBar()
bool button(const char *label, bool active, const Vector2f &size=Vector2f(0, 0), ImGuiKey key=ImGuiKey_None)
#define DETAIL_MR_UNIT_ENUMS(X)
A list of all unit enums, for internal use.
Definition MRUnitInfo.h:113
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:484
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:122
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:266
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:118
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:127
int value
The permanent value of this setting, as set by the user by clicking the radio button.
Definition MRUIStyle.h:293
std::filesystem::path configDirectory
Directory where to save config.
Definition MRUIStyle.h:569
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:405
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:565
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 inputTextMultilineWithHint(const char *label, const char *hint, std::string &str, const ImVec2 &size=ImVec2(), ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=nullptr, void *user_data=nullptr)
Same as inputTextMultiline(), but shows the given hint in the field while the text is empty.
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:487
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:575
bool forceImGuiSpacing
Definition MRUIStyle.h:500
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:295
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
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)
void inputTextCenteredReadOnly(const char *label, const std::string &str, float width=0.0f, const std::optional< ImVec4 > &textColor={}, const std::optional< ImVec4 > &labelColor={}, bool selectable=true)
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:503
std::string label
label at the left part of separator (drawn after icon if present)
Definition MRUIStyle.h:490
bool checkboxFlags(const char *label, T &target, T flags)
Draw a checkbox toggling one or more bits in the mask.
Definition MRUIStyle.h:242
ImVec2 startAxisPoint
the point from which the axes will be drawn
Definition MRUIStyle.h:111
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:573
bool warnExisting
If true - warns user before overriding existing file, otherwise override without warning.
Definition MRUIStyle.h:577
float optimalLenth
optimal length between dashes
Definition MRUIStyle.h:116
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:579
std::string * inputName
String used by input.
Definition MRUIStyle.h:571
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:347
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
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:260
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:120
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:129
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:604
@ 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 strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRColor.h:12
parameters to customize buttonEx
Definition MRUIStyle.h:66
Definition MRUIStyle.h:97
Definition MRUIStyle.h:346
Definition MRUIStyle.h:258
Settings required for UI::saveCustomConfigModal
Definition MRUIStyle.h:563
Definition MRUIStyle.h:109
Definition MRUIStyle.h:291
Parameters for drawing custom separator.
Definition MRUIStyle.h:482
Controls how a value with a unit is converted to a string.
Definition MRUnits.h:71