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}
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}
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}
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
318MRVIEWER_API bool beginCombo( const char* label, const std::string& text = "Not selected", bool showPreview = true );
319MRVIEWER_API void endCombo( bool showPreview = true );
320
322MRVIEWER_API bool inputText( const char* label, std::string& str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
324MRVIEWER_API bool inputTextIntoArray( const char* label, char* array, std::size_t size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
325
327MRVIEWER_API bool inputTextMultiline( const char* label, std::string& str, const ImVec2& size = ImVec2(), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
329MRVIEWER_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 );
330
332{
333 std::optional<ImVec2> cachedSize;
334};
336MRVIEWER_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 );
337MRVIEWER_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 );
338
340MRVIEWER_API bool inputTextCentered( const char* label, std::string& str, float width = 0.0f, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
341
343MRVIEWER_API void inputTextCenteredReadOnly( const char* label, const std::string& str, float width = 0.0f, const std::optional<ImVec4>& textColor = {}, const std::optional<ImVec4>& labelColor = {} );
344
345
346namespace detail
347{
349 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 );
350
352 template <typename T>
353 concept Scalar = std::is_arithmetic_v<T> && !std::is_same_v<T, bool>;
354
356 template <typename T>
358
361 template <typename Bound, typename Target>
363 std::same_as<Bound, Target> ||
364 ( VectorTraits<Bound>::size == 1 && std::same_as<typename VectorTraits<Bound>::BaseType, typename VectorTraits<Target>::BaseType> );
365
368 template <typename Speed, typename Target>
370 std::same_as<Speed, typename VectorTraits<Target>::BaseType> || std::same_as<Speed, float> ||
371 std::same_as<Speed, Target> || std::same_as<Speed, typename VectorTraits<Target>::template ChangeBase<float>>;
372
383 template <UnitEnum E, VectorOrScalar T, typename F>
384 [[nodiscard]] bool unitWidget( const char* label, T& v, UnitToStringParams<E>& unitParams, F&& func );
385
386}
387
389inline constexpr int defaultSliderFlags = ImGuiSliderFlags_AlwaysClamp;
390
392template <UnitEnum E, detail::VectorOrScalar T>
393requires ( VectorTraits<T>::size == 1 )
394[[nodiscard]] float getDefaultDragSpeed();
395
397template <UnitEnum E, detail::VectorOrScalar T, detail::VectorOrScalar TargetType>
398[[nodiscard]] T getDefaultStep( bool fast );
399
404template <UnitEnum E, detail::VectorOrScalar T, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
405bool slider( const char* label, T& v, const U& vMin, const U& vMax, UnitToStringParams<E> unitParams = {}, ImGuiSliderFlags flags = defaultSliderFlags );
406
412template <UnitEnum E, detail::VectorOrScalar T, detail::ValidDragSpeedForTargetType<T> SpeedType = float, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
413bool 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 ) );
414
416template <UnitEnum E, detail::VectorOrScalar T, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
417bool 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 );
418
423template <UnitEnum E, detail::VectorOrScalar T>
424void readOnlyValue( const char* label, const T& v, std::optional<ImVec4> textColor = {}, UnitToStringParams<E> unitParams = {}, std::optional<ImVec4> labelColor = {} );
425
426
431template <UnitEnum E, detail::Scalar T, typename F>
432bool plusMinusGeneric( const char* label, T& plus, T& minus, UnitToStringParams<E> unitToStringParams, F&& func );
433
438template <UnitEnum E, detail::Scalar T, detail::ValidDragSpeedForTargetType<T> SpeedType = float, typename F = std::nullptr_t>
439bool 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 );
440
444template <UnitEnum E, detail::Scalar T, typename F = std::nullptr_t>
445bool 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 );
446
447
449MRVIEWER_API const std::pair<const char*, ImU32>& notificationChar( NotificationType type );
450
452MRVIEWER_API void mouseControlHint( ImGuiMouseButton btn, const std::string& hint );
453
455MRVIEWER_API void transparentText( const char* fmt, ... );
457MRVIEWER_API void transparentTextWrapped( const char* fmt, ... );
459MRVIEWER_API void notificationFrame( NotificationType type, const std::string& str );
460
462MRVIEWER_API void setTooltipIfHovered( const std::string& text );
463
466{
468 const ImGuiImage* icon{ nullptr };
469
471 Vector2f iconSize;
472
474 std::string label;
475
477 std::string suffix;
478
480 std::optional<Color> suffixFrameColor;
481
484 bool forceImGuiSpacing = false;
485
487 float extraScale = 1;
488};
489
491MRVIEWER_API void separator( const SeparatorParams& params );
492
497MRVIEWER_API void separator( const std::string& text = "", int issueCount = -1 );
498MRVIEWER_API void separator(
499 const std::string& text,
500 const ImVec4& color,
501 const std::string& issueCount );
504MRVIEWER_API void separator( const ImGuiImage& icon, const std::string& text, const Vector2f& iconSize = { 24.f, 24.f } );
505MRVIEWER_API void separator( const std::string& iconName, const std::string& text, const Vector2f& iconSize = { 24.f, 24.f } );
506
511MRVIEWER_API void progressBar( float fraction, const Vector2f& size = Vector2f( -1, 0 ) );
512
514MRVIEWER_API bool beginTabBar( const char* str_id, ImGuiTabBarFlags flags = 0 );
515MRVIEWER_API void endTabBar();
516MRVIEWER_API bool beginTabItem( const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0 );
517MRVIEWER_API void endTabItem();
518
528MRVIEWER_API void alignTextToFramePadding( float padding );
532MRVIEWER_API void alignTextToControl( float controlHeight );
534MRVIEWER_API void alignTextToRadioButton();
536MRVIEWER_API void alignTextToCheckBox();
538MRVIEWER_API void alignTextToButton();
539
543MRVIEWER_API void highlightWindowArea( const ImVec2& min = {-1.0f, -1.0f}, const ImVec2& max = { -1.0f, -1.0f } );
544
547{
549 std::string configName;
551 std::string imGuiIdKey;
553 std::filesystem::path configDirectory;
555 std::string* inputName{ nullptr };
557 bool inputNameDialog = true;
559 bool triggerSave = false;
561 bool warnExisting = true;
563 std::function<bool( const std::string& name )> onSave;
564
566 MRVIEWER_API std::string popupName() const;
567};
568
570MRVIEWER_API void saveCustomConfigModal(const CustomConfigModalSettings& settings );
571
574{
575 ImDrawList& list;
576 ImDrawFlags oldFlags{};
577
578public:
579 Disabler( ImDrawList& list, ImDrawFlags mask )
580 : list( list ), oldFlags( list.Flags )
581 {
582 list.Flags &= mask;
583 }
584
585 Disabler( const Disabler& ) = delete;
586 Disabler& operator=( const Disabler& ) = delete;
587
589 {
590 list.Flags = oldFlags;
591 }
592};
593
596{
597public:
598 LineAntialiasingDisabler( ImDrawList& list ) : Disabler( list, ~ImDrawListFlags_AntiAliasedLines )
599 {
600 }
601};
602
603}
604
605}
606
607#include "MRUIStyle.ipp"
Definition MRImGuiImage.h:18
While this exists, it temporarily disables in the given list the flags with 0 bits in the given mask.
Definition MRUIStyle.h:574
While this exists, it temporarily disables antialiasing for the lines drawn to this list.
Definition MRUIStyle.h:596
Whether T is a scalar type that we can use with our widgets.
Definition MRUIStyle.h:353
Definition MRUIStyle.h:362
Whether T is a scalar or vector that we can use with our widgets.
Definition MRUIStyle.h:357
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
float size
size plot by axis
Definition MRUIStyle.h:111
TextureType
enumeration texture types
Definition MRUIStyle.h:48
MRVIEWER_API bool checkboxOrModifier(const char *label, CheckboxOrModifierState &value, int modifiers, int respectedModifiers=-1, std::optional< bool > valueOverride={})
Disabler(const Disabler &)=delete
MRVIEWER_API std::unique_ptr< ImGuiImage > & getTexture(TextureType type)
get texture by type
MRVIEWER_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)
This version adds a horizontal scrollbar. Also it never draws the label, and uses full window width b...
VarUnitToStringParams labelFormatParams
the format of the text for labels
Definition MRUIStyle.h:128
MRVIEWER_API bool radioButtonOrModifier(const char *label, RadioButtonOrModifierState &value, int valButton, int modifiers, int respectedModifiers=-1, std::optional< int > valueOverride={})
MRVIEWER_API void endTabBar()
bool modifierHeld
Whether the setting is currently inverted because the modifier is held.
Definition MRUIStyle.h:259
MRVIEWER_API bool isItemActive(const char *name)
Checks if the item with this name in the current window is active.
bool forceImguiTextColor
force use if ImGuiCol_Text for text
Definition MRUIStyle.h:82
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)
MRVIEWER_API void transparentTextWrapped(const char *fmt,...)
similar to ImGui::TextWrapped but use current text color with alpha channel = 0.5
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:32
MRVIEWER_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)
This overload is for arrays, as opposed to std::strings.
MRVIEWER_API void endTabItem()
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
MRVIEWER_API void alignTextToButton()
Specialization of alignTextToFramePadding for UI::button with default height.
T getDefaultStep(bool fast)
Default step speed for UI::input().
MRVIEWER_API void alignTextToCheckBox()
Specialization of alignTextToFramePadding for UI::checkbox.
MRVIEWER_API bool readBool(std::string_view key, bool defaultValue=false)
ImGuiImage * customTexture
Definition MRUIStyle.h:76
Disabler(ImDrawList &list, ImDrawFlags mask)
Definition MRUIStyle.h:579
NotificationType
Definition MRNotificationType.h:10
LineAntialiasingDisabler(ImDrawList &list)
Definition MRUIStyle.h:598
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:477
MRVIEWER_API void notificationFrame(NotificationType type, const std::string &str)
similar to ImGui::TextWrapped but also have styled background and notification type indicator
std::string imGuiIdKey
Optional string added at the end of popup name to have unique names.
Definition MRUIStyle.h:551
std::optional< Color > suffixFrameColor
color of background frame behind suffix (if not present default ImGuiCol_FrameBg is used)
Definition MRUIStyle.h:480
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
bool enabled
If false, the button is grayed out and can't be clicked.
Definition MRUIStyle.h:68
MRVIEWER_API bool checkbox(const char *label, bool *value)
draw gradient checkbox
MRVIEWER_API std::string popupName() const
returns accumulated name of the popup
const ImGuiImage * icon
optional icon in the left part of separator
Definition MRUIStyle.h:468
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)
MRVIEWER_API void highlightWindowArea(const ImVec2 &min={-1.0f, -1.0f}, const ImVec2 &max={ -1.0f, -1.0f })
MRVIEWER_API float scale()
Returns the global UI scale. Use this instead of passing around the scale in parameters.
MRVIEWER_API 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
MRVIEWER_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)
size_t textDashIndicesStep
sign every nth dash
Definition MRUIStyle.h:119
static constexpr int size
Definition MRMesh/MRVectorTraits.h:22
CheckboxOrModifierState(bool baseValue)
Definition MRUIStyle.h:263
MRVIEWER_API void writeBool(std::string_view key, bool value)
MRVIEWER_API void separator(const SeparatorParams &params)
separator line with customizations
MRVIEWER_API void alignTextToControl(float controlHeight)
Disabler & operator=(const Disabler &)=delete
float minValue
the minimum value of the axis
Definition MRUIStyle.h:115
float lenDashWithText
length dash with text
Definition MRUIStyle.h:124
MRVIEWER_API bool checkKey(ImGuiKey passedKey)
returns true if button is pressed in this frame, preserve its further processing in viewer keyboard e...
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:553
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))
MRVIEWER_API void setScale(float newScale)
Strictly for internal use. Updates the value that scale() returns.
MRVIEWER_API bool beginCombo(const char *label, const std::string &text="Not selected", bool showPreview=true)
draw custom content combo box
float getDefaultDragSpeed()
Default drag speed for UI::drag().
constexpr int defaultSliderFlags
Default flags for slider() and drag() below.
Definition MRUIStyle.h:389
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:549
MRVIEWER_API 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
MRVIEWER_API const std::pair< const char *, ImU32 > & notificationChar(NotificationType type)
returns icons font character for given notification type, and its color
MRVIEWER_API bool radioButton(const char *label, int *value, int valButton)
draw gradient radio button
MRVIEWER_API void mouseControlHint(ImGuiMouseButton btn, const std::string &hint)
draws hint with corresponding mouse btn icon
MRVIEWER_API bool checkboxValid(const char *label, bool *value, bool valid)
If valid is false checkbox is disabled. Same as checkboxOrFixedValue( ..., valid ?...
MRVIEWER_API void alignTextToRadioButton()
Specialization of alignTextToFramePadding for UI::radioButton.
MRVIEWER_API void endCombo(bool showPreview=true)
MRVIEWER_API 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)
MRVIEWER_API 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.
MRVIEWER_API void transparentText(const char *fmt,...)
similar to ImGui::Text but use current text color with alpha channel = 0.5
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)
A type-erased slider.
Vector2f iconSize
size of icon
Definition MRUIStyle.h:471
std::string testEngineName
if not empty, force use this string as name in TestEngine
Definition MRUIStyle.h:93
MRVIEWER_API void init()
init internal parameters
bool triggerSave
if true - opens modal in this frame, or saves if (!inputNameDialog && inputName)
Definition MRUIStyle.h:559
bool forceImGuiSpacing
Definition MRUIStyle.h:484
MRVIEWER_API 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...
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={})
bool textUnderImage
if false - text is to the right
Definition MRUIStyle.h:102
MRVIEWER_API bool colorEdit4(const char *label, Vector4f &color, ImGuiColorEditFlags flags=ImGuiColorEditFlags_None)
draw gradient color edit 4
MRVIEWER_API 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)
MRVIEWER_API 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().
MRVIEWER_API bool checkboxMixed(const char *label, bool *value, bool mixed)
draw gradient checkbox with mixed state
MRVIEWER_API 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)
MRVIEWER_API bool beginTabBar(const char *str_id, ImGuiTabBarFlags flags=0)
create and append items into a TabBar: see corresponding ImGui:: functions
MRVIEWER_API void drawPoltHorizontalAxis(const PlotAxis &plotAxis)
draw dash with text along the horizontal axis
float extraScale
The spacing is multiplied by this.
Definition MRUIStyle.h:487
std::string label
label at the left part of separator (drawn after icon if present)
Definition MRUIStyle.h:474
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.
MRVIEWER_API void drawPoltVerticalAxis(const PlotAxis &plotAxis)
draw dash with text along the vertical axis
bool inputNameDialog
If false, inputName is used (if inputName is nullptr this option is not used)
Definition MRUIStyle.h:557
bool warnExisting
If true - warns user before overriding existing file, otherwise override without warning.
Definition MRUIStyle.h:561
float optimalLenth
optimal length between dashes
Definition MRUIStyle.h:113
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:563
MRVIEWER_API void saveCustomConfigModal(const CustomConfigModalSettings &settings)
Draw modal window to save user configs (for example Palettes)
std::string * inputName
String used by input.
Definition MRUIStyle.h:555
MRVIEWER_API 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
MRVIEWER_API void setTooltipIfHovered(const std::string &text)
draw tooltip only if current item is hovered
bool enableTestEngine
Allow interacting with this button from UI::TestEngine.
Definition MRUIStyle.h:90
std::optional< ImVec2 > cachedSize
Definition MRUIStyle.h:333
MRVIEWER_API ImGuiKey getImGuiModPrimaryCtrl()
returns imgui modifier Id based on current environment
T BaseType
The base template handles scalars (or just non-vectors).
Definition MRMesh/MRVectorTraits.h:21
bool baseValue
The persistent value of this setting, as set by the user by clicking the checkbox.
Definition MRUIStyle.h:257
float maxValue
the maximal value of the axis
Definition MRUIStyle.h:117
MRVIEWER_API bool button(const char *label, bool active, const Vector2f &size=Vector2f(0, 0), ImGuiKey key=ImGuiKey_None)
ButtonCustomizationParams baseParams
basic customization parameters
Definition MRUIStyle.h:99
MRVIEWER_API const char * getImGuiPrimaryCtrlName()
returns "Ctrl" by default or "Command" if ImGui has changed it internally for macos
MRVIEWER_API bool toggle(const char *label, bool *value)
draws checkbox-like toggle (enabled/disabled states)(O=)/(=O)
MRVIEWER_API 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 ...
float textPadding
text offset from dash
Definition MRUIStyle.h:126
MRVIEWER_API 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().
MRVIEWER_API void progressBar(float fraction, const Vector2f &size=Vector2f(-1, 0))
MRVIEWER_API void alignTextToFramePadding(float padding)
std::variant< > VarUnitToStringParams
The std::variant of UnitToStringParams<E> for all known Es (unit kinds).
Definition MRUnits.h:125
MRVIEWER_API bool beginTabItem(const char *label, bool *p_open=NULL, ImGuiTabItemFlags flags=0)
MRVIEWER_API 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
~Disabler()
Definition MRUIStyle.h:588
MRVIEWER_API bool buttonCommonSize(const char *label, const Vector2f &size=Vector2f(0, 0), ImGuiKey key=ImGuiKey_None)
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:332
Definition MRUIStyle.h:255
Settings required for UI::saveCustomConfigModal
Definition MRUIStyle.h:547
Definition MRUIStyle.h:106
Definition MRUIStyle.h:288
Parameters for drawing custom separator.
Definition MRUIStyle.h:466
Controls how a value with a unit is converted to a string.
Definition MRUnits.h:71
Common traits for (mathematical) vectors.
Definition MRMesh/MRVectorTraits.h:18