|
|
|
|
1
|
-// ImGui library
|
|
|
|
|
1
|
+// ImGui library v1.13
|
2
|
// See .cpp file for commentary.
|
2
|
// See .cpp file for commentary.
|
3
|
// See ImGui::ShowTestWindow() for sample code.
|
3
|
// See ImGui::ShowTestWindow() for sample code.
|
4
|
// Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
|
4
|
// Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
|
|
|
|
|
17
|
#include "imconfig.h"
|
17
|
#include "imconfig.h"
|
18
|
#include <float.h> // FLT_MAX
|
18
|
#include <float.h> // FLT_MAX
|
19
|
#include <stdarg.h> // va_list
|
19
|
#include <stdarg.h> // va_list
|
|
|
20
|
+#include <stddef.h> // ptrdiff_t
|
20
|
#include <stdlib.h> // NULL, malloc
|
21
|
#include <stdlib.h> // NULL, malloc
|
21
|
|
22
|
|
22
|
-#ifndef IM_MALLOC
|
|
|
23
|
-#define IM_MALLOC(_SIZE) malloc((_SIZE))
|
|
|
24
|
-#endif
|
|
|
25
|
-
|
|
|
26
|
-#ifndef IM_FREE
|
|
|
27
|
-#define IM_FREE(_PTR) free((_PTR))
|
|
|
28
|
-#endif
|
|
|
29
|
-
|
|
|
30
|
-#ifndef IM_REALLOC
|
|
|
31
|
-#define IM_REALLOC(_PTR, _SIZE) realloc((_PTR), (_SIZE))
|
|
|
32
|
-#endif
|
|
|
33
|
-
|
|
|
34
|
#ifndef IM_ASSERT
|
23
|
#ifndef IM_ASSERT
|
35
|
#include <assert.h>
|
24
|
#include <assert.h>
|
36
|
#define IM_ASSERT(_EXPR) assert(_EXPR)
|
25
|
#define IM_ASSERT(_EXPR) assert(_EXPR)
|
37
|
#endif
|
26
|
#endif
|
38
|
|
27
|
|
39
|
typedef unsigned int ImU32;
|
28
|
typedef unsigned int ImU32;
|
|
|
29
|
+typedef unsigned short ImWchar;
|
40
|
typedef ImU32 ImGuiID;
|
30
|
typedef ImU32 ImGuiID;
|
41
|
typedef int ImGuiCol; // enum ImGuiCol_
|
31
|
typedef int ImGuiCol; // enum ImGuiCol_
|
42
|
typedef int ImGuiKey; // enum ImGuiKey_
|
32
|
typedef int ImGuiKey; // enum ImGuiKey_
|
|
|
|
|
67
|
#endif
|
57
|
#endif
|
68
|
};
|
58
|
};
|
69
|
|
59
|
|
|
|
60
|
+namespace ImGui
|
|
|
61
|
+{
|
|
|
62
|
+ // Proxy functions to access the MemAllocFn/MemFreeFn/MemReallocFn pointers in ImGui::GetIO(). The only reason they exist here is to allow ImVector<> to compile inline.
|
|
|
63
|
+ void* MemAlloc(size_t sz);
|
|
|
64
|
+ void MemFree(void* ptr);
|
|
|
65
|
+ void* MemRealloc(void* ptr, size_t sz);
|
|
|
66
|
+};
|
|
|
67
|
+
|
70
|
// std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
|
68
|
// std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
|
71
|
-// this implementation does NOT call c++ constructors! we don't need them! also only provide the minimum functionalities we need.
|
|
|
|
|
69
|
+// Use '#define ImVector std::vector' if you want to use the STL type or your own type.
|
|
|
70
|
+// Our implementation does NOT call c++ constructors! because the data types we use don't need them (but that could be added as well). Only provide the minimum functionalities we need.
|
72
|
#ifndef ImVector
|
71
|
#ifndef ImVector
|
73
|
template<typename T>
|
72
|
template<typename T>
|
74
|
class ImVector
|
73
|
class ImVector
|
|
|
|
|
84
|
typedef const value_type* const_iterator;
|
83
|
typedef const value_type* const_iterator;
|
85
|
|
84
|
|
86
|
ImVector() { Size = Capacity = 0; Data = NULL; }
|
85
|
ImVector() { Size = Capacity = 0; Data = NULL; }
|
87
|
- ~ImVector() { if (Data) IM_FREE(Data); }
|
|
|
|
|
86
|
+ ~ImVector() { if (Data) ImGui::MemFree(Data); }
|
88
|
|
87
|
|
89
|
inline bool empty() const { return Size == 0; }
|
88
|
inline bool empty() const { return Size == 0; }
|
90
|
inline size_t size() const { return Size; }
|
89
|
inline size_t size() const { return Size; }
|
|
|
|
|
95
|
inline value_type& operator[](size_t i) { IM_ASSERT(i < Size); return Data[i]; }
|
94
|
inline value_type& operator[](size_t i) { IM_ASSERT(i < Size); return Data[i]; }
|
96
|
inline const value_type& operator[](size_t i) const { IM_ASSERT(i < Size); return Data[i]; }
|
95
|
inline const value_type& operator[](size_t i) const { IM_ASSERT(i < Size); return Data[i]; }
|
97
|
|
96
|
|
98
|
- inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } }
|
|
|
|
|
97
|
+ inline void clear() { if (Data) { Size = Capacity = 0; ImGui::MemFree(Data); Data = NULL; } }
|
99
|
inline iterator begin() { return Data; }
|
98
|
inline iterator begin() { return Data; }
|
100
|
inline const_iterator begin() const { return Data; }
|
99
|
inline const_iterator begin() const { return Data; }
|
101
|
inline iterator end() { return Data + Size; }
|
100
|
inline iterator end() { return Data + Size; }
|
|
|
|
|
106
|
inline const value_type& back() const { IM_ASSERT(Size > 0); return at(Size-1); }
|
105
|
inline const value_type& back() const { IM_ASSERT(Size > 0); return at(Size-1); }
|
107
|
inline void swap(ImVector<T>& rhs) { const size_t rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; const size_t rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
|
106
|
inline void swap(ImVector<T>& rhs) { const size_t rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; const size_t rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
|
108
|
|
107
|
|
109
|
- inline void reserve(size_t new_capacity) { Data = (value_type*)IM_REALLOC(Data, new_capacity * sizeof(value_type)); Capacity = new_capacity; }
|
|
|
|
|
108
|
+ inline void reserve(size_t new_capacity) { Data = (value_type*)ImGui::MemRealloc(Data, new_capacity * sizeof(value_type)); Capacity = new_capacity; }
|
110
|
inline void resize(size_t new_size) { if (new_size > Capacity) reserve(new_size); Size = new_size; }
|
109
|
inline void resize(size_t new_size) { if (new_size > Capacity) reserve(new_size); Size = new_size; }
|
111
|
|
110
|
|
112
|
inline void push_back(const value_type& v) { if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); Data[Size++] = v; }
|
111
|
inline void push_back(const value_type& v) { if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); Data[Size++] = v; }
|
113
|
inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
|
112
|
inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
|
114
|
|
113
|
|
115
|
- inline iterator erase(const_iterator it) { IM_ASSERT(it >= begin() && it < end()); const int off = it - begin(); memmove(Data + off, Data + off + 1, (Size - off - 1) * sizeof(value_type)); Size--; return Data + off; }
|
|
|
116
|
- inline void insert(const_iterator it, const value_type& v) { IM_ASSERT(it >= begin() && it <= end()); const int off = it - begin(); if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); if (off < (int)Size) memmove(Data + off + 1, Data + off, (Size - off) * sizeof(value_type)); Data[off] = v; Size++; }
|
|
|
|
|
114
|
+ inline iterator erase(const_iterator it) { IM_ASSERT(it >= begin() && it < end()); const ptrdiff_t off = it - begin(); memmove(Data + off, Data + off + 1, (Size - off - 1) * sizeof(value_type)); Size--; return Data + off; }
|
|
|
115
|
+ inline void insert(const_iterator it, const value_type& v) { IM_ASSERT(it >= begin() && it <= end()); const ptrdiff_t off = it - begin(); if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); if (off < (int)Size) memmove(Data + off + 1, Data + off, (Size - off) * sizeof(value_type)); Data[off] = v; Size++; }
|
117
|
};
|
116
|
};
|
118
|
#endif // #ifndef ImVector
|
117
|
#endif // #ifndef ImVector
|
119
|
|
118
|
|
|
|
|
|
152
|
ImVec2 GetWindowContentRegionMin();
|
151
|
ImVec2 GetWindowContentRegionMin();
|
153
|
ImVec2 GetWindowContentRegionMax();
|
152
|
ImVec2 GetWindowContentRegionMax();
|
154
|
ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives.
|
153
|
ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives.
|
155
|
- void SetFontScale(float scale);
|
|
|
|
|
154
|
+ void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontBaseScale if you want to scale all windows together.
|
156
|
void SetScrollPosHere(); // adjust scrolling position to center into the current cursor position.
|
155
|
void SetScrollPosHere(); // adjust scrolling position to center into the current cursor position.
|
157
|
void SetTreeStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it).
|
156
|
void SetTreeStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it).
|
158
|
ImGuiStorage* GetTreeStateStorage();
|
157
|
ImGuiStorage* GetTreeStateStorage();
|
|
|
|
|
166
|
|
165
|
|
167
|
// Tooltip
|
166
|
// Tooltip
|
168
|
void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins.
|
167
|
void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins.
|
|
|
168
|
+ void SetTooltipV(const char* fmt, va_list args);
|
169
|
void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text.
|
169
|
void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text.
|
170
|
void EndTooltip();
|
170
|
void EndTooltip();
|
171
|
|
171
|
|
|
|
|
|
178
|
float GetColumnOffset(int column_index = -1);
|
178
|
float GetColumnOffset(int column_index = -1);
|
179
|
void SetColumnOffset(int column_index, float offset);
|
179
|
void SetColumnOffset(int column_index, float offset);
|
180
|
float GetColumnWidth(int column_index = -1);
|
180
|
float GetColumnWidth(int column_index = -1);
|
181
|
- ImVec2 GetCursorPos(); // cursor position relative to window position
|
|
|
|
|
181
|
+ ImVec2 GetCursorPos(); // cursor position is relative to window position
|
182
|
void SetCursorPos(const ImVec2& pos); // "
|
182
|
void SetCursorPos(const ImVec2& pos); // "
|
183
|
void SetCursorPosX(float x); // "
|
183
|
void SetCursorPosX(float x); // "
|
184
|
void SetCursorPosY(float y); // "
|
184
|
void SetCursorPosY(float y); // "
|
185
|
- ImVec2 GetCursorScreenPos(); // cursor position in screen space
|
|
|
|
|
185
|
+ ImVec2 GetCursorScreenPos(); // cursor position in screen space
|
186
|
void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets.
|
186
|
void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets.
|
187
|
float GetTextLineSpacing();
|
187
|
float GetTextLineSpacing();
|
188
|
float GetTextLineHeight();
|
188
|
float GetTextLineHeight();
|
|
|
|
|
197
|
void Text(const char* fmt, ...);
|
197
|
void Text(const char* fmt, ...);
|
198
|
void TextV(const char* fmt, va_list args);
|
198
|
void TextV(const char* fmt, va_list args);
|
199
|
void TextColored(const ImVec4& col, const char* fmt, ...); // shortcut to doing PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
|
199
|
void TextColored(const ImVec4& col, const char* fmt, ...); // shortcut to doing PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
|
|
|
200
|
+ void TextColoredV(const ImVec4& col, const char* fmt, va_list args);
|
200
|
void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, better for long chunks of text.
|
201
|
void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, better for long chunks of text.
|
201
|
void LabelText(const char* label, const char* fmt, ...);
|
202
|
void LabelText(const char* label, const char* fmt, ...);
|
|
|
203
|
+ void LabelTextV(const char* label, const char* fmt, va_list args);
|
202
|
void BulletText(const char* fmt, ...);
|
204
|
void BulletText(const char* fmt, ...);
|
|
|
205
|
+ void BulletTextV(const char* fmt, va_list args);
|
203
|
bool Button(const char* label, ImVec2 size = ImVec2(0,0), bool repeat_when_held = false);
|
206
|
bool Button(const char* label, ImVec2 size = ImVec2(0,0), bool repeat_when_held = false);
|
204
|
bool SmallButton(const char* label);
|
207
|
bool SmallButton(const char* label);
|
205
|
bool CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
|
208
|
bool CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
|
206
|
bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders.
|
209
|
bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders.
|
207
|
bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
210
|
bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
208
|
bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
211
|
bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
209
|
- bool SliderFloat4(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
|
|
|
|
212
|
+ bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
210
|
bool SliderAngle(const char* label, float* v, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f); // *v in radians
|
213
|
bool SliderAngle(const char* label, float* v, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f); // *v in radians
|
211
|
bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f");
|
214
|
bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f");
|
212
|
void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
|
215
|
void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
|
|
|
|
|
231
|
bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop
|
234
|
bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop
|
232
|
bool TreeNode(const char* str_id, const char* fmt, ...); // "
|
235
|
bool TreeNode(const char* str_id, const char* fmt, ...); // "
|
233
|
bool TreeNode(const void* ptr_id, const char* fmt, ...); // "
|
236
|
bool TreeNode(const void* ptr_id, const char* fmt, ...); // "
|
|
|
237
|
+ bool TreeNodeV(const char* str_id, const char* fmt, va_list args); // "
|
|
|
238
|
+ bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args); // "
|
234
|
void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose
|
239
|
void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose
|
235
|
void TreePush(const void* ptr_id = NULL); // "
|
240
|
void TreePush(const void* ptr_id = NULL); // "
|
236
|
void TreePop();
|
241
|
void TreePop();
|
|
|
|
|
260
|
bool IsKeyPressed(int key_index, bool repeat = true); // key_index into the keys_down[512] array, imgui doesn't know the semantic of each entry
|
265
|
bool IsKeyPressed(int key_index, bool repeat = true); // key_index into the keys_down[512] array, imgui doesn't know the semantic of each entry
|
261
|
bool IsMouseClicked(int button, bool repeat = false);
|
266
|
bool IsMouseClicked(int button, bool repeat = false);
|
262
|
bool IsMouseDoubleClicked(int button);
|
267
|
bool IsMouseDoubleClicked(int button);
|
263
|
- bool IsMouseHoveringBox(const ImVec2& box_min, const ImVec2& box_max);
|
|
|
264
|
- ImVec2 GetMousePos();
|
|
|
|
|
268
|
+ bool IsMouseHoveringWindow(); // is mouse hovering current window ("window" in API names always refer to current window)
|
|
|
269
|
+ bool IsMouseHoveringAnyWindow(); // is mouse hovering any active imgui window
|
|
|
270
|
+ bool IsMouseHoveringBox(const ImVec2& box_min, const ImVec2& box_max); // is mouse hovering given bounding box
|
|
|
271
|
+ bool IsPosHoveringAnyWindow(const ImVec2& pos); // is given position hovering any active imgui window
|
|
|
272
|
+ ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
265
|
float GetTime();
|
273
|
float GetTime();
|
266
|
int GetFrameCount();
|
274
|
int GetFrameCount();
|
267
|
const char* GetStyleColorName(ImGuiCol idx);
|
275
|
const char* GetStyleColorName(ImGuiCol idx);
|
|
|
|
|
394
|
// Read 'Programmer guide' section in .cpp file for general usage.
|
402
|
// Read 'Programmer guide' section in .cpp file for general usage.
|
395
|
struct ImGuiIO
|
403
|
struct ImGuiIO
|
396
|
{
|
404
|
{
|
|
|
405
|
+ //------------------------------------------------------------------
|
397
|
// Settings (fill once) // Default value:
|
406
|
// Settings (fill once) // Default value:
|
|
|
407
|
+ //------------------------------------------------------------------
|
|
|
408
|
+
|
398
|
ImVec2 DisplaySize; // <unset> // Display size, in pixels. For clamping windows positions.
|
409
|
ImVec2 DisplaySize; // <unset> // Display size, in pixels. For clamping windows positions.
|
399
|
float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds.
|
410
|
float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds.
|
400
|
float IniSavingRate; // = 5.0f // Maximum time between saving .ini file, in seconds. Set to a negative value to disable .ini saving.
|
411
|
float IniSavingRate; // = 5.0f // Maximum time between saving .ini file, in seconds. Set to a negative value to disable .ini saving.
|
|
|
|
|
404
|
float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
|
415
|
float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
|
405
|
int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array
|
416
|
int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array
|
406
|
ImFont Font; // <auto> // Gets passed to text functions. Typedef ImFont to the type you want (ImBitmapFont* or your own font).
|
417
|
ImFont Font; // <auto> // Gets passed to text functions. Typedef ImFont to the type you want (ImBitmapFont* or your own font).
|
407
|
- float FontYOffset; // = 0.0f // Offset font rendering by xx pixels in Y axis.
|
|
|
|
|
418
|
+ float FontYOffset; // = 0.0f // Offset font rendering by xx pixels in Y axis.
|
408
|
ImVec2 FontTexUvForWhite; // = (0.0f,0.0f) // Font texture must have a white pixel at this UV coordinate. Adjust if you are using custom texture.
|
419
|
ImVec2 FontTexUvForWhite; // = (0.0f,0.0f) // Font texture must have a white pixel at this UV coordinate. Adjust if you are using custom texture.
|
409
|
- bool FontAllowScaling; // = false // Set to allow scaling text with CTRL+Wheel.
|
|
|
|
|
420
|
+ float FontBaseScale; // = 1.0f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
|
|
|
421
|
+ bool FontAllowUserScaling; // = false // Set to allow scaling text with CTRL+Wheel.
|
|
|
422
|
+ ImWchar FontFallbackGlyph; // = '?' // Replacement glyph is one isn't found.
|
410
|
float PixelCenterOffset; // = 0.0f // Try to set to 0.5f or 0.375f if rendering is blurry
|
423
|
float PixelCenterOffset; // = 0.0f // Try to set to 0.5f or 0.375f if rendering is blurry
|
411
|
|
424
|
|
412
|
- // Settings - Rendering function (REQUIRED)
|
|
|
|
|
425
|
+ //------------------------------------------------------------------
|
|
|
426
|
+ // User Functions
|
|
|
427
|
+ //------------------------------------------------------------------
|
|
|
428
|
+
|
|
|
429
|
+ // REQUIRED: rendering function.
|
413
|
// See example code if you are unsure of how to implement this.
|
430
|
// See example code if you are unsure of how to implement this.
|
414
|
- void (*RenderDrawListsFn)(ImDrawList** const draw_lists, int count);
|
|
|
|
|
431
|
+ void (*RenderDrawListsFn)(ImDrawList** const draw_lists, int count);
|
|
|
432
|
+
|
|
|
433
|
+ // Optional: access OS clipboard (default to use native Win32 clipboard on Windows, otherwise use a ImGui private clipboard)
|
|
|
434
|
+ // Override to access OS clipboard on other architectures.
|
|
|
435
|
+ const char* (*GetClipboardTextFn)();
|
|
|
436
|
+ void (*SetClipboardTextFn)(const char* text);
|
415
|
|
437
|
|
416
|
- // Settings - Clipboard Support
|
|
|
417
|
- // Override to provide your clipboard handlers.
|
|
|
418
|
- // On Windows architecture, defaults to use the native Win32 clipboard, otherwise default to use a ImGui private clipboard.
|
|
|
419
|
- // NB- for SetClipboardTextFn, the string is *NOT* zero-terminated at 'text_end'
|
|
|
420
|
- const char* (*GetClipboardTextFn)();
|
|
|
421
|
- void (*SetClipboardTextFn)(const char* text, const char* text_end);
|
|
|
|
|
438
|
+ // Optional: override memory allocations (default to posix malloc/realloc/free)
|
|
|
439
|
+ void* (*MemAllocFn)(size_t sz);
|
|
|
440
|
+ void* (*MemReallocFn)(void* ptr, size_t sz);
|
|
|
441
|
+ void (*MemFreeFn)(void* ptr);
|
422
|
|
442
|
|
|
|
443
|
+ // Optional: notify OS Input Method Editor of text input position (e.g. when using Japanese/Chinese inputs, otherwise this isn't needed)
|
|
|
444
|
+ void (*ImeSetInputScreenPosFn)(int x, int y);
|
|
|
445
|
+
|
|
|
446
|
+ //------------------------------------------------------------------
|
423
|
// Input - Fill before calling NewFrame()
|
447
|
// Input - Fill before calling NewFrame()
|
|
|
448
|
+ //------------------------------------------------------------------
|
|
|
449
|
+
|
424
|
ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
450
|
ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
425
|
bool MouseDown[5]; // Mouse buttons. ImGui itself only uses button 0 (left button) but you can use others as storage for convenience.
|
451
|
bool MouseDown[5]; // Mouse buttons. ImGui itself only uses button 0 (left button) but you can use others as storage for convenience.
|
426
|
int MouseWheel; // Mouse wheel: -1,0,+1
|
452
|
int MouseWheel; // Mouse wheel: -1,0,+1
|
427
|
bool KeyCtrl; // Keyboard modifier pressed: Control
|
453
|
bool KeyCtrl; // Keyboard modifier pressed: Control
|
428
|
bool KeyShift; // Keyboard modifier pressed: Shift
|
454
|
bool KeyShift; // Keyboard modifier pressed: Shift
|
429
|
bool KeysDown[512]; // Keyboard keys that are pressed (in whatever order user naturally has access to keyboard data)
|
455
|
bool KeysDown[512]; // Keyboard keys that are pressed (in whatever order user naturally has access to keyboard data)
|
430
|
- char InputCharacters[16]; // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper.
|
|
|
|
|
456
|
+ ImWchar InputCharacters[16]; // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper.
|
431
|
|
457
|
|
|
|
458
|
+ // Function
|
|
|
459
|
+ void AddInputCharacter(ImWchar); // Helper to add a new character into InputCharacters[]
|
|
|
460
|
+
|
|
|
461
|
+ //------------------------------------------------------------------
|
432
|
// Output - Retrieve after calling NewFrame(), you can use them to discard inputs or hide them from the rest of your application
|
462
|
// Output - Retrieve after calling NewFrame(), you can use them to discard inputs or hide them from the rest of your application
|
433
|
- bool WantCaptureMouse; // ImGui is using your mouse input (= window is being hovered or widget is active).
|
|
|
434
|
- bool WantCaptureKeyboard; // imGui is using your keyboard input (= widget is active).
|
|
|
|
|
463
|
+ //------------------------------------------------------------------
|
435
|
|
464
|
|
436
|
- // Function
|
|
|
437
|
- void AddInputCharacter(char c); // Helper to add a new character into InputCharacters[]
|
|
|
|
|
465
|
+ bool WantCaptureMouse; // Mouse is hovering a window or widget is active (= ImGui will use your mouse input)
|
|
|
466
|
+ bool WantCaptureKeyboard; // Widget is active (= ImGui will use your keyboard input)
|
438
|
|
467
|
|
|
|
468
|
+ //------------------------------------------------------------------
|
439
|
// [Internal] ImGui will maintain those fields for you
|
469
|
// [Internal] ImGui will maintain those fields for you
|
|
|
470
|
+ //------------------------------------------------------------------
|
|
|
471
|
+
|
440
|
ImVec2 MousePosPrev;
|
472
|
ImVec2 MousePosPrev;
|
441
|
ImVec2 MouseDelta;
|
473
|
ImVec2 MouseDelta;
|
442
|
bool MouseClicked[5];
|
474
|
bool MouseClicked[5];
|
|
|
|
|
468
|
// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
|
500
|
// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
|
469
|
struct ImGuiTextFilter
|
501
|
struct ImGuiTextFilter
|
470
|
{
|
502
|
{
|
471
|
- struct TextRange
|
|
|
472
|
- {
|
|
|
473
|
- const char* b;
|
|
|
|
|
503
|
+ struct TextRange
|
|
|
504
|
+ {
|
|
|
505
|
+ const char* b;
|
474
|
const char* e;
|
506
|
const char* e;
|
475
|
|
507
|
|
476
|
TextRange() { b = e = NULL; }
|
508
|
TextRange() { b = e = NULL; }
|
|
|
|
|
479
|
const char* end() const { return e; }
|
511
|
const char* end() const { return e; }
|
480
|
bool empty() const { return b == e; }
|
512
|
bool empty() const { return b == e; }
|
481
|
char front() const { return *b; }
|
513
|
char front() const { return *b; }
|
482
|
- static bool isblank(char c) { return c == ' ' || c == '\t'; }
|
|
|
|
|
514
|
+ static bool isblank(char c) { return c == ' ' || c == '\t'; }
|
483
|
void trim_blanks() { while (b < e && isblank(*b)) b++; while (e > b && isblank(*(e-1))) e--; }
|
515
|
void trim_blanks() { while (b < e && isblank(*b)) b++; while (e > b && isblank(*(e-1))) e--; }
|
484
|
void split(char separator, ImVector<TextRange>& out);
|
516
|
void split(char separator, ImVector<TextRange>& out);
|
485
|
};
|
517
|
};
|
|
|
|
|
655
|
void BuildLookupTable();
|
687
|
void BuildLookupTable();
|
656
|
const FntGlyph * FindGlyph(unsigned short c) const;
|
688
|
const FntGlyph * FindGlyph(unsigned short c) const;
|
657
|
float GetFontSize() const { return (float)Info->FontSize; }
|
689
|
float GetFontSize() const { return (float)Info->FontSize; }
|
658
|
- bool IsLoaded() const { return Info != NULL && Common != NULL && Glyphs != NULL; }
|
|
|
|
|
690
|
+ bool IsLoaded() const { return Info != NULL && Common != NULL && Glyphs != NULL; }
|
659
|
|
691
|
|
660
|
- ImVec2 CalcTextSize(float size, float max_width, const char* text_begin, const char* text_end, const char** remaining = NULL) const;
|
|
|
|
|
692
|
+ ImVec2 CalcTextSizeA(float size, float max_width, const char* text_begin, const char* text_end, const char** remaining = NULL) const; // utf8
|
|
|
693
|
+ ImVec2 CalcTextSizeW(float size, float max_width, const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL) const; // wchar
|
661
|
void RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawVert*& out_vertices) const;
|
694
|
void RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawVert*& out_vertices) const;
|
662
|
};
|
695
|
};
|