|
@@ -1,4 +1,4 @@
|
1
|
|
-// ImGui library v1.16 wip
|
|
1
|
+// ImGui library v1.18 wip
|
2
|
2
|
// See .cpp file for commentary.
|
3
|
3
|
// See ImGui::ShowTestWindow() for sample code.
|
4
|
4
|
// Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
|
|
@@ -7,7 +7,7 @@
|
7
|
7
|
#pragma once
|
8
|
8
|
|
9
|
9
|
struct ImDrawList;
|
10
|
|
-struct ImBitmapFont;
|
|
10
|
+struct ImFont;
|
11
|
11
|
struct ImGuiAabb;
|
12
|
12
|
struct ImGuiIO;
|
13
|
13
|
struct ImGuiStorage;
|
|
@@ -30,15 +30,15 @@ struct ImGuiWindow;
|
30
|
30
|
#endif
|
31
|
31
|
|
32
|
32
|
typedef unsigned int ImU32;
|
33
|
|
-typedef unsigned short ImWchar;
|
34
|
|
-typedef ImU32 ImGuiID;
|
|
33
|
+typedef unsigned short ImWchar; // hold a character for display
|
|
34
|
+typedef ImU32 ImGuiID; // hold widget unique ID
|
35
|
35
|
typedef int ImGuiCol; // enum ImGuiCol_
|
36
|
36
|
typedef int ImGuiStyleVar; // enum ImGuiStyleVar_
|
37
|
37
|
typedef int ImGuiKey; // enum ImGuiKey_
|
38
|
38
|
typedef int ImGuiColorEditMode; // enum ImGuiColorEditMode_
|
39
|
39
|
typedef int ImGuiWindowFlags; // enum ImGuiWindowFlags_
|
40
|
40
|
typedef int ImGuiInputTextFlags; // enum ImGuiInputTextFlags_
|
41
|
|
-typedef ImBitmapFont* ImFont;
|
|
41
|
+struct ImGuiTextEditCallbackData;
|
42
|
42
|
|
43
|
43
|
struct ImVec2
|
44
|
44
|
{
|
|
@@ -77,7 +77,7 @@ namespace ImGui
|
77
|
77
|
template<typename T>
|
78
|
78
|
class ImVector
|
79
|
79
|
{
|
80
|
|
-private:
|
|
80
|
+protected:
|
81
|
81
|
size_t Size;
|
82
|
82
|
size_t Capacity;
|
83
|
83
|
T* Data;
|
|
@@ -122,7 +122,7 @@ public:
|
122
|
122
|
#endif // #ifndef ImVector
|
123
|
123
|
|
124
|
124
|
// Helpers at bottom of the file:
|
125
|
|
-// - if (IMGUI_ONCE_UPON_A_FRAME) // Execute a block of code once per frame only
|
|
125
|
+// - IMGUI_ONCE_UPON_A_FRAME // Execute a block of code once per frame only (convenient for creating UI within deep-nested code that runs multiple times)
|
126
|
126
|
// - struct ImGuiTextFilter // Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
|
127
|
127
|
// - struct ImGuiTextBuffer // Text buffer for logging/accumulating text
|
128
|
128
|
// - struct ImGuiStorage // Custom key value storage (if you need to alter open/close states manually)
|
|
@@ -151,16 +151,16 @@ namespace ImGui
|
151
|
151
|
IMGUI_API bool GetWindowIsFocused();
|
152
|
152
|
IMGUI_API ImVec2 GetWindowSize();
|
153
|
153
|
IMGUI_API float GetWindowWidth();
|
154
|
|
- IMGUI_API void SetWindowSize(const ImVec2& size); // set to ImVec2(0,0) to force an auto-fit
|
|
154
|
+ IMGUI_API void SetWindowSize(const ImVec2& size); // set to ImVec2(0,0) to force an auto-fit
|
155
|
155
|
IMGUI_API ImVec2 GetWindowPos(); // you should rarely need/care about the window position, but it can be useful if you want to use your own drawing.
|
156
|
156
|
IMGUI_API void SetWindowPos(const ImVec2& pos); // set current window pos.
|
157
|
157
|
IMGUI_API ImVec2 GetContentRegionMax(); // window or current column boundaries
|
158
|
158
|
IMGUI_API ImVec2 GetWindowContentRegionMin(); // window boundaries
|
159
|
159
|
IMGUI_API ImVec2 GetWindowContentRegionMax();
|
160
|
160
|
IMGUI_API ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives.
|
161
|
|
- IMGUI_API ImFont GetWindowFont();
|
|
161
|
+ IMGUI_API ImFont* GetWindowFont();
|
162
|
162
|
IMGUI_API float GetWindowFontSize();
|
163
|
|
- IMGUI_API void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontBaseScale if you want to scale all windows together.
|
|
163
|
+ IMGUI_API void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows.
|
164
|
164
|
IMGUI_API void SetScrollPosHere(); // adjust scrolling position to center into the current cursor position.
|
165
|
165
|
IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use 'offset' to access sub components of a multiple component widget.
|
166
|
166
|
IMGUI_API void SetTreeStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it).
|
|
@@ -172,10 +172,10 @@ namespace ImGui
|
172
|
172
|
IMGUI_API void PushAllowKeyboardFocus(bool v); // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets.
|
173
|
173
|
IMGUI_API void PopAllowKeyboardFocus();
|
174
|
174
|
IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4& col);
|
175
|
|
- IMGUI_API void PopStyleColor();
|
|
175
|
+ IMGUI_API void PopStyleColor(int count = 1);
|
176
|
176
|
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val);
|
177
|
177
|
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val);
|
178
|
|
- IMGUI_API void PopStyleVar();
|
|
178
|
+ IMGUI_API void PopStyleVar(int count = 1);
|
179
|
179
|
IMGUI_API void PushTextWrapPos(float wrap_pos_x = 0.0f); // word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space.
|
180
|
180
|
IMGUI_API void PopTextWrapPos();
|
181
|
181
|
|
|
@@ -238,7 +238,7 @@ namespace ImGui
|
238
|
238
|
IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
|
239
|
239
|
IMGUI_API bool RadioButton(const char* label, bool active);
|
240
|
240
|
IMGUI_API bool RadioButton(const char* label, int* v, int v_button);
|
241
|
|
- IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0);
|
|
241
|
+ IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, void (*callback)(ImGuiTextEditCallbackData*) = NULL, void* user_data = NULL);
|
242
|
242
|
IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);
|
243
|
243
|
IMGUI_API bool InputFloat2(const char* label, float v[2], int decimal_precision = -1);
|
244
|
244
|
IMGUI_API bool InputFloat3(const char* label, float v[3], int decimal_precision = -1);
|
|
@@ -295,7 +295,7 @@ namespace ImGui
|
295
|
295
|
IMGUI_API int GetFrameCount();
|
296
|
296
|
IMGUI_API const char* GetStyleColorName(ImGuiCol idx);
|
297
|
297
|
IMGUI_API void GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size);
|
298
|
|
- IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_hash = true, float wrap_width = -1.0f);
|
|
298
|
+ IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = true, float wrap_width = -1.0f);
|
299
|
299
|
|
300
|
300
|
} // namespace ImGui
|
301
|
301
|
|
|
@@ -308,11 +308,13 @@ enum ImGuiWindowFlags_
|
308
|
308
|
ImGuiWindowFlags_NoResize = 1 << 2,
|
309
|
309
|
ImGuiWindowFlags_NoMove = 1 << 3,
|
310
|
310
|
ImGuiWindowFlags_NoScrollbar = 1 << 4,
|
311
|
|
- ImGuiWindowFlags_ChildWindow = 1 << 5, // For internal use by BeginChild()
|
312
|
|
- ImGuiWindowFlags_ChildWindowAutoFitX = 1 << 6, // For internal use by BeginChild()
|
313
|
|
- ImGuiWindowFlags_ChildWindowAutoFitY = 1 << 7, // For internal use by BeginChild()
|
314
|
|
- ImGuiWindowFlags_ComboBox = 1 << 8, // For internal use by ComboBox()
|
315
|
|
- ImGuiWindowFlags_Tooltip = 1 << 9 // For internal use by Render() when using Tooltip
|
|
311
|
+ ImGuiWindowFlags_NoScrollWithMouse = 1 << 5,
|
|
312
|
+ ImGuiWindowFlags_AlwaysAutoResize = 1 << 6,
|
|
313
|
+ ImGuiWindowFlags_ChildWindow = 1 << 7, // For internal use by BeginChild()
|
|
314
|
+ ImGuiWindowFlags_ChildWindowAutoFitX = 1 << 8, // For internal use by BeginChild()
|
|
315
|
+ ImGuiWindowFlags_ChildWindowAutoFitY = 1 << 9, // For internal use by BeginChild()
|
|
316
|
+ ImGuiWindowFlags_ComboBox = 1 << 10, // For internal use by ComboBox()
|
|
317
|
+ ImGuiWindowFlags_Tooltip = 1 << 11 // For internal use by Render() when using Tooltip
|
316
|
318
|
};
|
317
|
319
|
|
318
|
320
|
// Flags for ImGui::InputText()
|
|
@@ -322,8 +324,11 @@ enum ImGuiInputTextFlags_
|
322
|
324
|
ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/
|
323
|
325
|
ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef
|
324
|
326
|
ImGuiInputTextFlags_AutoSelectAll = 1 << 2, // Select entire text when first taking focus
|
325
|
|
- ImGuiInputTextFlags_EnterReturnsTrue = 1 << 3 // Return 'true' when Enter is pressed (as opposed to when the value was modified)
|
326
|
|
- //ImGuiInputTextFlags_AlignCenter = 1 << 3,
|
|
327
|
+ ImGuiInputTextFlags_EnterReturnsTrue = 1 << 3, // Return 'true' when Enter is pressed (as opposed to when the value was modified)
|
|
328
|
+ ImGuiInputTextFlags_CallbackCompletion = 1 << 4, // Call user function on pressing TAB (for completion handling)
|
|
329
|
+ ImGuiInputTextFlags_CallbackHistory = 1 << 5, // Call user function on pressing Up/Down arrows (for history handling)
|
|
330
|
+ ImGuiInputTextFlags_CallbackAlways = 1 << 6 // Call user function every frame
|
|
331
|
+ //ImGuiInputTextFlags_AlignCenter = 1 << 6,
|
327
|
332
|
};
|
328
|
333
|
|
329
|
334
|
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
|
|
@@ -450,12 +455,9 @@ struct ImGuiIO
|
450
|
455
|
float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds.
|
451
|
456
|
float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
|
452
|
457
|
int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array
|
453
|
|
- ImFont Font; // <auto> // Gets passed to text functions. Typedef ImFont to the type you want (ImBitmapFont* or your own font).
|
454
|
|
- float FontYOffset; // = 0.0f // Offset font rendering by xx pixels in Y axis.
|
455
|
|
- ImVec2 FontTexUvForWhite; // = (0.0f,0.0f) // Font texture must have a white pixel at this UV coordinate. Adjust if you are using custom texture.
|
456
|
|
- float FontBaseScale; // = 1.0f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
|
457
|
|
- bool FontAllowUserScaling; // = false // Set to allow scaling text with CTRL+Wheel.
|
458
|
|
- ImWchar FontFallbackGlyph; // = '?' // Replacement glyph is one isn't found.
|
|
458
|
+ ImFont* Font; // <auto> // Font (also see 'Settings' fields inside ImFont structure for details)
|
|
459
|
+ float FontGlobalScale; // = 1.0f // Global scale all fonts
|
|
460
|
+ bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel.
|
459
|
461
|
float PixelCenterOffset; // = 0.0f // Try to set to 0.5f or 0.375f if rendering is blurry
|
460
|
462
|
|
461
|
463
|
void* UserData; // = NULL // Store your own data for retrieval by callbacks.
|
|
@@ -487,7 +489,7 @@ struct ImGuiIO
|
487
|
489
|
|
488
|
490
|
ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
489
|
491
|
bool MouseDown[5]; // Mouse buttons. ImGui itself only uses button 0 (left button) but you can use others as storage for convenience.
|
490
|
|
- int MouseWheel; // Mouse wheel: -1,0,+1
|
|
492
|
+ float MouseWheel; // Mouse wheel: 1 unit scrolls about 5 lines text.
|
491
|
493
|
bool KeyCtrl; // Keyboard modifier pressed: Control
|
492
|
494
|
bool KeyShift; // Keyboard modifier pressed: Shift
|
493
|
495
|
bool KeysDown[512]; // Keyboard keys that are pressed (in whatever order user naturally has access to keyboard data)
|
|
@@ -524,15 +526,19 @@ struct ImGuiIO
|
524
|
526
|
//-----------------------------------------------------------------------------
|
525
|
527
|
|
526
|
528
|
// Helper: execute a block of code once a frame only
|
527
|
|
-// Usage: if (IMGUI_ONCE_UPON_A_FRAME) {/*do something once a frame*/)
|
528
|
|
-#define IMGUI_ONCE_UPON_A_FRAME static ImGuiOncePerFrame im = ImGuiOncePerFrame()
|
529
|
|
-struct ImGuiOncePerFrame
|
|
529
|
+// Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame.
|
|
530
|
+// Usage:
|
|
531
|
+// IMGUI_ONCE_UPON_A_FRAME
|
|
532
|
+// {
|
|
533
|
+// // code block will be executed one per frame
|
|
534
|
+// }
|
|
535
|
+// Attention! the macro expands into 2 statement so make sure you don't use it within e.g. an if() statement without curly braces.
|
|
536
|
+#define IMGUI_ONCE_UPON_A_FRAME static ImGuiOnceUponAFrame imgui_oaf##__LINE__; if (imgui_oaf##__LINE__)
|
|
537
|
+struct ImGuiOnceUponAFrame
|
530
|
538
|
{
|
531
|
|
- ImGuiOncePerFrame() : LastFrame(-1) {}
|
532
|
|
- operator bool() const { return TryIsNewFrame(); }
|
533
|
|
-private:
|
534
|
|
- mutable int LastFrame;
|
535
|
|
- bool TryIsNewFrame() const { const int current_frame = ImGui::GetFrameCount(); if (LastFrame == current_frame) return false; LastFrame = current_frame; return true; }
|
|
539
|
+ ImGuiOnceUponAFrame() { RefFrame = -1; }
|
|
540
|
+ mutable int RefFrame;
|
|
541
|
+ operator bool() const { const int current_frame = ImGui::GetFrameCount(); if (RefFrame == current_frame) return false; RefFrame = current_frame; return true; }
|
536
|
542
|
};
|
537
|
543
|
|
538
|
544
|
// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
|
|
@@ -573,8 +579,8 @@ struct ImGuiTextBuffer
|
573
|
579
|
|
574
|
580
|
ImGuiTextBuffer() { Buf.push_back(0); }
|
575
|
581
|
~ImGuiTextBuffer() { clear(); }
|
576
|
|
- const char* begin() const { return Buf.begin(); }
|
577
|
|
- const char* end() const { return Buf.end()-1; }
|
|
582
|
+ const char* begin() const { return &Buf.front(); }
|
|
583
|
+ const char* end() const { return &Buf.back(); } // Buf is zero-terminated, so end() will point on the zero-terminator
|
578
|
584
|
size_t size() const { return Buf.size()-1; }
|
579
|
585
|
bool empty() { return Buf.empty(); }
|
580
|
586
|
void clear() { Buf.clear(); Buf.push_back(0); }
|
|
@@ -589,7 +595,7 @@ struct ImGuiTextBuffer
|
589
|
595
|
struct ImGuiStorage
|
590
|
596
|
{
|
591
|
597
|
struct Pair { ImU32 key; int val; };
|
592
|
|
- ImVector<Pair> Data;
|
|
598
|
+ ImVector<Pair> Data;
|
593
|
599
|
|
594
|
600
|
IMGUI_API void Clear();
|
595
|
601
|
IMGUI_API int GetInt(ImU32 key, int default_val = 0);
|
|
@@ -600,6 +606,24 @@ struct ImGuiStorage
|
600
|
606
|
IMGUI_API void Insert(ImU32 key, int val);
|
601
|
607
|
};
|
602
|
608
|
|
|
609
|
+// Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used.
|
|
610
|
+struct ImGuiTextEditCallbackData
|
|
611
|
+{
|
|
612
|
+ ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only
|
|
613
|
+ char* Buf; // Current text // Read-write (pointed data only)
|
|
614
|
+ size_t BufSize; // // Read-only
|
|
615
|
+ bool BufDirty; // Set if you modify Buf directly // Write
|
|
616
|
+ ImGuiInputTextFlags Flags; // What user passed to InputText() // Read-only
|
|
617
|
+ int CursorPos; // // Read-write
|
|
618
|
+ int SelectionStart; // // Read-write (== to SelectionEnd when no selection)
|
|
619
|
+ int SelectionEnd; // // Read-write
|
|
620
|
+ void* UserData; // What user passed to InputText()
|
|
621
|
+
|
|
622
|
+ // NB: calling those function loses selection.
|
|
623
|
+ void DeleteChars(int pos, int bytes_count);
|
|
624
|
+ void InsertChars(int pos, const char* text, const char* text_end = NULL);
|
|
625
|
+};
|
|
626
|
+
|
603
|
627
|
//-----------------------------------------------------------------------------
|
604
|
628
|
// Draw List
|
605
|
629
|
// Hold a series of drawing commands. The user provide a renderer for ImDrawList
|
|
@@ -659,19 +683,61 @@ struct ImDrawList
|
659
|
683
|
IMGUI_API void AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
|
660
|
684
|
IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
|
661
|
685
|
IMGUI_API void AddArc(const ImVec2& center, float rad, ImU32 col, int a_min, int a_max, bool tris = false, const ImVec2& third_point_offset = ImVec2(0,0));
|
662
|
|
- IMGUI_API void AddText(ImFont font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f);
|
|
686
|
+ IMGUI_API void AddText(ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f);
|
663
|
687
|
};
|
664
|
688
|
|
665
|
689
|
// Optional bitmap font data loader & renderer into vertices
|
666
|
|
-// #define ImFont to ImBitmapFont to use
|
667
|
690
|
// Using the .fnt format exported by BMFont
|
668
|
691
|
// - tool: http://www.angelcode.com/products/bmfont
|
669
|
692
|
// - file-format: http://www.angelcode.com/products/bmfont/doc/file_format.html
|
670
|
693
|
// Assume valid file data (won't handle invalid/malicious data)
|
671
|
|
-// Handle a subset of parameters.
|
672
|
|
-// - kerning pair are not supported (because ImGui code does per-character CalcTextSize calls, need to turn it into something more stateful to allow kerning)
|
673
|
|
-struct ImBitmapFont
|
|
694
|
+// Handle a subset of the options, namely:
|
|
695
|
+// - kerning pair are not supported (because some ImGui code does per-character CalcTextSize calls, need to turn it into something more state-ful to allow for kerning)
|
|
696
|
+struct ImFont
|
674
|
697
|
{
|
|
698
|
+ struct FntInfo;
|
|
699
|
+ struct FntCommon;
|
|
700
|
+ struct FntGlyph;
|
|
701
|
+ struct FntKerning;
|
|
702
|
+
|
|
703
|
+ // Settings
|
|
704
|
+ float Scale; // = 1.0f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
|
|
705
|
+ ImVec2 DisplayOffset; // = (0.0f,0.0f // Offset font rendering by xx pixels
|
|
706
|
+ ImVec2 TexUvForWhite; // = (0.0f,0.0f) // Font texture must have a white pixel at this UV coordinate. Adjust if you are using custom texture.
|
|
707
|
+ ImWchar FallbackChar; // = '?' // Replacement glyph is one isn't found.
|
|
708
|
+
|
|
709
|
+ // Data
|
|
710
|
+ unsigned char* Data; // Raw data, content of .fnt file
|
|
711
|
+ size_t DataSize; //
|
|
712
|
+ bool DataOwned; //
|
|
713
|
+ const FntInfo* Info; // (point into raw data)
|
|
714
|
+ const FntCommon* Common; // (point into raw data)
|
|
715
|
+ const FntGlyph* Glyphs; // (point into raw data)
|
|
716
|
+ size_t GlyphsCount; //
|
|
717
|
+ const FntKerning* Kerning; // (point into raw data) - NB: kerning is unsupported
|
|
718
|
+ size_t KerningCount; //
|
|
719
|
+ ImVector<const char*> Filenames; // (point into raw data)
|
|
720
|
+ ImVector<int> IndexLookup; // (built)
|
|
721
|
+ const FntGlyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
|
|
722
|
+
|
|
723
|
+ IMGUI_API ImFont();
|
|
724
|
+ IMGUI_API ~ImFont() { Clear(); }
|
|
725
|
+
|
|
726
|
+ IMGUI_API bool LoadFromMemory(const void* data, size_t data_size);
|
|
727
|
+ IMGUI_API bool LoadFromFile(const char* filename);
|
|
728
|
+ IMGUI_API void Clear();
|
|
729
|
+ IMGUI_API void BuildLookupTable();
|
|
730
|
+ IMGUI_API const FntGlyph* FindGlyph(unsigned short c) const;
|
|
731
|
+ IMGUI_API bool IsLoaded() const { return Info != NULL && Common != NULL && Glyphs != NULL; }
|
|
732
|
+
|
|
733
|
+ // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
|
|
734
|
+ // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
|
|
735
|
+ IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
|
|
736
|
+ IMGUI_API ImVec2 CalcTextSizeW(float size, float max_width, const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL) const; // wchar
|
|
737
|
+ IMGUI_API void RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawVert*& out_vertices, float wrap_width = 0.0f) const;
|
|
738
|
+
|
|
739
|
+ IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const;
|
|
740
|
+
|
675
|
741
|
#pragma pack(push, 1)
|
676
|
742
|
struct FntInfo
|
677
|
743
|
{
|
|
@@ -681,15 +747,13 @@ struct ImBitmapFont
|
681
|
747
|
unsigned short StretchH;
|
682
|
748
|
unsigned char AA;
|
683
|
749
|
unsigned char PaddingUp, PaddingRight, PaddingDown, PaddingLeft;
|
684
|
|
- unsigned char SpacingHoriz, SpacingVert;
|
685
|
|
- unsigned char Outline;
|
|
750
|
+ unsigned char SpacingHoriz, SpacingVert, Outline;
|
686
|
751
|
//char FontName[];
|
687
|
752
|
};
|
688
|
753
|
|
689
|
754
|
struct FntCommon
|
690
|
755
|
{
|
691
|
|
- unsigned short LineHeight;
|
692
|
|
- unsigned short Base;
|
|
756
|
+ unsigned short LineHeight, Base;
|
693
|
757
|
unsigned short ScaleW, ScaleH;
|
694
|
758
|
unsigned short Pages;
|
695
|
759
|
unsigned char BitField;
|
|
@@ -699,8 +763,7 @@ struct ImBitmapFont
|
699
|
763
|
struct FntGlyph
|
700
|
764
|
{
|
701
|
765
|
unsigned int Id;
|
702
|
|
- unsigned short X, Y;
|
703
|
|
- unsigned short Width, Height;
|
|
766
|
+ unsigned short X, Y, Width, Height;
|
704
|
767
|
signed short XOffset, YOffset;
|
705
|
768
|
signed short XAdvance;
|
706
|
769
|
unsigned char Page;
|
|
@@ -714,37 +777,4 @@ struct ImBitmapFont
|
714
|
777
|
signed short Amount;
|
715
|
778
|
};
|
716
|
779
|
#pragma pack(pop)
|
717
|
|
-
|
718
|
|
- unsigned char* Data; // Raw data, content of .fnt file
|
719
|
|
- size_t DataSize; //
|
720
|
|
- bool DataOwned; //
|
721
|
|
- const FntInfo* Info; // (point into raw data)
|
722
|
|
- const FntCommon* Common; // (point into raw data)
|
723
|
|
- const FntGlyph* Glyphs; // (point into raw data)
|
724
|
|
- size_t GlyphsCount; //
|
725
|
|
- const FntKerning* Kerning; // (point into raw data)
|
726
|
|
- size_t KerningCount; //
|
727
|
|
- int TabCount; // FIXME: mishandled (add fixed amount instead of aligning to column)
|
728
|
|
- ImVector<const char*> Filenames; // (point into raw data)
|
729
|
|
- ImVector<int> IndexLookup; // (built)
|
730
|
|
-
|
731
|
|
- IMGUI_API ImBitmapFont();
|
732
|
|
- IMGUI_API ~ImBitmapFont() { Clear(); }
|
733
|
|
-
|
734
|
|
- IMGUI_API bool LoadFromMemory(const void* data, size_t data_size);
|
735
|
|
- IMGUI_API bool LoadFromFile(const char* filename);
|
736
|
|
- IMGUI_API void Clear();
|
737
|
|
- IMGUI_API void BuildLookupTable();
|
738
|
|
- IMGUI_API const FntGlyph * FindGlyph(unsigned short c, const FntGlyph* fallback = NULL) const;
|
739
|
|
- IMGUI_API float GetFontSize() const { return (float)Info->FontSize; }
|
740
|
|
- IMGUI_API bool IsLoaded() const { return Info != NULL && Common != NULL && Glyphs != NULL; }
|
741
|
|
-
|
742
|
|
- // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
|
743
|
|
- // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
|
744
|
|
- IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
|
745
|
|
- IMGUI_API ImVec2 CalcTextSizeW(float size, float max_width, const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL) const; // wchar
|
746
|
|
- IMGUI_API void RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawVert*& out_vertices, float wrap_width = 0.0f) const;
|
747
|
|
-
|
748
|
|
-private:
|
749
|
|
- IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width, const FntGlyph* fallback_glyph) const;
|
750
|
780
|
};
|