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// enumeration texture types
33
34// get texture by type
35MRVIEWER_API std::unique_ptr<ImGuiImage>& getTexture( TextureType type );
36
38MRVIEWER_API void init();
39
42{
44 bool enabled = true;
45
47 ImGuiButtonFlags flags = ImGuiButtonFlags_None;
48
53
56
58 bool forceImguiTextColor = false;
60 bool border = false;
61
64
66 bool enableTestEngine = true;
67
69 std::string testEngineName;
70};
71
73{
74 // basic customization parameters
76
77 // if false - text is to the right
78 bool textUnderImage = true;
79};
80
82{
83 // the point from which the axes will be drawn
85
86 // size plot by axis
87 float size;
88 // optimal length between dashes
89 float optimalLenth = 10.0f;
90 // the minimum value of the axis
91 float minValue = 0.0f;
92 // the maximal value of the axis
93 float maxValue = 1.0f;
94 // sign every nth dash
96
97 // length dash without text
98 float lenDash = 8.0f;
99 // length dash with text
100 float lenDashWithText = 12.0f;
101 // text offset from dash
102 float textPadding = 3.0f;
103 // the format of the text for labels
105};
106
108MRVIEWER_API bool checkKey( ImGuiKey passedKey );
109
111[[deprecated( "Use UI::buttonEx( label, size, params ) instead" )]]
112MRVIEWER_API bool buttonEx( const char* label,bool active, const Vector2f& size = Vector2f( 0, 0 ),
113 ImGuiButtonFlags flags = ImGuiButtonFlags_None, const ButtonCustomizationParams& customParams = {} );
114
116MRVIEWER_API bool buttonEx( const char* label, const Vector2f& size = Vector2f( 0, 0 ), const ButtonCustomizationParams& customParams = {} );
119MRVIEWER_API bool button( const char* label, bool active, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None );
122inline bool button( const char* label, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None )
123{
124 return button( label, true, size, key );
125}
128MRVIEWER_API bool buttonCommonSize( const char* label, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None );
130MRVIEWER_API bool buttonUnique( const char* label, int* value, int ownValue, const Vector2f& size = Vector2f( 0, 0 ), ImGuiKey key = ImGuiKey_None );
131
132// draw dash with text along the horizontal axis
133MRVIEWER_API void drawPoltHorizontalAxis( float menuScaling, const PlotAxis& plotAxis );
134// draw dash with text along the vertical axis
135MRVIEWER_API void drawPoltVerticalAxis( float menuScaling, const PlotAxis& plotAxis );
136
137// draw a button with an icon and text under it
138MRVIEWER_API bool buttonIconEx(
139 const std::string& name,
140 const Vector2f& iconSize,
141 const std::string& text,
142 const ImVec2& buttonSize,
143 const ButtonIconCustomizationParams& params = {} );
144
145// button with a gradient, always active
146inline bool buttonIcon( const std::string& name, const Vector2f& iconSize, const std::string& text, const ImVec2& buttonSize )
147{
148 return buttonIconEx( name, iconSize, text, buttonSize );
149}
150// button without a gradient, always active, configurable by an external style
151inline bool buttonIconFlatBG(
152 const std::string& name,
153 const Vector2f& iconSize,
154 const std::string& text,
155 const ImVec2& buttonSize,
156 bool textUnderIcon = true,
157 ImGuiKey key = ImGuiKey_None )
158{
160 params.baseParams.forceImGuiBackground = true;
161 params.baseParams.forceImguiTextColor = true;
162 params.textUnderImage = textUnderIcon;
163 params.baseParams.underlineFirstLetter = std::string_view( ImGui::GetKeyName( key ) ) == std::string_view( text.c_str(), 1 );
164 return buttonIconEx( name, iconSize, text, buttonSize, params ) || checkKey( key );
165}
168MRVIEWER_API bool buttonUniqueIcon(
169 const std::string& iconName,
170 const Vector2f& iconSize,
171 const std::string& text,
172 const ImVec2& buttonSize,
173 int* value,
174 int ownValue,
175 bool textUnderIcon = true,
176 ImGuiKey key = ImGuiKey_None );
177
178
180MRVIEWER_API bool toggle( const char* label, bool* value );
182MRVIEWER_API bool checkbox( const char* label, bool* value );
184MRVIEWER_API bool checkboxOrFixedValue( const char* label, bool* value, std::optional<bool> valueOverride );
186MRVIEWER_API bool checkboxValid( const char* label, bool* value, bool valid );
188MRVIEWER_API bool checkboxMixed( const char* label, bool* value, bool mixed );
190template <typename Getter, typename Setter>
191bool checkbox( const char* label, Getter get, Setter set )
192{
193 bool value = get();
194 bool ret = checkbox( label, &value );
195 set( value );
196 return ret;
197}
198template <typename Getter, typename Setter>
199bool checkboxValid( const char* label, Getter get, Setter set, bool valid )
200{
201 bool value = get();
202 bool ret = checkboxValid( label, &value, valid );
203 set( value );
204 return ret;
205}
206
208template <typename T>
209bool checkboxFlags( const char* label, T& target, T flags )
210{
211 bool value = bool( target & flags );
212 bool mixed = value && ( target & flags ) != flags;
213 if ( checkboxMixed( label, &value, mixed ) )
214 {
215 if ( value )
216 target |= flags;
217 else
218 target &= ~flags;
219 return true;
220 }
221 return false;
222}
223
225{
226 // The persistent value of this setting, as set by the user by clicking the checkbox.
227 bool baseValue = false;
228 // Whether the setting is currently inverted because the modifier is held.
229 bool modifierHeld = false;
230
231 // You usually want to read this instead of the variables above.
232 // Returns `baseValue`, but inverted if `modifierHeld` is set.
233 [[nodiscard]] explicit operator bool() const { return baseValue != modifierHeld; }
234};
235
245MRVIEWER_API bool checkboxOrModifier( const char* label, CheckboxOrModifierState& value, int modifiers, int respectedModifiers = -1, std::optional<bool> valueOverride = {} );
246
247
249MRVIEWER_API bool radioButton( const char* label, int* value, int valButton );
251MRVIEWER_API bool radioButtonOrFixedValue( const char* label, int* value, int valButton, std::optional<int> valueOverride );
252
254{
255 // The permanent value of this setting, as set by the user by clicking the radio button.
256 int value{};
257 // The value that is displayed, and to be used - can differ from `value` if modifiers are pressed.
259
260 // The effective value, affected by modifiers.
261 [[nodiscard]] explicit operator int() const
262 {
263 return effectiveValue;
264 }
265};
266
273MRVIEWER_API bool radioButtonOrModifier( const char* label, RadioButtonOrModifierState& value, int valButton, int modifiers, int respectedModifiers = -1, std::optional<int> valueOverride = {} );
274
276MRVIEWER_API bool colorEdit4( const char* label, Vector4f& color, ImGuiColorEditFlags flags = ImGuiColorEditFlags_None );
277MRVIEWER_API bool colorEdit4( const char* label, Color& color, ImGuiColorEditFlags flags = ImGuiColorEditFlags_None );
278
280MRVIEWER_API bool combo( const char* label, int* v, const std::vector<std::string>& options,
281 bool showPreview = true, const std::vector<std::string>& tooltips = {}, const std::string& defaultText = "Not selected" );
282
284MRVIEWER_API bool beginCombo( const char* label, const std::string& text = "Not selected", bool showPreview = true );
285MRVIEWER_API void endCombo( bool showPreview = true );
286
288MRVIEWER_API bool inputText( const char* label, std::string& str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
290MRVIEWER_API bool inputTextIntoArray( const char* label, char* array, std::size_t size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
291
293MRVIEWER_API bool inputTextMultiline( const char* label, std::string& str, const ImVec2& size = ImVec2(), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
295MRVIEWER_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 );
296
298{
299 std::optional<ImVec2> cachedSize; // Reset this when manually modifying the text.
300};
302MRVIEWER_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 );
303MRVIEWER_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 );
304
306MRVIEWER_API bool inputTextCentered( const char* label, std::string& str, float width = 0.0f, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr );
307
309MRVIEWER_API void inputTextCenteredReadOnly( const char* label, const std::string& str, float width = 0.0f, const std::optional<ImVec4>& textColor = {}, const std::optional<ImVec4>& labelColor = {} );
310
311
312namespace detail
313{
314 // A type-erased slider.
315 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 );
316
317 // Whether `T` is a scalar type that we can use with our widgets.
318 template <typename T>
319 concept Scalar = std::is_arithmetic_v<T> && !std::is_same_v<T, bool>;
320
321 // Whether `T` is a scalar or vector that we can use with our widgets.
322 template <typename T>
324
325 // Whether `Bound` is a valid min/max bound for `Target`.
326 // That is, either the same type, or if `Target` is a vector, `Bound` can also be a scalar of the same type.
327 template <typename Bound, typename Target>
329 std::same_as<Bound, Target> ||
330 ( VectorTraits<Bound>::size == 1 && std::same_as<typename VectorTraits<Bound>::BaseType, typename VectorTraits<Target>::BaseType> );
331
332 // Whether `Speed` is a valid drag speed type for `Target`.
333 // That is, either a single/vector of `float` or the same type as target (or its element if it's a vector).
334 template <typename Speed, typename Target>
336 std::same_as<Speed, typename VectorTraits<Target>::BaseType> || std::same_as<Speed, float> ||
337 std::same_as<Speed, Target> || std::same_as<Speed, typename VectorTraits<Target>::template ChangeBase<float>>;
338
339 // A common code for sliders and other widgets dealing with measurement units.
340 // `E` must be explicitly set to a measurement unit enum. The other template parameters are deduced.
341 // `label` is the widget label, `v` is the target value.
342 // `func` draws the widget for an individual scalar. We call it more than once for vectors.
343 // `func` is `( const char* label, auto& elem, int i ) -> bool`.
344 // It receives `elem` already converted to the display units (so you must convert min/max bounds manually). `i` is the element index for vectors.
345 // 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.
346 // 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.
347 // Notice `unitParams` being accepted by an lvalue reference. For convenience, we reset the `sourceUnit` in it before calling the user callback,
348 // since at that point no further conversions are necessary.
349 template <UnitEnum E, VectorOrScalar T, typename F>
350 [[nodiscard]] bool unitWidget( const char* label, T& v, UnitToStringParams<E>& unitParams, F&& func );
351
352 // Some default slider parameters. For now they are hardcoded here, but we can move them elsewhere later.
353
354 // Default drag speed for `UI::drag()`.
355 template <UnitEnum E, VectorOrScalar T>
356 requires ( VectorTraits<T>::size == 1 )
357 [[nodiscard]] float getDefaultDragSpeed();
358
359 // Default step speed for `UI::input()`.
360 template <UnitEnum E, VectorOrScalar T, VectorOrScalar TargetType>
361 [[nodiscard]] T getDefaultStep( bool fast );
362}
363
364// Default flags for `slider()` and `drag()` below.
365inline constexpr int defaultSliderFlags = ImGuiSliderFlags_AlwaysClamp;
366
367// Draw a slider.
368// `E` must be specified explicitly, to one of: `NoUnit` `LengthUnit`, `AngleUnit`, ...
369// By default, for angles `v` will be converted to degrees for display (but `vMin`, `vMax` are still in radians, same as `v`),
370// while length and unit-less values will be left as is. This can be customized in `unitParams` or globally (see `MRUnits.h`).
371template <UnitEnum E, detail::VectorOrScalar T, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
372bool slider( const char* label, T& v, const U& vMin, const U& vMax, UnitToStringParams<E> unitParams = {}, ImGuiSliderFlags flags = defaultSliderFlags );
373
374// Draw a dragging widget. Also includes [+] and [-] buttons (for integers only by default_, like `ImGui::Input`).
375// `E` must be specified explicitly, to one of: `NoUnit` `LengthUnit`, `AngleUnit`, ...
376// By default, for angles `v` will be converted to degrees for display (but `vSpeed` is still in radians, same as `v`),
377// while length and unit-less values will be left as is. This can be customized in `unitParams` or globally (see `MRUnits.h`).
378// If only the min limit is specified, then the max limit is assumed to be the largest number.
379template <UnitEnum E, detail::VectorOrScalar T, detail::ValidDragSpeedForTargetType<T> SpeedType = float, detail::ValidBoundForTargetType<T> U = typename VectorTraits<T>::BaseType>
380bool drag( const char* label, T& v, SpeedType vSpeed = detail::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 = detail::getDefaultStep<E, U, T>( false ), const U& stepFast = detail::getDefaultStep<E, U, T>( true ) );
381
382// Draw a read-only copyable value.
383// `E` must be specified explicitly, to one of: `NoUnit` `LengthUnit`, `AngleUnit`, ...
384// By default, for angles `v` will be converted to degrees for display, while length and unit-less values will be left as is.
385// This can be customized in `unitParams` or globally (see `MRUnits.h`).
386template <UnitEnum E, detail::VectorOrScalar T>
387void readOnlyValue( const char* label, const T& v, std::optional<ImVec4> textColor = {}, UnitToStringParams<E> unitParams = {}, std::optional<ImVec4> labelColor = {} );
388
389
391MRVIEWER_API const std::pair<const char*, ImU32>& notificationChar( NotificationType type );
392
394MRVIEWER_API void mouseControlHint( ImGuiMouseButton btn, const std::string& hint, float scaling );
395
397MRVIEWER_API void transparentText( const char* fmt, ... );
399MRVIEWER_API void transparentTextWrapped( const char* fmt, ... );
401MRVIEWER_API void notificationFrame( NotificationType type, const std::string& str, float scaling );
402
404MRVIEWER_API void setTooltipIfHovered( const std::string& text, float scaling );
405
408{
410 const ImGuiImage* icon{ nullptr };
411
413 Vector2f iconSize;
414
416 std::string label;
417
419 std::string suffix;
420
422 std::optional<Color> suffixFrameColor;
423
426 bool forceImGuiSpacing = false;
427};
428
430MRVIEWER_API void separator( float scaling, const SeparatorParams& params );
431
436MRVIEWER_API void separator( float scaling, const std::string& text = "", int issueCount = -1 );
437MRVIEWER_API void separator(
438 float scaling,
439 const std::string& text,
440 const ImVec4& color,
441 const std::string& issueCount );
442// separator line with icon and text
443// iconSize icon size without scaling
444MRVIEWER_API void separator( float scaling, const ImGuiImage& icon, const std::string& text, const Vector2f& iconSize = { 24.f, 24.f } );
445MRVIEWER_API void separator( float scaling, const std::string& iconName, const std::string& text, const Vector2f& iconSize = { 24.f, 24.f } );
446
451MRVIEWER_API void progressBar( float scaling, float fraction, const Vector2f& size = Vector2f( -1, 0 ) );
452
453// create and append items into a TabBar: see corresponding ImGui:: functions
454MRVIEWER_API bool beginTabBar( const char* str_id, ImGuiTabBarFlags flags = 0 );
455MRVIEWER_API void endTabBar();
456MRVIEWER_API bool beginTabItem( const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0 );
457MRVIEWER_API void endTabItem();
458
468MRVIEWER_API void alignTextToFramePadding( float padding );
472MRVIEWER_API void alignTextToControl( float controlHeight );
474MRVIEWER_API void alignTextToRadioButton( float scaling );
476MRVIEWER_API void alignTextToCheckBox( float scaling );
478MRVIEWER_API void alignTextToButton( float scaling );
479
483MRVIEWER_API void highlightWindowArea( float scaling, const ImVec2& min = {-1.0f, -1.0f}, const ImVec2& max = { -1.0f, -1.0f } );
484
485} // namespace UI
486
487}
488
489#include "MRUIStyle.ipp"
Definition MRImGuiImage.h:14
Definition MRUIStyle.h:319
Definition MRUIStyle.h:328
Definition MRUIStyle.h:323
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
T getDefaultStep(bool fast)
float getDefaultDragSpeed()
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:24
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 void alignTextToRadioButton(float scaling)
Specialization of alignTextToFramePadding for UI::radioButton.
MRVIEWER_API void highlightWindowArea(float scaling, const ImVec2 &min={-1.0f, -1.0f}, const ImVec2 &max={ -1.0f, -1.0f })
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={})
bool drag(const char *label, T &v, SpeedType vSpeed=detail::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=detail::getDefaultStep< E, U, T >(false), const U &stepFast=detail::getDefaultStep< E, U, T >(true))
MRVIEWER_API void endTabBar()
MRVIEWER_API void separator(float scaling, const SeparatorParams &params)
separator line with customizations
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:146
MRVIEWER_API void mouseControlHint(ImGuiMouseButton btn, const std::string &hint, float scaling)
draws hint with corresponding mouse btn icon
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:151
MRVIEWER_API bool checkbox(const char *label, bool *value)
draw gradient checkbox
MRVIEWER_API void notificationFrame(NotificationType type, const std::string &str, float scaling)
similar to ImGui::TextWrapped but also have styled background and notification type indicator
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 alignTextToButton(float scaling)
Specialization of alignTextToFramePadding for UI::button with default height.
MRVIEWER_API void alignTextToCheckBox(float scaling)
Specialization of alignTextToFramePadding for UI::checkbox.
MRVIEWER_API void alignTextToControl(float controlHeight)
MRVIEWER_API void drawPoltHorizontalAxis(float menuScaling, const PlotAxis &plotAxis)
MRVIEWER_API bool checkKey(ImGuiKey passedKey)
returns true if button is pressed in this frame, preserve its further processing in viewer keyboard e...
MRVIEWER_API void drawPoltVerticalAxis(float menuScaling, const PlotAxis &plotAxis)
MRVIEWER_API bool beginCombo(const char *label, const std::string &text="Not selected", bool showPreview=true)
draw custom content combo box
constexpr int defaultSliderFlags
Definition MRUIStyle.h:365
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 setTooltipIfHovered(const std::string &text, float scaling)
draw tooltip only if current item is hovered
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 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 void progressBar(float scaling, float fraction, const Vector2f &size=Vector2f(-1, 0))
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)
bool checkboxFlags(const char *label, T &target, T flags)
Draw a checkbox toggling one or more bits in the mask.
Definition MRUIStyle.h:209
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 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 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:321
Definition MRMesh/MRColor.h:9
parameters to customize buttonEx
Definition MRUIStyle.h:42
bool forceImguiTextColor
force use if ImGuiCol_Text for text
Definition MRUIStyle.h:58
ImGuiImage * customTexture
Definition MRUIStyle.h:52
bool border
show border or not
Definition MRUIStyle.h:60
ImGuiButtonFlags flags
imgui flags for this button
Definition MRUIStyle.h:47
bool enabled
determines if this button is enabled or disabled
Definition MRUIStyle.h:44
std::string testEngineName
if not empty, force use this string as name in TestEngine
Definition MRUIStyle.h:69
bool underlineFirstLetter
draw line under first letter of label
Definition MRUIStyle.h:63
bool forceImGuiBackground
force use imgui background if !customTexture
Definition MRUIStyle.h:55
bool enableTestEngine
Allow interacting with this button from UI::TestEngine.
Definition MRUIStyle.h:66
Definition MRUIStyle.h:73
bool textUnderImage
Definition MRUIStyle.h:78
ButtonCustomizationParams baseParams
Definition MRUIStyle.h:75
Definition MRUIStyle.h:298
std::optional< ImVec2 > cachedSize
Definition MRUIStyle.h:299
Definition MRUIStyle.h:225
bool modifierHeld
Definition MRUIStyle.h:229
bool baseValue
Definition MRUIStyle.h:227
Definition MRUIStyle.h:82
float size
Definition MRUIStyle.h:87
VarUnitToStringParams labelFormatParams
Definition MRUIStyle.h:104
float lenDash
Definition MRUIStyle.h:98
size_t textDashIndicesStep
Definition MRUIStyle.h:95
float minValue
Definition MRUIStyle.h:91
float lenDashWithText
Definition MRUIStyle.h:100
ImVec2 startAxisPoint
Definition MRUIStyle.h:84
float optimalLenth
Definition MRUIStyle.h:89
float maxValue
Definition MRUIStyle.h:93
float textPadding
Definition MRUIStyle.h:102
Definition MRUIStyle.h:254
int value
Definition MRUIStyle.h:256
int effectiveValue
Definition MRUIStyle.h:258
Parameters for drawing custom separator.
Definition MRUIStyle.h:408
std::string suffix
framed text after label (might be used for some indications)
Definition MRUIStyle.h:419
std::optional< Color > suffixFrameColor
color of background frame behind suffix (if not present default ImGuiCol_FrameBg is used)
Definition MRUIStyle.h:422
const ImGuiImage * icon
optional icon in the left part of separator
Definition MRUIStyle.h:410
Vector2f iconSize
size of icon
Definition MRUIStyle.h:413
bool forceImGuiSpacing
Definition MRUIStyle.h:426
std::string label
label at the left part of separator (drawn after icon if present)
Definition MRUIStyle.h:416
Definition MRUnits.h:269
Definition MRMesh/MRVectorTraits.h:15
static constexpr int size
Definition MRMesh/MRVectorTraits.h:19
T BaseType
Definition MRMesh/MRVectorTraits.h:18