MeshLib C++ Docs
Loading...
Searching...
No Matches
MRUIStyle.h
Go to the documentation of this file.
1#pragma once
2#include "MRMesh/MRFinally.h"
3#include "MRPch/MRFmt.h"
5#include "exports.h"
6#include "MRUnits.h"
7#include "MRVectorTraits.h"
8#include "MRImGui.h"
9#include "MRColorTheme.h"
10#include <span>
11#include <string>
12#include <optional>
13
14namespace MR
15{
16
17class ImGuiImage;
18
19namespace UI
20{
21
22// Returns the global UI scale. Use this instead of passing around the scale in parameters.
23[[nodiscard]] MRVIEWER_API float scale();
24
25namespace detail
26{
27 // Strictly for internal use. Updates the value that `scale()` returns.
28 MRVIEWER_API void setScale( float newScale );
29}
30
31// Checks if the item with this name in the current window is active.
32[[nodiscard]] MRVIEWER_API bool isItemActive( const char* name );
33
34// Use this to store state across frames. Like what `CollapsingHeader()` uses to store it's open/close state.
35namespace StateStorage
36{
37
38[[nodiscard]] MRVIEWER_API bool readBool( std::string_view key, bool defaultValue = false );
39MRVIEWER_API void writeBool( std::string_view key, bool value );
40
41}
42
43// enumeration texture types
54
55// get texture by type
56MRVIEWER_API std::unique_ptr<ImGuiImage>& getTexture( TextureType type );
57
59MRVIEWER_API void init();
60
63{
65 bool enabled = true;
66
68 ImGuiButtonFlags flags = ImGuiButtonFlags_None;
69
74
77
79 bool forceImguiTextColor = false;
81 bool border = false;
82
85
87 bool enableTestEngine = true;
88
90 std::string testEngineName;
91};
92
94{
95 // basic customization parameters
97
98 // if false - text is to the right
99 bool textUnderImage = true;
100};
101
103{
104 // the point from which the axes will be drawn
106
107 // size plot by axis
108 float size = 100.f;
109 // optimal length between dashes
110 float optimalLenth = 10.0f;
111 // the minimum value of the axis
112 float minValue = 0.0f;
113 // the maximal value of the axis
114 float maxValue = 1.0f;
115 // sign every nth dash
117
118 // length dash without text
119 float lenDash = 8.0f;
120 // length dash with text
121 float lenDashWithText = 12.0f;
122 // text offset from dash
123 float textPadding = 3.0f;
124 // the format of the text for labels
126};
127
129MRVIEWER_API ImGuiKey getImGuiModPrimaryCtrl();
130
132MRVIEWER_API bool checkKey( ImGuiKey passedKey );
133
135[[deprecated( "Use UI::buttonEx( label, size, params ) instead" )]]
136MRVIEWER_API bool buttonEx( const char* label,bool active, const Vector2f& size = Vector2f( 0, 0 ),
137 ImGuiButtonFlags flags = ImGuiButtonFlags_None, const ButtonCustomizationParams& customParams = {} );
138
140MRVIEWER_API bool buttonEx( const char* label, const Vector2f& size = Vector2f( 0, 0 ), const ButtonCustomizationParams& customParams = {} );
143MRVIEWER_API bool button( const char* label, bool active, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None );
146inline bool button( const char* label, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None )
147{
148 return button( label, true, size, key );
149}
152MRVIEWER_API bool buttonCommonSize( const char* label, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None );
154MRVIEWER_API bool buttonUnique( const char* label, int* value, int ownValue, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None );
155
156// draw dash with text along the horizontal axis
157MRVIEWER_API void drawPoltHorizontalAxis( const PlotAxis& plotAxis );
158// draw dash with text along the vertical axis
159MRVIEWER_API void drawPoltVerticalAxis( const PlotAxis& plotAxis );
160
161// draw a button with an icon and text under it
162MRVIEWER_API bool buttonIconEx(
163 const std::string& name,
164 const Vector2f& iconSize,
165 const std::string& text,
166 const ImVec2& buttonSize,
167 const ButtonIconCustomizationParams& params = {} );
168
169// button with a gradient, always active
170inline bool buttonIcon( const std::string& name, const Vector2f& iconSize, const std::string& text, const ImVec2& buttonSize )
171{
172 return buttonIconEx( name, iconSize, text, buttonSize );
173}
174// button without a gradient, always active, configurable by an external style
176 const std::string& name,
177 const Vector2f& iconSize,
178 const std::string& text,
179 const ImVec2& buttonSize,
180 bool textUnderIcon = true,
181 ImGuiKey key = ImGuiKey_None )
182{
184 params.baseParams.forceImGuiBackground = true;
185 params.baseParams.forceImguiTextColor = true;
186 params.textUnderImage = textUnderIcon;
187 params.baseParams.underlineFirstLetter = std::string_view( ImGui::GetKeyName( key ) ) == std::string_view( text.c_str(), 1 );
188 return buttonIconEx( name, iconSize, text, buttonSize, params ) || checkKey( key );
189}
192MRVIEWER_API bool buttonUniqueIcon(
193 const std::string& iconName,
194 const Vector2f& iconSize,
195 const std::string& text,
196 const ImVec2& buttonSize,
197 int* value,
198 int ownValue,
199 bool textUnderIcon = true,
200 ImGuiKey key = ImGuiKey_None );
201
202
204MRVIEWER_API bool toggle( const char* label, bool* value );
206MRVIEWER_API bool checkbox( const char* label, bool* value );
208MRVIEWER_API bool checkboxOrFixedValue( const char* label, bool* value, std::optional<bool> valueOverride );
210MRVIEWER_API bool checkboxValid( const char* label, bool* value, bool valid );
212MRVIEWER_API bool checkboxMixed( const char* label, bool* value, bool mixed );
214template <typename Getter, typename Setter>
215bool checkbox( const char* label, Getter get, Setter set )
216{
217 bool value = get();
218 bool ret = checkbox( label, &value );
219 set( value );
220 return ret;
221}
222template <typename Getter, typename Setter>
223bool checkboxValid( const char* label, Getter get, Setter set, bool valid )
224{
225 bool value = get();
226 bool ret = checkboxValid( label, &value, valid );
227 set( value );
228 return ret;
229}
230
232template <typename T>
233bool checkboxFlags( const char* label, T& target, T flags )
234{
235 bool value = bool( target & flags );
236 bool mixed = value && ( target & flags ) != flags;
237 if ( checkboxMixed( label, &value, mixed ) )
238 {
239 if ( value )
240 target |= flags;
241 else
242 target &= ~flags;
243 return true;
244 }
245 return false;
246}
247
249{
250 // The persistent value of this setting, as set by the user by clicking the checkbox.
251 bool baseValue = false;
252 // Whether the setting is currently inverted because the modifier is held.
253 bool modifierHeld = false;
254
256
258
259 // You usually want to read this instead of the variables above.
260 // Returns `baseValue`, but inverted if `modifierHeld` is set.
261 [[nodiscard]] explicit operator bool() const { return baseValue != modifierHeld; }
262};
263
273MRVIEWER_API bool checkboxOrModifier( const char* label, CheckboxOrModifierState& value, int modifiers, int respectedModifiers = -1, std::optional<bool> valueOverride = {} );
274
275
277MRVIEWER_API bool radioButton( const char* label, int* value, int valButton );
279MRVIEWER_API bool radioButtonOrFixedValue( const char* label, int* value, int valButton, std::optional<int> valueOverride );
280
282{
283 // The permanent value of this setting, as set by the user by clicking the radio button.
284 int value{};
285 // The value that is displayed, and to be used - can differ from `value` if modifiers are pressed.
287
288 // The effective value, affected by modifiers.
289 [[nodiscard]] explicit operator int() const
290 {
291 return effectiveValue;
292 }
293};
294
301MRVIEWER_API bool radioButtonOrModifier( const char* label, RadioButtonOrModifierState& value, int valButton, int modifiers, int respectedModifiers = -1, std::optional<int> valueOverride = {} );
302
304MRVIEWER_API bool colorEdit4( const char* label, Vector4f& color, ImGuiColorEditFlags flags = ImGuiColorEditFlags_None );
305MRVIEWER_API bool colorEdit4( const char* label, Color& color, ImGuiColorEditFlags flags = ImGuiColorEditFlags_None );
306
308MRVIEWER_API bool combo( const char* label, int* v, const std::vector<std::string>& options,
309 bool showPreview = true, const std::vector<std::string>& tooltips = {}, const std::string& defaultText = "Not selected" );
310
312MRVIEWER_API bool beginCombo( const char* label, const std::string& text = "Not selected", bool showPreview = true );
313MRVIEWER_API void endCombo( bool showPreview = true );
314
316MRVIEWER_API bool inputText( const char* label, std::string& str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
318MRVIEWER_API bool inputTextIntoArray( const char* label, char* array, std::size_t size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
319
321MRVIEWER_API bool inputTextMultiline( const char* label, std::string& str, const ImVec2& size = ImVec2(), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
323MRVIEWER_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 );
324
326{
327 std::optional<ImVec2> cachedSize; // Reset this when manually modifying the text.
328};
330MRVIEWER_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 );
331MRVIEWER_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 );
332
334MRVIEWER_API bool inputTextCentered( const char* label, std::string& str, float width = 0.0f, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
335
337MRVIEWER_API void inputTextCenteredReadOnly( const char* label, const std::string& str, float width = 0.0f, const std::optional<ImVec4>& textColor = {}, const std::optional<ImVec4>& labelColor = {} );
338
339
340namespace detail
341{
342 // A type-erased slider.
343 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 );
344
345 // Whether `T` is a scalar type that we can use with our widgets.
346 template <typename T>
347 concept Scalar = std::is_arithmetic_v<T> && !std::is_same_v<T, bool>;
348
349 // Whether `T` is a scalar or vector that we can use with our widgets.
350 template <typename T>
352
353 // Whether `Bound` is a valid min/max bound for `Target`.
354 // That is, either the same type, or if `Target` is a vector, `Bound` can also be a scalar of the same type.
355 template <typename Bound, typename Target>
357 std::same_as<Bound, Target> ||
358 ( VectorTraits<Bound>::size == 1 && std::same_as<typename VectorTraits<Bound>::BaseType, typename VectorTraits<Target>::BaseType> );
359
360 // Whether `Speed` is a valid drag speed type for `Target`.
361 // That is, either a single/vector of `float` or the same type as target (or its element if it's a vector).
362 template <typename Speed, typename Target>
364 std::same_as<Speed, typename VectorTraits<Target>::BaseType> || std::same_as<Speed, float> ||
365 std::same_as<Speed, Target> || std::same_as<Speed, typename VectorTraits<Target>::template ChangeBase<float>>;
366
367 // A common code for sliders and other widgets dealing with measurement units.
368 // `E` must be explicitly set to a measurement unit enum. The other template parameters are deduced.
369 // `label` is the widget label, `v` is the target value.
370 // `func` draws the widget for an individual scalar. We call it more than once for vectors.
371 // `func` is `( const char* label, auto& elem, int i ) -> bool`.
372 // It receives `elem` already converted to the display units (so you must convert min/max bounds manually). `i` is the element index for vectors.
373 // When `v` is integral, `func` will be instantiated for both integral and floating-point element type. The latter is required if we're doing conversions.
374 // NOTE: For integral `v`, in `func` you must look at the type of `elem` and convert your min/max bounds (etc) to the same type.
375 // Notice `unitParams` being accepted by an lvalue reference. For convenience, we reset the `sourceUnit` in it before calling the user callback,
376 // since at that point no further conversions are necessary.
377 template <UnitEnum E, VectorOrScalar T, typename F>
378 [[nodiscard]] bool unitWidget( const char* label, T& v, UnitToStringParams<E>& unitParams, F&& func );
379
380}
381
382// Default flags for `slider()` and `drag()` below.
383inline constexpr int defaultSliderFlags = ImGuiSliderFlags_AlwaysClamp;
384
385// Default drag speed for `UI::drag()`.
386template <UnitEnum E, detail::VectorOrScalar T>
387requires ( VectorTraits<T>::size == 1 )
388[[nodiscard]] float getDefaultDragSpeed();
389
390// Default step speed for `UI::input()`.
391template <UnitEnum E, detail::VectorOrScalar T, detail::VectorOrScalar TargetType>
392[[nodiscard]] T getDefaultStep( bool fast );
393
394// Draw a slider.
395// `E` must be specified explicitly, to one of: `NoUnit` `LengthUnit`, `AngleUnit`, ...
396// By default, for angles `v` will be converted to degrees for display (but `vMin`, `vMax` are still in radians, same as `v`),
397// while length and unit-less values will be left as is. This can be customized in `unitParams` or globally (see `MRUnits.h`).
398template <UnitEnum E, detail::VectorOrScalar T, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
399bool slider( const char* label, T& v, const U& vMin, const U& vMax, UnitToStringParams<E> unitParams = {}, ImGuiSliderFlags flags = defaultSliderFlags );
400
401// Draw a dragging widget. Also includes [+] and [-] buttons (for integers only by default_, like `ImGui::Input`).
402// `E` must be specified explicitly, to one of: `NoUnit` `LengthUnit`, `AngleUnit`, ...
403// By default, for angles `v` will be converted to degrees for display (but `vSpeed` is still in radians, same as `v`),
404// while length and unit-less values will be left as is. This can be customized in `unitParams` or globally (see `MRUnits.h`).
405// If only the min limit is specified, then the max limit is assumed to be the largest number.
406template <UnitEnum E, detail::VectorOrScalar T, detail::ValidDragSpeedForTargetType<T> SpeedType = float, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
407bool 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 ) );
408
409// Like `drag()`, but clicking it immediately activates text input, so it's not actually draggable.
410template <UnitEnum E, detail::VectorOrScalar T, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
411bool 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 );
412
413// Draw a read-only copyable value.
414// `E` must be specified explicitly, to one of: `NoUnit` `LengthUnit`, `AngleUnit`, ...
415// By default, for angles `v` will be converted to degrees for display, while length and unit-less values will be left as is.
416// This can be customized in `unitParams` or globally (see `MRUnits.h`).
417template <UnitEnum E, detail::VectorOrScalar T>
418void readOnlyValue( const char* label, const T& v, std::optional<ImVec4> textColor = {}, UnitToStringParams<E> unitParams = {}, std::optional<ImVec4> labelColor = {} );
419
420
421// A generic wrapper for drawing plus-minus drags/inputs/etc that can be toggled between symmetric and asymmetric mode.
422// Prefer `inputPlusMinus()` and other functions written on top of this one.
423// `func` is a `(const char* subLabel, T& value, const UnitToStringParams<E>& subUnitParams) -> bool`, draw your widget there with the automatic width,
424// the specified label and value, and return its return value. `value` will receive either `plus` or `minus`.
425template <UnitEnum E, detail::Scalar T, typename F>
426bool plusMinusGeneric( const char* label, T& plus, T& minus, UnitToStringParams<E> unitToStringParams, F&& func );
427
428// A `drag()` for two numbers that can be toggled between symmetric and asymmetric mode.
429// Notice the `wrapFunc` parameter. If specified, it is a `(const char* subLabel, T& value, auto&& f) -> bool` lambda that must do `return f();`.
430// That is called for each of the two plus/minus parts of the widget, and lets you e.g. set a custom style for those.
431// Here we intentionally don't allow passing the step values, that wouldn't render too well.
432template <UnitEnum E, detail::Scalar T, detail::ValidDragSpeedForTargetType<T> SpeedType = float, typename F = std::nullptr_t>
433bool 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 );
434
435// An `input()` for two numbers that can be toggled between symmetric and asymmetric mode.
436// Notice the `wrapFunc` parameter. If specified, it is a `(const char* subLabel, T& value, auto&& f) -> bool` lambda that must do `return f();`.
437// That is called for each of the two plus/minus parts of the widget, and lets you e.g. set a custom style for those.
438template <UnitEnum E, detail::Scalar T, typename F = std::nullptr_t>
439bool 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 );
440
441
443MRVIEWER_API const std::pair<const char*, ImU32>& notificationChar( NotificationType type );
444
446MRVIEWER_API void mouseControlHint( ImGuiMouseButton btn, const std::string& hint );
447
449MRVIEWER_API void transparentText( const char* fmt, ... );
451MRVIEWER_API void transparentTextWrapped( const char* fmt, ... );
453MRVIEWER_API void notificationFrame( NotificationType type, const std::string& str );
454
456MRVIEWER_API void setTooltipIfHovered( const std::string& text );
457
460{
462 const ImGuiImage* icon{ nullptr };
463
465 Vector2f iconSize;
466
468 std::string label;
469
471 std::string suffix;
472
474 std::optional<Color> suffixFrameColor;
475
478 bool forceImGuiSpacing = false;
479
481 float extraScale = 1;
482};
483
485MRVIEWER_API void separator( const SeparatorParams& params );
486
491MRVIEWER_API void separator( const std::string& text = "", int issueCount = -1 );
492MRVIEWER_API void separator(
493 const std::string& text,
494 const ImVec4& color,
495 const std::string& issueCount );
496// separator line with icon and text
497// iconSize icon size without scaling
498MRVIEWER_API void separator( const ImGuiImage& icon, const std::string& text, const Vector2f& iconSize = { 24.f, 24.f } );
499MRVIEWER_API void separator( const std::string& iconName, const std::string& text, const Vector2f& iconSize = { 24.f, 24.f } );
500
505MRVIEWER_API void progressBar( float fraction, const Vector2f& size = Vector2f( -1, 0 ) );
506
507// create and append items into a TabBar: see corresponding ImGui:: functions
508MRVIEWER_API bool beginTabBar( const char* str_id, ImGuiTabBarFlags flags = 0 );
509MRVIEWER_API void endTabBar();
510MRVIEWER_API bool beginTabItem( const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0 );
511MRVIEWER_API void endTabItem();
512
522MRVIEWER_API void alignTextToFramePadding( float padding );
526MRVIEWER_API void alignTextToControl( float controlHeight );
528MRVIEWER_API void alignTextToRadioButton();
530MRVIEWER_API void alignTextToCheckBox();
532MRVIEWER_API void alignTextToButton();
533
537MRVIEWER_API void highlightWindowArea( const ImVec2& min = {-1.0f, -1.0f}, const ImVec2& max = { -1.0f, -1.0f } );
538
539// While this exists, it temporarily disables antialiasing for the lines drawn to this list.
541{
542 ImDrawList& list;
543 ImDrawFlags oldFlags{};
544
545public:
546 LineAntialiasingDisabler( ImDrawList& list )
547 : list( list ), oldFlags( list.Flags )
548 {
549 list.Flags &= ~ImDrawListFlags_AntiAliasedLines;
550 }
551
554
556 {
557 list.Flags = oldFlags;
558 }
559};
560
561} // namespace UI
562
563}
564
565#include "MRUIStyle.ipp"
Definition MRImGuiImage.h:14
Definition MRUIStyle.h:541
LineAntialiasingDisabler & operator=(const LineAntialiasingDisabler &)=delete
LineAntialiasingDisabler(ImDrawList &list)
Definition MRUIStyle.h:546
LineAntialiasingDisabler(const LineAntialiasingDisabler &)=delete
~LineAntialiasingDisabler()
Definition MRUIStyle.h:555
Definition MRUIStyle.h:347
Definition MRUIStyle.h:356
Definition MRUIStyle.h:351
auto width(const Box< V > &box)
returns size along x axis
Definition MRMesh/MRBox.h:341
constexpr const V & get(const Box< V > &box) noexcept
get<0> returns min, get<1> returns max
Definition MRMesh/MRBox.h:387
MRVIEWER_API bool readBool(std::string_view key, bool defaultValue=false)
MRVIEWER_API void writeBool(std::string_view key, bool value)
MRVIEWER_API void setScale(float newScale)
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)
bool unitWidget(const char *label, T &v, UnitToStringParams< E > &unitParams, F &&func)
TextureType
Definition MRUIStyle.h:45
MRVIEWER_API bool checkboxOrModifier(const char *label, CheckboxOrModifierState &value, int modifiers, int respectedModifiers=-1, std::optional< bool > valueOverride={})
MRVIEWER_API std::unique_ptr< ImGuiImage > & getTexture(TextureType 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...
MRVIEWER_API bool radioButtonOrModifier(const char *label, RadioButtonOrModifierState &value, int valButton, int modifiers, int respectedModifiers=-1, std::optional< int > valueOverride={})
MRVIEWER_API void endTabBar()
MRVIEWER_API bool isItemActive(const char *name)
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
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)
Definition MRUIStyle.h:170
MRVIEWER_API void alignTextToButton()
Specialization of alignTextToFramePadding for UI::button with default height.
T getDefaultStep(bool fast)
MRVIEWER_API void alignTextToCheckBox()
Specialization of alignTextToFramePadding for UI::checkbox.
MRVIEWER_API void notificationFrame(NotificationType type, const std::string &str)
similar to ImGui::TextWrapped but also have styled background and notification type indicator
bool buttonIconFlatBG(const std::string &name, const Vector2f &iconSize, const std::string &text, const ImVec2 &buttonSize, bool textUnderIcon=true, ImGuiKey key=ImGuiKey_None)
Definition MRUIStyle.h:175
MRVIEWER_API bool checkbox(const char *label, bool *value)
draw gradient checkbox
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()
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)
MRVIEWER_API void separator(const SeparatorParams &params)
separator line with customizations
MRVIEWER_API void alignTextToControl(float controlHeight)
MRVIEWER_API bool checkKey(ImGuiKey passedKey)
returns true if button is pressed in this frame, preserve its further processing in viewer keyboard e...
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 bool beginCombo(const char *label, const std::string &text="Not selected", bool showPreview=true)
draw custom content combo box
float getDefaultDragSpeed()
constexpr int defaultSliderFlags
Definition MRUIStyle.h:383
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)
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 void init()
init internal parameters
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...
void readOnlyValue(const char *label, const T &v, std::optional< ImVec4 > textColor={}, UnitToStringParams< E > unitParams={}, std::optional< ImVec4 > labelColor={})
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={})
MRVIEWER_API bool beginTabBar(const char *str_id, ImGuiTabBarFlags flags=0)
MRVIEWER_API void drawPoltHorizontalAxis(const PlotAxis &plotAxis)
bool checkboxFlags(const char *label, T &target, T flags)
Draw a checkbox toggling one or more bits in the mask.
Definition MRUIStyle.h:233
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)
MRVIEWER_API void drawPoltVerticalAxis(const PlotAxis &plotAxis)
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
MRVIEWER_API ImGuiKey getImGuiModPrimaryCtrl()
returns imgui modifier Id based on current environment
MRVIEWER_API bool button(const char *label, bool active, const Vector2f &size=Vector2f(0, 0), ImGuiKey key=ImGuiKey_None)
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 ...
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)
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
MRVIEWER_API bool buttonCommonSize(const char *label, const Vector2f &size=Vector2f(0, 0), ImGuiKey key=ImGuiKey_None)
Definition MRCameraOrientationPlugin.h:8
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:29
NotificationType
Definition MRNotificationType.h:7
std::variant< > VarUnitToStringParams
Definition MRUnits.h:330
Definition MRMesh/MRColor.h:9
parameters to customize buttonEx
Definition MRUIStyle.h:63
bool forceImguiTextColor
force use if ImGuiCol_Text for text
Definition MRUIStyle.h:79
ImGuiImage * customTexture
Definition MRUIStyle.h:73
bool border
show border or not
Definition MRUIStyle.h:81
ImGuiButtonFlags flags
imgui flags for this button
Definition MRUIStyle.h:68
bool enabled
If false, the button is grayed out and can't be clicked.
Definition MRUIStyle.h:65
std::string testEngineName
if not empty, force use this string as name in TestEngine
Definition MRUIStyle.h:90
bool underlineFirstLetter
draw line under first letter of label
Definition MRUIStyle.h:84
bool forceImGuiBackground
force use imgui background if !customTexture
Definition MRUIStyle.h:76
bool enableTestEngine
Allow interacting with this button from UI::TestEngine.
Definition MRUIStyle.h:87
Definition MRUIStyle.h:94
bool textUnderImage
Definition MRUIStyle.h:99
ButtonCustomizationParams baseParams
Definition MRUIStyle.h:96
Definition MRUIStyle.h:326
std::optional< ImVec2 > cachedSize
Definition MRUIStyle.h:327
Definition MRUIStyle.h:249
bool modifierHeld
Definition MRUIStyle.h:253
CheckboxOrModifierState()
Definition MRUIStyle.h:255
CheckboxOrModifierState(bool baseValue)
Definition MRUIStyle.h:257
bool baseValue
Definition MRUIStyle.h:251
Definition MRUIStyle.h:103
float size
Definition MRUIStyle.h:108
VarUnitToStringParams labelFormatParams
Definition MRUIStyle.h:125
float lenDash
Definition MRUIStyle.h:119
size_t textDashIndicesStep
Definition MRUIStyle.h:116
float minValue
Definition MRUIStyle.h:112
float lenDashWithText
Definition MRUIStyle.h:121
ImVec2 startAxisPoint
Definition MRUIStyle.h:105
float optimalLenth
Definition MRUIStyle.h:110
float maxValue
Definition MRUIStyle.h:114
float textPadding
Definition MRUIStyle.h:123
Definition MRUIStyle.h:282
int value
Definition MRUIStyle.h:284
int effectiveValue
Definition MRUIStyle.h:286
Parameters for drawing custom separator.
Definition MRUIStyle.h:460
std::string suffix
framed text after label (might be used for some indications)
Definition MRUIStyle.h:471
std::optional< Color > suffixFrameColor
color of background frame behind suffix (if not present default ImGuiCol_FrameBg is used)
Definition MRUIStyle.h:474
const ImGuiImage * icon
optional icon in the left part of separator
Definition MRUIStyle.h:462
Vector2f iconSize
size of icon
Definition MRUIStyle.h:465
bool forceImGuiSpacing
Definition MRUIStyle.h:478
float extraScale
The spacing is multiplied by this.
Definition MRUIStyle.h:481
std::string label
label at the left part of separator (drawn after icon if present)
Definition MRUIStyle.h:468
Definition MRUnits.h:276
Definition MRMesh/MRVectorTraits.h:15
static constexpr int size
Definition MRMesh/MRVectorTraits.h:19
T BaseType
Definition MRMesh/MRVectorTraits.h:18