Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
imgui_widgets.cpp File Reference
#include "imgui.h"
#include "imgui_internal.h"
#include <locale.h>
#include <ctype.h>
#include <stdint.h>
#include "imstb_textedit.h"
+ Include dependency graph for imgui_widgets.cpp:

Go to the source code of this file.

Classes

struct  ImGuiPlotArrayGetterData
 
struct  ImGuiTabBarSection
 

Namespaces

namespace  ImStb
 
namespace  ImGui
 

Macros

#define IMGUI_DEFINE_MATH_OPERATORS
 
#define STB_TEXTEDIT_MOVEWORDLEFT   STB_TEXTEDIT_MOVEWORDLEFT_IMPL
 
#define STB_TEXTEDIT_MOVEWORDRIGHT   STB_TEXTEDIT_MOVEWORDRIGHT_IMPL
 
#define STB_TEXTEDIT_K_LEFT   0x200000
 
#define STB_TEXTEDIT_K_RIGHT   0x200001
 
#define STB_TEXTEDIT_K_UP   0x200002
 
#define STB_TEXTEDIT_K_DOWN   0x200003
 
#define STB_TEXTEDIT_K_LINESTART   0x200004
 
#define STB_TEXTEDIT_K_LINEEND   0x200005
 
#define STB_TEXTEDIT_K_TEXTSTART   0x200006
 
#define STB_TEXTEDIT_K_TEXTEND   0x200007
 
#define STB_TEXTEDIT_K_DELETE   0x200008
 
#define STB_TEXTEDIT_K_BACKSPACE   0x200009
 
#define STB_TEXTEDIT_K_UNDO   0x20000A
 
#define STB_TEXTEDIT_K_REDO   0x20000B
 
#define STB_TEXTEDIT_K_WORDLEFT   0x20000C
 
#define STB_TEXTEDIT_K_WORDRIGHT   0x20000D
 
#define STB_TEXTEDIT_K_PGUP   0x20000E
 
#define STB_TEXTEDIT_K_PGDOWN   0x20000F
 
#define STB_TEXTEDIT_K_SHIFT   0x400000
 
#define STB_TEXTEDIT_IMPLEMENTATION
 

Functions

static bool InputTextFilterCharacter (unsigned int *p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void *user_data, ImGuiInputSource input_source)
 
static int InputTextCalcTextLenAndLineCount (const char *text_begin, const char **out_text_end)
 
static ImVec2 InputTextCalcTextSizeW (const ImWchar *text_begin, const ImWchar *text_end, const ImWchar **remaining=NULL, ImVec2 *out_offset=NULL, bool stop_on_new_line=false)
 
static int IMGUI_CDECL ShrinkWidthItemComparer (const void *lhs, const void *rhs)
 
static float CalcMaxPopupHeightFromItemCount (int items_count)
 
static bool Items_ArrayGetter (void *data, int idx, const char **out_text)
 
static bool Items_SingleStringGetter (void *data, int idx, const char **out_text)
 
 IM_STATIC_ASSERT (IM_ARRAYSIZE(GDataTypeInfo)==ImGuiDataType_COUNT)
 
static const char * PatchFormatStringFloatToInt (const char *fmt)
 
template<typename T >
static int DataTypeCompareT (const T *lhs, const T *rhs)
 
template<typename T >
static bool DataTypeClampT (T *v, const T *v_min, const T *v_max)
 
static float GetMinimumStepAtDecimalPrecision (int decimal_precision)
 
template<typename TYPE >
static const char * ImAtoi (const char *src, TYPE *output)
 
static void SanitizeFormatString (const char *fmt, char *fmt_out, size_t fmt_out_size)
 
const char * ImParseFormatFindStart (const char *fmt)
 
const char * ImParseFormatFindEnd (const char *fmt)
 
const char * ImParseFormatTrimDecorations (const char *fmt, char *buf, size_t buf_size)
 
int ImParseFormatPrecision (const char *fmt, int default_precision)
 
static int ImStb::STB_TEXTEDIT_STRINGLEN (const ImGuiInputTextState *obj)
 
static ImWchar ImStb::STB_TEXTEDIT_GETCHAR (const ImGuiInputTextState *obj, int idx)
 
static float ImStb::STB_TEXTEDIT_GETWIDTH (ImGuiInputTextState *obj, int line_start_idx, int char_idx)
 
static int ImStb::STB_TEXTEDIT_KEYTOTEXT (int key)
 
static void ImStb::STB_TEXTEDIT_LAYOUTROW (StbTexteditRow *r, ImGuiInputTextState *obj, int line_start_idx)
 
static bool ImStb::is_separator (unsigned int c)
 
static int ImStb::is_word_boundary_from_right (ImGuiInputTextState *obj, int idx)
 
static int ImStb::STB_TEXTEDIT_MOVEWORDLEFT_IMPL (ImGuiInputTextState *obj, int idx)
 
static int ImStb::STB_TEXTEDIT_MOVEWORDRIGHT_IMPL (ImGuiInputTextState *obj, int idx)
 
static void ImStb::STB_TEXTEDIT_DELETECHARS (ImGuiInputTextState *obj, int pos, int n)
 
static bool ImStb::STB_TEXTEDIT_INSERTCHARS (ImGuiInputTextState *obj, int pos, const ImWchar *new_text, int new_text_len)
 
static void ImStb::stb_textedit_replace (ImGuiInputTextState *str, STB_TexteditState *state, const STB_TEXTEDIT_CHARTYPE *text, int text_len)
 
static void RenderArrowsForVerticalBar (ImDrawList *draw_list, ImVec2 pos, ImVec2 half_sz, float bar_w, float alpha)
 
static float Plot_ArrayGetter (void *data, int idx)
 
static void ImGui::TabBarLayout (ImGuiTabBar *tab_bar)
 
static ImU32 ImGui::TabBarCalcTabID (ImGuiTabBar *tab_bar, const char *label)
 
static float ImGui::TabBarCalcMaxTabWidth ()
 
static float ImGui::TabBarScrollClamp (ImGuiTabBar *tab_bar, float scrolling)
 
static void ImGui::TabBarScrollToTab (ImGuiTabBar *tab_bar, ImGuiID tab_id, ImGuiTabBarSection *sections)
 
static ImGuiTabItemImGui::TabBarScrollingButtons (ImGuiTabBar *tab_bar)
 
static ImGuiTabItemImGui::TabBarTabListPopupButton (ImGuiTabBar *tab_bar)
 
static int TabItemGetSectionIdx (const ImGuiTabItem *tab)
 
static int IMGUI_CDECL TabItemComparerBySection (const void *lhs, const void *rhs)
 
static int IMGUI_CDECL TabItemComparerByBeginOrder (const void *lhs, const void *rhs)
 
static ImGuiTabBarGetTabBarFromTabBarRef (const ImGuiPtrOrIndex &ref)
 
static ImGuiPtrOrIndex GetTabBarRefFromTabBar (ImGuiTabBar *tab_bar)
 

Variables

static const float DRAGDROP_HOLD_TO_OPEN_TIMER = 0.70f
 
static const float DRAG_MOUSE_THRESHOLD_FACTOR = 0.50f
 
static const signed char IM_S8_MIN = -128
 
static const signed char IM_S8_MAX = 127
 
static const unsigned char IM_U8_MIN = 0
 
static const unsigned char IM_U8_MAX = 0xFF
 
static const signed short IM_S16_MIN = -32768
 
static const signed short IM_S16_MAX = 32767
 
static const unsigned short IM_U16_MIN = 0
 
static const unsigned short IM_U16_MAX = 0xFFFF
 
static const ImS32 IM_S32_MIN = INT_MIN
 
static const ImS32 IM_S32_MAX = INT_MAX
 
static const ImU32 IM_U32_MIN = 0
 
static const ImU32 IM_U32_MAX = UINT_MAX
 
static const ImS64 IM_S64_MIN = -9223372036854775807LL - 1
 
static const ImS64 IM_S64_MAX = 9223372036854775807LL
 
static const ImU64 IM_U64_MIN = 0
 
static const ImU64 IM_U64_MAX = (2ULL * 9223372036854775807LL + 1)
 
static const ImGuiDataTypeInfo GDataTypeInfo []
 
static ImWchar ImStb::STB_TEXTEDIT_NEWLINE = '\n'
 

Macro Definition Documentation

◆ IMGUI_DEFINE_MATH_OPERATORS

#define IMGUI_DEFINE_MATH_OPERATORS

◆ STB_TEXTEDIT_IMPLEMENTATION

#define STB_TEXTEDIT_IMPLEMENTATION

◆ STB_TEXTEDIT_K_BACKSPACE

#define STB_TEXTEDIT_K_BACKSPACE   0x200009

◆ STB_TEXTEDIT_K_DELETE

#define STB_TEXTEDIT_K_DELETE   0x200008

◆ STB_TEXTEDIT_K_DOWN

#define STB_TEXTEDIT_K_DOWN   0x200003

◆ STB_TEXTEDIT_K_LEFT

#define STB_TEXTEDIT_K_LEFT   0x200000

◆ STB_TEXTEDIT_K_LINEEND

#define STB_TEXTEDIT_K_LINEEND   0x200005

◆ STB_TEXTEDIT_K_LINESTART

#define STB_TEXTEDIT_K_LINESTART   0x200004

◆ STB_TEXTEDIT_K_PGDOWN

#define STB_TEXTEDIT_K_PGDOWN   0x20000F

◆ STB_TEXTEDIT_K_PGUP

#define STB_TEXTEDIT_K_PGUP   0x20000E

◆ STB_TEXTEDIT_K_REDO

#define STB_TEXTEDIT_K_REDO   0x20000B

◆ STB_TEXTEDIT_K_RIGHT

#define STB_TEXTEDIT_K_RIGHT   0x200001

◆ STB_TEXTEDIT_K_SHIFT

#define STB_TEXTEDIT_K_SHIFT   0x400000

◆ STB_TEXTEDIT_K_TEXTEND

#define STB_TEXTEDIT_K_TEXTEND   0x200007

◆ STB_TEXTEDIT_K_TEXTSTART

#define STB_TEXTEDIT_K_TEXTSTART   0x200006

◆ STB_TEXTEDIT_K_UNDO

#define STB_TEXTEDIT_K_UNDO   0x20000A

◆ STB_TEXTEDIT_K_UP

#define STB_TEXTEDIT_K_UP   0x200002

◆ STB_TEXTEDIT_K_WORDLEFT

#define STB_TEXTEDIT_K_WORDLEFT   0x20000C

◆ STB_TEXTEDIT_K_WORDRIGHT

#define STB_TEXTEDIT_K_WORDRIGHT   0x20000D

◆ STB_TEXTEDIT_MOVEWORDLEFT

#define STB_TEXTEDIT_MOVEWORDLEFT   STB_TEXTEDIT_MOVEWORDLEFT_IMPL

◆ STB_TEXTEDIT_MOVEWORDRIGHT

#define STB_TEXTEDIT_MOVEWORDRIGHT   STB_TEXTEDIT_MOVEWORDRIGHT_IMPL

Function Documentation

◆ CalcMaxPopupHeightFromItemCount()

static float CalcMaxPopupHeightFromItemCount ( int  items_count)
static
1548{
1549 ImGuiContext& g = *GImGui;
1550 if (items_count <= 0)
1551 return FLT_MAX;
1552 return (g.FontSize + g.Style.ItemSpacing.y) * items_count - g.Style.ItemSpacing.y + (g.Style.WindowPadding.y * 2);
1553}
ImGuiContext * GImGui
Definition imgui.cpp:960
Definition imgui_internal.h:1351
ImGuiStyle Style
Definition imgui_internal.h:1355
float FontSize
Definition imgui_internal.h:1357
ImVec2 WindowPadding
Definition imgui.h:1723
ImVec2 ItemSpacing
Definition imgui.h:1736
float y
Definition imgui.h:246

References ImGuiContext::FontSize, GImGui, ImGuiStyle::ItemSpacing, ImGuiContext::Style, ImGuiStyle::WindowPadding, and ImVec2::y.

Referenced by ImGui::BeginCombo().

+ Here is the caller graph for this function:

◆ DataTypeClampT()

template<typename T >
static bool DataTypeClampT ( T *  v,
const T *  v_min,
const T *  v_max 
)
static
2043{
2044 // Clamp, both sides are optional, return true if modified
2045 if (v_min && *v < *v_min) { *v = *v_min; return true; }
2046 if (v_max && *v > *v_max) { *v = *v_max; return true; }
2047 return false;
2048}

◆ DataTypeCompareT()

template<typename T >
static int DataTypeCompareT ( const T *  lhs,
const T *  rhs 
)
static
2015{
2016 if (*lhs < *rhs) return -1;
2017 if (*lhs > *rhs) return +1;
2018 return 0;
2019}

◆ GetMinimumStepAtDecimalPrecision()

static float GetMinimumStepAtDecimalPrecision ( int  decimal_precision)
static
2071{
2072 static const float min_steps[10] = { 1.0f, 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f };
2073 if (decimal_precision < 0)
2074 return FLT_MIN;
2075 return (decimal_precision < IM_ARRAYSIZE(min_steps)) ? min_steps[decimal_precision] : ImPow(10.0f, (float)-decimal_precision);
2076}
#define IM_ARRAYSIZE(_ARR)
Definition imgui.h:83
static float ImPow(float x, float y)
Definition imgui_internal.h:391

References IM_ARRAYSIZE, and ImPow().

+ Here is the call graph for this function:

◆ GetTabBarFromTabBarRef()

static ImGuiTabBar * GetTabBarFromTabBarRef ( const ImGuiPtrOrIndex ref)
static
7002{
7003 ImGuiContext& g = *GImGui;
7004 return ref.Ptr ? (ImGuiTabBar*)ref.Ptr : g.TabBars.GetByIndex(ref.Index);
7005}
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:33
void * Ptr
Definition imgui_internal.h:1142
Definition imgui_internal.h:1972

References ImPool< T >::GetByIndex(), GImGui, ImGuiPtrOrIndex::Index, ImGuiPtrOrIndex::Ptr, and ImGuiContext::TabBars.

Referenced by ImGui::EndTabBar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetTabBarRefFromTabBar()

static ImGuiPtrOrIndex GetTabBarRefFromTabBar ( ImGuiTabBar tab_bar)
static
7008{
7009 ImGuiContext& g = *GImGui;
7010 if (g.TabBars.Contains(tab_bar))
7011 return ImGuiPtrOrIndex(g.TabBars.GetIndex(tab_bar));
7012 return ImGuiPtrOrIndex(tab_bar);
7013}
ImPool< ImGuiTabBar > TabBars
Definition imgui_internal.h:1528
Definition imgui_internal.h:1141
bool Contains(const T *p) const
Definition imgui_internal.h:619
ImPoolIdx GetIndex(const T *p) const
Definition imgui_internal.h:617

References ImPool< T >::Contains(), ImPool< T >::GetIndex(), GImGui, and ImGuiContext::TabBars.

Referenced by ImGui::BeginTabBarEx().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IM_STATIC_ASSERT()

IM_STATIC_ASSERT ( IM_ARRAYSIZE(GDataTypeInfo = =ImGuiDataType_COUNT)

◆ ImAtoi()

template<typename TYPE >
static const char * ImAtoi ( const char *  src,
TYPE *  output 
)
static
2080{
2081 int negative = 0;
2082 if (*src == '-') { negative = 1; src++; }
2083 if (*src == '+') { src++; }
2084 TYPE v = 0;
2085 while (*src >= '0' && *src <= '9')
2086 v = (v * 10) + (*src++ - '0');
2087 *output = negative ? -v : v;
2088 return src;
2089}

◆ ImParseFormatFindEnd()

const char * ImParseFormatFindEnd ( const char *  fmt)
3220{
3221 // Printf/scanf types modifiers: I/L/h/j/l/t/w/z. Other uppercase letters qualify as types aka end of the format.
3222 if (fmt[0] != '%')
3223 return fmt;
3224 const unsigned int ignored_uppercase_mask = (1 << ('I'-'A')) | (1 << ('L'-'A'));
3225 const unsigned int ignored_lowercase_mask = (1 << ('h'-'a')) | (1 << ('j'-'a')) | (1 << ('l'-'a')) | (1 << ('t'-'a')) | (1 << ('w'-'a')) | (1 << ('z'-'a'));
3226 for (char c; (c = *fmt) != 0; fmt++)
3227 {
3228 if (c >= 'A' && c <= 'Z' && ((1 << (c - 'A')) & ignored_uppercase_mask) == 0)
3229 return fmt + 1;
3230 if (c >= 'a' && c <= 'z' && ((1 << (c - 'a')) & ignored_lowercase_mask) == 0)
3231 return fmt + 1;
3232 }
3233 return fmt;
3234}

Referenced by ImParseFormatTrimDecorations(), PatchFormatStringFloatToInt(), and SanitizeFormatString().

+ Here is the caller graph for this function:

◆ ImParseFormatFindStart()

const char * ImParseFormatFindStart ( const char *  fmt)
3207{
3208 while (char c = fmt[0])
3209 {
3210 if (c == '%' && fmt[1] != '%')
3211 return fmt;
3212 else if (c == '%')
3213 fmt++;
3214 fmt++;
3215 }
3216 return fmt;
3217}

Referenced by ImParseFormatPrecision(), ImParseFormatTrimDecorations(), and PatchFormatStringFloatToInt().

+ Here is the caller graph for this function:

◆ ImParseFormatPrecision()

int ImParseFormatPrecision ( const char *  fmt,
int  default_precision 
)
3256{
3257 fmt = ImParseFormatFindStart(fmt);
3258 if (fmt[0] != '%')
3259 return default_precision;
3260 fmt++;
3261 while (*fmt >= '0' && *fmt <= '9')
3262 fmt++;
3263 int precision = INT_MAX;
3264 if (*fmt == '.')
3265 {
3266 fmt = ImAtoi<int>(fmt + 1, &precision);
3267 if (precision < 0 || precision > 99)
3268 precision = default_precision;
3269 }
3270 if (*fmt == 'e' || *fmt == 'E') // Maximum precision with scientific notation
3271 precision = -1;
3272 if ((*fmt == 'g' || *fmt == 'G') && precision == INT_MAX)
3273 precision = -1;
3274 return (precision == INT_MAX) ? default_precision : precision;
3275}
const char * ImParseFormatFindStart(const char *fmt)
Definition imgui_widgets.cpp:3206

References ImParseFormatFindStart().

+ Here is the call graph for this function:

◆ ImParseFormatTrimDecorations()

const char * ImParseFormatTrimDecorations ( const char *  fmt,
char *  buf,
size_t  buf_size 
)
3242{
3243 const char* fmt_start = ImParseFormatFindStart(fmt);
3244 if (fmt_start[0] != '%')
3245 return fmt;
3246 const char* fmt_end = ImParseFormatFindEnd(fmt_start);
3247 if (fmt_end[0] == 0) // If we only have leading decoration, we don't need to copy the data.
3248 return fmt_start;
3249 ImStrncpy(buf, fmt_start, ImMin((size_t)(fmt_end - fmt_start) + 1, buf_size));
3250 return buf;
3251}
void ImStrncpy(char *dst, const char *src, size_t count)
Definition imgui.cpp:1314
static T ImMin(T lhs, T rhs)
Definition imgui_internal.h:409
const char * ImParseFormatFindEnd(const char *fmt)
Definition imgui_widgets.cpp:3219

References ImMin(), ImParseFormatFindEnd(), ImParseFormatFindStart(), and ImStrncpy().

Referenced by ImGui::TempInputScalar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InputTextCalcTextLenAndLineCount()

static int InputTextCalcTextLenAndLineCount ( const char *  text_begin,
const char **  out_text_end 
)
static
3524{
3525 int line_count = 0;
3526 const char* s = text_begin;
3527 while (char c = *s++) // We are only matching for \n so we can ignore UTF-8 decoding
3528 if (c == '\n')
3529 line_count++;
3530 s--;
3531 if (s[0] != '\n' && s[0] != '\r')
3532 line_count++;
3533 *out_text_end = s;
3534 return line_count;
3535}

Referenced by ImGui::InputTextEx().

+ Here is the caller graph for this function:

◆ InputTextCalcTextSizeW()

static ImVec2 InputTextCalcTextSizeW ( const ImWchar text_begin,
const ImWchar text_end,
const ImWchar **  remaining = NULL,
ImVec2 out_offset = NULL,
bool  stop_on_new_line = false 
)
static
3538{
3539 ImGuiContext& g = *GImGui;
3540 ImFont* font = g.Font;
3541 const float line_height = g.FontSize;
3542 const float scale = line_height / font->FontSize;
3543
3544 ImVec2 text_size = ImVec2(0, 0);
3545 float line_width = 0.0f;
3546
3547 const ImWchar* s = text_begin;
3548 while (s < text_end)
3549 {
3550 unsigned int c = (unsigned int)(*s++);
3551 if (c == '\n')
3552 {
3553 text_size.x = ImMax(text_size.x, line_width);
3554 text_size.y += line_height;
3555 line_width = 0.0f;
3556 if (stop_on_new_line)
3557 break;
3558 continue;
3559 }
3560 if (c == '\r')
3561 continue;
3562
3563 const float char_width = font->GetCharAdvance((ImWchar)c) * scale;
3564 line_width += char_width;
3565 }
3566
3567 if (text_size.x < line_width)
3568 text_size.x = line_width;
3569
3570 if (out_offset)
3571 *out_offset = ImVec2(line_width, text_size.y + line_height); // offset allow for the possibility of sitting after a trailing \n
3572
3573 if (line_width > 0 || text_size.y == 0.0f) // whereas size.y will ignore the trailing \n
3574 text_size.y += line_height;
3575
3576 if (remaining)
3577 *remaining = s;
3578
3579 return text_size;
3580}
int scale(const int val)
Definition WipeTowerDialog.cpp:14
ImWchar16 ImWchar
Definition imgui.h:220
static T ImMax(T lhs, T rhs)
Definition imgui_internal.h:410
Definition imgui.h:2690
float FontSize
Definition imgui.h:2694
float GetCharAdvance(ImWchar c) const
Definition imgui.h:2718
ImFont * Font
Definition imgui_internal.h:1356
Definition imgui.h:245
float x
Definition imgui.h:246

References ImGuiContext::Font, ImFont::FontSize, ImGuiContext::FontSize, ImFont::GetCharAdvance(), GImGui, ImMax(), scale(), ImVec2::x, and ImVec2::y.

Referenced by ImGui::InputTextEx(), and ImStb::STB_TEXTEDIT_LAYOUTROW().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InputTextFilterCharacter()

static bool InputTextFilterCharacter ( unsigned int *  p_char,
ImGuiInputTextFlags  flags,
ImGuiInputTextCallback  callback,
void user_data,
ImGuiInputSource  input_source 
)
static
3773{
3774 IM_ASSERT(input_source == ImGuiInputSource_Keyboard || input_source == ImGuiInputSource_Clipboard);
3775 unsigned int c = *p_char;
3776
3777 // Filter non-printable (NB: isprint is unreliable! see #2467)
3778 if (c < 0x20)
3779 {
3780 bool pass = false;
3781 pass |= (c == '\n' && (flags & ImGuiInputTextFlags_Multiline));
3782 pass |= (c == '\t' && (flags & ImGuiInputTextFlags_AllowTabInput));
3783 if (!pass)
3784 return false;
3785 }
3786
3787 if (input_source != ImGuiInputSource_Clipboard)
3788 {
3789 // We ignore Ascii representation of delete (emitted from Backspace on OSX, see #2578, #2817)
3790 if (c == 127)
3791 return false;
3792
3793 // Filter private Unicode range. GLFW on OSX seems to send private characters for special keys like arrow keys (FIXME)
3794 if (c >= 0xE000 && c <= 0xF8FF)
3795 return false;
3796 }
3797
3798 // Filter Unicode ranges we are not handling in this build
3800 return false;
3801
3802 // Generic named filters
3804 {
3805 // The libc allows overriding locale, with e.g. 'setlocale(LC_NUMERIC, "de_DE.UTF-8");' which affect the output/input of printf/scanf.
3806 // The standard mandate that programs starts in the "C" locale where the decimal point is '.'.
3807 // We don't really intend to provide widespread support for it, but out of empathy for people stuck with using odd API, we support the bare minimum aka overriding the decimal point.
3808 // Change the default decimal_point with:
3809 ImGui::GetCurrentContext()->PlatformLocaleDecimalPoint = *localeconv()->decimal_point;
3810 ImGuiContext& g = *GImGui;
3811 const unsigned c_decimal_point = (unsigned int)g.PlatformLocaleDecimalPoint;
3812
3813 // Allow 0-9 . - + * /
3815 if (!(c >= '0' && c <= '9') && (c != c_decimal_point) && (c != '-') && (c != '+') && (c != '*') && (c != '/'))
3816 return false;
3817
3818 // Allow 0-9 . - + * / e E
3820 if (!(c >= '0' && c <= '9') && (c != c_decimal_point) && (c != '-') && (c != '+') && (c != '*') && (c != '/') && (c != 'e') && (c != 'E'))
3821 return false;
3822
3823 // Allow 0-9 a-F A-F
3825 if (!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f') && !(c >= 'A' && c <= 'F'))
3826 return false;
3827
3828 // Turn a-z into A-Z
3830 if (c >= 'a' && c <= 'z')
3831 *p_char = (c += (unsigned int)('A' - 'a'));
3832
3834 if (ImCharIsBlankW(c))
3835 return false;
3836 }
3837
3838 // Custom callback filter
3840 {
3841 ImGuiInputTextCallbackData callback_data;
3842 memset(&callback_data, 0, sizeof(ImGuiInputTextCallbackData));
3844 callback_data.EventChar = (ImWchar)c;
3845 callback_data.Flags = flags;
3846 callback_data.UserData = user_data;
3847 if (callback(&callback_data) != 0)
3848 return false;
3849 *p_char = callback_data.EventChar;
3850 if (!callback_data.EventChar)
3851 return false;
3852 }
3853
3854 return true;
3855}
@ ImGuiInputTextFlags_CharsNoBlank
Definition imgui.h:959
@ ImGuiInputTextFlags_CallbackCharFilter
Definition imgui.h:965
@ ImGuiInputTextFlags_AllowTabInput
Definition imgui.h:966
@ ImGuiInputTextFlags_CharsHexadecimal
Definition imgui.h:957
@ ImGuiInputTextFlags_CharsScientific
Definition imgui.h:973
@ ImGuiInputTextFlags_CharsDecimal
Definition imgui.h:956
@ ImGuiInputTextFlags_CharsUppercase
Definition imgui.h:958
#define IM_ASSERT(_EXPR)
Definition imgui.h:81
#define IM_UNICODE_CODEPOINT_MAX
Definition imgui.h:2010
@ ImGuiInputTextFlags_Multiline
Definition imgui_internal.h:770
static bool ImCharIsBlankW(unsigned int c)
Definition imgui_internal.h:322
@ ImGuiInputSource_Clipboard
Definition imgui_internal.h:882
@ ImGuiInputSource_Keyboard
Definition imgui_internal.h:879
IMGUI_API ImGuiContext * GetCurrentContext()
Definition imgui.cpp:3361
char PlatformLocaleDecimalPoint
Definition imgui_internal.h:1556
Definition imgui.h:1917
ImGuiInputTextFlags EventFlag
Definition imgui.h:1918
ImWchar EventChar
Definition imgui.h:1925
ImGuiInputTextFlags Flags
Definition imgui.h:1919
void * UserData
Definition imgui.h:1920

References ImGuiInputTextCallbackData::EventChar, ImGuiInputTextCallbackData::EventFlag, ImGuiInputTextCallbackData::Flags, ImGui::GetCurrentContext(), GImGui, IM_ASSERT, IM_UNICODE_CODEPOINT_MAX, ImCharIsBlankW(), ImGuiInputSource_Clipboard, ImGuiInputSource_Keyboard, ImGuiInputTextFlags_AllowTabInput, ImGuiInputTextFlags_CallbackCharFilter, ImGuiInputTextFlags_CharsDecimal, ImGuiInputTextFlags_CharsHexadecimal, ImGuiInputTextFlags_CharsNoBlank, ImGuiInputTextFlags_CharsScientific, ImGuiInputTextFlags_CharsUppercase, ImGuiInputTextFlags_Multiline, ImGuiContext::PlatformLocaleDecimalPoint, and ImGuiInputTextCallbackData::UserData.

Referenced by ImGui::InputTextEx().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Items_ArrayGetter()

static bool Items_ArrayGetter ( void data,
int  idx,
const char **  out_text 
)
static
1681{
1682 const char* const* items = (const char* const*)data;
1683 if (out_text)
1684 *out_text = items[idx];
1685 return true;
1686}

Referenced by ImGui::Combo(), and ImGui::ListBox().

+ Here is the caller graph for this function:

◆ Items_SingleStringGetter()

static bool Items_SingleStringGetter ( void data,
int  idx,
const char **  out_text 
)
static
1690{
1691 // FIXME-OPT: we could pre-compute the indices to fasten this. But only 1 active combo means the waste is limited.
1692 const char* items_separated_by_zeros = (const char*)data;
1693 int items_count = 0;
1694 const char* p = items_separated_by_zeros;
1695 while (*p)
1696 {
1697 if (idx == items_count)
1698 break;
1699 p += strlen(p) + 1;
1700 items_count++;
1701 }
1702 if (!*p)
1703 return false;
1704 if (out_text)
1705 *out_text = p;
1706 return true;
1707}

Referenced by ImGui::Combo().

+ Here is the caller graph for this function:

◆ PatchFormatStringFloatToInt()

static const char * PatchFormatStringFloatToInt ( const char *  fmt)
static
1811{
1812 if (fmt[0] == '%' && fmt[1] == '.' && fmt[2] == '0' && fmt[3] == 'f' && fmt[4] == 0) // Fast legacy path for "%.0f" which is expected to be the most common case.
1813 return "%d";
1814 const char* fmt_start = ImParseFormatFindStart(fmt); // Find % (if any, and ignore %%)
1815 const char* fmt_end = ImParseFormatFindEnd(fmt_start); // Find end of format specifier, which itself is an exercise of confidence/recklessness (because snprintf is dependent on libc or user).
1816 if (fmt_end > fmt_start && fmt_end[-1] == 'f')
1817 {
1818#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
1819 if (fmt_start == fmt && fmt_end[0] == 0)
1820 return "%d";
1821 ImGuiContext& g = *GImGui;
1822 ImFormatString(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), "%.*s%%d%s", (int)(fmt_start - fmt), fmt, fmt_end); // Honor leading and trailing decorations, but lose alignment/precision.
1823 return g.TempBuffer;
1824#else
1825 IM_ASSERT(0 && "DragInt(): Invalid format string!"); // Old versions used a default parameter of "%.0f", please replace with e.g. "%d"
1826#endif
1827 }
1828 return fmt;
1829}
int ImFormatString(char *buf, size_t buf_size, const char *fmt,...)
Definition imgui.cpp:1435
char TempBuffer[1024 *3+1]
Definition imgui_internal.h:1594

References GImGui, IM_ARRAYSIZE, IM_ASSERT, ImFormatString(), ImParseFormatFindEnd(), ImParseFormatFindStart(), and ImGuiContext::TempBuffer.

Referenced by ImGui::DragScalar(), ImGui::SliderScalar(), and ImGui::VSliderScalar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Plot_ArrayGetter()

static float Plot_ArrayGetter ( void data,
int  idx 
)
static
6435{
6437 const float v = *(const float*)(const void*)((const unsigned char*)plot_data->Values + (size_t)idx * plot_data->Stride);
6438 return v;
6439}
Definition imgui_widgets.cpp:6427
const float * Values
Definition imgui_widgets.cpp:6428
int Stride
Definition imgui_widgets.cpp:6429

References ImGuiPlotArrayGetterData::Stride, and ImGuiPlotArrayGetterData::Values.

Referenced by ImGui::PlotHistogram(), and ImGui::PlotLines().

+ Here is the caller graph for this function:

◆ RenderArrowsForVerticalBar()

static void RenderArrowsForVerticalBar ( ImDrawList draw_list,
ImVec2  pos,
ImVec2  half_sz,
float  bar_w,
float  alpha 
)
static
4943{
4944 ImU32 alpha8 = IM_F32_TO_INT8_SAT(alpha);
4945 ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x + 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Right, IM_COL32(0,0,0,alpha8));
4946 ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x, pos.y), half_sz, ImGuiDir_Right, IM_COL32(255,255,255,alpha8));
4947 ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x - 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Left, IM_COL32(0,0,0,alpha8));
4948 ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x, pos.y), half_sz, ImGuiDir_Left, IM_COL32(255,255,255,alpha8));
4949}
unsigned int ImU32
Definition imgui.h:229
#define IM_COL32(R, G, B, A)
Definition imgui.h:2177
@ ImGuiDir_Right
Definition imgui.h:1297
@ ImGuiDir_Left
Definition imgui.h:1296
#define IM_F32_TO_INT8_SAT(_VAL)
Definition imgui_internal.h:231
IMGUI_API void RenderArrowPointingAt(ImDrawList *draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col)
Definition imgui_draw.cpp:3811
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:14

References IM_COL32, IM_F32_TO_INT8_SAT, ImGuiDir_Left, ImGuiDir_Right, ImGui::RenderArrowPointingAt(), ImVec2::x, and ImVec2::y.

Referenced by ImGui::ColorPicker4().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SanitizeFormatString()

static void SanitizeFormatString ( const char *  fmt,
char *  fmt_out,
size_t  fmt_out_size 
)
static
2095{
2096 IM_UNUSED(fmt_out_size);
2097 const char* fmt_end = ImParseFormatFindEnd(fmt);
2098 IM_ASSERT((size_t)(fmt_end - fmt + 1) < fmt_out_size); // Format is too long, let us know if this happens to you!
2099 while (fmt < fmt_end)
2100 {
2101 char c = *(fmt++);
2102 if (c != '\'' && c != '$' && c != '_') // Custom flags provided by stb_sprintf.h. POSIX 2008 also supports '.
2103 *(fmt_out++) = c;
2104 }
2105 *fmt_out = 0; // Zero-terminate
2106}
#define IM_UNUSED(_VAR)
Definition imgui.h:84

References IM_ASSERT, IM_UNUSED, and ImParseFormatFindEnd().

+ Here is the call graph for this function:

◆ ShrinkWidthItemComparer()

static int IMGUI_CDECL ShrinkWidthItemComparer ( const void lhs,
const void rhs 
)
static
1491{
1492 const ImGuiShrinkWidthItem* a = (const ImGuiShrinkWidthItem*)lhs;
1493 const ImGuiShrinkWidthItem* b = (const ImGuiShrinkWidthItem*)rhs;
1494 if (int d = (int)(b->Width - a->Width))
1495 return d;
1496 return (b->Index - a->Index);
1497}
Definition imgui_internal.h:1135

Referenced by ImGui::ShrinkWidths().

+ Here is the caller graph for this function:

◆ TabItemComparerByBeginOrder()

static int IMGUI_CDECL TabItemComparerByBeginOrder ( const void lhs,
const void rhs 
)
static
6995{
6996 const ImGuiTabItem* a = (const ImGuiTabItem*)lhs;
6997 const ImGuiTabItem* b = (const ImGuiTabItem*)rhs;
6998 return (int)(a->BeginOrder - b->BeginOrder);
6999}
Definition imgui_internal.h:1954

Referenced by ImGui::BeginTabBarEx().

+ Here is the caller graph for this function:

◆ TabItemComparerBySection()

static int IMGUI_CDECL TabItemComparerBySection ( const void lhs,
const void rhs 
)
static
6984{
6985 const ImGuiTabItem* a = (const ImGuiTabItem*)lhs;
6986 const ImGuiTabItem* b = (const ImGuiTabItem*)rhs;
6987 const int a_section = TabItemGetSectionIdx(a);
6988 const int b_section = TabItemGetSectionIdx(b);
6989 if (a_section != b_section)
6990 return a_section - b_section;
6991 return (int)(a->IndexDuringLayout - b->IndexDuringLayout);
6992}
static int TabItemGetSectionIdx(const ImGuiTabItem *tab)
Definition imgui_widgets.cpp:6978

References TabItemGetSectionIdx().

Referenced by ImGui::TabBarLayout().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TabItemGetSectionIdx()

static int TabItemGetSectionIdx ( const ImGuiTabItem tab)
inlinestatic
6979{
6980 return (tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
6981}
@ ImGuiTabItemFlags_Trailing
Definition imgui.h:1080
@ ImGuiTabItemFlags_Leading
Definition imgui.h:1079
ImGuiTabItemFlags Flags
Definition imgui_internal.h:1956

References ImGuiTabItem::Flags, ImGuiTabItemFlags_Leading, and ImGuiTabItemFlags_Trailing.

Referenced by ImGui::TabBarLayout(), and TabItemComparerBySection().

+ Here is the caller graph for this function:

Variable Documentation

◆ DRAG_MOUSE_THRESHOLD_FACTOR

const float DRAG_MOUSE_THRESHOLD_FACTOR = 0.50f
static

Referenced by ImGui::DragScalar().

◆ DRAGDROP_HOLD_TO_OPEN_TIMER

const float DRAGDROP_HOLD_TO_OPEN_TIMER = 0.70f
static

Referenced by ImGui::ButtonBehavior().

◆ GDataTypeInfo

const ImGuiDataTypeInfo GDataTypeInfo[]
static
Initial value:
=
{
{ sizeof(char), "S8", "%d", "%d" },
{ sizeof(unsigned char), "U8", "%u", "%u" },
{ sizeof(short), "S16", "%d", "%d" },
{ sizeof(unsigned short), "U16", "%u", "%u" },
{ sizeof(int), "S32", "%d", "%d" },
{ sizeof(unsigned int), "U32", "%u", "%u" },
{ sizeof(ImS64), "S64", "%lld", "%lld" },
{ sizeof(ImU64), "U64", "%llu", "%llu" },
{ sizeof(float), "float", "%.3f","%f" },
{ sizeof(double), "double","%f", "%lf" },
}
unsigned long long ImU64
Definition imgui.h:239
signed long long ImS64
Definition imgui.h:238

Referenced by ImGui::DataTypeGetInfo(), ImGui::DragScalarN(), ImGui::InputScalarN(), and ImGui::SliderScalarN().

◆ IM_S16_MAX

const signed short IM_S16_MAX = 32767
static

◆ IM_S16_MIN

const signed short IM_S16_MIN = -32768
static

◆ IM_S32_MAX

const ImS32 IM_S32_MAX = INT_MAX
static

◆ IM_S32_MIN

const ImS32 IM_S32_MIN = INT_MIN
static

◆ IM_S64_MAX

const ImS64 IM_S64_MAX = 9223372036854775807LL
static

◆ IM_S64_MIN

const ImS64 IM_S64_MIN = -9223372036854775807LL - 1
static

◆ IM_S8_MAX

const signed char IM_S8_MAX = 127
static

◆ IM_S8_MIN

const signed char IM_S8_MIN = -128
static

◆ IM_U16_MAX

const unsigned short IM_U16_MAX = 0xFFFF
static

◆ IM_U16_MIN

const unsigned short IM_U16_MIN = 0
static

◆ IM_U32_MAX

const ImU32 IM_U32_MAX = UINT_MAX
static

◆ IM_U32_MIN

const ImU32 IM_U32_MIN = 0
static

◆ IM_U64_MAX

const ImU64 IM_U64_MAX = (2ULL * 9223372036854775807LL + 1)
static

◆ IM_U64_MIN

const ImU64 IM_U64_MIN = 0
static

◆ IM_U8_MAX

const unsigned char IM_U8_MAX = 0xFF
static

◆ IM_U8_MIN

const unsigned char IM_U8_MIN = 0
static