trunk/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
r245119 | r245120 | |
1 | | // ImGui library v1.32 wip |
| 1 | // ImGui library v1.35 |
2 | 2 | // See ImGui::ShowTestWindow() for sample code. |
3 | 3 | // Read 'Programmer guide' below for notes on how to setup ImGui in your codebase. |
4 | 4 | // Get latest version at https://github.com/ocornut/imgui |
r245119 | r245120 | |
9 | 9 | Index |
10 | 10 | - MISSION STATEMENT |
11 | 11 | - END-USER GUIDE |
12 | | - PROGRAMMER GUIDE |
13 | | - API BREAKING CHANGES |
14 | | - TROUBLESHOOTING & FREQUENTLY ASKED QUESTIONS |
| 12 | - PROGRAMMER GUIDE (read me!) |
| 13 | - API BREAKING CHANGES (read me when you update!) |
| 14 | - FREQUENTLY ASKED QUESTIONS (FAQ) & TROUBLESHOOTING (read me!) |
15 | 15 | - ISSUES & TODO-LIST |
16 | 16 | - CODE |
17 | 17 | - SAMPLE CODE |
r245119 | r245120 | |
27 | 27 | - minimize screen real-estate usage |
28 | 28 | - minimize setup and maintenance |
29 | 29 | - minimize state storage on user side |
30 | | - portable, minimize dependencies, run on target (consoles, etc.) |
| 30 | - portable, minimize dependencies, run on target (consoles, phones, etc.) |
31 | 31 | - efficient runtime (NB- we do allocate when "growing" content - creating a window / opening a tree node for the first time, etc. - but a typical frame won't allocate anything) |
32 | | - read about immediate-mode GUI principles @ http://mollyrocket.com/861, http://mollyrocket.com/forums/index.html |
| 32 | - read about immediate-mode gui principles @ http://mollyrocket.com/861, http://mollyrocket.com/forums/index.html |
33 | 33 | |
34 | 34 | Designed for developers and content-creators, not the typical end-user! Some of the weaknesses includes: |
35 | 35 | - doesn't look fancy, doesn't animate |
36 | 36 | - limited layout features, intricate layouts are typically crafted in code |
37 | | - occasionally use statically sized buffers for string manipulations - won't crash, but some long text may be clipped |
| 37 | - occasionally uses statically sized buffers for string manipulations - won't crash, but some long text may be clipped. functions like ImGui::TextUnformatted() don't have such restriction. |
38 | 38 | |
39 | 39 | |
40 | 40 | END-USER GUIDE |
r245119 | r245120 | |
63 | 63 | PROGRAMMER GUIDE |
64 | 64 | ================ |
65 | 65 | |
66 | | - your code creates the UI, if your code doesn't run the UI is gone! == dynamic UI, no construction step, less data retention on your side, no state duplication, less sync, less errors. |
67 | | - call and read ImGui::ShowTestWindow() for user-side sample code |
| 66 | - read the FAQ below this section! |
| 67 | - your code creates the UI, if your code doesn't run the UI is gone! == very dynamic UI, no construction/destructions steps, less data retention on your side, no state duplication, less sync, less bugs. |
| 68 | - call and read ImGui::ShowTestWindow() for sample code demonstrating most features. |
68 | 69 | - see examples/ folder for standalone sample applications. |
69 | 70 | - customization: use the style editor or PushStyleColor/PushStyleVar to tweak the look of the interface (e.g. if you want a more compact UI or a different color scheme). |
70 | 71 | |
71 | | |
72 | 72 | - getting started: |
73 | 73 | - initialisation: call ImGui::GetIO() and fill the 'Settings' data. |
74 | 74 | - every frame: |
r245119 | r245120 | |
96 | 96 | // TODO: store your texture pointer/identifier in 'io.Fonts->TexID' |
97 | 97 | |
98 | 98 | // Application main loop |
99 | | for (;;) |
| 99 | while (true) |
100 | 100 | { |
101 | 101 | // 1) get low-level input |
102 | 102 | // e.g. on Win32, GetKeyboardState(), or poll your events, etc. |
r245119 | r245120 | |
129 | 129 | Occasionally introducing changes that are breaking the API. The breakage are generally minor and easy to fix. |
130 | 130 | Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code. |
131 | 131 | |
| 132 | - 2015/03/08 (1.35) - renamed style.ScrollBarWidth to style.ScrollbarWidth |
| 133 | - 2015/02/27 (1.34) - renamed OpenNextNode(bool) to SetNextTreeNodeOpened(bool, ImGuiSetCond), kept inline redirection function. |
| 134 | - 2015/02/27 (1.34) - renamed ImGuiSetCondition_*** to ImGuiSetCond_***, and _FirstUseThisSession becomes _Once. |
| 135 | - 2015/02/11 (1.32) - changed text input callback ImGuiTextEditCallback return type from void-->int. reserved for future use, return 0 for now. |
132 | 136 | - 2015/02/10 (1.32) - renamed GetItemWidth() to CalcItemWidth() to clarify its evolving behavior |
133 | 137 | - 2015/02/08 (1.31) - renamed GetTextLineSpacing() to GetTextLineHeightWithSpacing() |
134 | 138 | - 2015/02/01 (1.31) - removed IO.MemReallocFn (unused) |
r245119 | r245120 | |
164 | 168 | - 2014/08/28 (1.09) - changed the behavior of IO.PixelCenterOffset following various rendering fixes |
165 | 169 | |
166 | 170 | |
167 | | TROUBLESHOOTING & FREQUENTLY ASKED QUESTIONS |
168 | | ============================================ |
| 171 | FREQUENTLY ASKED QUESTIONS (FAQ) & TROUBLESHOOTING |
| 172 | ================================================== |
169 | 173 | |
170 | 174 | If text or lines are blurry when integrating ImGui in your engine: |
| 175 | |
171 | 176 | - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f) |
172 | 177 | |
173 | | If you are confused about the meaning or use of ID in ImGui: |
174 | | - many widgets requires state to be carried over multiple frames (most typically ImGui often wants remember what is the "active" widget). |
175 | | to do so they need an unique ID. unique ID are typically derived from a string label, an indice or a pointer. |
176 | | when you call Button("OK") the button shows "OK" and also use "OK" as an ID. |
| 178 | A primer on the meaning and use of ID in ImGui: |
| 179 | |
| 180 | - widgets require state to be carried over multiple frames (most typically ImGui often needs to remember what is the "active" widget). |
| 181 | to do so they need an unique ID. unique ID are typically derived from a string label, an integer index or a pointer. |
| 182 | |
| 183 | Button("OK"); // Label = "OK", ID = hash of "OK" |
| 184 | Button("Cancel"); // Label = "Cancel", ID = hash of "Cancel" |
| 185 | |
177 | 186 | - ID are uniquely scoped within Windows so no conflict can happen if you have two buttons called "OK" in two different Windows. |
178 | | within a same Window, use PushID() / PopID() to easily create scopes and avoid ID conflicts. |
179 | | so if you have a loop creating "multiple" items, you can use PushID() / PopID() with the index of each item, or their pointer, etc. |
180 | | some functions like TreeNode() implicitly creates a scope for you by calling PushID() |
181 | | - when dealing with trees, ID are important because you want to preserve the opened/closed state of tree nodes. |
182 | | depending on your use cases you may want to use strings, indices or pointers as ID. experiment and see what makes more sense! |
183 | | e.g. When displaying a single object that may change over time, using a static string as ID will preserve your node open/closed state when the targeted object change |
184 | | e.g. When displaying a list of objects, using indices or pointers as ID will preserve the node open/closed state per object |
185 | | - when passing a label you can optionally specify extra unique ID information within the same string using "##". This helps solving the simpler collision cases. |
186 | | e.g. "Label" display "Label" and uses "Label" as ID |
187 | | e.g. "Label##Foobar" display "Label" and uses "Label##Foobar" as ID |
188 | | e.g. "##Foobar" display an empty label and uses "##Foobar" as ID |
189 | | - read articles about immediate-mode ui principles (see web links) to understand the requirement and use of ID. |
190 | 187 | |
| 188 | - when passing a label you can optionally specify extra unique ID information within string itself. This helps solving the simpler collision cases. |
| 189 | use "##" to pass a complement to the ID that won't be visible to the end-user: |
| 190 | |
| 191 | Button("Play##0"); // Label = "Play", ID = hash of "Play##0" |
| 192 | Button("Play##1"); // Label = "Play", ID = hash of "Play##1" (different from above) |
| 193 | |
| 194 | use "###" to pass a label that isn't part of ID. You can use that to change labels while preserving a constant ID. |
| 195 | |
| 196 | Button("Hello###ID"; // Label = "Hello", ID = hash of "ID" |
| 197 | Button("World###ID"; // Label = "World", ID = hash of "ID" (same as above) |
| 198 | |
| 199 | - use PushID() / PopID() to create scopes and avoid ID conflicts within the same Window: |
| 200 | |
| 201 | Button("Click"); // Label = "Click", ID = hash of "Click" |
| 202 | PushID("node"); |
| 203 | Button("Click"); // Label = "Click", ID = hash of "node" and "Click" |
| 204 | for (int i = 0; i < 100; i++) |
| 205 | { |
| 206 | PushID(i); |
| 207 | Button("Click"); // Label = "Click", ID = hash of "node" and i and "label" |
| 208 | PopID(); |
| 209 | } |
| 210 | PopID(); |
| 211 | PushID(my_ptr); |
| 212 | Button("Click"); // Label = "Click", ID = hash of ptr and "Click" |
| 213 | PopID(); |
| 214 | |
| 215 | so if you have a loop creating multiple items, you can use PushID() / PopID() with the index of each item, or their pointer, etc. |
| 216 | some functions like TreeNode() implicitly creates a scope for you by calling PushID(). |
| 217 | |
| 218 | - when working with trees, ID are used to preserve the opened/closed state of tree nodes. |
| 219 | depending on your use cases you may want to use strings, indices or pointers as ID. |
| 220 | e.g. when displaying a single object that may change over time (1-1 relationship), using a static string as ID will preserve your node open/closed state when the targeted object change. |
| 221 | e.g. when displaying a list of objects, using indices or pointers as ID will preserve the node open/closed state differently. experiment and see what makes more sense! |
| 222 | |
191 | 223 | If you want to load a different font than the default (ProggyClean.ttf, size 13) |
192 | 224 | |
193 | 225 | io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels); |
r245119 | r245120 | |
204 | 236 | |
205 | 237 | io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, io.Fonts->GetGlyphRangesJapanese()); // Load Japanese characters |
206 | 238 | io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8() |
| 239 | io.ImeWindowHandle = MY_HWND; // To input using Microsoft IME, give ImGui the hwnd of your application |
207 | 240 | |
208 | | If you want to input Japanese/Chinese/Korean in the text input widget: |
209 | | |
210 | | - when loading the font, pass a range that contains the characters you need, e.g.: io.Fonts->GetGlyphRangesJapanese() |
211 | | - to have the Microsoft IME cursor appears at the right location in the screen, setup a handler for the io.ImeSetInputScreenPosFn function: |
212 | | |
213 | | #include <Windows.h> |
214 | | #include <Imm.h> |
215 | | static void ImImpl_ImeSetInputScreenPosFn(int x, int y) |
216 | | { |
217 | | // Notify OS Input Method Editor of text input position |
218 | | HWND hwnd = glfwGetWin32Window(window); |
219 | | if (HIMC himc = ImmGetContext(hwnd)) |
220 | | { |
221 | | COMPOSITIONFORM cf; |
222 | | cf.ptCurrentPos.x = x; |
223 | | cf.ptCurrentPos.y = y; |
224 | | cf.dwStyle = CFS_FORCE_POSITION; |
225 | | ImmSetCompositionWindow(himc, &cf); |
226 | | } |
227 | | } |
228 | | |
229 | | // Set pointer to handler in ImGuiIO structure |
230 | | io.ImeSetInputScreenPosFn = ImImpl_ImeSetInputScreenPosFn; |
231 | | |
232 | 241 | - tip: the construct 'IMGUI_ONCE_UPON_A_FRAME { ... }' will run the block of code only once a frame. You can use it to quickly add custom UI in the middle of a deep nested inner loop in your code. |
233 | 242 | - tip: you can create widgets without a Begin()/End() block, they will go in an implicit window called "Debug" |
234 | 243 | - tip: you can call Begin() multiple times with the same name during the same frame, it will keep appending to the same window. |
r245119 | r245120 | |
254 | 263 | - main: IsItemHovered() returns true even if mouse is active on another widget (e.g. dragging outside of sliders). Maybe not a sensible default? Add parameter or alternate function? |
255 | 264 | - main: IsItemHovered() make it more consistent for various type of widgets, widgets with multiple components, etc. also effectively IsHovered() region sometimes differs from hot region, e.g tree nodes |
256 | 265 | - main: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode? |
257 | | - scrollbar: use relative mouse movement when first-clicking inside of scroll grab box. |
258 | | - scrollbar: make the grab visible and a minimum size for long scroll regions |
259 | 266 | !- input number: very large int not reliably supported because of int<>float conversions. |
260 | 267 | - input number: optional range min/max for Input*() functions |
261 | 268 | - input number: holding [-]/[+] buttons could increase the step speed non-linearly (or user-controlled) |
r245119 | r245120 | |
268 | 275 | - columns: declare column set (each column: fixed size, %, fill, distribute default size among fills) |
269 | 276 | - columns: columns header to act as button (~sort op) and allow resize/reorder |
270 | 277 | - columns: user specify columns size |
| 278 | - columns: tree node example, removing the last NextColumn() makes a padding difference (it should not) |
271 | 279 | - combo: turn child handling code into pop up helper |
272 | 280 | - combo: contents should extends to fit label if combo widget is small |
273 | 281 | - listbox: multiple selection |
r245119 | r245120 | |
281 | 289 | - plot: add a helper e.g. Plot(char* label, float value, float time_span=2.0f) that stores values and Plot them for you - probably another function name. and/or automatically allow to plot ANY displayed value (more reliance on stable ID) |
282 | 290 | - file selection widget -> build the tool in our codebase to improve model-dialog idioms |
283 | 291 | - slider: allow using the [-]/[+] buttons used by InputFloat()/InputInt() |
284 | | - slider: initial absolute click is imprecise. change to relative movement slider? hide mouse cursor, allow more precise input using less screen-space. |
285 | | - text edit: clean up the mess caused by converting UTF-8 <> wchar. the code is rather ineficient right now. |
| 292 | - slider: initial absolute click is imprecise. change to relative movement slider? hide mouse cursor, allow more precise input using less screen-space. same as scrollbar. |
| 293 | - text edit: clean up the mess caused by converting UTF-8 <> wchar. the code is rather inefficient right now. |
286 | 294 | - text edit: centered text for slider as input text so it matches typical positioning. |
287 | 295 | - text edit: flag to disable live update of the user buffer. |
288 | 296 | - text edit: field resize behavior - field could stretch when being edited? hover tooltip shows more text? |
r245119 | r245120 | |
293 | 301 | ! style: store rounded corners in texture to use 1 quad per corner (filled and wireframe). so rounding have minor cost. |
294 | 302 | - style: checkbox: padding for "active" color should be a multiplier of the |
295 | 303 | - style: colorbox not always square? |
| 304 | - text: simple markup language for color change? |
296 | 305 | - log: LogButtons() options for specifying depth and/or hiding depth slider |
297 | 306 | - log: have more control over the log scope (e.g. stop logging when leaving current tree node scope) |
298 | 307 | - log: be able to right-click and log a window or tree-node into tty/file/clipboard / generalized context menu? |
r245119 | r245120 | |
340 | 349 | #pragma clang diagnostic ignored "-Wformat-nonliteral" // warning : format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code. |
341 | 350 | #pragma clang diagnostic ignored "-Wexit-time-destructors" // warning : declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals. |
342 | 351 | #pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference it. |
343 | | #pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion chanjges signedness // |
344 | | #elif defined(__GNUC__) |
345 | | #pragma GCC diagnostic ignored "-Wtype-limits" |
346 | | #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" |
347 | | #pragma GCC diagnostic ignored "-Wunused-function" |
| 352 | #pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness // |
348 | 353 | #endif |
| 354 | #ifdef __GNUC__ |
| 355 | #pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used |
| 356 | #pragma GCC diagnostic ignored "-Wunused-parameter" // warning: unused parameter ‘xxxx’ |
| 357 | #pragma GCC diagnostic ignored "-Wtype-limits" // warning: comparison is always true due to limited range of data type |
| 358 | #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // warning: ‘xxxx’ may be used uninitialized in this function |
| 359 | #endif |
349 | 360 | |
350 | 361 | //------------------------------------------------------------------------- |
351 | 362 | // STB libraries implementation |
r245119 | r245120 | |
384 | 395 | #endif |
385 | 396 | #include "stb_truetype.h" |
386 | 397 | |
387 | | #define STB_TEXTEDIT_STRING ImGuiTextEditState |
388 | | #define STB_TEXTEDIT_CHARTYPE ImWchar |
| 398 | #define STB_TEXTEDIT_STRING ImGuiTextEditState |
| 399 | #define STB_TEXTEDIT_CHARTYPE ImWchar |
389 | 400 | #include "stb_textedit.h" |
390 | 401 | |
391 | 402 | #ifdef __clang__ |
r245119 | r245120 | |
401 | 412 | // Forward Declarations |
402 | 413 | //------------------------------------------------------------------------- |
403 | 414 | |
| 415 | struct ImGuiColMod; |
| 416 | struct ImGuiStyleMod; |
404 | 417 | struct ImGuiAabb; |
| 418 | struct ImGuiDrawContext; |
| 419 | struct ImGuiTextEditState; |
| 420 | struct ImGuiIniData; |
| 421 | struct ImGuiState; |
| 422 | struct ImGuiWindow; |
405 | 423 | |
406 | 424 | static bool ButtonBehaviour(const ImGuiAabb& bb, const ImGuiID& id, bool* out_hovered, bool* out_held, bool allow_key_modifiers, bool repeat = false, bool pressed_on_click = false); |
407 | 425 | static void LogText(const ImVec2& ref_pos, const char* text, const char* text_end = NULL); |
r245119 | r245120 | |
413 | 431 | static void RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale = 1.0f, bool shadow = false); |
414 | 432 | |
415 | 433 | static void SetFont(ImFont* font); |
416 | | static bool ItemAdd(const ImGuiAabb& aabb, const ImGuiID* id); |
| 434 | static bool ItemAdd(const ImGuiAabb& bb, const ImGuiID* id); |
417 | 435 | static void ItemSize(ImVec2 size, ImVec2* adjust_start_offset = NULL); |
418 | | static void ItemSize(const ImGuiAabb& aabb, ImVec2* adjust_start_offset = NULL); |
| 436 | static void ItemSize(const ImGuiAabb& bb, ImVec2* adjust_start_offset = NULL); |
419 | 437 | static void PushColumnClipRect(int column_index = -1); |
420 | | static bool IsClipped(const ImGuiAabb& aabb); |
| 438 | static bool IsClipped(const ImGuiAabb& bb); |
421 | 439 | |
422 | | static bool IsMouseHoveringBox(const ImGuiAabb& box); |
| 440 | static bool IsMouseHoveringBox(const ImGuiAabb& bb); |
423 | 441 | static bool IsKeyPressedMap(ImGuiKey key, bool repeat = true); |
424 | 442 | |
| 443 | static void Scrollbar(ImGuiWindow* window); |
425 | 444 | static bool CloseWindowButton(bool* p_opened = NULL); |
426 | 445 | static void FocusWindow(ImGuiWindow* window); |
427 | 446 | static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs); |
r245119 | r245120 | |
436 | 455 | static size_t ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args); |
437 | 456 | |
438 | 457 | // Helpers: Misc |
439 | | static ImU32 ImCrc32(const void* data, size_t data_size, ImU32 seed); |
| 458 | static ImU32 ImHash(const void* data, size_t data_size, ImU32 seed); |
440 | 459 | static bool ImLoadFileToMemory(const char* filename, const char* file_open_mode, void** out_file_data, size_t* out_file_size, size_t padding_bytes = 0); |
441 | | static int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; } |
| 460 | static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; } |
| 461 | static inline bool ImCharIsSpace(int c) { return c == ' ' || c == '\t' || c == 0x3000; } |
442 | 462 | |
443 | 463 | // Helpers: UTF-8 <> wchar |
444 | 464 | static int ImTextCharToUtf8(char* buf, size_t buf_size, unsigned int in_char); // return output UTF-8 bytes count |
445 | 465 | static ptrdiff_t ImTextStrToUtf8(char* buf, size_t buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count |
446 | 466 | static int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // return input UTF-8 bytes count |
447 | | static ptrdiff_t ImTextStrFromUtf8(ImWchar* buf, size_t buf_size, const char* in_text, const char* in_text_end); // return input UTF-8 bytes count |
| 467 | static ptrdiff_t ImTextStrFromUtf8(ImWchar* buf, size_t buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count |
448 | 468 | static int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count) |
449 | | static int ImTextCountUtf8BytesFromWchar(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string as UTF-8 code-points |
| 469 | static int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string as UTF-8 code-points |
450 | 470 | |
451 | 471 | //----------------------------------------------------------------------------- |
452 | 472 | // Platform dependent default implementations |
r245119 | r245120 | |
454 | 474 | |
455 | 475 | static const char* GetClipboardTextFn_DefaultImpl(); |
456 | 476 | static void SetClipboardTextFn_DefaultImpl(const char* text); |
| 477 | static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y); |
457 | 478 | |
458 | 479 | //----------------------------------------------------------------------------- |
459 | 480 | // Texture Atlas data |
r245119 | r245120 | |
486 | 507 | WindowFillAlphaDefault = 0.70f; // Default alpha of window background, if not specified in ImGui::Begin() |
487 | 508 | TreeNodeSpacing = 22.0f; // Horizontal spacing when entering a tree node |
488 | 509 | ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns |
489 | | ScrollBarWidth = 16.0f; // Width of the vertical scroll bar |
| 510 | ScrollbarWidth = 16.0f; // Width of the vertical scrollbar |
| 511 | GrabMinSize = 10.0f; // Minimum width/height of a slider or scrollbar grab |
490 | 512 | |
491 | 513 | Colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); |
492 | 514 | Colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); |
r245119 | r245120 | |
529 | 551 | Colors[ImGuiCol_TooltipBg] = ImVec4(0.05f, 0.05f, 0.10f, 0.90f); |
530 | 552 | } |
531 | 553 | |
532 | | // Statically allocated font atlas. This is merely a maneuver to keep its definition at the bottom of the .H file. |
533 | | // Because we cannot new() at this point (before users may define IO.MemAllocFn) |
| 554 | // Statically allocated font atlas. This is merely a maneuver to keep ImFontAtlas definition at the bottom of the .h file (otherwise it'd be inside ImGuiIO) |
| 555 | // Also we wouldn't be able to new() one at this point, before users may define IO.MemAllocFn. |
534 | 556 | static ImFontAtlas GDefaultFontAtlas; |
535 | 557 | |
536 | 558 | ImGuiIO::ImGuiIO() |
r245119 | r245120 | |
557 | 579 | MemFreeFn = free; |
558 | 580 | GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations |
559 | 581 | SetClipboardTextFn = SetClipboardTextFn_DefaultImpl; |
560 | | ImeSetInputScreenPosFn = NULL; |
| 582 | ImeSetInputScreenPosFn = ImeSetInputScreenPosFn_DefaultImpl; |
561 | 583 | } |
562 | 584 | |
563 | 585 | // Pass in translated ASCII characters for text input. |
564 | 586 | // - with glfw you can get those from the callback set in glfwSetCharCallback() |
565 | | // - on Windows you can get those using ToAscii+keyboard state, or via the VM_CHAR message |
| 587 | // - on Windows you can get those using ToAscii+keyboard state, or via the WM_CHAR message |
566 | 588 | void ImGuiIO::AddInputCharacter(ImWchar c) |
567 | 589 | { |
568 | 590 | const size_t n = ImStrlenW(InputCharacters); |
r245119 | r245120 | |
588 | 610 | #define IM_INT_MAX 2147483647 |
589 | 611 | #endif |
590 | 612 | |
591 | | // Play it nice with Windows users. Notepad in 2014 still doesn't display text data with Unix-style \n. |
| 613 | // Play it nice with Windows users. Notepad in 2015 still doesn't display text data with Unix-style \n. |
592 | 614 | #ifdef _MSC_VER |
593 | 615 | #define STR_NEWLINE "\r\n" |
594 | 616 | #else |
r245119 | r245120 | |
647 | 669 | static size_t ImStrlenW(const ImWchar* str) |
648 | 670 | { |
649 | 671 | size_t n = 0; |
650 | | while (*str++) |
651 | | n++; |
| 672 | while (*str++) n++; |
652 | 673 | return n; |
653 | 674 | } |
654 | 675 | |
r245119 | r245120 | |
675 | 696 | } |
676 | 697 | |
677 | 698 | // Pass data_size==0 for zero-terminated string |
678 | | static ImU32 ImCrc32(const void* data, size_t data_size, ImU32 seed = 0) |
| 699 | // Try to replace with FNV1a hash? |
| 700 | static ImU32 ImHash(const void* data, size_t data_size, ImU32 seed = 0) |
679 | 701 | { |
680 | 702 | static ImU32 crc32_lut[256] = { 0 }; |
681 | 703 | if (!crc32_lut[1]) |
r245119 | r245120 | |
689 | 711 | crc32_lut[i] = crc; |
690 | 712 | } |
691 | 713 | } |
692 | | ImU32 crc = ~seed; |
| 714 | |
| 715 | seed = ~seed; |
| 716 | ImU32 crc = seed; |
693 | 717 | const unsigned char* current = (const unsigned char*)data; |
694 | 718 | |
695 | 719 | if (data_size > 0) |
r245119 | r245120 | |
702 | 726 | { |
703 | 727 | // Zero-terminated string |
704 | 728 | while (unsigned char c = *current++) |
| 729 | { |
| 730 | // We support a syntax of "label###id" where only "###id" is included in the hash, and only "label" gets displayed. |
| 731 | // Because this syntax is rarely used we are optimizing for the common case. |
| 732 | // - If we reach ### in the string we discard the hash so far and reset to the seed. |
| 733 | // - We don't do 'current += 2; continue;' after handling ### to keep the code smaller. |
| 734 | if (c == '#' && current[0] == '#' && current[1] == '#') |
| 735 | crc = seed; |
| 736 | |
705 | 737 | crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c]; |
| 738 | } |
706 | 739 | } |
707 | 740 | return ~crc; |
708 | 741 | } |
r245119 | r245120 | |
841 | 874 | ImVec2 PreviousValue; |
842 | 875 | }; |
843 | 876 | |
844 | | struct ImGuiAabb // 2D axis aligned bounding-box |
| 877 | struct ImGuiAabb // 2D axis aligned bounding-box |
845 | 878 | { |
846 | 879 | ImVec2 Min; |
847 | 880 | ImVec2 Max; |
r245119 | r245120 | |
887 | 920 | ImVector<float> TextWrapPos; |
888 | 921 | ImGuiColorEditMode ColorEditMode; |
889 | 922 | ImGuiStorage* StateStorage; |
890 | | int OpenNextNode; // FIXME: Reformulate this feature like SetNextWindowCollapsed() API |
891 | 923 | |
892 | 924 | float ColumnsStartX; // Start position from left of window (increased by TreePush/TreePop, etc.) |
893 | 925 | float ColumnsOffsetX; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API. |
r245119 | r245120 | |
898 | 930 | float ColumnsCellMaxY; |
899 | 931 | bool ColumnsShowBorders; |
900 | 932 | ImGuiID ColumnsSetID; |
| 933 | ImVector<float> ColumnsOffsetsT; // Columns offset normalized 0.0 (far left) -> 1.0 (far right) |
901 | 934 | |
902 | 935 | ImGuiDrawContext() |
903 | 936 | { |
r245119 | r245120 | |
909 | 942 | LastItemAabb = ImGuiAabb(0.0f,0.0f,0.0f,0.0f); |
910 | 943 | LastItemHovered = false; |
911 | 944 | StateStorage = NULL; |
912 | | OpenNextNode = -1; |
913 | 945 | |
914 | 946 | ColumnsStartX = 0.0f; |
915 | 947 | ColumnsOffsetX = 0.0f; |
r245119 | r245120 | |
925 | 957 | // Internal state of the currently focused/edited text input box |
926 | 958 | struct ImGuiTextEditState |
927 | 959 | { |
| 960 | ImGuiID Id; // widget id owning the text state |
928 | 961 | ImWchar Text[1024]; // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer. |
929 | | char InitialText[1024*3+1]; // backup of end-user buffer at the time of focus (in UTF-8, unconverted) |
930 | | size_t BufSize; // end-user buffer size, <= 1024 (or increase above) |
| 962 | char InitialText[1024*4+1]; // backup of end-user buffer at the time of focus (in UTF-8, unaltered) |
| 963 | int CurLenA, CurLenW; // we need to maintain our buffer length in both UTF-8 and wchar format. |
| 964 | size_t BufSizeA; // end-user buffer size, <= 1024 (or increase above) |
931 | 965 | float Width; // widget width |
932 | 966 | float ScrollX; |
933 | 967 | STB_TexteditState StbState; |
934 | 968 | float CursorAnim; |
935 | | ImVec2 LastCursorPos; // Cursor position in screen space to be used by IME callback. |
| 969 | ImVec2 InputCursorScreenPos; // Cursor position in screen space to be used by IME callback. |
936 | 970 | bool SelectedAllMouseLock; |
937 | 971 | ImFont* Font; |
938 | 972 | float FontSize; |
r245119 | r245120 | |
954 | 988 | static void RenderTextScrolledClipped(ImFont* font, float font_size, const char* text, ImVec2 pos_base, float width, float scroll_x); |
955 | 989 | }; |
956 | 990 | |
| 991 | // Data saved in imgui.ini file |
957 | 992 | struct ImGuiIniData |
958 | 993 | { |
959 | 994 | char* Name; |
| 995 | ImGuiID ID; |
960 | 996 | ImVec2 Pos; |
961 | 997 | ImVec2 Size; |
962 | 998 | bool Collapsed; |
r245119 | r245120 | |
965 | 1001 | ~ImGuiIniData() { if (Name) { ImGui::MemFree(Name); Name = NULL; } } |
966 | 1002 | }; |
967 | 1003 | |
| 1004 | // Main state for ImGui |
968 | 1005 | struct ImGuiState |
969 | 1006 | { |
970 | 1007 | bool Initialized; |
r245119 | r245120 | |
987 | 1024 | ImGuiID ActiveId; |
988 | 1025 | ImGuiID ActiveIdPreviousFrame; |
989 | 1026 | bool ActiveIdIsAlive; |
| 1027 | bool ActiveIdIsFocusedOnly; // Set only by active widget. Denote focus but no active interaction. |
| 1028 | ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window. Only valid if ActiveID is the "#MOVE" identifier of a window. |
990 | 1029 | float SettingsDirtyTimer; |
991 | 1030 | ImVector<ImGuiIniData*> Settings; |
992 | 1031 | ImVector<ImGuiColMod> ColorModifiers; |
993 | 1032 | ImVector<ImGuiStyleMod> StyleModifiers; |
994 | 1033 | ImVector<ImFont*> FontStack; |
| 1034 | |
995 | 1035 | ImVec2 SetNextWindowPosVal; |
996 | | ImGuiSetCondition SetNextWindowPosCond; |
| 1036 | ImGuiSetCond SetNextWindowPosCond; |
997 | 1037 | ImVec2 SetNextWindowSizeVal; |
998 | | ImGuiSetCondition SetNextWindowSizeCond; |
| 1038 | ImGuiSetCond SetNextWindowSizeCond; |
999 | 1039 | bool SetNextWindowCollapsedVal; |
1000 | | ImGuiSetCondition SetNextWindowCollapsedCond; |
| 1040 | ImGuiSetCond SetNextWindowCollapsedCond; |
| 1041 | bool SetNextWindowFocus; |
| 1042 | bool SetNextTreeNodeOpenedVal; |
| 1043 | ImGuiSetCond SetNextTreeNodeOpenedCond; |
1001 | 1044 | |
1002 | 1045 | // Render |
1003 | 1046 | ImVector<ImDrawList*> RenderDrawLists; |
r245119 | r245120 | |
1008 | 1051 | ImGuiID SliderAsInputTextId; |
1009 | 1052 | ImGuiStorage ColorEditModeStorage; // for user selection |
1010 | 1053 | ImGuiID ActiveComboID; |
| 1054 | float ScrollbarClickDeltaToGrabCenter; // distance between mouse and center of grab box, normalized in parent space |
1011 | 1055 | char Tooltip[1024]; |
1012 | 1056 | char* PrivateClipboard; // if no custom clipboard handler is defined |
1013 | 1057 | |
r245119 | r245120 | |
1018 | 1062 | int LogStartDepth; |
1019 | 1063 | int LogAutoExpandMaxDepth; |
1020 | 1064 | |
| 1065 | // Misc |
| 1066 | float FramerateSecPerFrame[120]; // calculate estimate of framerate for user |
| 1067 | int FramerateSecPerFrameIdx; |
| 1068 | float FramerateSecPerFrameAccum; |
| 1069 | |
1021 | 1070 | ImGuiState() |
1022 | 1071 | { |
1023 | 1072 | Initialized = false; |
| 1073 | Font = NULL; |
| 1074 | FontSize = 0.0f; |
| 1075 | FontTexUvWhitePixel = ImVec2(0.0f, 0.0f); |
| 1076 | |
1024 | 1077 | Time = 0.0f; |
1025 | 1078 | FrameCount = 0; |
1026 | 1079 | FrameCountRendered = -1; |
r245119 | r245120 | |
1028 | 1081 | FocusedWindow = NULL; |
1029 | 1082 | HoveredWindow = NULL; |
1030 | 1083 | HoveredRootWindow = NULL; |
| 1084 | HoveredId = 0; |
| 1085 | ActiveId = 0; |
| 1086 | ActiveIdPreviousFrame = 0; |
1031 | 1087 | ActiveIdIsAlive = false; |
| 1088 | ActiveIdIsFocusedOnly = false; |
| 1089 | MovedWindow = NULL; |
1032 | 1090 | SettingsDirtyTimer = 0.0f; |
| 1091 | |
1033 | 1092 | SetNextWindowPosVal = ImVec2(0.0f, 0.0f); |
1034 | 1093 | SetNextWindowPosCond = 0; |
1035 | 1094 | SetNextWindowSizeVal = ImVec2(0.0f, 0.0f); |
1036 | 1095 | SetNextWindowSizeCond = 0; |
1037 | 1096 | SetNextWindowCollapsedVal = false; |
1038 | 1097 | SetNextWindowCollapsedCond = 0; |
| 1098 | SetNextWindowFocus = false; |
| 1099 | SetNextTreeNodeOpenedVal = false; |
| 1100 | SetNextTreeNodeOpenedCond = 0; |
| 1101 | |
1039 | 1102 | SliderAsInputTextId = 0; |
1040 | 1103 | ActiveComboID = 0; |
| 1104 | ScrollbarClickDeltaToGrabCenter = 0.0f; |
1041 | 1105 | memset(Tooltip, 0, sizeof(Tooltip)); |
1042 | 1106 | PrivateClipboard = NULL; |
| 1107 | |
1043 | 1108 | LogEnabled = false; |
1044 | 1109 | LogFile = NULL; |
| 1110 | LogClipboard = NULL; |
1045 | 1111 | LogStartDepth = 0; |
1046 | 1112 | LogAutoExpandMaxDepth = 2; |
1047 | | LogClipboard = NULL; |
| 1113 | |
| 1114 | memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame)); |
| 1115 | FramerateSecPerFrameIdx = 0; |
| 1116 | FramerateSecPerFrameAccum = 0.0f; |
1048 | 1117 | } |
1049 | 1118 | }; |
1050 | 1119 | |
r245119 | r245120 | |
1060 | 1129 | ImVec2 Pos; // Position rounded-up to nearest pixel |
1061 | 1130 | ImVec2 Size; // Current size (==SizeFull or collapsed title bar size) |
1062 | 1131 | ImVec2 SizeFull; // Size when non collapsed |
1063 | | ImVec2 SizeContentsFit; // Size of contents (extents reach by the drawing cursor) - may not fit within Size. |
| 1132 | ImVec2 SizeContents; // Size of contents (== extents reach of the drawing cursor) from previous frame |
| 1133 | ImVec2 SizeContentsCurrent; // Size of contents, currently extending |
1064 | 1134 | float ScrollY; |
1065 | 1135 | float NextScrollY; |
1066 | 1136 | bool ScrollbarY; |
r245119 | r245120 | |
1070 | 1140 | bool SkipItems; // == Visible && !Collapsed |
1071 | 1141 | int AutoFitFrames; |
1072 | 1142 | bool AutoFitOnlyGrows; |
1073 | | int SetWindowPosAllowFlags; // bit ImGuiSetCondition_*** specify if SetWindowPos() call is allowed with this particular flag. |
1074 | | int SetWindowSizeAllowFlags; // bit ImGuiSetCondition_*** specify if SetWindowSize() call is allowed with this particular flag. |
1075 | | int SetWindowCollapsedAllowFlags; // bit ImGuiSetCondition_*** specify if SetWindowCollapsed() call is allowed with this particular flag. |
| 1143 | int SetWindowPosAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowPos() call is allowed with this particular flag. |
| 1144 | int SetWindowSizeAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowSize() call is allowed with this particular flag. |
| 1145 | int SetWindowCollapsedAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowCollapsed() call is allowed with this particular flag. |
1076 | 1146 | |
1077 | 1147 | ImGuiDrawContext DC; |
1078 | 1148 | ImVector<ImGuiID> IDStack; |
1079 | 1149 | ImVector<ImVec4> ClipRectStack; // Scissoring / clipping rectangle. x1, y1, x2, y2. |
| 1150 | ImGuiAabb ClippedAabb; // = ClipRectStack.front() after setup in Begin() |
1080 | 1151 | int LastFrameDrawn; |
1081 | 1152 | float ItemWidthDefault; |
1082 | 1153 | ImGuiStorage StateStorage; |
r245119 | r245120 | |
1109 | 1180 | ImVec2 CursorPos() const { return DC.CursorPos; } |
1110 | 1181 | float TitleBarHeight() const { return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0 : FontSize() + GImGui->Style.FramePadding.y * 2.0f; } |
1111 | 1182 | ImGuiAabb TitleBarAabb() const { return ImGuiAabb(Pos, Pos + ImVec2(SizeFull.x, TitleBarHeight())); } |
1112 | | ImVec2 WindowPadding() const { return ((Flags & ImGuiWindowFlags_ChildWindow) && !(Flags & ImGuiWindowFlags_ShowBorders)) ? ImVec2(1,1) : GImGui->Style.WindowPadding; } |
| 1183 | ImVec2 WindowPadding() const { return ((Flags & ImGuiWindowFlags_ChildWindow) && !(Flags & ImGuiWindowFlags_ShowBorders)) ? ImVec2(0,0) : GImGui->Style.WindowPadding; } |
1113 | 1184 | ImU32 Color(ImGuiCol idx, float a=1.f) const { ImVec4 c = GImGui->Style.Colors[idx]; c.w *= GImGui->Style.Alpha * a; return ImGui::ColorConvertFloat4ToU32(c); } |
1114 | 1185 | ImU32 Color(const ImVec4& col) const { ImVec4 c = col; c.w *= GImGui->Style.Alpha; return ImGui::ColorConvertFloat4ToU32(c); } |
1115 | 1186 | }; |
1116 | 1187 | |
1117 | | static ImGuiWindow* GetCurrentWindow() |
| 1188 | static inline ImGuiWindow* GetCurrentWindow() |
1118 | 1189 | { |
1119 | 1190 | ImGuiState& g = *GImGui; |
1120 | 1191 | IM_ASSERT(g.CurrentWindow != NULL); // ImGui::NewFrame() hasn't been called yet? |
r245119 | r245120 | |
1122 | 1193 | return g.CurrentWindow; |
1123 | 1194 | } |
1124 | 1195 | |
| 1196 | static inline ImGuiWindow* GetParentWindow() |
| 1197 | { |
| 1198 | ImGuiState& g = *GImGui; |
| 1199 | IM_ASSERT(g.CurrentWindowStack.size() >= 2); |
| 1200 | return g.CurrentWindowStack[g.CurrentWindowStack.size() - 2]; |
| 1201 | } |
| 1202 | |
1125 | 1203 | static void SetActiveId(ImGuiID id) |
1126 | 1204 | { |
1127 | 1205 | ImGuiState& g = *GImGui; |
1128 | 1206 | g.ActiveId = id; |
| 1207 | g.ActiveIdIsFocusedOnly = false; |
1129 | 1208 | } |
1130 | 1209 | |
1131 | 1210 | static void RegisterAliveId(const ImGuiID& id) |
r245119 | r245120 | |
1251 | 1330 | //----------------------------------------------------------------------------- |
1252 | 1331 | |
1253 | 1332 | // Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]" |
1254 | | ImGuiTextFilter::ImGuiTextFilter() |
| 1333 | ImGuiTextFilter::ImGuiTextFilter(const char* default_filter) |
1255 | 1334 | { |
1256 | | InputBuf[0] = 0; |
1257 | | CountGrep = 0; |
| 1335 | if (default_filter) |
| 1336 | { |
| 1337 | ImFormatString(InputBuf, IM_ARRAYSIZE(InputBuf), "%s", default_filter); |
| 1338 | Build(); |
| 1339 | } |
| 1340 | else |
| 1341 | { |
| 1342 | InputBuf[0] = 0; |
| 1343 | CountGrep = 0; |
| 1344 | } |
1258 | 1345 | } |
1259 | 1346 | |
1260 | 1347 | void ImGuiTextFilter::Draw(const char* label, float width) |
1261 | 1348 | { |
1262 | | ImGuiWindow* window = GetCurrentWindow(); |
1263 | | if (width < 0.0f) |
1264 | | { |
1265 | | ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true); |
1266 | | width = ImMax(window->Pos.x + ImGui::GetContentRegionMax().x - window->DC.CursorPos.x - (label_size.x + GImGui->Style.ItemSpacing.x*4), 10.0f); |
1267 | | } |
1268 | | ImGui::PushItemWidth(width); |
| 1349 | if (width > 0.0f) |
| 1350 | ImGui::PushItemWidth(width); |
1269 | 1351 | ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf)); |
1270 | | ImGui::PopItemWidth(); |
| 1352 | if (width > 0.0f) |
| 1353 | ImGui::PopItemWidth(); |
1271 | 1354 | Build(); |
1272 | 1355 | } |
1273 | 1356 | |
r245119 | r245120 | |
1383 | 1466 | ImGuiWindow::ImGuiWindow(const char* name) |
1384 | 1467 | { |
1385 | 1468 | Name = ImStrdup(name); |
1386 | | ID = GetID(name); |
| 1469 | ID = ImHash(name, 0); |
1387 | 1470 | IDStack.push_back(ID); |
1388 | 1471 | |
| 1472 | Flags = 0; |
1389 | 1473 | PosFloat = Pos = ImVec2(0.0f, 0.0f); |
1390 | 1474 | Size = SizeFull = ImVec2(0.0f, 0.0f); |
1391 | | SizeContentsFit = ImVec2(0.0f, 0.0f); |
| 1475 | SizeContents = SizeContentsCurrent = ImVec2(0.0f, 0.0f); |
1392 | 1476 | ScrollY = 0.0f; |
1393 | 1477 | NextScrollY = 0.0f; |
1394 | 1478 | ScrollbarY = false; |
r245119 | r245120 | |
1398 | 1482 | SkipItems = false; |
1399 | 1483 | AutoFitFrames = -1; |
1400 | 1484 | AutoFitOnlyGrows = false; |
1401 | | SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiSetCondition_Always | ImGuiSetCondition_FirstUseThisSession | ImGuiSetCondition_FirstUseEver; |
| 1485 | SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiSetCond_Always | ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver; |
1402 | 1486 | |
1403 | 1487 | LastFrameDrawn = -1; |
1404 | 1488 | ItemWidthDefault = 0.0f; |
r245119 | r245120 | |
1412 | 1496 | |
1413 | 1497 | DrawList = (ImDrawList*)ImGui::MemAlloc(sizeof(ImDrawList)); |
1414 | 1498 | new(DrawList) ImDrawList(); |
| 1499 | RootWindow = NULL; |
1415 | 1500 | |
1416 | 1501 | FocusIdxAllCounter = FocusIdxTabCounter = -1; |
1417 | 1502 | FocusIdxAllRequestCurrent = FocusIdxTabRequestCurrent = IM_INT_MAX; |
r245119 | r245120 | |
1429 | 1514 | |
1430 | 1515 | ImGuiID ImGuiWindow::GetID(const char* str) |
1431 | 1516 | { |
1432 | | const ImGuiID seed = IDStack.empty() ? 0 : IDStack.back(); |
1433 | | const ImGuiID id = ImCrc32(str, 0, seed); |
| 1517 | ImGuiID seed = IDStack.back(); |
| 1518 | const ImGuiID id = ImHash(str, 0, seed); |
1434 | 1519 | RegisterAliveId(id); |
1435 | 1520 | return id; |
1436 | 1521 | } |
1437 | 1522 | |
1438 | 1523 | ImGuiID ImGuiWindow::GetID(const void* ptr) |
1439 | 1524 | { |
1440 | | const ImGuiID seed = IDStack.empty() ? 0 : IDStack.back(); |
1441 | | const ImGuiID id = ImCrc32(&ptr, sizeof(void*), seed); |
| 1525 | ImGuiID seed = IDStack.back(); |
| 1526 | const ImGuiID id = ImHash(&ptr, sizeof(void*), seed); |
1442 | 1527 | RegisterAliveId(id); |
1443 | 1528 | return id; |
1444 | 1529 | } |
r245119 | r245120 | |
1510 | 1595 | static ImGuiIniData* FindWindowSettings(const char* name) |
1511 | 1596 | { |
1512 | 1597 | ImGuiState& g = *GImGui; |
| 1598 | ImGuiID id = ImHash(name, 0); |
1513 | 1599 | for (size_t i = 0; i != g.Settings.size(); i++) |
1514 | 1600 | { |
1515 | 1601 | ImGuiIniData* ini = g.Settings[i]; |
1516 | | if (ImStricmp(ini->Name, name) == 0) |
| 1602 | if (ini->ID == id) |
1517 | 1603 | return ini; |
1518 | 1604 | } |
1519 | 1605 | return NULL; |
r245119 | r245120 | |
1524 | 1610 | ImGuiIniData* ini = (ImGuiIniData*)ImGui::MemAlloc(sizeof(ImGuiIniData)); |
1525 | 1611 | new(ini) ImGuiIniData(); |
1526 | 1612 | ini->Name = ImStrdup(name); |
| 1613 | ini->ID = ImHash(name, 0); |
1527 | 1614 | ini->Collapsed = false; |
1528 | 1615 | ini->Pos = ImVec2(FLT_MAX,FLT_MAX); |
1529 | 1616 | ini->Size = ImVec2(0,0); |
r245119 | r245120 | |
1608 | 1695 | const ImGuiIniData* settings = g.Settings[i]; |
1609 | 1696 | if (settings->Pos.x == FLT_MAX) |
1610 | 1697 | continue; |
1611 | | fprintf(f, "[%s]\n", settings->Name); |
| 1698 | const char* name = settings->Name; |
| 1699 | if (const char* p = strstr(name, "###")) // Skip to the "###" marker if any. We don't skip past to match the behavior of GetID() |
| 1700 | name = p; |
| 1701 | fprintf(f, "[%s]\n", name); |
1612 | 1702 | fprintf(f, "Pos=%d,%d\n", (int)settings->Pos.x, (int)settings->Pos.y); |
1613 | 1703 | fprintf(f, "Size=%d,%d\n", (int)settings->Size.x, (int)settings->Size.y); |
1614 | 1704 | fprintf(f, "Collapsed=%d\n", settings->Collapsed); |
r245119 | r245120 | |
1715 | 1805 | for (size_t i = 0; i < IM_ARRAYSIZE(g.IO.KeysDown); i++) |
1716 | 1806 | g.IO.KeysDownTime[i] = g.IO.KeysDown[i] ? (g.IO.KeysDownTime[i] < 0.0f ? 0.0f : g.IO.KeysDownTime[i] + g.IO.DeltaTime) : -1.0f; |
1717 | 1807 | |
| 1808 | // Calculate frame-rate for the user, as a purely luxurious feature |
| 1809 | g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx]; |
| 1810 | g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime; |
| 1811 | g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame); |
| 1812 | g.IO.Framerate = 1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame)); |
| 1813 | |
1718 | 1814 | // Clear reference to active widget if the widget isn't alive anymore |
1719 | 1815 | g.HoveredId = 0; |
1720 | 1816 | if (!g.ActiveIdIsAlive && g.ActiveIdPreviousFrame == g.ActiveId && g.ActiveId != 0) |
1721 | 1817 | SetActiveId(0); |
1722 | 1818 | g.ActiveIdPreviousFrame = g.ActiveId; |
1723 | 1819 | g.ActiveIdIsAlive = false; |
| 1820 | if (!g.ActiveId) |
| 1821 | g.MovedWindow = NULL; |
1724 | 1822 | |
1725 | 1823 | // Delay saving settings so we don't spam disk too much |
1726 | 1824 | if (g.SettingsDirtyTimer > 0.0f) |
r245119 | r245120 | |
1795 | 1893 | } |
1796 | 1894 | |
1797 | 1895 | // Mark all windows as not visible |
1798 | | // Clear root windows at this point. |
1799 | 1896 | for (size_t i = 0; i != g.Windows.size(); i++) |
1800 | 1897 | { |
1801 | 1898 | ImGuiWindow* window = g.Windows[i]; |
1802 | 1899 | window->Visible = false; |
1803 | 1900 | window->Accessed = false; |
1804 | | window->RootWindow = NULL; |
1805 | 1901 | } |
1806 | 1902 | |
1807 | 1903 | // No window should be open at the beginning of the frame. |
r245119 | r245120 | |
1932 | 2028 | g.CurrentWindow->Visible = false; |
1933 | 2029 | ImGui::End(); |
1934 | 2030 | |
1935 | | // Select window for move/focus when we're done with all our widgets (we only consider non-child windows here) |
| 2031 | // Select window for move/focus when we're done with all our widgets (we use the root window ID here) |
1936 | 2032 | if (g.ActiveId == 0 && g.HoveredId == 0 && g.HoveredRootWindow != NULL && g.IO.MouseClicked[0]) |
| 2033 | { |
| 2034 | IM_ASSERT(g.MovedWindow == NULL); |
| 2035 | g.MovedWindow = g.HoveredWindow; |
1937 | 2036 | SetActiveId(g.HoveredRootWindow->GetID("#MOVE")); |
| 2037 | } |
1938 | 2038 | |
1939 | 2039 | // Sort the window list so that all child windows are after their parent |
1940 | 2040 | // We cannot do that on FocusWindow() because childs may not exist yet |
r245119 | r245120 | |
2010 | 2110 | static const char* FindTextDisplayEnd(const char* text, const char* text_end = NULL) |
2011 | 2111 | { |
2012 | 2112 | const char* text_display_end = text; |
2013 | | while ((!text_end || text_display_end < text_end) && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#')) |
| 2113 | if (!text_end) |
| 2114 | text_end = (const char*)-1; |
| 2115 | while (text_display_end < text_end && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#')) |
2014 | 2116 | text_display_end++; |
2015 | 2117 | return text_display_end; |
2016 | 2118 | } |
r245119 | r245120 | |
2217 | 2319 | |
2218 | 2320 | if (shadow && (window->Flags & ImGuiWindowFlags_ShowBorders) != 0) |
2219 | 2321 | window->DrawList->AddTriangleFilled(a+ImVec2(2,2), b+ImVec2(2,2), c+ImVec2(2,2), window->Color(ImGuiCol_BorderShadow)); |
2220 | | window->DrawList->AddTriangleFilled(a, b, c, window->Color(ImGuiCol_Border)); |
| 2322 | window->DrawList->AddTriangleFilled(a, b, c, window->Color(ImGuiCol_Text)); |
2221 | 2323 | } |
2222 | 2324 | |
2223 | 2325 | // Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. |
r245119 | r245120 | |
2294 | 2396 | continue; |
2295 | 2397 | if (excluding_childs && (window->Flags & ImGuiWindowFlags_ChildWindow) != 0) |
2296 | 2398 | continue; |
2297 | | ImGuiAabb bb(window->Pos - g.Style.TouchExtraPadding, window->Pos + window->Size + g.Style.TouchExtraPadding); |
| 2399 | |
| 2400 | // Using the clipped AABB so a child window will typically be clipped by its parent. |
| 2401 | ImGuiAabb bb(window->ClippedAabb.Min - g.Style.TouchExtraPadding, window->ClippedAabb.Max + g.Style.TouchExtraPadding); |
2298 | 2402 | if (bb.Contains(pos)) |
2299 | 2403 | return window; |
2300 | 2404 | } |
r245119 | r245120 | |
2304 | 2408 | // Test if mouse cursor is hovering given aabb |
2305 | 2409 | // NB- Box is clipped by our current clip setting |
2306 | 2410 | // NB- Expand the aabb to be generous on imprecise inputs systems (g.Style.TouchExtraPadding) |
2307 | | static bool IsMouseHoveringBox(const ImGuiAabb& box) |
| 2411 | static bool IsMouseHoveringBox(const ImGuiAabb& bb) |
2308 | 2412 | { |
2309 | 2413 | ImGuiState& g = *GImGui; |
2310 | 2414 | ImGuiWindow* window = GetCurrentWindow(); |
2311 | 2415 | |
2312 | 2416 | // Clip |
2313 | | ImGuiAabb box_clipped = box; |
| 2417 | ImGuiAabb box_clipped = bb; |
2314 | 2418 | if (!window->ClipRectStack.empty()) |
2315 | 2419 | { |
2316 | 2420 | const ImVec4 clip_rect = window->ClipRectStack.back(); |
r245119 | r245120 | |
2417 | 2521 | return false; |
2418 | 2522 | } |
2419 | 2523 | |
| 2524 | bool ImGui::IsAnyItemActive() |
| 2525 | { |
| 2526 | ImGuiState& g = *GImGui; |
| 2527 | return g.ActiveId != 0; |
| 2528 | } |
| 2529 | |
2420 | 2530 | ImVec2 ImGui::GetItemBoxMin() |
2421 | 2531 | { |
2422 | 2532 | ImGuiWindow* window = GetCurrentWindow(); |
r245119 | r245120 | |
2467 | 2577 | ImGui::End(); |
2468 | 2578 | } |
2469 | 2579 | |
2470 | | void ImGui::BeginChild(ImGuiID id, ImVec2 size, bool border, ImGuiWindowFlags extra_flags) |
| 2580 | bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) |
2471 | 2581 | { |
2472 | | char str_id[32]; |
2473 | | ImFormatString(str_id, IM_ARRAYSIZE(str_id), "child_%x", id); |
2474 | | ImGui::BeginChild(str_id, size, border, extra_flags); |
2475 | | } |
2476 | | |
2477 | | void ImGui::BeginChild(const char* str_id, ImVec2 size, bool border, ImGuiWindowFlags extra_flags) |
2478 | | { |
2479 | 2582 | ImGuiState& g = *GImGui; |
2480 | 2583 | ImGuiWindow* window = GetCurrentWindow(); |
2481 | 2584 | |
r245119 | r245120 | |
2483 | 2586 | |
2484 | 2587 | const ImVec2 content_max = window->Pos + ImGui::GetContentRegionMax(); |
2485 | 2588 | const ImVec2 cursor_pos = window->Pos + ImGui::GetCursorPos(); |
| 2589 | ImVec2 size = size_arg; |
2486 | 2590 | if (size.x <= 0.0f) |
2487 | 2591 | { |
2488 | 2592 | if (size.x == 0.0f) |
r245119 | r245120 | |
2503 | 2607 | ImFormatString(title, IM_ARRAYSIZE(title), "%s.%s", window->Name, str_id); |
2504 | 2608 | |
2505 | 2609 | const float alpha = 1.0f; |
2506 | | ImGui::Begin(title, NULL, size, alpha, flags); |
| 2610 | bool ret = ImGui::Begin(title, NULL, size, alpha, flags); |
2507 | 2611 | |
2508 | 2612 | if (!(window->Flags & ImGuiWindowFlags_ShowBorders)) |
2509 | 2613 | g.CurrentWindow->Flags &= ~ImGuiWindowFlags_ShowBorders; |
| 2614 | |
| 2615 | return ret; |
2510 | 2616 | } |
2511 | 2617 | |
| 2618 | bool ImGui::BeginChild(ImGuiID id, const ImVec2& size, bool border, ImGuiWindowFlags extra_flags) |
| 2619 | { |
| 2620 | char str_id[32]; |
| 2621 | ImFormatString(str_id, IM_ARRAYSIZE(str_id), "child_%x", id); |
| 2622 | bool ret = ImGui::BeginChild(str_id, size, border, extra_flags); |
| 2623 | return ret; |
| 2624 | } |
| 2625 | |
2512 | 2626 | void ImGui::EndChild() |
2513 | 2627 | { |
2514 | 2628 | ImGuiWindow* window = GetCurrentWindow(); |
r245119 | r245120 | |
2528 | 2642 | sz.y = 0; |
2529 | 2643 | |
2530 | 2644 | ImGui::End(); |
| 2645 | |
| 2646 | window = GetCurrentWindow(); |
| 2647 | ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + sz); |
2531 | 2648 | ItemSize(sz); |
| 2649 | ItemAdd(bb, NULL); |
2532 | 2650 | } |
2533 | 2651 | } |
2534 | 2652 | |
r245119 | r245120 | |
2551 | 2669 | |
2552 | 2670 | static ImGuiWindow* FindWindowByName(const char* name) |
2553 | 2671 | { |
2554 | | // FIXME-OPT: Consider optimizing this (e.g. sorted hashes to window pointers) |
| 2672 | // FIXME-OPT: Store sorted hashes -> pointers. |
2555 | 2673 | ImGuiState& g = *GImGui; |
2556 | | for (size_t i = 0; i != g.Windows.size(); i++) |
2557 | | if (strcmp(g.Windows[i]->Name, name) == 0) |
| 2674 | ImGuiID id = ImHash(name, 0); |
| 2675 | for (size_t i = 0; i < g.Windows.size(); i++) |
| 2676 | if (g.Windows[i]->ID == id) |
2558 | 2677 | return g.Windows[i]; |
2559 | 2678 | return NULL; |
2560 | 2679 | } |
r245119 | r245120 | |
2587 | 2706 | } |
2588 | 2707 | else |
2589 | 2708 | { |
2590 | | window->SetWindowPosAllowFlags &= ~ImGuiSetCondition_FirstUseEver; |
2591 | | window->SetWindowSizeAllowFlags &= ~ImGuiSetCondition_FirstUseEver; |
2592 | | window->SetWindowCollapsedAllowFlags &= ~ImGuiSetCondition_FirstUseEver; |
| 2709 | window->SetWindowPosAllowFlags &= ~ImGuiSetCond_FirstUseEver; |
| 2710 | window->SetWindowSizeAllowFlags &= ~ImGuiSetCond_FirstUseEver; |
| 2711 | window->SetWindowCollapsedAllowFlags &= ~ImGuiSetCond_FirstUseEver; |
2593 | 2712 | } |
2594 | 2713 | |
2595 | 2714 | if (settings->Pos.x != FLT_MAX) |
r245119 | r245120 | |
2608 | 2727 | } |
2609 | 2728 | |
2610 | 2729 | // Push a new ImGui window to add widgets to. |
2611 | | // - A default window called "Debug" is automatically stacked at the beginning of every frame. |
2612 | | // - This can be called multiple times during the frame with the same window name to append content to the same window. |
2613 | | // - The window name is used as a unique identifier to preserve window information across frames (and save rudimentary information to the .ini file). Note that you can use ## to append unique data that isn't displayed, e.g. "My window##1" will use "My window##1" as unique window ID but display "My window" to the user. |
| 2730 | // - 'size' for a regular window denote the initial size for first-time creation (no saved data) and isn't that useful. Use SetNextWindowSize() prior to calling Begin() for more flexible window manipulation. |
| 2731 | // - A default window called "Debug" is automatically stacked at the beginning of every frame so you can use widgets without explicitly calling a Begin/End pair. |
| 2732 | // - Begin/End can be called multiple times during the frame with the same window name to append content. |
| 2733 | // - The window name is used as a unique identifier to preserve window information across frames (and save rudimentary information to the .ini file). |
| 2734 | // You can use the "##" or "###" markers to use the same label with different id, or same id with different label. See documentation at the top of this file. |
2614 | 2735 | // - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned. |
2615 | 2736 | // - Passing 'bool* p_opened' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed. |
2616 | | // - Passing non-zero 'size' is roughly equivalent to calling SetNextWindowSize(size, ImGuiSetCondition_FirstUseEver) prior to calling Begin(). |
2617 | | bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alpha, ImGuiWindowFlags flags) |
| 2737 | // - Passing non-zero 'size' is roughly equivalent to calling SetNextWindowSize(size, ImGuiSetCond_FirstUseEver) prior to calling Begin(). |
| 2738 | bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg_alpha, ImGuiWindowFlags flags) |
2618 | 2739 | { |
2619 | 2740 | ImGuiState& g = *GImGui; |
2620 | 2741 | const ImGuiStyle& style = g.Style; |
r245119 | r245120 | |
2651 | 2772 | ImGui::SetWindowCollapsed(g.SetNextWindowCollapsedVal, g.SetNextWindowCollapsedCond); |
2652 | 2773 | g.SetNextWindowCollapsedCond = 0; |
2653 | 2774 | } |
| 2775 | if (g.SetNextWindowFocus) |
| 2776 | { |
| 2777 | ImGui::SetWindowFocus(); |
| 2778 | g.SetNextWindowFocus = false; |
| 2779 | } |
2654 | 2780 | |
2655 | 2781 | // Find parent |
2656 | 2782 | ImGuiWindow* parent_window = (flags & ImGuiWindowFlags_ChildWindow) != 0 ? g.CurrentWindowStack[g.CurrentWindowStack.size()-2] : NULL; |
2657 | 2783 | |
2658 | | // Find root (if we are a child window) |
| 2784 | // Update known root window (if we are a child window, otherwise window == window->RootWindow) |
2659 | 2785 | size_t root_idx = g.CurrentWindowStack.size() - 1; |
2660 | 2786 | while (root_idx > 0) |
2661 | 2787 | { |
r245119 | r245120 | |
2666 | 2792 | window->RootWindow = g.CurrentWindowStack[root_idx]; |
2667 | 2793 | |
2668 | 2794 | // Default alpha |
2669 | | if (fill_alpha < 0.0f) |
2670 | | fill_alpha = style.WindowFillAlphaDefault; |
| 2795 | if (bg_alpha < 0.0f) |
| 2796 | bg_alpha = style.WindowFillAlphaDefault; |
2671 | 2797 | |
2672 | 2798 | // When reusing window again multiple times a frame, just append content (don't need to setup again) |
2673 | 2799 | const int current_frame = ImGui::GetFrameCount(); |
r245119 | r245120 | |
2684 | 2810 | window->LastFrameDrawn = current_frame; |
2685 | 2811 | window->ClipRectStack.resize(0); |
2686 | 2812 | |
| 2813 | // Reset contents size for auto-fitting |
| 2814 | window->SizeContents = window->SizeContentsCurrent; |
| 2815 | window->SizeContentsCurrent = ImVec2(0.0f, 0.0f); |
| 2816 | |
2687 | 2817 | if (flags & ImGuiWindowFlags_ChildWindow) |
2688 | 2818 | { |
2689 | 2819 | parent_window->DC.ChildWindows.push_back(window); |
r245119 | r245120 | |
2706 | 2836 | // Setup and draw window |
2707 | 2837 | if (first_begin_of_the_frame) |
2708 | 2838 | { |
2709 | | // Seed ID stack with our window pointer |
2710 | | window->IDStack.resize(0); |
2711 | | ImGui::PushID(window); |
| 2839 | // Reset ID stack |
| 2840 | window->IDStack.resize(1); |
2712 | 2841 | |
2713 | | // Move window (at the beginning of the frame to avoid input lag or sheering) |
| 2842 | // Move window (at the beginning of the frame to avoid input lag or sheering). Only valid for root windows. |
2714 | 2843 | const ImGuiID move_id = window->GetID("#MOVE"); |
2715 | 2844 | RegisterAliveId(move_id); |
2716 | 2845 | if (g.ActiveId == move_id) |
r245119 | r245120 | |
2723 | 2852 | if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings)) |
2724 | 2853 | MarkSettingsDirty(); |
2725 | 2854 | } |
2726 | | FocusWindow(window); |
| 2855 | IM_ASSERT(g.MovedWindow != NULL); |
| 2856 | FocusWindow(g.MovedWindow); |
2727 | 2857 | } |
2728 | 2858 | else |
2729 | 2859 | { |
2730 | 2860 | SetActiveId(0); |
| 2861 | g.MovedWindow = NULL; // Not strictly necessary but doing it for sanity. |
2731 | 2862 | } |
2732 | 2863 | } |
2733 | 2864 | |
r245119 | r245120 | |
2777 | 2908 | window->ScrollY = window->NextScrollY; |
2778 | 2909 | window->ScrollY = ImMax(window->ScrollY, 0.0f); |
2779 | 2910 | if (!window->Collapsed && !window->SkipItems) |
2780 | | window->ScrollY = ImMin(window->ScrollY, ImMax(0.0f, (float)window->SizeContentsFit.y - window->SizeFull.y)); |
| 2911 | window->ScrollY = ImMin(window->ScrollY, ImMax(0.0f, window->SizeContents.y - window->SizeFull.y)); |
2781 | 2912 | window->NextScrollY = window->ScrollY; |
2782 | 2913 | |
2783 | 2914 | // At this point we don't have a clipping rectangle setup yet, so we can test and draw in title bar |
r245119 | r245120 | |
2817 | 2948 | if ((window->Flags & ImGuiWindowFlags_Tooltip) != 0) |
2818 | 2949 | { |
2819 | 2950 | // Tooltip always resize. We keep the spacing symmetric on both axises for aesthetic purpose. |
2820 | | const ImVec2 size_auto_fit = window->SizeContentsFit + style.WindowPadding - ImVec2(0.0f, style.ItemSpacing.y); |
| 2951 | const ImVec2 size_auto_fit = window->SizeContents + style.WindowPadding - ImVec2(0.0f, style.ItemSpacing.y); |
2821 | 2952 | window->SizeFull = size_auto_fit; |
2822 | 2953 | } |
2823 | 2954 | else |
2824 | 2955 | { |
2825 | | const ImVec2 size_auto_fit = ImClamp(window->SizeContentsFit + style.AutoFitPadding, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - style.AutoFitPadding)); |
| 2956 | const ImVec2 size_auto_fit = ImClamp(window->SizeContents + style.AutoFitPadding, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - style.AutoFitPadding)); |
2826 | 2957 | if ((window->Flags & ImGuiWindowFlags_AlwaysAutoResize) != 0) |
2827 | 2958 | { |
2828 | 2959 | // Don't continuously mark settings as dirty, the size of the window doesn't need to be stored. |
r245119 | r245120 | |
2842 | 2973 | { |
2843 | 2974 | // Manual resize grip |
2844 | 2975 | const ImGuiAabb resize_aabb(window->Aabb().GetBR()-ImVec2(18,18), window->Aabb().GetBR()); |
2845 | | const ImGuiID resize_id = window->GetID("##RESIZE"); |
| 2976 | const ImGuiID resize_id = window->GetID("#RESIZE"); |
2846 | 2977 | bool hovered, held; |
2847 | 2978 | ButtonBehaviour(resize_aabb, resize_id, &hovered, &held, true); |
2848 | 2979 | resize_col = window->Color(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip); |
r245119 | r245120 | |
2870 | 3001 | } |
2871 | 3002 | |
2872 | 3003 | // Scrollbar |
2873 | | window->ScrollbarY = (window->SizeContentsFit.y > window->Size.y) && !(window->Flags & ImGuiWindowFlags_NoScrollbar); |
| 3004 | window->ScrollbarY = (window->SizeContents.y > window->Size.y) && !(window->Flags & ImGuiWindowFlags_NoScrollbar); |
2874 | 3005 | |
2875 | 3006 | // Window background |
2876 | | if (fill_alpha > 0.0f) |
| 3007 | if (bg_alpha > 0.0f) |
2877 | 3008 | { |
2878 | 3009 | if ((window->Flags & ImGuiWindowFlags_ComboBox) != 0) |
2879 | | window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_ComboBg, fill_alpha), window_rounding); |
| 3010 | window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_ComboBg, bg_alpha), window_rounding); |
2880 | 3011 | else if ((window->Flags & ImGuiWindowFlags_Tooltip) != 0) |
2881 | | window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_TooltipBg, fill_alpha), window_rounding); |
| 3012 | window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_TooltipBg, bg_alpha), window_rounding); |
2882 | 3013 | else if ((window->Flags & ImGuiWindowFlags_ChildWindow) != 0) |
2883 | | window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size-ImVec2(window->ScrollbarY?style.ScrollBarWidth:0.0f,0.0f), window->Color(ImGuiCol_ChildWindowBg, fill_alpha), window_rounding, window->ScrollbarY ? (1|8) : (0xF)); |
| 3014 | window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size-ImVec2(window->ScrollbarY?style.ScrollbarWidth:0.0f,0.0f), window->Color(ImGuiCol_ChildWindowBg, bg_alpha), window_rounding, window->ScrollbarY ? (1|8) : (0xF)); |
2884 | 3015 | else |
2885 | | window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_WindowBg, fill_alpha), window_rounding); |
| 3016 | window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_WindowBg, bg_alpha), window_rounding); |
2886 | 3017 | } |
2887 | 3018 | |
2888 | 3019 | // Title bar |
r245119 | r245120 | |
2900 | 3031 | |
2901 | 3032 | // Scrollbar |
2902 | 3033 | if (window->ScrollbarY) |
2903 | | { |
2904 | | ImGuiAabb scrollbar_bb(window->Aabb().Max.x - style.ScrollBarWidth, title_bar_aabb.Max.y+1, window->Aabb().Max.x, window->Aabb().Max.y-1); |
2905 | | //window->DrawList->AddLine(scrollbar_bb.GetTL(), scrollbar_bb.GetBL(), g.Colors[ImGuiCol_Border]); |
2906 | | window->DrawList->AddRectFilled(scrollbar_bb.Min, scrollbar_bb.Max, window->Color(ImGuiCol_ScrollbarBg)); |
2907 | | scrollbar_bb.Expand(ImVec2(-3,-3)); |
| 3034 | Scrollbar(window); |
2908 | 3035 | |
2909 | | const float grab_size_y_norm = ImSaturate(window->Size.y / ImMax(window->SizeContentsFit.y, window->Size.y)); |
2910 | | const float grab_size_y = scrollbar_bb.GetHeight() * grab_size_y_norm; |
2911 | | |
2912 | | // Handle input right away (none of the code above is relying on scrolling position) |
2913 | | bool held = false; |
2914 | | bool hovered = false; |
2915 | | if (grab_size_y_norm < 1.0f) |
2916 | | { |
2917 | | const ImGuiID scrollbar_id = window->GetID("#SCROLLY"); |
2918 | | ButtonBehaviour(scrollbar_bb, scrollbar_id, &hovered, &held, true); |
2919 | | if (held) |
2920 | | { |
2921 | | g.HoveredId = scrollbar_id; |
2922 | | const float pos_y_norm = ImSaturate((g.IO.MousePos.y - (scrollbar_bb.Min.y + grab_size_y*0.5f)) / (scrollbar_bb.GetHeight() - grab_size_y)) * (1.0f - grab_size_y_norm); |
2923 | | window->ScrollY = (float)(int)(pos_y_norm * window->SizeContentsFit.y); |
2924 | | window->NextScrollY = window->ScrollY; |
2925 | | } |
2926 | | } |
2927 | | |
2928 | | // Normalized height of the grab |
2929 | | const float pos_y_norm = ImSaturate(window->ScrollY / ImMax(0.0f, window->SizeContentsFit.y)); |
2930 | | const ImU32 grab_col = window->Color(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab); |
2931 | | window->DrawList->AddRectFilled( |
2932 | | ImVec2(scrollbar_bb.Min.x, ImLerp(scrollbar_bb.Min.y, scrollbar_bb.Max.y, pos_y_norm)), |
2933 | | ImVec2(scrollbar_bb.Max.x, ImLerp(scrollbar_bb.Min.y, scrollbar_bb.Max.y, pos_y_norm + grab_size_y_norm)), grab_col); |
2934 | | } |
2935 | | |
2936 | 3036 | // Render resize grip |
2937 | 3037 | // (after the input handling so we don't have a frame of latency) |
2938 | 3038 | if (!(window->Flags & ImGuiWindowFlags_NoResize)) |
r245119 | r245120 | |
2975 | 3075 | window->DC.ColumnsCellMinY = window->DC.ColumnsCellMaxY = window->DC.ColumnsStartPos.y; |
2976 | 3076 | window->DC.TreeDepth = 0; |
2977 | 3077 | window->DC.StateStorage = &window->StateStorage; |
2978 | | window->DC.OpenNextNode = -1; |
2979 | 3078 | |
2980 | | // Reset contents size for auto-fitting |
2981 | | window->SizeContentsFit = ImVec2(0.0f, 0.0f); |
2982 | 3079 | if (window->AutoFitFrames > 0) |
2983 | 3080 | window->AutoFitFrames--; |
2984 | 3081 | |
r245119 | r245120 | |
2999 | 3096 | const ImVec2 text_max = window->Pos + ImVec2(window->Size.x - (p_opened ? (title_bar_aabb.GetHeight()-3) : style.FramePadding.x), style.FramePadding.y*2 + text_size.y); |
3000 | 3097 | RenderTextClipped(text_min, name, NULL, &text_size, text_max); |
3001 | 3098 | } |
| 3099 | |
| 3100 | // Save clipped aabb so we can access it in constant-time in FindHoveredWindow() |
| 3101 | window->ClippedAabb = window->Aabb(); |
| 3102 | window->ClippedAabb.Clip(window->ClipRectStack.front()); |
3002 | 3103 | } |
3003 | 3104 | |
3004 | 3105 | // Inner clipping rectangle |
r245119 | r245120 | |
3006 | 3107 | const ImGuiAabb title_bar_aabb = window->TitleBarAabb(); |
3007 | 3108 | ImVec4 clip_rect(title_bar_aabb.Min.x+0.5f+window->WindowPadding().x*0.5f, title_bar_aabb.Max.y+0.5f, window->Aabb().Max.x+0.5f-window->WindowPadding().x*0.5f, window->Aabb().Max.y-1.5f); |
3008 | 3109 | if (window->ScrollbarY) |
3009 | | clip_rect.z -= style.ScrollBarWidth; |
| 3110 | clip_rect.z -= style.ScrollbarWidth; |
3010 | 3111 | PushClipRect(clip_rect); |
3011 | 3112 | |
3012 | 3113 | // Clear 'accessed' flag last thing |
r245119 | r245120 | |
3018 | 3119 | if (flags & ImGuiWindowFlags_ChildWindow) |
3019 | 3120 | { |
3020 | 3121 | IM_ASSERT((flags & ImGuiWindowFlags_NoTitleBar) != 0); |
| 3122 | window->Collapsed = parent_window && parent_window->Collapsed; |
| 3123 | |
3021 | 3124 | const ImVec4 clip_rect_t = window->ClipRectStack.back(); |
3022 | | window->Collapsed = (clip_rect_t.x >= clip_rect_t.z || clip_rect_t.y >= clip_rect_t.w); |
| 3125 | window->Collapsed |= (clip_rect_t.x >= clip_rect_t.z || clip_rect_t.y >= clip_rect_t.w); |
3023 | 3126 | |
3024 | 3127 | // We also hide the window from rendering because we've already added its border to the command list. |
3025 | 3128 | // (we could perform the check earlier in the function but it is simpler at this point) |
r245119 | r245120 | |
3049 | 3152 | ImGui::LogFinish(); |
3050 | 3153 | |
3051 | 3154 | // Pop |
3052 | | // NB: we don't clear 'window->RootWindow' yet, it will be used then cleared in NewFrame() |
| 3155 | // NB: we don't clear 'window->RootWindow'. The pointer is allowed to live until the next call to Begin(). |
3053 | 3156 | g.CurrentWindowStack.pop_back(); |
3054 | 3157 | g.CurrentWindow = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back(); |
3055 | 3158 | } |
3056 | 3159 | |
| 3160 | // Vertical scrollbar |
| 3161 | // The entire piece of code below is rather confusing because: |
| 3162 | // - We handle absolute seeking (when first clicking outside the grab) and relative manipulation (afterward or when clicking inside the grab) |
| 3163 | // - We store values as ratio and in a form that allows the window content to change while we are holding on a scrollbar |
| 3164 | static void Scrollbar(ImGuiWindow* window) |
| 3165 | { |
| 3166 | ImGuiState& g = *GImGui; |
| 3167 | const ImGuiStyle& style = g.Style; |
| 3168 | const ImGuiID id = window->GetID("#SCROLLY"); |
| 3169 | |
| 3170 | // Render background |
| 3171 | ImGuiAabb bb(window->Aabb().Max.x - style.ScrollbarWidth, window->Pos.y + window->TitleBarHeight()+1, window->Aabb().Max.x, window->Aabb().Max.y-1); |
| 3172 | window->DrawList->AddRectFilled(bb.Min, bb.Max, window->Color(ImGuiCol_ScrollbarBg)); |
| 3173 | bb.Expand(ImVec2(-3,-3)); |
| 3174 | const float scrollbar_height = bb.GetHeight(); |
| 3175 | |
| 3176 | // The grabable box size generally represent the amount visible (vs the total scrollable amount) |
| 3177 | // But we maintain a minimum size in pixel to allow for the user to still aim inside. |
| 3178 | const float grab_h_pixels = ImMax(style.GrabMinSize, scrollbar_height * ImSaturate(window->Size.y / ImMax(window->SizeContents.y, window->Size.y))); |
| 3179 | const float grab_h_norm = grab_h_pixels / scrollbar_height; |
| 3180 | |
| 3181 | // Handle input right away. None of the code of Begin() is relying on scrolling position before calling Scrollbar(). |
| 3182 | bool held = false; |
| 3183 | bool hovered = false; |
| 3184 | const bool previously_held = (g.ActiveId == id); |
| 3185 | ButtonBehaviour(bb, id, &hovered, &held, true); |
| 3186 | |
| 3187 | const float scroll_max = ImMax(1.0f, window->SizeContents.y - window->Size.y); |
| 3188 | float scroll_ratio = ImSaturate(window->ScrollY / scroll_max); |
| 3189 | float grab_y_norm = scroll_ratio * (scrollbar_height - grab_h_pixels) / scrollbar_height; |
| 3190 | if (held) |
| 3191 | { |
| 3192 | const float clicked_y_norm = ImSaturate((g.IO.MousePos.y - bb.Min.y) / scrollbar_height); // Click position in scrollbar space (0.0f->1.0f) |
| 3193 | g.HoveredId = id; |
| 3194 | |
| 3195 | bool seek_absolute = false; |
| 3196 | if (!previously_held) |
| 3197 | { |
| 3198 | // On initial click calculate the distance between mouse and the center of the grab |
| 3199 | if (clicked_y_norm >= grab_y_norm && clicked_y_norm <= grab_y_norm + grab_h_norm) |
| 3200 | { |
| 3201 | g.ScrollbarClickDeltaToGrabCenter = clicked_y_norm - grab_y_norm - grab_h_norm*0.5f; |
| 3202 | } |
| 3203 | else |
| 3204 | { |
| 3205 | seek_absolute = true; |
| 3206 | g.ScrollbarClickDeltaToGrabCenter = 0; |
| 3207 | } |
| 3208 | } |
| 3209 | |
| 3210 | // Apply scroll |
| 3211 | const float scroll_y_norm = ImSaturate((clicked_y_norm - g.ScrollbarClickDeltaToGrabCenter - grab_h_norm*0.5f) / (1.0f - grab_h_norm)); |
| 3212 | window->ScrollY = (float)(int)(0.5f + scroll_y_norm * (window->SizeContents.y - window->Size.y)); |
| 3213 | window->NextScrollY = window->ScrollY; |
| 3214 | |
| 3215 | // Update values for rendering |
| 3216 | scroll_ratio = ImSaturate(window->ScrollY / scroll_max); |
| 3217 | grab_y_norm = scroll_ratio * (scrollbar_height - grab_h_pixels) / scrollbar_height; |
| 3218 | |
| 3219 | // Update distance to grab now that we have seeked and saturated |
| 3220 | if (seek_absolute) |
| 3221 | g.ScrollbarClickDeltaToGrabCenter = clicked_y_norm - grab_y_norm - grab_h_norm*0.5f; |
| 3222 | } |
| 3223 | |
| 3224 | // Render |
| 3225 | const ImU32 grab_col = window->Color(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab); |
| 3226 | window->DrawList->AddRectFilled(ImVec2(bb.Min.x, ImLerp(bb.Min.y, bb.Max.y, grab_y_norm)), ImVec2(bb.Max.x, ImLerp(bb.Min.y, bb.Max.y, grab_y_norm) + grab_h_pixels), grab_col); |
| 3227 | } |
| 3228 | |
3057 | 3229 | // Moving window to front of display (which happens to be back of our sorted list) |
3058 | 3230 | static void FocusWindow(ImGuiWindow* window) |
3059 | 3231 | { |
3060 | 3232 | ImGuiState& g = *GImGui; |
| 3233 | |
| 3234 | // Always mark the window we passed as focused. This is used for keyboard interactions such as tabbing. |
3061 | 3235 | g.FocusedWindow = window; |
3062 | 3236 | |
| 3237 | // And move its root window to the top of the pile |
| 3238 | if (window->RootWindow) |
| 3239 | window = window->RootWindow; |
| 3240 | |
3063 | 3241 | if (g.Windows.back() == window) |
3064 | 3242 | return; |
3065 | 3243 | |
r245119 | r245120 | |
3109 | 3287 | g.Font = font; |
3110 | 3288 | g.FontSize = g.IO.FontGlobalScale * g.Font->FontSize * g.Font->Scale; |
3111 | 3289 | g.FontTexUvWhitePixel = g.Font->ContainerAtlas->TexUvWhitePixel; |
3112 | | g.Font->FallbackGlyph = NULL; |
3113 | | g.Font->FallbackGlyph = g.Font->FindGlyph(g.Font->FallbackChar); |
3114 | 3290 | } |
3115 | 3291 | |
3116 | 3292 | void ImGui::PushFont(ImFont* font) |
r245119 | r245120 | |
3228 | 3404 | ImGuiState& g = *GImGui; |
3229 | 3405 | |
3230 | 3406 | ImVec2* pvar = GetStyleVarVec2Addr(idx); |
3231 | | IM_ASSERT(pvar != NULL); // Called function with wrong-type? Varialble is not a ImVec2. |
| 3407 | IM_ASSERT(pvar != NULL); // Called function with wrong-type? Variable is not a ImVec2. |
3232 | 3408 | ImGuiStyleMod backup; |
3233 | 3409 | backup.Var = idx; |
3234 | 3410 | backup.PreviousValue = *pvar; |
r245119 | r245120 | |
3320 | 3496 | return window->Pos; |
3321 | 3497 | } |
3322 | 3498 | |
3323 | | void ImGui::SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond) |
| 3499 | static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiSetCond cond) |
3324 | 3500 | { |
3325 | | ImGuiWindow* window = GetCurrentWindow(); |
3326 | | |
3327 | 3501 | // Test condition (NB: bit 0 is always true) and clear flags for next time |
3328 | 3502 | if (cond && (window->SetWindowPosAllowFlags & cond) == 0) |
3329 | 3503 | return; |
3330 | | window->SetWindowPosAllowFlags &= ~(ImGuiSetCondition_FirstUseThisSession | ImGuiSetCondition_FirstUseEver); |
| 3504 | window->SetWindowPosAllowFlags &= ~(ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver); |
3331 | 3505 | |
3332 | 3506 | // Set |
3333 | 3507 | const ImVec2 old_pos = window->Pos; |
r245119 | r245120 | |
3336 | 3510 | window->DC.CursorPos += (window->Pos - old_pos); // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor |
3337 | 3511 | } |
3338 | 3512 | |
| 3513 | void ImGui::SetWindowPos(const ImVec2& pos, ImGuiSetCond cond) |
| 3514 | { |
| 3515 | ImGuiWindow* window = GetCurrentWindow(); |
| 3516 | SetWindowPos(window, pos, cond); |
| 3517 | } |
| 3518 | |
| 3519 | void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond) |
| 3520 | { |
| 3521 | ImGuiWindow* window = FindWindowByName(name); |
| 3522 | if (window) |
| 3523 | SetWindowPos(window, pos, cond); |
| 3524 | } |
| 3525 | |
3339 | 3526 | ImVec2 ImGui::GetWindowSize() |
3340 | 3527 | { |
3341 | 3528 | ImGuiWindow* window = GetCurrentWindow(); |
3342 | 3529 | return window->Size; |
3343 | 3530 | } |
3344 | 3531 | |
3345 | | void ImGui::SetWindowSize(const ImVec2& size, ImGuiSetCondition cond) |
| 3532 | static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiSetCond cond) |
3346 | 3533 | { |
3347 | | ImGuiWindow* window = GetCurrentWindow(); |
3348 | | |
3349 | 3534 | // Test condition (NB: bit 0 is always true) and clear flags for next time |
3350 | 3535 | if (cond && (window->SetWindowSizeAllowFlags & cond) == 0) |
3351 | 3536 | return; |
3352 | | window->SetWindowSizeAllowFlags &= ~(ImGuiSetCondition_FirstUseThisSession | ImGuiSetCondition_FirstUseEver); |
| 3537 | window->SetWindowSizeAllowFlags &= ~(ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver); |
3353 | 3538 | |
3354 | 3539 | // Set |
3355 | 3540 | if (ImLengthSqr(size) > 0.00001f) |
r245119 | r245120 | |
3365 | 3550 | } |
3366 | 3551 | } |
3367 | 3552 | |
3368 | | void ImGui::SetWindowCollapsed(bool collapsed, ImGuiSetCondition cond) |
| 3553 | void ImGui::SetWindowSize(const ImVec2& size, ImGuiSetCond cond) |
3369 | 3554 | { |
3370 | 3555 | ImGuiWindow* window = GetCurrentWindow(); |
| 3556 | SetWindowSize(window, size, cond); |
| 3557 | } |
3371 | 3558 | |
| 3559 | void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond) |
| 3560 | { |
| 3561 | ImGuiWindow* window = FindWindowByName(name); |
| 3562 | if (window) |
| 3563 | SetWindowSize(window, size, cond); |
| 3564 | } |
| 3565 | |
| 3566 | static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiSetCond cond) |
| 3567 | { |
3372 | 3568 | // Test condition (NB: bit 0 is always true) and clear flags for next time |
3373 | 3569 | if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0) |
3374 | 3570 | return; |
3375 | | window->SetWindowCollapsedAllowFlags &= ~(ImGuiSetCondition_FirstUseThisSession | ImGuiSetCondition_FirstUseEver); |
| 3571 | window->SetWindowCollapsedAllowFlags &= ~(ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver); |
3376 | 3572 | |
3377 | 3573 | // Set |
3378 | 3574 | window->Collapsed = collapsed; |
3379 | 3575 | } |
3380 | 3576 | |
3381 | | void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiSetCondition cond) |
| 3577 | void ImGui::SetWindowCollapsed(bool collapsed, ImGuiSetCond cond) |
3382 | 3578 | { |
| 3579 | ImGuiWindow* window = GetCurrentWindow(); |
| 3580 | SetWindowCollapsed(window, collapsed, cond); |
| 3581 | } |
| 3582 | |
| 3583 | bool ImGui::GetWindowCollapsed() |
| 3584 | { |
| 3585 | ImGuiWindow* window = GetCurrentWindow(); |
| 3586 | return window->Collapsed; |
| 3587 | } |
| 3588 | |
| 3589 | void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond) |
| 3590 | { |
| 3591 | ImGuiWindow* window = FindWindowByName(name); |
| 3592 | if (window) |
| 3593 | SetWindowCollapsed(window, collapsed, cond); |
| 3594 | } |
| 3595 | |
| 3596 | void ImGui::SetWindowFocus() |
| 3597 | { |
| 3598 | ImGuiWindow* window = GetCurrentWindow(); |
| 3599 | FocusWindow(window); |
| 3600 | } |
| 3601 | |
| 3602 | void ImGui::SetWindowFocus(const char* name) |
| 3603 | { |
| 3604 | ImGuiWindow* window = FindWindowByName(name); |
| 3605 | if (window) |
| 3606 | FocusWindow(window); |
| 3607 | } |
| 3608 | |
| 3609 | void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond) |
| 3610 | { |
3383 | 3611 | ImGuiState& g = *GImGui; |
3384 | 3612 | g.SetNextWindowPosVal = pos; |
3385 | | g.SetNextWindowPosCond = cond ? cond : ImGuiSetCondition_Always; |
| 3613 | g.SetNextWindowPosCond = cond ? cond : ImGuiSetCond_Always; |
3386 | 3614 | } |
3387 | 3615 | |
3388 | | void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiSetCondition cond) |
| 3616 | void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond) |
3389 | 3617 | { |
3390 | 3618 | ImGuiState& g = *GImGui; |
3391 | 3619 | g.SetNextWindowSizeVal = size; |
3392 | | g.SetNextWindowSizeCond = cond ? cond : ImGuiSetCondition_Always; |
| 3620 | g.SetNextWindowSizeCond = cond ? cond : ImGuiSetCond_Always; |
3393 | 3621 | } |
3394 | 3622 | |
3395 | | void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiSetCondition cond) |
| 3623 | void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond) |
3396 | 3624 | { |
3397 | 3625 | ImGuiState& g = *GImGui; |
3398 | 3626 | g.SetNextWindowCollapsedVal = collapsed; |
3399 | | g.SetNextWindowCollapsedCond = cond ? cond : ImGuiSetCondition_Always; |
| 3627 | g.SetNextWindowCollapsedCond = cond ? cond : ImGuiSetCond_Always; |
3400 | 3628 | } |
3401 | 3629 | |
| 3630 | void ImGui::SetNextWindowFocus() |
| 3631 | { |
| 3632 | ImGuiState& g = *GImGui; |
| 3633 | g.SetNextWindowFocus = true; |
| 3634 | } |
| 3635 | |
3402 | 3636 | ImVec2 ImGui::GetContentRegionMax() |
3403 | 3637 | { |
3404 | 3638 | ImGuiWindow* window = GetCurrentWindow(); |
3405 | | ImVec2 mx = window->Size - window->WindowPadding(); |
| 3639 | ImVec2 window_padding = window->WindowPadding(); |
| 3640 | ImVec2 mx = window->Size - window_padding; |
3406 | 3641 | if (window->DC.ColumnsCount != 1) |
3407 | 3642 | { |
3408 | 3643 | mx.x = ImGui::GetColumnOffset(window->DC.ColumnsCurrent + 1); |
3409 | | mx.x -= GImGui->Style.WindowPadding.x; |
| 3644 | mx.x -= window_padding.x; |
3410 | 3645 | } |
3411 | 3646 | else |
3412 | 3647 | { |
3413 | 3648 | if (window->ScrollbarY) |
3414 | | mx.x -= GImGui->Style.ScrollBarWidth; |
| 3649 | mx.x -= GImGui->Style.ScrollbarWidth; |
3415 | 3650 | } |
3416 | 3651 | return mx; |
3417 | 3652 | } |
r245119 | r245120 | |
3427 | 3662 | ImGuiWindow* window = GetCurrentWindow(); |
3428 | 3663 | ImVec2 m = window->Size - window->WindowPadding(); |
3429 | 3664 | if (window->ScrollbarY) |
3430 | | m.x -= GImGui->Style.ScrollBarWidth; |
| 3665 | m.x -= GImGui->Style.ScrollbarWidth; |
3431 | 3666 | return m; |
3432 | 3667 | } |
3433 | 3668 | |
r245119 | r245120 | |
3490 | 3725 | { |
3491 | 3726 | ImGuiWindow* window = GetCurrentWindow(); |
3492 | 3727 | window->DC.CursorPos = window->Pos + pos; |
3493 | | window->SizeContentsFit = ImMax(window->SizeContentsFit, pos + ImVec2(0.0f, window->ScrollY)); |
| 3728 | window->SizeContentsCurrent = ImMax(window->SizeContentsCurrent, pos + ImVec2(0.0f, window->ScrollY)); |
3494 | 3729 | } |
3495 | 3730 | |
3496 | 3731 | void ImGui::SetCursorPosX(float x) |
3497 | 3732 | { |
3498 | 3733 | ImGuiWindow* window = GetCurrentWindow(); |
3499 | 3734 | window->DC.CursorPos.x = window->Pos.x + x; |
3500 | | window->SizeContentsFit.x = ImMax(window->SizeContentsFit.x, x); |
| 3735 | window->SizeContentsCurrent.x = ImMax(window->SizeContentsCurrent.x, x); |
3501 | 3736 | } |
3502 | 3737 | |
3503 | 3738 | void ImGui::SetCursorPosY(float y) |
3504 | 3739 | { |
3505 | 3740 | ImGuiWindow* window = GetCurrentWindow(); |
3506 | 3741 | window->DC.CursorPos.y = window->Pos.y + y; |
3507 | | window->SizeContentsFit.y = ImMax(window->SizeContentsFit.y, y + window->ScrollY); |
| 3742 | window->SizeContentsCurrent.y = ImMax(window->SizeContentsCurrent.y, y + window->ScrollY); |
3508 | 3743 | } |
3509 | 3744 | |
3510 | 3745 | ImVec2 ImGui::GetCursorScreenPos() |
r245119 | r245120 | |
3519 | 3754 | window->DC.CursorPos = screen_pos; |
3520 | 3755 | } |
3521 | 3756 | |
| 3757 | float ImGui::GetScrollPosY() |
| 3758 | { |
| 3759 | ImGuiWindow* window = GetCurrentWindow(); |
| 3760 | return window->ScrollY; |
| 3761 | } |
| 3762 | |
| 3763 | float ImGui::GetScrollMaxY() |
| 3764 | { |
| 3765 | ImGuiWindow* window = GetCurrentWindow(); |
| 3766 | return window->SizeContents.y - window->SizeFull.y; |
| 3767 | } |
| 3768 | |
3522 | 3769 | void ImGui::SetScrollPosHere() |
3523 | 3770 | { |
3524 | 3771 | ImGuiWindow* window = GetCurrentWindow(); |
r245119 | r245120 | |
3720 | 3967 | const char* value_text_begin = &buf[0]; |
3721 | 3968 | const char* value_text_end = value_text_begin + ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args); |
3722 | 3969 | |
3723 | | const ImVec2 text_size = CalcTextSize(label, NULL, true); |
3724 | | const ImGuiAabb value_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w + style.FramePadding.x*2, text_size.y)); |
3725 | | const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w + style.FramePadding.x*2 + (text_size.x > 0.0f ? style.ItemInnerSpacing.x : 0.0f), 0.0f) + text_size); |
| 3970 | const ImVec2 label_size = CalcTextSize(label, NULL, true); |
| 3971 | const ImGuiAabb value_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w + style.FramePadding.x*2, label_size.y)); |
| 3972 | const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w + style.FramePadding.x*2 + (label_size.x > 0.0f ? style.ItemInnerSpacing.x : 0.0f), 0.0f) + label_size); |
3726 | 3973 | ItemSize(bb); |
3727 | 3974 | if (!ItemAdd(value_bb, NULL)) |
3728 | 3975 | return; |
r245119 | r245120 | |
3746 | 3993 | if (g.HoveredId == 0) |
3747 | 3994 | { |
3748 | 3995 | ImGuiWindow* window = GetCurrentWindow(); |
3749 | | const bool hovered = (g.HoveredRootWindow == window->RootWindow) && (g.ActiveId == 0 || g.ActiveId == id) && IsMouseHoveringBox(bb); |
3750 | | return hovered; |
| 3996 | if (g.HoveredRootWindow == window->RootWindow) |
| 3997 | { |
| 3998 | bool hovered = (g.ActiveId == 0 || g.ActiveId == id || g.ActiveIdIsFocusedOnly) && IsMouseHoveringBox(bb); |
| 3999 | return hovered; |
| 4000 | } |
3751 | 4001 | } |
3752 | 4002 | return false; |
3753 | 4003 | } |
r245119 | r245120 | |
3814 | 4064 | |
3815 | 4065 | const ImGuiStyle& style = g.Style; |
3816 | 4066 | const ImGuiID id = window->GetID(label); |
3817 | | const ImVec2 text_size = CalcTextSize(label, NULL, true); |
| 4067 | const ImVec2 label_size = CalcTextSize(label, NULL, true); |
3818 | 4068 | |
3819 | | const ImVec2 size(size_arg.x != 0.0f ? size_arg.x : text_size.x, size_arg.y != 0.0f ? size_arg.y : text_size.y); |
| 4069 | const ImVec2 size(size_arg.x != 0.0f ? size_arg.x : label_size.x, size_arg.y != 0.0f ? size_arg.y : label_size.y); |
3820 | 4070 | const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + size + style.FramePadding*2.0f); |
3821 | 4071 | ItemSize(bb); |
3822 | 4072 | if (!ItemAdd(bb, &id)) |
r245119 | r245120 | |
3829 | 4079 | const ImU32 col = window->Color((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); |
3830 | 4080 | RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding); |
3831 | 4081 | |
3832 | | const ImVec2 off = ImVec2(ImMax(0.0f, size.x - text_size.x) * 0.5f, ImMax(0.0f, size.y - text_size.y) * 0.5f); // Center (only applies if we explicitly gave a size bigger than the text size, which isn't the common path) |
3833 | | RenderTextClipped(bb.Min + style.FramePadding + off, label, NULL, &text_size, bb.Max); // Render clip (only applies if we explicitly gave a size smaller than the text size, which isn't the commmon path) |
| 4082 | const ImVec2 off = ImVec2(ImMax(0.0f, size.x - label_size.x) * 0.5f, ImMax(0.0f, size.y - label_size.y) * 0.5f); // Center (only applies if we explicitly gave a size bigger than the text size, which isn't the common path) |
| 4083 | RenderTextClipped(bb.Min + style.FramePadding + off, label, NULL, &label_size, bb.Max); // Render clip (only applies if we explicitly gave a size smaller than the text size, which isn't the commmon path) |
3834 | 4084 | |
3835 | 4085 | return pressed; |
3836 | 4086 | } |
r245119 | r245120 | |
3845 | 4095 | |
3846 | 4096 | const ImGuiStyle& style = g.Style; |
3847 | 4097 | const ImGuiID id = window->GetID(label); |
3848 | | const ImVec2 text_size = CalcTextSize(label, NULL, true); |
| 4098 | const ImVec2 label_size = CalcTextSize(label, NULL, true); |
3849 | 4099 | |
3850 | | const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + text_size + ImVec2(style.FramePadding.x*2,0)); |
| 4100 | const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + label_size + ImVec2(style.FramePadding.x*2,0)); |
3851 | 4101 | ItemSize(bb); |
3852 | 4102 | if (!ItemAdd(bb, &id)) |
3853 | 4103 | return false; |
r245119 | r245120 | |
3888 | 4138 | { |
3889 | 4139 | ImGuiWindow* window = GetCurrentWindow(); |
3890 | 4140 | |
3891 | | const ImGuiID id = window->GetID("##CLOSE"); |
| 4141 | const ImGuiID id = window->GetID("#CLOSE"); |
3892 | 4142 | const float size = window->TitleBarHeight() - 4.0f; |
3893 | 4143 | const ImGuiAabb bb(window->Aabb().GetTR() + ImVec2(-3.0f-size,2.0f), window->Aabb().GetTR() + ImVec2(-3.0f,2.0f+size)); |
3894 | 4144 | |
r245119 | r245120 | |
4082 | 4332 | LogToClipboard(g.LogAutoExpandMaxDepth); |
4083 | 4333 | } |
4084 | 4334 | |
4085 | | bool ImGui::CollapsingHeader(const char* label, const char* str_id, const bool display_frame, const bool default_open) |
| 4335 | bool ImGui::CollapsingHeader(const char* label, const char* str_id, bool display_frame, bool default_open) |
4086 | 4336 | { |
4087 | 4337 | ImGuiState& g = *GImGui; |
4088 | 4338 | ImGuiWindow* window = GetCurrentWindow(); |
r245119 | r245120 | |
4098 | 4348 | label = str_id; |
4099 | 4349 | const ImGuiID id = window->GetID(str_id); |
4100 | 4350 | |
4101 | | // We only write to the tree storage if the user clicks |
| 4351 | // We only write to the tree storage if the user clicks (or explicitely use SetNextTreeNode*** functions) |
4102 | 4352 | ImGuiStorage* storage = window->DC.StateStorage; |
4103 | 4353 | bool opened; |
4104 | | if (window->DC.OpenNextNode != -1) |
| 4354 | if (g.SetNextTreeNodeOpenedCond != 0) |
4105 | 4355 | { |
4106 | | opened = window->DC.OpenNextNode > 0; |
4107 | | storage->SetInt(id, opened); |
4108 | | window->DC.OpenNextNode = -1; |
| 4356 | if (g.SetNextTreeNodeOpenedCond & ImGuiSetCond_Always) |
| 4357 | { |
| 4358 | opened = g.SetNextTreeNodeOpenedVal; |
| 4359 | storage->SetInt(id, opened); |
| 4360 | } |
| 4361 | else |
| 4362 | { |
| 4363 | // We treat ImGuiSetCondition_Once and ImGuiSetCondition_FirstUseEver the same because tree node state are not saved persistently. |
| 4364 | const int stored_value = storage->GetInt(id, -1); |
| 4365 | if (stored_value == -1) |
| 4366 | { |
| 4367 | opened = g.SetNextTreeNodeOpenedVal; |
| 4368 | storage->SetInt(id, opened); |
| 4369 | } |
| 4370 | else |
| 4371 | { |
| 4372 | opened = stored_value != 0; |
| 4373 | } |
| 4374 | } |
| 4375 | g.SetNextTreeNodeOpenedCond = 0; |
4109 | 4376 | } |
4110 | 4377 | else |
4111 | 4378 | { |
r245119 | r245120 | |
4114 | 4381 | |
4115 | 4382 | // Framed header expand a little outside the default padding |
4116 | 4383 | const ImVec2 window_padding = window->WindowPadding(); |
4117 | | const ImVec2 text_size = CalcTextSize(label, NULL, true); |
| 4384 | const ImVec2 label_size = CalcTextSize(label, NULL, true); |
4118 | 4385 | const ImVec2 pos_min = window->DC.CursorPos; |
4119 | 4386 | const ImVec2 pos_max = window->Pos + GetContentRegionMax(); |
4120 | | ImGuiAabb bb = ImGuiAabb(pos_min, ImVec2(pos_max.x, pos_min.y + text_size.y)); |
| 4387 | ImGuiAabb bb = ImGuiAabb(pos_min, ImVec2(pos_max.x, pos_min.y + label_size.y)); |
4121 | 4388 | if (display_frame) |
4122 | 4389 | { |
4123 | 4390 | bb.Min.x -= window_padding.x*0.5f - 1; |
r245119 | r245120 | |
4125 | 4392 | bb.Max.y += style.FramePadding.y * 2; |
4126 | 4393 | } |
4127 | 4394 | |
4128 | | const ImGuiAabb text_bb(bb.Min, bb.Min + ImVec2(window->FontSize() + style.FramePadding.x*2*2,0) + text_size); |
| 4395 | const ImGuiAabb text_bb(bb.Min, bb.Min + ImVec2(window->FontSize() + style.FramePadding.x*2*2,0) + label_size); |
4129 | 4396 | ItemSize(ImVec2(text_bb.GetSize().x, bb.GetSize().y)); // NB: we don't provide our width so that it doesn't get feed back into AutoFit |
4130 | 4397 | |
4131 | 4398 | // When logging is enabled, if automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behaviour). |
4132 | 4399 | // NB- If we are above max depth we still allow manually opened nodes to be logged. |
4133 | | if (!display_frame) |
4134 | | if (g.LogEnabled && window->DC.TreeDepth < g.LogAutoExpandMaxDepth) |
4135 | | opened = true; |
| 4400 | if (g.LogEnabled && !display_frame && window->DC.TreeDepth < g.LogAutoExpandMaxDepth) |
| 4401 | opened = true; |
4136 | 4402 | |
4137 | 4403 | if (!ItemAdd(bb, &id)) |
4138 | 4404 | return opened; |
r245119 | r245120 | |
4179 | 4445 | return opened; |
4180 | 4446 | } |
4181 | 4447 | |
| 4448 | void ImGui::Bullet() |
| 4449 | { |
| 4450 | ImGuiState& g = *GImGui; |
| 4451 | ImGuiWindow* window = GetCurrentWindow(); |
| 4452 | if (window->SkipItems) |
| 4453 | return; |
| 4454 | |
| 4455 | const ImGuiStyle& style = g.Style; |
| 4456 | const float line_height = window->FontSize(); |
| 4457 | const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(line_height, line_height)); |
| 4458 | ItemSize(bb); |
| 4459 | if (!ItemAdd(bb, NULL)) |
| 4460 | return; |
| 4461 | |
| 4462 | // Render |
| 4463 | const float bullet_size = line_height*0.15f; |
| 4464 | window->DrawList->AddCircleFilled(bb.Min + ImVec2(style.FramePadding.x + line_height*0.5f, line_height*0.5f), bullet_size, window->Color(ImGuiCol_Text)); |
| 4465 | |
| 4466 | // Stay on same line |
| 4467 | ImGui::SameLine(0, -1); |
| 4468 | } |
| 4469 | |
4182 | 4470 | // Text with a little bullet aligned to the typical tree node. |
4183 | 4471 | void ImGui::BulletTextV(const char* fmt, va_list args) |
4184 | 4472 | { |
r245119 | r245120 | |
4187 | 4475 | if (window->SkipItems) |
4188 | 4476 | return; |
4189 | 4477 | |
4190 | | const ImGuiStyle& style = g.Style; |
4191 | | |
4192 | 4478 | static char buf[1024]; |
4193 | 4479 | const char* text_begin = buf; |
4194 | 4480 | const char* text_end = text_begin + ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args); |
4195 | 4481 | |
| 4482 | const ImGuiStyle& style = g.Style; |
4196 | 4483 | const float line_height = window->FontSize(); |
4197 | | const ImVec2 text_size = CalcTextSize(text_begin, text_end, true); |
4198 | | const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(line_height + (text_size.x > 0.0f ? (style.FramePadding.x*2) : 0.0f),0) + text_size); // Empty text doesn't add padding |
| 4484 | const ImVec2 label_size = CalcTextSize(text_begin, text_end, true); |
| 4485 | const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(line_height + (label_size.x > 0.0f ? (style.FramePadding.x*2) : 0.0f),0) + label_size); // Empty text doesn't add padding |
4199 | 4486 | ItemSize(bb); |
4200 | 4487 | if (!ItemAdd(bb, NULL)) |
4201 | 4488 | return; |
r245119 | r245120 | |
4275 | 4562 | return TreeNode(str_label_id, "%s", str_label_id); |
4276 | 4563 | } |
4277 | 4564 | |
4278 | | void ImGui::OpenNextNode(bool open) |
| 4565 | void ImGui::SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond) |
4279 | 4566 | { |
4280 | | ImGuiWindow* window = GetCurrentWindow(); |
4281 | | window->DC.OpenNextNode = open ? 1 : 0; |
| 4567 | ImGuiState& g = *GImGui; |
| 4568 | g.SetNextTreeNodeOpenedVal = opened; |
| 4569 | g.SetNextTreeNodeOpenedCond = cond ? cond : ImGuiSetCond_Always; |
4282 | 4570 | } |
4283 | 4571 | |
4284 | 4572 | void ImGui::PushID(const char* str_id) |
r245119 | r245120 | |
4322 | 4610 | // NB: only call right after InputText because we are using its InitialValue storage |
4323 | 4611 | static void ApplyNumericalTextInput(const char* buf, float *v) |
4324 | 4612 | { |
4325 | | while (*buf == ' ' || *buf == '\t') |
| 4613 | while (ImCharIsSpace(*buf)) |
4326 | 4614 | buf++; |
4327 | 4615 | |
4328 | 4616 | // We don't support '-' op because it would conflict with inputing negative value. |
r245119 | r245120 | |
4331 | 4619 | if (op == '+' || op == '*' || op == '/') |
4332 | 4620 | { |
4333 | 4621 | buf++; |
4334 | | while (*buf == ' ' || *buf == '\t') |
| 4622 | while (ImCharIsSpace(*buf)) |
4335 | 4623 | buf++; |
4336 | 4624 | } |
4337 | 4625 | else |
r245119 | r245120 | |
4395 | 4683 | } |
4396 | 4684 | } |
4397 | 4685 | |
4398 | | const ImVec2 text_size = CalcTextSize(label, NULL, true); |
4399 | | const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, text_size.y) + style.FramePadding*2.0f); |
| 4686 | const ImVec2 label_size = CalcTextSize(label, NULL, true); |
| 4687 | const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y) + style.FramePadding*2.0f); |
4400 | 4688 | const ImGuiAabb slider_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding); |
4401 | | const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(text_size.x > 0.0f ? style.ItemInnerSpacing.x + text_size.x : 0.0f, 0.0f)); |
| 4689 | const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); |
4402 | 4690 | |
4403 | 4691 | // NB- we don't call ItemSize() yet becausae we may turn into a text edit box later in the function |
4404 | 4692 | if (!ItemAdd(slider_bb, &id)) |
r245119 | r245120 | |
4414 | 4702 | const float grab_size_in_units = 1.0f; // In 'v' units. Probably needs to be parametrized, based on a 'v_step' value? decimal precision? |
4415 | 4703 | float grab_size_in_pixels; |
4416 | 4704 | if (decimal_precision > 0 || is_unbound) |
4417 | | grab_size_in_pixels = 10.0f; |
| 4705 | grab_size_in_pixels = style.GrabMinSize; |
4418 | 4706 | else |
4419 | | grab_size_in_pixels = ImMax(grab_size_in_units * (w / (v_max-v_min+1.0f)), 8.0f); // Integer sliders |
| 4707 | grab_size_in_pixels = ImMax(grab_size_in_units * (w / (v_max-v_min+1.0f)), style.GrabMinSize); // Integer sliders |
4420 | 4708 | const float slider_effective_w = slider_bb.GetWidth() - grab_size_in_pixels; |
4421 | 4709 | const float slider_effective_x1 = slider_bb.Min.x + grab_size_in_pixels*0.5f; |
4422 | 4710 | const float slider_effective_x2 = slider_bb.Max.x - grab_size_in_pixels*0.5f; |
r245119 | r245120 | |
4471 | 4759 | if (g.SliderAsInputTextId == 0) |
4472 | 4760 | { |
4473 | 4761 | // First frame |
4474 | | IM_ASSERT(g.ActiveId == id); // InputText ID should match the Slider ID (else we'd need to store them both which is also possible) |
| 4762 | IM_ASSERT(g.ActiveId == id); // InputText ID expected to match the Slider ID (else we'd need to store them both, which is also possible) |
4475 | 4763 | g.SliderAsInputTextId = g.ActiveId; |
4476 | | SetActiveId(id); |
4477 | 4764 | g.HoveredId = id; |
4478 | 4765 | } |
4479 | | else |
| 4766 | else if (g.ActiveId != g.SliderAsInputTextId) |
4480 | 4767 | { |
4481 | | if (g.ActiveId == g.SliderAsInputTextId) |
4482 | | SetActiveId(id); |
4483 | | else |
4484 | | { |
4485 | | SetActiveId(0); |
4486 | | g.SliderAsInputTextId = 0; |
4487 | | } |
| 4768 | // Release |
| 4769 | g.SliderAsInputTextId = 0; |
4488 | 4770 | } |
4489 | 4771 | if (value_changed) |
4490 | 4772 | { |
r245119 | r245120 | |
4579 | 4861 | |
4580 | 4862 | // Draw value using user-provided display format so user can add prefix/suffix/decorations to the value. |
4581 | 4863 | char value_buf[64]; |
4582 | | ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), display_format, *v); |
4583 | | RenderText(ImVec2(slider_bb.GetCenter().x-CalcTextSize(value_buf, NULL, true).x*0.5f, frame_bb.Min.y + style.FramePadding.y), value_buf); |
| 4864 | char* value_buf_end = value_buf + ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), display_format, *v); |
| 4865 | const ImVec2 value_text_size = CalcTextSize(value_buf, value_buf_end, true); |
| 4866 | RenderTextClipped(ImVec2(ImMax(frame_bb.Min.x + style.FramePadding.x, slider_bb.GetCenter().x - value_text_size.x*0.5f), frame_bb.Min.y + style.FramePadding.y), value_buf, value_buf_end, &value_text_size, frame_bb.Max); |
4584 | 4867 | |
4585 | 4868 | RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, slider_bb.Min.y), label); |
4586 | 4869 | |
r245119 | r245120 | |
4721 | 5004 | |
4722 | 5005 | const ImGuiStyle& style = g.Style; |
4723 | 5006 | |
4724 | | const ImVec2 text_size = ImGui::CalcTextSize(label, NULL, true); |
| 5007 | const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true); |
4725 | 5008 | if (graph_size.x == 0.0f) |
4726 | 5009 | graph_size.x = ImGui::CalcItemWidth(); |
4727 | 5010 | if (graph_size.y == 0.0f) |
4728 | | graph_size.y = text_size.y; |
| 5011 | graph_size.y = label_size.y; |
4729 | 5012 | |
4730 | 5013 | const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(graph_size.x, graph_size.y) + style.FramePadding*2.0f); |
4731 | 5014 | const ImGuiAabb graph_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding); |
4732 | | const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(text_size.x > 0.0f ? style.ItemInnerSpacing.x + text_size.x : 0.0f, 0)); |
| 5015 | const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0)); |
4733 | 5016 | ItemSize(bb); |
4734 | 5017 | if (!ItemAdd(bb, NULL)) |
4735 | 5018 | return; |
r245119 | r245120 | |
4854 | 5137 | |
4855 | 5138 | const ImGuiStyle& style = g.Style; |
4856 | 5139 | const ImGuiID id = window->GetID(label); |
4857 | | const ImVec2 text_size = CalcTextSize(label, NULL, true); |
| 5140 | const ImVec2 label_size = CalcTextSize(label, NULL, true); |
4858 | 5141 | |
4859 | | const ImGuiAabb check_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(text_size.y + style.FramePadding.y*2, text_size.y + style.FramePadding.y*2)); |
| 5142 | const ImGuiAabb check_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(label_size.y + style.FramePadding.y*2, label_size.y + style.FramePadding.y*2)); |
4860 | 5143 | ItemSize(check_bb); |
4861 | 5144 | |
4862 | 5145 | ImGuiAabb total_bb = check_bb; |
4863 | | if (text_size.x > 0) |
| 5146 | if (label_size.x > 0) |
4864 | 5147 | SameLine(0, (int)style.ItemInnerSpacing.x); |
4865 | | const ImGuiAabb text_bb(window->DC.CursorPos + ImVec2(0,style.FramePadding.y), window->DC.CursorPos + ImVec2(0,style.FramePadding.y) + text_size); |
4866 | | if (text_size.x > 0) |
| 5148 | const ImGuiAabb text_bb(window->DC.CursorPos + ImVec2(0,style.FramePadding.y), window->DC.CursorPos + ImVec2(0,style.FramePadding.y) + label_size); |
| 5149 | if (label_size.x > 0) |
4867 | 5150 | { |
4868 | 5151 | ItemSize(ImVec2(text_bb.GetWidth(), check_bb.GetHeight())); |
4869 | 5152 | total_bb = ImGuiAabb(ImMin(check_bb.Min, text_bb.Min), ImMax(check_bb.Max, text_bb.Max)); |
r245119 | r245120 | |
4912 | 5195 | |
4913 | 5196 | const ImGuiStyle& style = g.Style; |
4914 | 5197 | const ImGuiID id = window->GetID(label); |
| 5198 | const ImVec2 label_size = CalcTextSize(label, NULL, true); |
4915 | 5199 | |
4916 | | const ImVec2 text_size = CalcTextSize(label, NULL, true); |
4917 | | |
4918 | | const ImGuiAabb check_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(text_size.y + style.FramePadding.y*2-1, text_size.y + style.FramePadding.y*2-1)); |
| 5200 | const ImGuiAabb check_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(label_size.y + style.FramePadding.y*2-1, label_size.y + style.FramePadding.y*2-1)); |
4919 | 5201 | ItemSize(check_bb); |
4920 | 5202 | |
4921 | 5203 | ImGuiAabb total_bb = check_bb; |
4922 | | if (text_size.x > 0) |
| 5204 | if (label_size.x > 0) |
4923 | 5205 | SameLine(0, (int)style.ItemInnerSpacing.x); |
4924 | | const ImGuiAabb text_bb(window->DC.CursorPos + ImVec2(0, style.FramePadding.y), window->DC.CursorPos + ImVec2(0, style.FramePadding.y) + text_size); |
4925 | | if (text_size.x > 0) |
| 5206 | const ImGuiAabb text_bb(window->DC.CursorPos + ImVec2(0, style.FramePadding.y), window->DC.CursorPos + ImVec2(0, style.FramePadding.y) + label_size); |
| 5207 | if (label_size.x > 0) |
4926 | 5208 | { |
4927 | 5209 | ItemSize(ImVec2(text_bb.GetWidth(), check_bb.GetHeight())); |
4928 | 5210 | total_bb.Add(text_bb); |
r245119 | r245120 | |
4988 | 5270 | r->num_chars = (int)(text_remaining - (obj->Text + line_start_idx)); |
4989 | 5271 | } |
4990 | 5272 | |
4991 | | static bool is_white(unsigned int c) { return c==0 || c==' ' || c=='\t' || c=='\r' || c=='\n'; } |
4992 | 5273 | static bool is_separator(unsigned int c) { return c==',' || c==';' || c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' || c=='|'; } |
4993 | | #define STB_TEXTEDIT_IS_SPACE(CH) ( is_white((unsigned int)CH) || is_separator((unsigned int)CH) ) |
4994 | | static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, int pos, int n) { ImWchar* dst = obj->Text+pos; const ImWchar* src = obj->Text+pos+n; while (ImWchar c = *src++) *dst++ = c; *dst = '\0'; } |
| 5274 | #define STB_TEXTEDIT_IS_SPACE(CH) ( ImCharIsSpace((unsigned int)CH) || is_separator((unsigned int)CH) ) |
| 5275 | static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, int pos, int n) |
| 5276 | { |
| 5277 | ImWchar* dst = obj->Text + pos; |
| 5278 | |
| 5279 | // We maintain our buffer length in both UTF-8 and wchar formats |
| 5280 | obj->CurLenA -= ImTextCountUtf8BytesFromStr(dst, dst + n); |
| 5281 | obj->CurLenW -= n; |
| 5282 | |
| 5283 | // Offset remaining text |
| 5284 | const ImWchar* src = obj->Text + pos + n; |
| 5285 | while (ImWchar c = *src++) |
| 5286 | *dst++ = c; |
| 5287 | *dst = '\0'; |
| 5288 | } |
| 5289 | |
4995 | 5290 | static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const ImWchar* new_text, int new_text_len) |
4996 | 5291 | { |
4997 | | const size_t text_len = ImStrlenW(obj->Text); |
4998 | | if ((size_t)new_text_len + text_len + 1 >= obj->BufSize) |
| 5292 | const size_t text_len = obj->CurLenW; |
| 5293 | if ((size_t)new_text_len + text_len + 1 > IM_ARRAYSIZE(obj->Text)) |
4999 | 5294 | return false; |
5000 | 5295 | |
| 5296 | const int new_text_len_utf8 = ImTextCountUtf8BytesFromStr(new_text, new_text + new_text_len); |
| 5297 | if ((size_t)new_text_len_utf8 + obj->CurLenA + 1 > obj->BufSizeA) |
| 5298 | return false; |
| 5299 | |
5001 | 5300 | if (pos != (int)text_len) |
5002 | 5301 | memmove(obj->Text + (size_t)pos + new_text_len, obj->Text + (size_t)pos, (text_len - (size_t)pos) * sizeof(ImWchar)); |
5003 | 5302 | memcpy(obj->Text + (size_t)pos, new_text, (size_t)new_text_len * sizeof(ImWchar)); |
5004 | | obj->Text[text_len + (size_t)new_text_len] = '\0'; |
5005 | 5303 | |
| 5304 | obj->CurLenW += new_text_len; |
| 5305 | obj->CurLenA += new_text_len_utf8; |
| 5306 | obj->Text[obj->CurLenW] = '\0'; |
| 5307 | |
5006 | 5308 | return true; |
5007 | 5309 | } |
5008 | 5310 | |
r245119 | r245120 | |
5096 | 5398 | const char* text_start = GetTextPointerClippedA(font, font_size, buf, scroll_x, NULL); |
5097 | 5399 | const char* text_end = GetTextPointerClippedA(font, font_size, text_start, width, &text_size); |
5098 | 5400 | |
| 5401 | // We need to test for the possibility of malformed UTF-8 (instead of just text_end[0] != 0) |
| 5402 | unsigned int text_end_char = 0; |
| 5403 | ImTextCharFromUtf8(&text_end_char, text_end, NULL); |
| 5404 | |
5099 | 5405 | // Draw a little clip symbol if we've got text on either left or right of the box |
5100 | 5406 | const char symbol_c = '~'; |
5101 | 5407 | const float symbol_w = font_size*0.40f; // FIXME: compute correct width |
5102 | 5408 | const float clip_begin = (text_start > buf && text_start < text_end) ? symbol_w : 0.0f; |
5103 | | const float clip_end = (text_end[0] != '\0' && text_end > text_start) ? symbol_w : 0.0f; |
| 5409 | const float clip_end = (text_end_char != 0 && text_end > text_start) ? symbol_w : 0.0f; |
5104 | 5410 | |
5105 | 5411 | // Draw text |
5106 | 5412 | RenderText(pos+ImVec2(clip_begin,0), text_start+(clip_begin>0.0f?1:0), text_end-(clip_end>0.0f?1:0), false); |
r245119 | r245120 | |
5122 | 5428 | |
5123 | 5429 | const ImGuiStyle& style = g.Style; |
5124 | 5430 | const float w = ImGui::CalcItemWidth(); |
5125 | | const ImVec2 text_size = CalcTextSize(label, NULL, true); |
5126 | | const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, text_size.y) + style.FramePadding*2.0f); |
| 5431 | const ImVec2 label_size = CalcTextSize(label, NULL, true); |
| 5432 | const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y) + style.FramePadding*2.0f); |
5127 | 5433 | |
5128 | 5434 | ImGui::PushID(label); |
5129 | 5435 | const float button_sz = window->FontSize(); |
r245119 | r245120 | |
5163 | 5469 | |
5164 | 5470 | ImGui::PopID(); |
5165 | 5471 | |
5166 | | if (text_size.x > 0) |
| 5472 | if (label_size.x > 0) |
5167 | 5473 | { |
5168 | 5474 | ImGui::SameLine(0, (int)style.ItemInnerSpacing.x); |
5169 | | ItemSize(text_size); |
| 5475 | ItemSize(label_size); |
5170 | 5476 | RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); |
5171 | 5477 | } |
5172 | 5478 | |
r245119 | r245120 | |
5222 | 5528 | SelectionStart = SelectionEnd = CursorPos; |
5223 | 5529 | } |
5224 | 5530 | |
5225 | | static bool InputTextFilterCharacter(ImWchar c, ImGuiInputTextFlags flags) |
| 5531 | // Return false to discard a character. |
| 5532 | static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data) |
5226 | 5533 | { |
| 5534 | unsigned int c = *p_char; |
| 5535 | |
5227 | 5536 | if (c < 128 && c != ' ' && !isprint((int)(c & 0xFF))) |
5228 | | return true; |
| 5537 | return false; |
5229 | 5538 | |
5230 | 5539 | if (c >= 0xE000 && c <= 0xF8FF) // Filter private Unicode range. I don't imagine anybody would want to input them. GLFW on OSX seems to send private characters for special keys like arrow keys. |
5231 | | return true; |
| 5540 | return false; |
5232 | 5541 | |
5233 | | if (flags & ImGuiInputTextFlags_CharsDecimal) |
5234 | | if (!(c >= '0' && c <= '9') && (c != '.') && (c != '-') && (c != '+') && (c != '*') && (c != '/')) |
5235 | | return true; |
| 5542 | if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank)) |
| 5543 | { |
| 5544 | if (flags & ImGuiInputTextFlags_CharsDecimal) |
| 5545 | if (!(c >= '0' && c <= '9') && (c != '.') && (c != '-') && (c != '+') && (c != '*') && (c != '/')) |
| 5546 | return false; |
5236 | 5547 | |
5237 | | if (flags & ImGuiInputTextFlags_CharsHexadecimal) |
5238 | | if (!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f') && !(c >= 'A' && c <= 'F')) |
5239 | | return true; |
| 5548 | if (flags & ImGuiInputTextFlags_CharsHexadecimal) |
| 5549 | if (!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f') && !(c >= 'A' && c <= 'F')) |
| 5550 | return false; |
5240 | 5551 | |
5241 | | return false; |
| 5552 | if (flags & ImGuiInputTextFlags_CharsUppercase) |
| 5553 | if (c >= 'a' && c <= 'z') |
| 5554 | *p_char = (c += (unsigned int)('A'-'a')); |
| 5555 | |
| 5556 | if (flags & ImGuiInputTextFlags_CharsNoBlank) |
| 5557 | if (ImCharIsSpace(c)) |
| 5558 | return false; |
| 5559 | } |
| 5560 | |
| 5561 | if (flags & ImGuiInputTextFlags_CallbackCharFilter) |
| 5562 | { |
| 5563 | ImGuiTextEditCallbackData callback_data; |
| 5564 | memset(&callback_data, 0, sizeof(ImGuiTextEditCallbackData)); |
| 5565 | callback_data.EventFlag = ImGuiInputTextFlags_CallbackCharFilter; |
| 5566 | callback_data.EventChar = c; |
| 5567 | callback_data.Flags = flags; |
| 5568 | callback_data.UserData = user_data; |
| 5569 | if (callback(&callback_data) != 0) |
| 5570 | return false; |
| 5571 | *p_char = callback_data.EventChar; |
| 5572 | if (!callback_data.EventChar) |
| 5573 | return false; |
| 5574 | } |
| 5575 | |
| 5576 | return true; |
5242 | 5577 | } |
5243 | 5578 | |
5244 | 5579 | // Edit a string of text |
5245 | | bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags, void (*callback)(ImGuiTextEditCallbackData*), void* user_data) |
| 5580 | bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data) |
5246 | 5581 | { |
5247 | 5582 | ImGuiState& g = *GImGui; |
5248 | 5583 | ImGuiWindow* window = GetCurrentWindow(); |
r245119 | r245120 | |
5255 | 5590 | const ImGuiID id = window->GetID(label); |
5256 | 5591 | const float w = ImGui::CalcItemWidth(); |
5257 | 5592 | |
5258 | | const ImVec2 text_size = CalcTextSize(label, NULL, true); |
5259 | | const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, text_size.y) + style.FramePadding*2.0f); |
5260 | | const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(text_size.x > 0.0f ? (style.ItemInnerSpacing.x + text_size.x) : 0.0f, 0.0f)); |
| 5593 | const ImVec2 label_size = CalcTextSize(label, NULL, true); |
| 5594 | const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y) + style.FramePadding*2.0f); |
| 5595 | const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? (style.ItemInnerSpacing.x + label_size.x) : 0.0f, 0.0f)); |
5261 | 5596 | ItemSize(bb); |
5262 | 5597 | if (!ItemAdd(frame_bb, &id)) |
5263 | 5598 | return false; |
r245119 | r245120 | |
5267 | 5602 | |
5268 | 5603 | const bool is_ctrl_down = io.KeyCtrl; |
5269 | 5604 | const bool is_shift_down = io.KeyShift; |
5270 | | const bool tab_focus_requested = window->FocusItemRegister(g.ActiveId == id, (flags & ImGuiInputTextFlags_CallbackCompletion) == 0); // Using completion callback disable keyboard tabbing |
5271 | | //const bool align_center = (bool)(flags & ImGuiInputTextFlags_AlignCenter); // FIXME: Unsupported |
| 5605 | const bool focus_requested = window->FocusItemRegister(g.ActiveId == id, (flags & ImGuiInputTextFlags_CallbackCompletion) == 0); // Using completion callback disable keyboard tabbing |
| 5606 | const bool focus_requested_by_code = focus_requested && (window->FocusIdxAllCounter == window->FocusIdxAllRequestCurrent); |
| 5607 | const bool focus_requested_by_tab = focus_requested && !focus_requested_by_code; |
5272 | 5608 | |
5273 | 5609 | const bool hovered = IsHovered(frame_bb, id); |
5274 | 5610 | if (hovered) |
5275 | 5611 | g.HoveredId = id; |
| 5612 | const bool user_clicked = hovered && io.MouseClicked[0]; |
5276 | 5613 | |
5277 | 5614 | bool select_all = (g.ActiveId != id) && (flags & ImGuiInputTextFlags_AutoSelectAll) != 0; |
5278 | | if (tab_focus_requested || (hovered && io.MouseClicked[0])) |
| 5615 | if (focus_requested || user_clicked) |
5279 | 5616 | { |
5280 | 5617 | if (g.ActiveId != id) |
5281 | 5618 | { |
5282 | 5619 | // Start edition |
5283 | 5620 | // Take a copy of the initial buffer value (both in original UTF-8 format and converted to wchar) |
| 5621 | // From the moment we focused we are ignoring the content of 'buf' |
5284 | 5622 | ImFormatString(edit_state.InitialText, IM_ARRAYSIZE(edit_state.InitialText), "%s", buf); |
5285 | | ImTextStrFromUtf8(edit_state.Text, IM_ARRAYSIZE(edit_state.Text), buf, NULL); |
5286 | | edit_state.ScrollX = 0.0f; |
| 5623 | const char* buf_end = NULL; |
| 5624 | edit_state.CurLenW = (int)ImTextStrFromUtf8(edit_state.Text, IM_ARRAYSIZE(edit_state.Text), buf, NULL, &buf_end); |
| 5625 | edit_state.CurLenA = (int)(buf_end - buf); // We can't get the result from ImFormatString() above because it is not UTF-8 aware. Here we'll cut off malformed UTF-8. |
5287 | 5626 | edit_state.Width = w; |
5288 | | stb_textedit_initialize_state(&edit_state.StbState, true); |
| 5627 | edit_state.InputCursorScreenPos = ImVec2(-1.f,-1.f); |
5289 | 5628 | edit_state.CursorAnimReset(); |
5290 | | edit_state.LastCursorPos = ImVec2(-1.f,-1.f); |
5291 | 5629 | |
5292 | | if (tab_focus_requested || is_ctrl_down) |
| 5630 | if (edit_state.Id != id) |
| 5631 | { |
| 5632 | edit_state.Id = id; |
| 5633 | edit_state.ScrollX = 0.0f; |
| 5634 | stb_textedit_initialize_state(&edit_state.StbState, true); |
| 5635 | if (focus_requested_by_code) |
| 5636 | select_all = true; |
| 5637 | } |
| 5638 | else |
| 5639 | { |
| 5640 | // Recycle existing cursor/selection/undo stack but clamp position |
| 5641 | // Note a single mouse click will override the cursor/position immediately by calling stb_textedit_click handler. |
| 5642 | edit_state.StbState.cursor = ImMin(edit_state.StbState.cursor, edit_state.CurLenW); |
| 5643 | edit_state.StbState.select_start = ImMin(edit_state.StbState.select_start, edit_state.CurLenW); |
| 5644 | edit_state.StbState.select_end = ImMin(edit_state.StbState.select_end, edit_state.CurLenW); |
| 5645 | } |
| 5646 | if (focus_requested_by_tab || (user_clicked && is_ctrl_down)) |
5293 | 5647 | select_all = true; |
5294 | 5648 | } |
5295 | 5649 | SetActiveId(id); |
r245119 | r245120 | |
5304 | 5658 | } |
5305 | 5659 | } |
5306 | 5660 | |
| 5661 | // Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget. |
| 5662 | // Down the line we should have a cleaner concept of focused vs active in the library. |
| 5663 | if (g.ActiveId == id) |
| 5664 | g.ActiveIdIsFocusedOnly = !io.MouseDown[0]; |
| 5665 | |
5307 | 5666 | bool value_changed = false; |
5308 | 5667 | bool cancel_edit = false; |
5309 | 5668 | bool enter_pressed = false; |
r245119 | r245120 | |
5311 | 5670 | if (g.ActiveId == id) |
5312 | 5671 | { |
5313 | 5672 | // Edit in progress |
5314 | | edit_state.BufSize = buf_size < IM_ARRAYSIZE(edit_state.Text) ? buf_size : IM_ARRAYSIZE(edit_state.Text); |
| 5673 | edit_state.BufSizeA = buf_size; |
5315 | 5674 | edit_state.Font = window->Font(); |
5316 | 5675 | edit_state.FontSize = window->FontSize(); |
5317 | 5676 | |
r245119 | r245120 | |
5343 | 5702 | // Process text input (before we check for Return because using some IME will effectively send a Return?) |
5344 | 5703 | for (int n = 0; n < IM_ARRAYSIZE(g.IO.InputCharacters) && g.IO.InputCharacters[n]; n++) |
5345 | 5704 | { |
5346 | | const ImWchar c = g.IO.InputCharacters[n]; |
| 5705 | unsigned int c = (unsigned int)g.IO.InputCharacters[n]; |
5347 | 5706 | if (c) |
5348 | 5707 | { |
5349 | 5708 | // Insert character if they pass filtering |
5350 | | if (InputTextFilterCharacter(c, flags)) |
| 5709 | if (!InputTextFilterCharacter(&c, flags, callback, user_data)) |
5351 | 5710 | continue; |
5352 | | edit_state.OnKeyPressed(c); |
| 5711 | edit_state.OnKeyPressed((int)c); |
5353 | 5712 | } |
5354 | 5713 | } |
5355 | 5714 | |
r245119 | r245120 | |
5379 | 5738 | if (g.IO.SetClipboardTextFn) |
5380 | 5739 | { |
5381 | 5740 | const int ib = edit_state.HasSelection() ? ImMin(edit_state.StbState.select_start, edit_state.StbState.select_end) : 0; |
5382 | | const int ie = edit_state.HasSelection() ? ImMax(edit_state.StbState.select_start, edit_state.StbState.select_end) : (int)ImStrlenW(edit_state.Text); |
| 5741 | const int ie = edit_state.HasSelection() ? ImMax(edit_state.StbState.select_start, edit_state.StbState.select_end) : edit_state.CurLenW; |
5383 | 5742 | ImTextStrToUtf8(text_tmp_utf8, IM_ARRAYSIZE(text_tmp_utf8), edit_state.Text+ib, edit_state.Text+ie); |
5384 | 5743 | g.IO.SetClipboardTextFn(text_tmp_utf8); |
5385 | 5744 | } |
r245119 | r245120 | |
5395 | 5754 | if (const char* clipboard = g.IO.GetClipboardTextFn()) |
5396 | 5755 | { |
5397 | 5756 | // Remove new-line from pasted buffer |
5398 | | size_t clipboard_len = strlen(clipboard); |
| 5757 | const size_t clipboard_len = strlen(clipboard); |
5399 | 5758 | ImWchar* clipboard_filtered = (ImWchar*)ImGui::MemAlloc((clipboard_len+1) * sizeof(ImWchar)); |
5400 | 5759 | int clipboard_filtered_len = 0; |
5401 | 5760 | for (const char* s = clipboard; *s; ) |
5402 | 5761 | { |
5403 | 5762 | unsigned int c; |
5404 | | const int bytes_count = ImTextCharFromUtf8(&c, s, NULL); |
5405 | | if (bytes_count <= 0) |
| 5763 | s += ImTextCharFromUtf8(&c, s, NULL); |
| 5764 | if (c == 0) |
5406 | 5765 | break; |
5407 | | s += bytes_count; |
5408 | 5766 | if (c >= 0x10000) |
5409 | 5767 | continue; |
5410 | | if (InputTextFilterCharacter((ImWchar)c, flags)) |
| 5768 | if (!InputTextFilterCharacter(&c, flags, callback, user_data)) |
5411 | 5769 | continue; |
5412 | 5770 | clipboard_filtered[clipboard_filtered_len++] = (ImWchar)c; |
5413 | 5771 | } |
r245119 | r245120 | |
5442 | 5800 | IM_ASSERT(callback != NULL); |
5443 | 5801 | |
5444 | 5802 | // The reason we specify the usage semantic (Completion/History) is that Completion needs to disable keyboard TABBING at the moment. |
| 5803 | ImGuiInputTextFlags event_flag = 0; |
5445 | 5804 | ImGuiKey event_key = ImGuiKey_COUNT; |
5446 | 5805 | if ((flags & ImGuiInputTextFlags_CallbackCompletion) != 0 && IsKeyPressedMap(ImGuiKey_Tab)) |
| 5806 | { |
| 5807 | event_flag = ImGuiInputTextFlags_CallbackCompletion; |
5447 | 5808 | event_key = ImGuiKey_Tab; |
| 5809 | } |
5448 | 5810 | else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_UpArrow)) |
| 5811 | { |
| 5812 | event_flag = ImGuiInputTextFlags_CallbackHistory; |
5449 | 5813 | event_key = ImGuiKey_UpArrow; |
| 5814 | } |
5450 | 5815 | else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_DownArrow)) |
| 5816 | { |
| 5817 | event_flag = ImGuiInputTextFlags_CallbackHistory; |
5451 | 5818 | event_key = ImGuiKey_DownArrow; |
| 5819 | } |
5452 | 5820 | |
5453 | 5821 | if (event_key != ImGuiKey_COUNT || (flags & ImGuiInputTextFlags_CallbackAlways) != 0) |
5454 | 5822 | { |
5455 | 5823 | ImGuiTextEditCallbackData callback_data; |
| 5824 | callback_data.EventFlag = event_flag; |
5456 | 5825 | callback_data.EventKey = event_key; |
5457 | 5826 | callback_data.Buf = text_tmp_utf8; |
5458 | | callback_data.BufSize = edit_state.BufSize; |
| 5827 | callback_data.BufSize = edit_state.BufSizeA; |
5459 | 5828 | callback_data.BufDirty = false; |
5460 | 5829 | callback_data.Flags = flags; |
5461 | 5830 | callback_data.UserData = user_data; |
5462 | 5831 | |
5463 | 5832 | // We have to convert from position from wchar to UTF-8 positions |
5464 | | const int utf8_cursor_pos = callback_data.CursorPos = ImTextCountUtf8BytesFromWchar(edit_state.Text, edit_state.Text + edit_state.StbState.cursor); |
5465 | | const int utf8_selection_start = callback_data.SelectionStart = ImTextCountUtf8BytesFromWchar(edit_state.Text, edit_state.Text + edit_state.StbState.select_start); |
5466 | | const int utf8_selection_end = callback_data.SelectionEnd = ImTextCountUtf8BytesFromWchar(edit_state.Text, edit_state.Text + edit_state.StbState.select_end); |
| 5833 | const int utf8_cursor_pos = callback_data.CursorPos = ImTextCountUtf8BytesFromStr(edit_state.Text, edit_state.Text + edit_state.StbState.cursor); |
| 5834 | const int utf8_selection_start = callback_data.SelectionStart = ImTextCountUtf8BytesFromStr(edit_state.Text, edit_state.Text + edit_state.StbState.select_start); |
| 5835 | const int utf8_selection_end = callback_data.SelectionEnd = ImTextCountUtf8BytesFromStr(edit_state.Text, edit_state.Text + edit_state.StbState.select_end); |
5467 | 5836 | |
5468 | 5837 | // Call user code |
5469 | 5838 | callback(&callback_data); |
5470 | 5839 | |
5471 | 5840 | // Read back what user may have modified |
5472 | 5841 | IM_ASSERT(callback_data.Buf == text_tmp_utf8); // Invalid to modify those fields |
5473 | | IM_ASSERT(callback_data.BufSize == edit_state.BufSize); |
| 5842 | IM_ASSERT(callback_data.BufSize == edit_state.BufSizeA); |
5474 | 5843 | IM_ASSERT(callback_data.Flags == flags); |
5475 | 5844 | if (callback_data.CursorPos != utf8_cursor_pos) edit_state.StbState.cursor = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.CursorPos); |
5476 | 5845 | if (callback_data.SelectionStart != utf8_selection_start) edit_state.StbState.select_start = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionStart); |
r245119 | r245120 | |
5509 | 5878 | } |
5510 | 5879 | } |
5511 | 5880 | |
5512 | | // FIXME: 'align_center' unsupported |
5513 | 5881 | ImGuiTextEditState::RenderTextScrolledClipped(window->Font(), window->FontSize(), buf, frame_bb.Min + style.FramePadding, w, (g.ActiveId == id) ? edit_state.ScrollX : 0.0f); |
5514 | 5882 | |
5515 | 5883 | if (g.ActiveId == id) |
r245119 | r245120 | |
5520 | 5888 | if (g.InputTextState.CursorIsVisible()) |
5521 | 5889 | window->DrawList->AddRect(cursor_pos - font_off_up + ImVec2(0,2), cursor_pos + font_off_dn - ImVec2(0,3), window->Color(ImGuiCol_Text)); |
5522 | 5890 | |
5523 | | // Notify OS of text input position |
5524 | | if (io.ImeSetInputScreenPosFn && ImLengthSqr(edit_state.LastCursorPos - cursor_pos) > 0.0001f) |
| 5891 | // Notify OS of text input position for advanced IME |
| 5892 | if (io.ImeSetInputScreenPosFn && ImLengthSqr(edit_state.InputCursorScreenPos - cursor_pos) > 0.0001f) |
5525 | 5893 | io.ImeSetInputScreenPosFn((int)cursor_pos.x - 1, (int)(cursor_pos.y - window->FontSize())); // -1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety. |
5526 | 5894 | |
5527 | | edit_state.LastCursorPos = cursor_pos; |
| 5895 | edit_state.InputCursorScreenPos = cursor_pos; |
5528 | 5896 | } |
5529 | 5897 | |
5530 | | RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); |
| 5898 | if (label_size.x > 0) |
| 5899 | RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); |
5531 | 5900 | |
5532 | 5901 | if ((flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0) |
5533 | 5902 | return enter_pressed; |
r245119 | r245120 | |
5646 | 6015 | const ImGuiID id = window->GetID(label); |
5647 | 6016 | const float w = ImGui::CalcItemWidth(); |
5648 | 6017 | |
5649 | | const ImVec2 text_size = CalcTextSize(label, NULL, true); |
5650 | | const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, text_size.y) + style.FramePadding*2.0f); |
5651 | | ItemSize(frame_bb); |
| 6018 | const ImVec2 label_size = CalcTextSize(label, NULL, true); |
| 6019 | const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y) + style.FramePadding*2.0f); |
| 6020 | const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(style.ItemInnerSpacing.x + label_size.x,0)); |
| 6021 | ItemSize(bb); |
5652 | 6022 | if (!ItemAdd(frame_bb, &id)) |
5653 | 6023 | return false; |
5654 | 6024 | |
5655 | | const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(style.ItemInnerSpacing.x + text_size.x,0)); |
5656 | 6025 | const float arrow_size = (window->FontSize() + style.FramePadding.x * 2.0f); |
5657 | 6026 | const bool hovered = IsHovered(frame_bb, id); |
5658 | 6027 | |
r245119 | r245120 | |
5669 | 6038 | RenderTextClipped(frame_bb.Min + style.FramePadding, item_text, NULL, NULL, value_bb.Max); |
5670 | 6039 | } |
5671 | 6040 | |
5672 | | // Empty text doesn't add padding |
5673 | | if (text_size.x > 0) |
5674 | | { |
5675 | | ImGui::SameLine(0, (int)style.ItemInnerSpacing.x); |
5676 | | ImGui::TextUnformatted(label, FindTextDisplayEnd(label)); |
5677 | | } |
| 6041 | if (label_size.x > 0) |
| 6042 | RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); |
5678 | 6043 | |
5679 | 6044 | ImGui::PushID((int)id); |
5680 | 6045 | bool menu_toggled = false; |
r245119 | r245120 | |
5698 | 6063 | |
5699 | 6064 | const ImVec2 backup_pos = ImGui::GetCursorPos(); |
5700 | 6065 | const float popup_off_x = 0.0f;//style.ItemInnerSpacing.x; |
5701 | | const float popup_height = (text_size.y + style.ItemSpacing.y) * ImMin(items_count, height_in_items) + style.WindowPadding.y; |
| 6066 | const float popup_height = (label_size.y + style.ItemSpacing.y) * ImMin(items_count, height_in_items) + style.WindowPadding.y; |
5702 | 6067 | const ImGuiAabb popup_aabb(ImVec2(frame_bb.Min.x+popup_off_x, frame_bb.Max.y), ImVec2(frame_bb.Max.x+popup_off_x, frame_bb.Max.y + popup_height)); |
5703 | 6068 | ImGui::SetCursorPos(popup_aabb.Min - window->Pos); |
5704 | 6069 | |
r245119 | r245120 | |
5752 | 6117 | |
5753 | 6118 | const ImGuiStyle& style = g.Style; |
5754 | 6119 | const ImGuiID id = window->GetID(label); |
5755 | | const ImVec2 text_size = CalcTextSize(label, NULL, true); |
| 6120 | const ImVec2 label_size = CalcTextSize(label, NULL, true); |
5756 | 6121 | |
5757 | 6122 | const float w = window->Pos.x + ImGui::GetContentRegionMax().x - window->DC.CursorPos.x; |
5758 | | const ImVec2 size(size_arg.x != 0.0f ? size_arg.x : w, size_arg.y != 0.0f ? size_arg.y : text_size.y); |
| 6123 | const ImVec2 size(size_arg.x != 0.0f ? size_arg.x : w, size_arg.y != 0.0f ? size_arg.y : label_size.y); |
5759 | 6124 | const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + size); |
5760 | 6125 | ItemSize(bb); |
5761 | 6126 | |
r245119 | r245120 | |
5783 | 6148 | } |
5784 | 6149 | |
5785 | 6150 | //const ImVec2 off = ImVec2(ImMax(0.0f, size.x - text_size.x) * 0.5f, ImMax(0.0f, size.y - text_size.y) * 0.5f); |
5786 | | RenderTextClipped(bb.Min, label, NULL, &text_size, bb_with_spacing.Max); |
| 6151 | RenderTextClipped(bb.Min, label, NULL, &label_size, bb_with_spacing.Max); |
5787 | 6152 | |
5788 | 6153 | return pressed; |
5789 | 6154 | } |
r245119 | r245120 | |
5803 | 6168 | bool ImGui::ListBoxHeader(const char* label, const ImVec2& size_arg) |
5804 | 6169 | { |
5805 | 6170 | ImGuiWindow* window = GetCurrentWindow(); |
5806 | | if (window->SkipItems) |
5807 | | return false; |
5808 | 6171 | |
5809 | 6172 | const ImGuiStyle& style = ImGui::GetStyle(); |
5810 | 6173 | const ImGuiID id = ImGui::GetID(label); |
r245119 | r245120 | |
5816 | 6179 | size.y = (size_arg.y != 0.0f) ? size_arg.y : ImGui::GetTextLineHeightWithSpacing() * 7.4f + style.ItemSpacing.y; |
5817 | 6180 | const ImVec2 frame_size = ImVec2(size.x, ImMax(size.y, label_size.y)); |
5818 | 6181 | const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size); |
| 6182 | const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); |
| 6183 | window->DC.LastItemAabb = bb; |
5819 | 6184 | |
5820 | 6185 | if (label_size.x > 0) |
5821 | 6186 | RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); |
r245119 | r245120 | |
5842 | 6207 | |
5843 | 6208 | void ImGui::ListBoxFooter() |
5844 | 6209 | { |
| 6210 | ImGuiWindow* parent_window = GetParentWindow(); |
| 6211 | const ImGuiAabb bb = parent_window->DC.LastItemAabb; |
| 6212 | |
5845 | 6213 | ImGui::EndChildFrame(); |
| 6214 | |
| 6215 | parent_window->DC.CursorPos = bb.Min; |
| 6216 | ItemSize(bb, NULL); |
5846 | 6217 | } |
5847 | 6218 | |
5848 | 6219 | bool ImGui::ListBox(const char* label, int* current_item, const char** items, int items_count, int height_items) |
r245119 | r245120 | |
5853 | 6224 | |
5854 | 6225 | bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int height_in_items) |
5855 | 6226 | { |
| 6227 | ImGuiWindow* window = GetCurrentWindow(); |
| 6228 | if (window->SkipItems) |
| 6229 | return false; |
| 6230 | |
5856 | 6231 | if (!ImGui::ListBoxHeader(label, items_count, height_in_items)) |
5857 | 6232 | return false; |
5858 | 6233 | |
r245119 | r245120 | |
5886 | 6261 | return false; |
5887 | 6262 | |
5888 | 6263 | const ImGuiStyle& style = g.Style; |
5889 | | const ImGuiID id = window->GetID("##colorbutton"); |
| 6264 | const ImGuiID id = window->GetID("#colorbutton"); |
5890 | 6265 | const float square_size = window->FontSize(); |
5891 | 6266 | const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(square_size + style.FramePadding.x*2, square_size + (small_height ? 0 : style.FramePadding.y*2))); |
5892 | 6267 | ItemSize(bb); |
r245119 | r245120 | |
6006 | 6381 | value_changed |= ImGui::InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal); |
6007 | 6382 | ImGui::PopItemWidth(); |
6008 | 6383 | char* p = buf; |
6009 | | while (*p == '#' || *p == ' ' || *p == '\t') |
| 6384 | while (*p == '#' || ImCharIsSpace(*p)) |
6010 | 6385 | p++; |
6011 | 6386 | |
6012 | 6387 | // Treat at unsigned (%X is unsigned) |
r245119 | r245120 | |
6094 | 6469 | window->DrawList->AddLine(bb.Min, bb.Max, window->Color(ImGuiCol_Border)); |
6095 | 6470 | |
6096 | 6471 | if (window->DC.ColumnsCount > 1) |
| 6472 | { |
6097 | 6473 | PushColumnClipRect(); |
| 6474 | window->DC.ColumnsCellMinY = window->DC.CursorPos.y; |
| 6475 | } |
6098 | 6476 | } |
6099 | 6477 | |
6100 | 6478 | // A little vertical spacing. |
r245119 | r245120 | |
6123 | 6501 | window->DC.CursorPosPrevLine = ImVec2(window->DC.CursorPos.x + size.x, window->DC.CursorPos.y); |
6124 | 6502 | window->DC.CursorPos = ImVec2((float)(int)(window->Pos.x + window->DC.ColumnsStartX + window->DC.ColumnsOffsetX), (float)(int)(window->DC.CursorPos.y + line_height + g.Style.ItemSpacing.y)); |
6125 | 6503 | |
6126 | | window->SizeContentsFit = ImMax(window->SizeContentsFit, ImVec2(window->DC.CursorPosPrevLine.x, window->DC.CursorPos.y) - window->Pos + ImVec2(0.0f, window->ScrollY)); |
| 6504 | window->SizeContentsCurrent = ImMax(window->SizeContentsCurrent, ImVec2(window->DC.CursorPosPrevLine.x - window->Pos.x, window->DC.CursorPos.y + window->ScrollY - window->Pos.y)); |
6127 | 6505 | |
6128 | 6506 | window->DC.PrevLineHeight = line_height; |
6129 | 6507 | window->DC.CurrentLineHeight = 0.0f; |
6130 | 6508 | } |
6131 | 6509 | |
6132 | | static void ItemSize(const ImGuiAabb& aabb, ImVec2* adjust_start_offset) |
| 6510 | static void ItemSize(const ImGuiAabb& bb, ImVec2* adjust_start_offset) |
6133 | 6511 | { |
6134 | | ItemSize(aabb.GetSize(), adjust_start_offset); |
| 6512 | ItemSize(bb.GetSize(), adjust_start_offset); |
6135 | 6513 | } |
6136 | 6514 | |
6137 | 6515 | static bool IsClipped(const ImGuiAabb& bb) |
r245119 | r245120 | |
6160 | 6538 | window->DC.LastItemHovered = false; |
6161 | 6539 | return false; |
6162 | 6540 | } |
6163 | | window->DC.LastItemHovered = IsMouseHoveringBox(bb); // this is a sensible default but widgets are free to override it after calling ItemAdd() |
| 6541 | |
| 6542 | // This is a sensible default, but widgets are free to override it after calling ItemAdd() |
| 6543 | const bool hovered = IsMouseHoveringBox(bb); |
| 6544 | //const bool hovered = (g.ActiveId == 0 || (id && g.ActiveId == *id) || g.ActiveIdIsFocusedOnly) && IsMouseHoveringBox(bb); // matching the behaviour of IsHovered(), not always what the user wants? |
| 6545 | window->DC.LastItemHovered = hovered; |
6164 | 6546 | return true; |
6165 | 6547 | } |
6166 | 6548 | |
r245119 | r245120 | |
6225 | 6607 | } |
6226 | 6608 | } |
6227 | 6609 | |
6228 | | // FIMXE-OPT: This is called too often. We need to cache offset for active columns set. |
| 6610 | int ImGui::GetColumnIndex() |
| 6611 | { |
| 6612 | ImGuiWindow* window = GetCurrentWindow(); |
| 6613 | return window->DC.ColumnsCurrent; |
| 6614 | } |
| 6615 | |
| 6616 | int ImGui::GetColumnsCount() |
| 6617 | { |
| 6618 | ImGuiWindow* window = GetCurrentWindow(); |
| 6619 | return window->DC.ColumnsCount; |
| 6620 | } |
| 6621 | |
6229 | 6622 | float ImGui::GetColumnOffset(int column_index) |
6230 | 6623 | { |
6231 | 6624 | ImGuiState& g = *GImGui; |
r245119 | r245120 | |
6233 | 6626 | if (column_index < 0) |
6234 | 6627 | column_index = window->DC.ColumnsCurrent; |
6235 | 6628 | |
6236 | | const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index); |
6237 | | RegisterAliveId(column_id); |
6238 | | const float default_t = column_index / (float)window->DC.ColumnsCount; |
6239 | | const float t = window->StateStorage.GetFloat(column_id, default_t); // Cheaply store our floating point value inside the integer (could store an union into the map?) |
| 6629 | // Read from cache |
| 6630 | IM_ASSERT(column_index < (int)window->DC.ColumnsOffsetsT.size()); |
| 6631 | const float t = window->DC.ColumnsOffsetsT[column_index]; |
6240 | 6632 | |
6241 | | const float offset = window->DC.ColumnsStartX + t * (window->Size.x - g.Style.ScrollBarWidth - window->DC.ColumnsStartX); |
| 6633 | const float min_x = window->DC.ColumnsStartX; |
| 6634 | const float max_x = window->Size.x - (g.Style.ScrollbarWidth);// - window->WindowPadding().x; |
| 6635 | const float offset = min_x + t * (max_x - min_x); |
6242 | 6636 | return offset; |
6243 | 6637 | } |
6244 | 6638 | |
r245119 | r245120 | |
6249 | 6643 | if (column_index < 0) |
6250 | 6644 | column_index = window->DC.ColumnsCurrent; |
6251 | 6645 | |
| 6646 | IM_ASSERT(column_index < (int)window->DC.ColumnsOffsetsT.size()); |
6252 | 6647 | const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index); |
6253 | | const float t = (offset - window->DC.ColumnsStartX) / (window->Size.x - g.Style.ScrollBarWidth - window->DC.ColumnsStartX); |
6254 | | window->StateStorage.SetFloat(column_id, t); |
| 6648 | |
| 6649 | const float min_x = window->DC.ColumnsStartX; |
| 6650 | const float max_x = window->Size.x - (g.Style.ScrollbarWidth);// - window->WindowPadding().x; |
| 6651 | const float t = (offset - min_x) / (max_x - min_x); |
| 6652 | window->DC.StateStorage->SetFloat(column_id, t); |
| 6653 | window->DC.ColumnsOffsetsT[column_index] = t; |
6255 | 6654 | } |
6256 | 6655 | |
6257 | 6656 | float ImGui::GetColumnWidth(int column_index) |
r245119 | r245120 | |
6279 | 6678 | { |
6280 | 6679 | ImGuiState& g = *GImGui; |
6281 | 6680 | ImGuiWindow* window = GetCurrentWindow(); |
6282 | | if (window->SkipItems) |
6283 | | return; |
6284 | 6681 | |
6285 | 6682 | if (window->DC.ColumnsCount != 1) |
6286 | 6683 | { |
r245119 | r245120 | |
6294 | 6691 | } |
6295 | 6692 | |
6296 | 6693 | // Draw columns borders and handle resize at the time of "closing" a columns set |
6297 | | if (window->DC.ColumnsCount != columns_count && window->DC.ColumnsCount != 1 && window->DC.ColumnsShowBorders) |
| 6694 | if (window->DC.ColumnsCount != columns_count && window->DC.ColumnsCount != 1 && window->DC.ColumnsShowBorders && !window->SkipItems) |
6298 | 6695 | { |
6299 | 6696 | const float y1 = window->DC.ColumnsStartPos.y; |
6300 | 6697 | const float y2 = window->DC.CursorPos.y; |
r245119 | r245120 | |
6338 | 6735 | |
6339 | 6736 | if (window->DC.ColumnsCount != 1) |
6340 | 6737 | { |
| 6738 | // Cache column offsets |
| 6739 | window->DC.ColumnsOffsetsT.resize((size_t)columns_count + 1); |
| 6740 | for (int column_index = 0; column_index < columns_count + 1; column_index++) |
| 6741 | { |
| 6742 | const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index); |
| 6743 | RegisterAliveId(column_id); |
| 6744 | const float default_t = column_index / (float)window->DC.ColumnsCount; |
| 6745 | const float t = window->DC.StateStorage->GetFloat(column_id, default_t); // Cheaply store our floating point value inside the integer (could store an union into the map?) |
| 6746 | window->DC.ColumnsOffsetsT[column_index] = t; |
| 6747 | } |
| 6748 | |
6341 | 6749 | PushColumnClipRect(); |
6342 | 6750 | ImGui::PushItemWidth(ImGui::GetColumnWidth() * 0.65f); |
6343 | 6751 | } |
| 6752 | else |
| 6753 | { |
| 6754 | window->DC.ColumnsOffsetsT.resize(2); |
| 6755 | window->DC.ColumnsOffsetsT[0] = 0.0f; |
| 6756 | window->DC.ColumnsOffsetsT[1] = 1.0f; |
| 6757 | } |
6344 | 6758 | } |
6345 | 6759 | |
6346 | 6760 | void ImGui::TreePush(const char* str_id) |
r245119 | r245120 | |
7146 | 7560 | TexUvWhitePixel = ImVec2((TexExtraDataPos.x + 0.5f) / TexWidth, (TexExtraDataPos.y + 0.5f) / TexHeight); |
7147 | 7561 | |
7148 | 7562 | // Draw a mouse cursor into texture |
7149 | | // Because our font uses an alpha texture, we have to spread the cursor in 2 parts (black/white) which will be rendered separately. |
| 7563 | // Because our font uses a single color channel, we have to spread the cursor in 2 layers (black/white) which will be rendered separately. |
7150 | 7564 | const char cursor_pixels[] = |
7151 | 7565 | { |
7152 | 7566 | "X " |
r245119 | r245120 | |
7195 | 7609 | DisplayOffset = ImVec2(-0.5f, 0.5f); |
7196 | 7610 | ContainerAtlas = NULL; |
7197 | 7611 | Glyphs.clear(); |
| 7612 | FallbackGlyph = NULL; |
| 7613 | FallbackXAdvance = 0.0f; |
| 7614 | IndexXAdvance.clear(); |
7198 | 7615 | IndexLookup.clear(); |
7199 | | FallbackGlyph = NULL; |
7200 | 7616 | } |
7201 | 7617 | |
7202 | 7618 | // Retrieve list of range (2 int per range, values are inclusive) |
r245119 | r245120 | |
7215 | 7631 | static const ImWchar ranges[] = |
7216 | 7632 | { |
7217 | 7633 | 0x0020, 0x00FF, // Basic Latin + Latin Supplement |
7218 | | 0x3040, 0x309F, // Hiragana, Katakana |
| 7634 | 0x3000, 0x30FF, // Punctuations, Hiragana, Katakana |
| 7635 | 0x31F0, 0x31FF, // Katakana Phonetic Extensions |
7219 | 7636 | 0xFF00, 0xFFEF, // Half-width characters |
7220 | 7637 | 0x4e00, 0x9FAF, // CJK Ideograms |
7221 | 7638 | 0, |
r245119 | r245120 | |
7263 | 7680 | 109,2,18,23,0,0,9,61,3,0,28,41,77,27,19,17,81,5,2,14,5,83,57,252,14,154,263,14,20,8,13,6,57,39,38, |
7264 | 7681 | }; |
7265 | 7682 | static int ranges_unpacked = false; |
7266 | | static ImWchar ranges[6 + 1 + IM_ARRAYSIZE(offsets_from_0x4E00)*2] = |
| 7683 | static ImWchar ranges[8 + IM_ARRAYSIZE(offsets_from_0x4E00)*2 + 1] = |
7267 | 7684 | { |
7268 | 7685 | 0x0020, 0x00FF, // Basic Latin + Latin Supplement |
7269 | | 0x3040, 0x309F, // Hiragana, Katakana |
| 7686 | 0x3000, 0x30FF, // Punctuations, Hiragana, Katakana |
| 7687 | 0x31F0, 0x31FF, // Katakana Phonetic Extensions |
7270 | 7688 | 0xFF00, 0xFFEF, // Half-width characters |
7271 | | 0, |
7272 | 7689 | }; |
7273 | 7690 | if (!ranges_unpacked) |
7274 | 7691 | { |
7275 | 7692 | // Unpack |
7276 | 7693 | int codepoint = 0x4e00; |
7277 | | ImWchar* dst = &ranges[6]; |
| 7694 | ImWchar* dst = &ranges[8]; |
7278 | 7695 | for (int n = 0; n < IM_ARRAYSIZE(offsets_from_0x4E00); n++, dst += 2) |
7279 | 7696 | dst[0] = dst[1] = (ImWchar)(codepoint += (offsets_from_0x4E00[n] + 1)); |
7280 | 7697 | dst[0] = 0; |
r245119 | r245120 | |
7289 | 7706 | for (size_t i = 0; i != Glyphs.size(); i++) |
7290 | 7707 | max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint); |
7291 | 7708 | |
| 7709 | IndexXAdvance.clear(); |
| 7710 | IndexXAdvance.resize((size_t)max_codepoint + 1); |
7292 | 7711 | IndexLookup.clear(); |
7293 | 7712 | IndexLookup.resize((size_t)max_codepoint + 1); |
7294 | | for (size_t i = 0; i < IndexLookup.size(); i++) |
| 7713 | for (size_t i = 0; i < (size_t)max_codepoint + 1; i++) |
| 7714 | { |
| 7715 | IndexXAdvance[i] = -1.0f; |
7295 | 7716 | IndexLookup[i] = -1; |
| 7717 | } |
7296 | 7718 | for (size_t i = 0; i < Glyphs.size(); i++) |
7297 | | IndexLookup[(int)Glyphs[i].Codepoint] = (int)i; |
| 7719 | { |
| 7720 | const size_t codepoint = (int)Glyphs[i].Codepoint; |
| 7721 | IndexXAdvance[codepoint] = Glyphs[i].XAdvance; |
| 7722 | IndexLookup[codepoint] = (int)i; |
| 7723 | } |
7298 | 7724 | |
7299 | 7725 | // Create a glyph to handle TAB |
7300 | 7726 | // FIXME: Needs proper TAB handling but it needs to be contextualized (can arbitrary say that each string starts at "column 0" |
7301 | | if (const ImFont::Glyph* space_glyph = FindGlyph((unsigned short)' ')) |
| 7727 | if (FindGlyph((unsigned short)' ')) |
7302 | 7728 | { |
7303 | | Glyphs.resize(Glyphs.size() + 1); |
| 7729 | if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times |
| 7730 | Glyphs.resize(Glyphs.size() + 1); |
7304 | 7731 | ImFont::Glyph& tab_glyph = Glyphs.back(); |
7305 | | tab_glyph = *space_glyph; |
| 7732 | tab_glyph = *FindGlyph((unsigned short)' '); |
7306 | 7733 | tab_glyph.Codepoint = '\t'; |
7307 | 7734 | tab_glyph.XAdvance *= 4; |
7308 | | IndexLookup[(int)tab_glyph.Codepoint] = (int)(Glyphs.size()-1); |
| 7735 | IndexXAdvance[(size_t)tab_glyph.Codepoint] = (float)tab_glyph.XAdvance; |
| 7736 | IndexLookup[(size_t)tab_glyph.Codepoint] = (int)(Glyphs.size()-1); |
7309 | 7737 | } |
| 7738 | |
| 7739 | FallbackGlyph = NULL; |
| 7740 | FallbackGlyph = FindGlyph(FallbackChar); |
| 7741 | FallbackXAdvance = FallbackGlyph ? FallbackGlyph->XAdvance : 0.0f; |
| 7742 | for (size_t i = 0; i < (size_t)max_codepoint + 1; i++) |
| 7743 | if (IndexXAdvance[i] < 0.0f) |
| 7744 | IndexXAdvance[i] = FallbackXAdvance; |
7310 | 7745 | } |
7311 | 7746 | |
| 7747 | void ImFont::SetFallbackChar(ImWchar c) |
| 7748 | { |
| 7749 | FallbackChar = c; |
| 7750 | BuildLookupTable(); |
| 7751 | } |
| 7752 | |
7312 | 7753 | const ImFont::Glyph* ImFont::FindGlyph(unsigned short c) const |
7313 | 7754 | { |
7314 | 7755 | if (c < (int)IndexLookup.size()) |
r245119 | r245120 | |
7322 | 7763 | |
7323 | 7764 | // Convert UTF-8 to 32-bits character, process single character input. |
7324 | 7765 | // Based on stb_from_utf8() from github.com/nothings/stb/ |
| 7766 | // We handle UTF-8 decoding error by skipping forward. |
7325 | 7767 | static int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end) |
7326 | 7768 | { |
7327 | | if (*in_text != 0) |
| 7769 | unsigned int c = (unsigned int)-1; |
| 7770 | const unsigned char* str = (const unsigned char*)in_text; |
| 7771 | if (!(*str & 0x80)) |
7328 | 7772 | { |
7329 | | unsigned int c = (unsigned int)-1; |
7330 | | const unsigned char* str = (const unsigned char*)in_text; |
7331 | | if (!(*str & 0x80)) |
7332 | | { |
7333 | | c = (unsigned int)(*str++); |
7334 | | *out_char = c; |
7335 | | return 1; |
7336 | | } |
7337 | | if ((*str & 0xe0) == 0xc0) |
7338 | | { |
7339 | | if (in_text_end && in_text_end - (const char*)str < 2) return -1; |
7340 | | if (*str < 0xc2) return -1; |
7341 | | c = (unsigned int)((*str++ & 0x1f) << 6); |
7342 | | if ((*str & 0xc0) != 0x80) return -1; |
7343 | | c += (*str++ & 0x3f); |
7344 | | *out_char = c; |
7345 | | return 2; |
7346 | | } |
7347 | | if ((*str & 0xf0) == 0xe0) |
7348 | | { |
7349 | | if (in_text_end && in_text_end - (const char*)str < 3) return -1; |
7350 | | if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return -1; |
7351 | | if (*str == 0xed && str[1] > 0x9f) return -1; // str[1] < 0x80 is checked below |
7352 | | c = (unsigned int)((*str++ & 0x0f) << 12); |
7353 | | if ((*str & 0xc0) != 0x80) return -1; |
7354 | | c += (unsigned int)((*str++ & 0x3f) << 6); |
7355 | | if ((*str & 0xc0) != 0x80) return -1; |
7356 | | c += (*str++ & 0x3f); |
7357 | | *out_char = c; |
7358 | | return 3; |
7359 | | } |
7360 | | if ((*str & 0xf8) == 0xf0) |
7361 | | { |
7362 | | if (in_text_end && in_text_end - (const char*)str < 4) return -1; |
7363 | | if (*str > 0xf4) return -1; |
7364 | | if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return -1; |
7365 | | if (*str == 0xf4 && str[1] > 0x8f) return -1; // str[1] < 0x80 is checked below |
7366 | | c = (unsigned int)((*str++ & 0x07) << 18); |
7367 | | if ((*str & 0xc0) != 0x80) return -1; |
7368 | | c += (unsigned int)((*str++ & 0x3f) << 12); |
7369 | | if ((*str & 0xc0) != 0x80) return -1; |
7370 | | c += (unsigned int)((*str++ & 0x3f) << 6); |
7371 | | if ((*str & 0xc0) != 0x80) return -1; |
7372 | | c += (*str++ & 0x3f); |
7373 | | // utf-8 encodings of values used in surrogate pairs are invalid |
7374 | | if ((c & 0xFFFFF800) == 0xD800) return -1; |
7375 | | *out_char = c; |
7376 | | return 4; |
7377 | | } |
| 7773 | c = (unsigned int)(*str++); |
| 7774 | *out_char = c; |
| 7775 | return 1; |
7378 | 7776 | } |
| 7777 | if ((*str & 0xe0) == 0xc0) |
| 7778 | { |
| 7779 | *out_char = 0; |
| 7780 | if (in_text_end && in_text_end - (const char*)str < 2) return 0; |
| 7781 | if (*str < 0xc2) return 0; |
| 7782 | c = (unsigned int)((*str++ & 0x1f) << 6); |
| 7783 | if ((*str & 0xc0) != 0x80) return 0; |
| 7784 | c += (*str++ & 0x3f); |
| 7785 | *out_char = c; |
| 7786 | return 2; |
| 7787 | } |
| 7788 | if ((*str & 0xf0) == 0xe0) |
| 7789 | { |
| 7790 | *out_char = 0; |
| 7791 | if (in_text_end && in_text_end - (const char*)str < 3) return 0; |
| 7792 | if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return 0; |
| 7793 | if (*str == 0xed && str[1] > 0x9f) return 0; // str[1] < 0x80 is checked below |
| 7794 | c = (unsigned int)((*str++ & 0x0f) << 12); |
| 7795 | if ((*str & 0xc0) != 0x80) return 0; |
| 7796 | c += (unsigned int)((*str++ & 0x3f) << 6); |
| 7797 | if ((*str & 0xc0) != 0x80) return 0; |
| 7798 | c += (*str++ & 0x3f); |
| 7799 | *out_char = c; |
| 7800 | return 3; |
| 7801 | } |
| 7802 | if ((*str & 0xf8) == 0xf0) |
| 7803 | { |
| 7804 | *out_char = 0; |
| 7805 | if (in_text_end && in_text_end - (const char*)str < 4) return 0; |
| 7806 | if (*str > 0xf4) return 0; |
| 7807 | if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return 0; |
| 7808 | if (*str == 0xf4 && str[1] > 0x8f) return 0; // str[1] < 0x80 is checked below |
| 7809 | c = (unsigned int)((*str++ & 0x07) << 18); |
| 7810 | if ((*str & 0xc0) != 0x80) return 0; |
| 7811 | c += (unsigned int)((*str++ & 0x3f) << 12); |
| 7812 | if ((*str & 0xc0) != 0x80) return 0; |
| 7813 | c += (unsigned int)((*str++ & 0x3f) << 6); |
| 7814 | if ((*str & 0xc0) != 0x80) return 0; |
| 7815 | c += (*str++ & 0x3f); |
| 7816 | // utf-8 encodings of values used in surrogate pairs are invalid |
| 7817 | if ((c & 0xFFFFF800) == 0xD800) return 0; |
| 7818 | *out_char = c; |
| 7819 | return 4; |
| 7820 | } |
7379 | 7821 | *out_char = 0; |
7380 | 7822 | return 0; |
7381 | 7823 | } |
7382 | 7824 | |
7383 | | static ptrdiff_t ImTextStrFromUtf8(ImWchar* buf, size_t buf_size, const char* in_text, const char* in_text_end) |
| 7825 | static ptrdiff_t ImTextStrFromUtf8(ImWchar* buf, size_t buf_size, const char* in_text, const char* in_text_end, const char** in_text_remaining) |
7384 | 7826 | { |
7385 | 7827 | ImWchar* buf_out = buf; |
7386 | 7828 | ImWchar* buf_end = buf + buf_size; |
r245119 | r245120 | |
7388 | 7830 | { |
7389 | 7831 | unsigned int c; |
7390 | 7832 | in_text += ImTextCharFromUtf8(&c, in_text, in_text_end); |
| 7833 | if (c == 0) |
| 7834 | break; |
7391 | 7835 | if (c < 0x10000) // FIXME: Losing characters that don't fit in 2 bytes |
7392 | 7836 | *buf_out++ = (ImWchar)c; |
7393 | 7837 | } |
7394 | 7838 | *buf_out = 0; |
| 7839 | if (in_text_remaining) |
| 7840 | *in_text_remaining = in_text; |
7395 | 7841 | return buf_out - buf; |
7396 | 7842 | } |
7397 | 7843 | |
r245119 | r245120 | |
7402 | 7848 | { |
7403 | 7849 | unsigned int c; |
7404 | 7850 | in_text += ImTextCharFromUtf8(&c, in_text, in_text_end); |
| 7851 | if (c == 0) |
| 7852 | break; |
7405 | 7853 | if (c < 0x10000) |
7406 | 7854 | char_count++; |
7407 | 7855 | } |
r245119 | r245120 | |
7466 | 7914 | return buf_out - buf; |
7467 | 7915 | } |
7468 | 7916 | |
7469 | | static int ImTextCountUtf8BytesFromWchar(const ImWchar* in_text, const ImWchar* in_text_end) |
| 7917 | static int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end) |
7470 | 7918 | { |
7471 | 7919 | int bytes_count = 0; |
7472 | 7920 | while ((!in_text_end || in_text < in_text_end) && *in_text) |
r245119 | r245120 | |
7506 | 7954 | const char* s = text; |
7507 | 7955 | while (s < text_end) |
7508 | 7956 | { |
7509 | | unsigned int c; |
7510 | | const int bytes_count = ImTextCharFromUtf8(&c, s, text_end); |
7511 | | const char* next_s = s + (bytes_count > 0 ? bytes_count : 1); |
| 7957 | unsigned int c = (unsigned int)*s; |
| 7958 | const char* next_s; |
| 7959 | if (c < 0x80) |
| 7960 | next_s = s + 1; |
| 7961 | else |
| 7962 | next_s = s + ImTextCharFromUtf8(&c, s, text_end); |
| 7963 | if (c == 0) |
| 7964 | break; |
7512 | 7965 | |
7513 | 7966 | if (c == '\n') |
7514 | 7967 | { |
r245119 | r245120 | |
7518 | 7971 | continue; |
7519 | 7972 | } |
7520 | 7973 | |
7521 | | float char_width = 0.0f; |
7522 | | if (const Glyph* glyph = FindGlyph((unsigned short)c)) |
7523 | | char_width = glyph->XAdvance * scale; |
7524 | | |
7525 | | if (c == ' ' || c == '\t') |
| 7974 | const float char_width = ((size_t)c < IndexXAdvance.size()) ? IndexXAdvance[(size_t)c] * scale : FallbackXAdvance; |
| 7975 | if (ImCharIsSpace(c)) |
7526 | 7976 | { |
7527 | 7977 | if (inside_word) |
7528 | 7978 | { |
r245119 | r245120 | |
7604 | 8054 | while (s < text_end) |
7605 | 8055 | { |
7606 | 8056 | const char c = *s; |
7607 | | if (c == ' ' || c == '\t') { s++; } else if (c == '\n') { s++; break; } else { break; } |
| 8057 | if (ImCharIsSpace(c)) { s++; } else if (c == '\n') { s++; break; } else { break; } |
7608 | 8058 | } |
7609 | 8059 | continue; |
7610 | 8060 | } |
7611 | 8061 | } |
7612 | 8062 | |
7613 | 8063 | // Decode and advance source (handle unlikely UTF-8 decoding failure by skipping to the next byte) |
7614 | | unsigned int c; |
7615 | | const int bytes_count = ImTextCharFromUtf8(&c, s, text_end); |
7616 | | s += bytes_count > 0 ? bytes_count : 1; |
| 8064 | unsigned int c = (unsigned int)*s; |
| 8065 | if (c < 0x80) |
| 8066 | { |
| 8067 | s += 1; |
| 8068 | } |
| 8069 | else |
| 8070 | { |
| 8071 | s += ImTextCharFromUtf8(&c, s, text_end); |
| 8072 | if (c == 0) |
| 8073 | break; |
| 8074 | } |
7617 | 8075 | |
7618 | 8076 | if (c == '\n') |
7619 | 8077 | { |
r245119 | r245120 | |
7623 | 8081 | continue; |
7624 | 8082 | } |
7625 | 8083 | |
7626 | | float char_width = 0.0f; |
7627 | | if (const Glyph* glyph = FindGlyph((unsigned short)c)) |
7628 | | char_width = glyph->XAdvance * scale; |
7629 | | |
| 8084 | const float char_width = ((size_t)c < IndexXAdvance.size()) ? IndexXAdvance[(size_t)c] * scale : FallbackXAdvance; |
7630 | 8085 | if (line_width + char_width >= max_width) |
7631 | 8086 | break; |
7632 | 8087 | |
r245119 | r245120 | |
7670 | 8125 | continue; |
7671 | 8126 | } |
7672 | 8127 | |
7673 | | float char_width = 0.0f; |
7674 | | if (const Glyph* glyph = FindGlyph((unsigned short)c)) |
7675 | | char_width = glyph->XAdvance * scale; |
7676 | | |
| 8128 | const float char_width = ((size_t)c < IndexXAdvance.size()) ? IndexXAdvance[(size_t)c] * scale : FallbackXAdvance; |
7677 | 8129 | if (line_width + char_width >= max_width) |
7678 | 8130 | break; |
7679 | 8131 | |
r245119 | r245120 | |
7740 | 8192 | while (s < text_end) |
7741 | 8193 | { |
7742 | 8194 | const char c = *s; |
7743 | | if (c == ' ' || c == '\t') { s++; } else if (c == '\n') { s++; break; } else { break; } |
| 8195 | if (ImCharIsSpace(c)) { s++; } else if (c == '\n') { s++; break; } else { break; } |
7744 | 8196 | } |
7745 | 8197 | continue; |
7746 | 8198 | } |
7747 | 8199 | } |
7748 | 8200 | |
7749 | 8201 | // Decode and advance source (handle unlikely UTF-8 decoding failure by skipping to the next byte) |
7750 | | unsigned int c; |
7751 | | const int bytes_count = ImTextCharFromUtf8(&c, s, text_end); |
7752 | | s += bytes_count > 0 ? bytes_count : 1; |
| 8202 | unsigned int c = (unsigned int)*s; |
| 8203 | if (c < 0x80) |
| 8204 | { |
| 8205 | s += 1; |
| 8206 | } |
| 8207 | else |
| 8208 | { |
| 8209 | s += ImTextCharFromUtf8(&c, s, text_end); |
| 8210 | if (c == 0) |
| 8211 | break; |
| 8212 | } |
7753 | 8213 | |
7754 | 8214 | if (c == '\n') |
7755 | 8215 | { |
r245119 | r245120 | |
7831 | 8291 | |
7832 | 8292 | #if defined(_MSC_VER) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS) |
7833 | 8293 | |
| 8294 | #ifndef _WINDOWS_ |
7834 | 8295 | #define WIN32_LEAN_AND_MEAN |
7835 | 8296 | #include <windows.h> |
| 8297 | #endif |
7836 | 8298 | |
7837 | 8299 | // Win32 API clipboard implementation |
7838 | | static const char* GetClipboardTextFn_DefaultImpl() |
| 8300 | static const char* GetClipboardTextFn_DefaultImpl() |
7839 | 8301 | { |
7840 | 8302 | static char* buf_local = NULL; |
7841 | 8303 | if (buf_local) |
r245119 | r245120 | |
7845 | 8307 | } |
7846 | 8308 | if (!OpenClipboard(NULL)) |
7847 | 8309 | return NULL; |
7848 | | HANDLE buf_handle = GetClipboardData(CF_TEXT); |
7849 | | if (buf_handle == NULL) |
| 8310 | HANDLE wbuf_handle = GetClipboardData(CF_UNICODETEXT); |
| 8311 | if (wbuf_handle == NULL) |
7850 | 8312 | return NULL; |
7851 | | if (char* buf_global = (char*)GlobalLock(buf_handle)) |
7852 | | buf_local = ImStrdup(buf_global); |
7853 | | GlobalUnlock(buf_handle); |
| 8313 | if (ImWchar* wbuf_global = (ImWchar*)GlobalLock(wbuf_handle)) |
| 8314 | { |
| 8315 | int buf_len = ImTextCountUtf8BytesFromStr(wbuf_global, NULL) + 1; |
| 8316 | buf_local = (char*)ImGui::MemAlloc(buf_len * sizeof(char)); |
| 8317 | ImTextStrToUtf8(buf_local, buf_len, wbuf_global, NULL); |
| 8318 | } |
| 8319 | GlobalUnlock(wbuf_handle); |
7854 | 8320 | CloseClipboard(); |
7855 | 8321 | return buf_local; |
7856 | 8322 | } |
r245119 | r245120 | |
7860 | 8326 | { |
7861 | 8327 | if (!OpenClipboard(NULL)) |
7862 | 8328 | return; |
7863 | | const char* text_end = text + strlen(text); |
7864 | | const int buf_length = (int)(text_end - text) + 1; |
7865 | | HGLOBAL buf_handle = GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)buf_length * sizeof(char)); |
7866 | | if (buf_handle == NULL) |
| 8329 | |
| 8330 | const int wbuf_length = ImTextCountCharsFromUtf8(text, NULL) + 1; |
| 8331 | HGLOBAL wbuf_handle = GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(ImWchar)); |
| 8332 | if (wbuf_handle == NULL) |
7867 | 8333 | return; |
7868 | | char* buf_global = (char *)GlobalLock(buf_handle); |
7869 | | memcpy(buf_global, text, (size_t)(text_end - text)); |
7870 | | buf_global[text_end - text] = 0; |
7871 | | GlobalUnlock(buf_handle); |
| 8334 | ImWchar* wbuf_global = (ImWchar*)GlobalLock(wbuf_handle); |
| 8335 | ImTextStrFromUtf8(wbuf_global, wbuf_length, text, NULL); |
| 8336 | GlobalUnlock(wbuf_handle); |
7872 | 8337 | EmptyClipboard(); |
7873 | | SetClipboardData(CF_TEXT, buf_handle); |
| 8338 | SetClipboardData(CF_UNICODETEXT, wbuf_handle); |
7874 | 8339 | CloseClipboard(); |
7875 | 8340 | } |
7876 | 8341 | |
7877 | 8342 | #else |
7878 | 8343 | |
7879 | 8344 | // Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers |
7880 | | static const char* GetClipboardTextFn_DefaultImpl() |
| 8345 | static const char* GetClipboardTextFn_DefaultImpl() |
7881 | 8346 | { |
7882 | 8347 | return GImGui->PrivateClipboard; |
7883 | 8348 | } |
r245119 | r245120 | |
7899 | 8364 | |
7900 | 8365 | #endif |
7901 | 8366 | |
| 8367 | #if defined(_MSC_VER) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS) |
| 8368 | |
| 8369 | #ifndef _WINDOWS_ |
| 8370 | #define WIN32_LEAN_AND_MEAN |
| 8371 | #include <windows.h> |
| 8372 | #endif |
| 8373 | #include <Imm.h> |
| 8374 | #pragma comment(lib, "imm32") |
| 8375 | |
| 8376 | static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y) |
| 8377 | { |
| 8378 | // Notify OS Input Method Editor of text input position |
| 8379 | if (HWND hwnd = (HWND)GImGui->IO.ImeWindowHandle) |
| 8380 | if (HIMC himc = ImmGetContext(hwnd)) |
| 8381 | { |
| 8382 | COMPOSITIONFORM cf; |
| 8383 | cf.ptCurrentPos.x = x; |
| 8384 | cf.ptCurrentPos.y = y; |
| 8385 | cf.dwStyle = CFS_FORCE_POSITION; |
| 8386 | ImmSetCompositionWindow(himc, &cf); |
| 8387 | } |
| 8388 | } |
| 8389 | |
| 8390 | #else |
| 8391 | |
| 8392 | static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y) |
| 8393 | { |
| 8394 | } |
| 8395 | |
| 8396 | #endif |
| 8397 | |
7902 | 8398 | //----------------------------------------------------------------------------- |
7903 | 8399 | // HELP |
7904 | 8400 | //----------------------------------------------------------------------------- |
r245119 | r245120 | |
7957 | 8453 | ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f"); |
7958 | 8454 | ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f"); |
7959 | 8455 | ImGui::SliderFloat("TreeNodeSpacing", &style.TreeNodeSpacing, 0.0f, 20.0f, "%.0f"); |
7960 | | ImGui::SliderFloat("ScrollBarWidth", &style.ScrollBarWidth, 0.0f, 20.0f, "%.0f"); |
| 8456 | ImGui::SliderFloat("ScrollBarWidth", &style.ScrollbarWidth, 1.0f, 20.0f, "%.0f"); |
| 8457 | ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f"); |
7961 | 8458 | ImGui::TreePop(); |
7962 | 8459 | } |
7963 | 8460 | |
r245119 | r245120 | |
8028 | 8525 | static void ShowExampleAppLongText(bool* opened); |
8029 | 8526 | static void ShowExampleAppAutoResize(bool* opened); |
8030 | 8527 | static void ShowExampleAppFixedOverlay(bool* opened); |
| 8528 | static void ShowExampleAppManipulatingWindowTitle(bool* opened); |
8031 | 8529 | static void ShowExampleAppCustomRendering(bool* opened); |
8032 | 8530 | |
8033 | 8531 | // Demonstrate ImGui features (unfortunately this makes this function a little bloated!) |
8034 | 8532 | void ImGui::ShowTestWindow(bool* opened) |
8035 | 8533 | { |
| 8534 | // Examples apps |
| 8535 | static bool show_app_console = false; |
| 8536 | static bool show_app_long_text = false; |
| 8537 | static bool show_app_auto_resize = false; |
| 8538 | static bool show_app_fixed_overlay = false; |
| 8539 | static bool show_app_custom_rendering = false; |
| 8540 | static bool show_app_manipulating_window_title = false; |
| 8541 | if (show_app_console) |
| 8542 | ShowExampleAppConsole(&show_app_console); |
| 8543 | if (show_app_long_text) |
| 8544 | ShowExampleAppLongText(&show_app_long_text); |
| 8545 | if (show_app_auto_resize) |
| 8546 | ShowExampleAppAutoResize(&show_app_auto_resize); |
| 8547 | if (show_app_fixed_overlay) |
| 8548 | ShowExampleAppFixedOverlay(&show_app_fixed_overlay); |
| 8549 | if (show_app_manipulating_window_title) |
| 8550 | ShowExampleAppManipulatingWindowTitle(&show_app_manipulating_window_title); |
| 8551 | if (show_app_custom_rendering) |
| 8552 | ShowExampleAppCustomRendering(&show_app_custom_rendering); |
| 8553 | |
8036 | 8554 | static bool no_titlebar = false; |
8037 | 8555 | static bool no_border = true; |
8038 | 8556 | static bool no_resize = false; |
8039 | 8557 | static bool no_move = false; |
8040 | 8558 | static bool no_scrollbar = false; |
8041 | 8559 | static bool no_collapse = false; |
8042 | | static float fill_alpha = 0.65f; |
| 8560 | static float bg_alpha = 0.65f; |
8043 | 8561 | |
8044 | 8562 | // Demonstrate the various window flags. Typically you would just use the default. |
8045 | 8563 | ImGuiWindowFlags window_flags = 0; |
r245119 | r245120 | |
8049 | 8567 | if (no_move) window_flags |= ImGuiWindowFlags_NoMove; |
8050 | 8568 | if (no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar; |
8051 | 8569 | if (no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse; |
8052 | | if (!ImGui::Begin("ImGui Test", opened, ImVec2(550,680), fill_alpha, window_flags)) |
| 8570 | if (!ImGui::Begin("ImGui Test", opened, ImVec2(550,680), bg_alpha, window_flags)) |
8053 | 8571 | { |
8054 | 8572 | // Early out if the window is collapsed, as an optimization. |
8055 | 8573 | ImGui::End(); |
8056 | 8574 | return; |
8057 | 8575 | } |
8058 | | ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.65f); |
8059 | 8576 | |
| 8577 | ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.65f); // 2/3 of the space for widget and 1/3 for labels |
| 8578 | //ImGui::PushItemWidth(-140); // Right align, keep 140 pixels for labels |
| 8579 | |
8060 | 8580 | ImGui::Text("ImGui says hello."); |
8061 | 8581 | //ImGui::Text("MousePos (%g, %g)", ImGui::GetIO().MousePos.x, ImGui::GetIO().MousePos.y); |
8062 | 8582 | //ImGui::Text("MouseWheel %d", ImGui::GetIO().MouseWheel); |
r245119 | r245120 | |
8078 | 8598 | ImGui::Checkbox("no move", &no_move); ImGui::SameLine(150); |
8079 | 8599 | ImGui::Checkbox("no scrollbar", &no_scrollbar); ImGui::SameLine(300); |
8080 | 8600 | ImGui::Checkbox("no collapse", &no_collapse); |
8081 | | ImGui::SliderFloat("fill alpha", &fill_alpha, 0.0f, 1.0f); |
| 8601 | ImGui::SliderFloat("bg alpha", &bg_alpha, 0.0f, 1.0f); |
8082 | 8602 | |
8083 | 8603 | if (ImGui::TreeNode("Style")) |
8084 | 8604 | { |
r245119 | r245120 | |
8149 | 8669 | { |
8150 | 8670 | ImGui::BulletText("Bullet point 1"); |
8151 | 8671 | ImGui::BulletText("Bullet point 2\nOn multiple lines"); |
8152 | | ImGui::BulletText("Bullet point 3"); |
| 8672 | ImGui::Bullet(); ImGui::Text("Bullet point 3 (two calls)"); |
| 8673 | ImGui::Bullet(); ImGui::SmallButton("Button 1"); |
| 8674 | ImGui::Bullet(); ImGui::SmallButton("Button 2"); |
8153 | 8675 | ImGui::TreePop(); |
8154 | 8676 | } |
8155 | 8677 | |
r245119 | r245120 | |
8291 | 8813 | ImGui::TreePop(); |
8292 | 8814 | } |
8293 | 8815 | |
| 8816 | if (ImGui::TreeNode("Filtered Text Input")) |
| 8817 | { |
| 8818 | static char buf1[64] = ""; ImGui::InputText("default", buf1, 64); |
| 8819 | static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal); |
| 8820 | static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase); |
| 8821 | static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase); |
| 8822 | static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank); |
| 8823 | struct TextFilters { static int FilterImGuiLetters(ImGuiTextEditCallbackData* data) { if (data->EventChar < 256 && strchr("imgui", (char)data->EventChar)) return 0; return 1; } }; |
| 8824 | static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters); |
| 8825 | ImGui::TreePop(); |
| 8826 | } |
| 8827 | |
8294 | 8828 | static bool check = true; |
8295 | 8829 | ImGui::Checkbox("checkbox", &check); |
8296 | 8830 | |
r245119 | r245120 | |
8392 | 8926 | static int listbox_item_current = 1; |
8393 | 8927 | ImGui::ListBox("listbox\n(single select)", &listbox_item_current, listbox_items, IM_ARRAYSIZE(listbox_items), 4); |
8394 | 8928 | |
| 8929 | //static int listbox_item_current2 = 2; |
8395 | 8930 | //ImGui::PushItemWidth(-1); |
8396 | 8931 | //ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4); |
8397 | 8932 | //ImGui::PopItemWidth(); |
r245119 | r245120 | |
8455 | 8990 | ImGui::SameLine(); |
8456 | 8991 | ImGui::Checkbox("Rich", &c4); |
8457 | 8992 | |
8458 | | // SliderFloat |
| 8993 | // Various |
8459 | 8994 | static float f0=1.0f, f1=2.0f, f2=3.0f; |
8460 | 8995 | ImGui::PushItemWidth(80); |
| 8996 | const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD" }; |
| 8997 | static int item = -1; |
| 8998 | ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items)); |
| 8999 | ImGui::SameLine(); |
8461 | 9000 | ImGui::SliderFloat("X", &f0, 0.0f,5.0f); |
8462 | 9001 | ImGui::SameLine(); |
8463 | 9002 | ImGui::SliderFloat("Y", &f1, 0.0f,5.0f); |
8464 | 9003 | ImGui::SameLine(); |
8465 | 9004 | ImGui::SliderFloat("Z", &f2, 0.0f,5.0f); |
| 9005 | ImGui::PopItemWidth(); |
| 9006 | |
| 9007 | ImGui::PushItemWidth(80); |
| 9008 | ImGui::Text("Lists:"); |
| 9009 | static int selection[4] = { 0, 1, 2, 3 }; |
| 9010 | for (int i = 0; i < 4; i++) |
| 9011 | { |
| 9012 | if (i > 0) ImGui::SameLine(); |
| 9013 | ImGui::PushID(i); |
| 9014 | ImGui::ListBox("", &selection[i], items, IM_ARRAYSIZE(items)); |
| 9015 | ImGui::PopID(); |
| 9016 | //if (ImGui::IsItemHovered()) ImGui::SetTooltip("ListBox %d hovered", i); |
| 9017 | } |
| 9018 | ImGui::PopItemWidth(); |
8466 | 9019 | } |
8467 | 9020 | |
8468 | 9021 | if (ImGui::CollapsingHeader("Child regions")) |
r245119 | r245120 | |
8505 | 9058 | |
8506 | 9059 | if (ImGui::CollapsingHeader("Columns")) |
8507 | 9060 | { |
8508 | | ImGui::Columns(4, "data", true); |
| 9061 | // Basic columns |
| 9062 | ImGui::Text("Basic:"); |
| 9063 | ImGui::Columns(4, "mycolumns"); |
8509 | 9064 | ImGui::Text("ID"); ImGui::NextColumn(); |
8510 | 9065 | ImGui::Text("Name"); ImGui::NextColumn(); |
8511 | 9066 | ImGui::Text("Path"); ImGui::NextColumn(); |
8512 | 9067 | ImGui::Text("Flags"); ImGui::NextColumn(); |
8513 | 9068 | ImGui::Separator(); |
| 9069 | const char* names[3] = { "Robert", "Stephanie", "C64" }; |
| 9070 | const char* paths[3] = { "/path/robert", "/path/stephanie", "/path/computer" }; |
| 9071 | for (int i = 0; i < 3; i++) |
| 9072 | { |
| 9073 | ImGui::Text("%04d", i); ImGui::NextColumn(); |
| 9074 | ImGui::Text(names[i]); ImGui::NextColumn(); |
| 9075 | ImGui::Text(paths[i]); ImGui::NextColumn(); |
| 9076 | ImGui::Text("...."); ImGui::NextColumn(); |
| 9077 | } |
| 9078 | ImGui::Columns(1); |
8514 | 9079 | |
8515 | | ImGui::Text("0000"); ImGui::NextColumn(); |
8516 | | ImGui::Text("Robert"); ImGui::NextColumn(); |
8517 | | ImGui::Text("/path/robert"); ImGui::NextColumn(); |
8518 | | ImGui::Text("...."); ImGui::NextColumn(); |
| 9080 | ImGui::Separator(); |
| 9081 | ImGui::Spacing(); |
8519 | 9082 | |
8520 | | ImGui::Text("0001"); ImGui::NextColumn(); |
8521 | | ImGui::Text("Stephanie"); ImGui::NextColumn(); |
8522 | | ImGui::Text("/path/stephanie"); ImGui::NextColumn(); |
8523 | | ImGui::Text("line 1"); ImGui::Text("line 2"); ImGui::NextColumn(); // two lines, two items |
8524 | | |
8525 | | ImGui::Text("0002"); ImGui::NextColumn(); |
8526 | | ImGui::Text("C64"); ImGui::NextColumn(); |
8527 | | ImGui::Text("/path/computer"); ImGui::NextColumn(); |
8528 | | ImGui::Text("...."); ImGui::NextColumn(); |
| 9083 | // Scrolling columns |
| 9084 | /* |
| 9085 | ImGui::Text("Scrolling:"); |
| 9086 | ImGui::BeginChild("##header", ImVec2(0, ImGui::GetTextLineHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y)); |
| 9087 | ImGui::Columns(3); |
| 9088 | ImGui::Text("ID"); ImGui::NextColumn(); |
| 9089 | ImGui::Text("Name"); ImGui::NextColumn(); |
| 9090 | ImGui::Text("Path"); ImGui::NextColumn(); |
8529 | 9091 | ImGui::Columns(1); |
| 9092 | ImGui::Separator(); |
| 9093 | ImGui::EndChild(); |
| 9094 | ImGui::BeginChild("##scrollingregion", ImVec2(0, 60)); |
| 9095 | ImGui::Columns(3); |
| 9096 | for (int i = 0; i < 10; i++) |
| 9097 | { |
| 9098 | ImGui::Text("%04d", i); ImGui::NextColumn(); |
| 9099 | ImGui::Text("Foobar"); ImGui::NextColumn(); |
| 9100 | ImGui::Text("/path/foobar/%04d/", i); ImGui::NextColumn(); |
| 9101 | } |
| 9102 | ImGui::Columns(1); |
| 9103 | ImGui::EndChild(); |
8530 | 9104 | |
8531 | 9105 | ImGui::Separator(); |
| 9106 | ImGui::Spacing(); |
| 9107 | */ |
8532 | 9108 | |
| 9109 | // Create multiple items in a same cell before switching to next column |
| 9110 | ImGui::Text("Mixed items:"); |
8533 | 9111 | ImGui::Columns(3, "mixed"); |
| 9112 | ImGui::Separator(); |
8534 | 9113 | |
8535 | | // Create multiple items in a same cell because switching to next column |
8536 | 9114 | static int e = 0; |
8537 | 9115 | ImGui::Text("Hello"); |
8538 | 9116 | ImGui::Button("Banana"); |
r245119 | r245120 | |
8542 | 9120 | ImGui::Text("ImGui"); |
8543 | 9121 | ImGui::Button("Apple"); |
8544 | 9122 | ImGui::RadioButton("radio b", &e, 1); |
| 9123 | static float foo = 1.0f; |
| 9124 | ImGui::InputFloat("red", &foo, 0.05f, 0, 3); |
8545 | 9125 | ImGui::Text("An extra line here."); |
8546 | 9126 | ImGui::NextColumn(); |
8547 | 9127 | |
8548 | 9128 | ImGui::Text("World!"); |
8549 | 9129 | ImGui::Button("Corniflower"); |
8550 | 9130 | ImGui::RadioButton("radio c", &e, 2); |
| 9131 | static float bar = 1.0f; |
| 9132 | ImGui::InputFloat("blue", &bar, 0.05f, 0, 3); |
8551 | 9133 | ImGui::NextColumn(); |
8552 | 9134 | |
8553 | 9135 | if (ImGui::CollapsingHeader("Category A")) ImGui::Text("Blah blah blah"); ImGui::NextColumn(); |
8554 | 9136 | if (ImGui::CollapsingHeader("Category B")) ImGui::Text("Blah blah blah"); ImGui::NextColumn(); |
8555 | 9137 | if (ImGui::CollapsingHeader("Category C")) ImGui::Text("Blah blah blah"); ImGui::NextColumn(); |
8556 | | |
8557 | 9138 | ImGui::Columns(1); |
8558 | 9139 | |
8559 | 9140 | ImGui::Separator(); |
| 9141 | ImGui::Spacing(); |
8560 | 9142 | |
8561 | | ImGui::Columns(2, "multiple components"); |
8562 | | static float foo = 1.0f; |
8563 | | ImGui::InputFloat("red", &foo, 0.05f, 0, 3); ImGui::NextColumn(); |
8564 | | static float bar = 1.0f; |
8565 | | ImGui::InputFloat("blue", &bar, 0.05f, 0, 3); ImGui::NextColumn(); |
| 9143 | // Tree items |
| 9144 | ImGui::Text("Tree items:"); |
| 9145 | ImGui::Columns(2, "tree items"); |
| 9146 | ImGui::Separator(); |
| 9147 | if (ImGui::TreeNode("Hello")) { ImGui::BulletText("World"); ImGui::TreePop(); } ImGui::NextColumn(); |
| 9148 | if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Monde"); ImGui::TreePop(); } ImGui::NextColumn(); |
8566 | 9149 | ImGui::Columns(1); |
8567 | 9150 | |
8568 | 9151 | ImGui::Separator(); |
| 9152 | ImGui::Spacing(); |
8569 | 9153 | |
8570 | | ImGui::Columns(2, "tree items"); |
8571 | | if (ImGui::TreeNode("Hello")) { ImGui::BulletText("World"); ImGui::TreePop(); } ImGui::NextColumn(); |
8572 | | if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Monde"); ImGui::TreePop(); } |
8573 | | ImGui::Columns(1); |
| 9154 | // Word-wrapping |
| 9155 | ImGui::Text("Word-wrapping:"); |
| 9156 | ImGui::Columns(2, "word-wrapping"); |
8574 | 9157 | ImGui::Separator(); |
8575 | | |
8576 | | ImGui::Columns(2, "word wrapping"); |
8577 | 9158 | ImGui::TextWrapped("The quick brown fox jumps over the lazy dog."); |
8578 | 9159 | ImGui::Text("Hello Left"); |
8579 | 9160 | ImGui::NextColumn(); |
r245119 | r245120 | |
8582 | 9163 | ImGui::Columns(1); |
8583 | 9164 | |
8584 | 9165 | ImGui::Separator(); |
| 9166 | ImGui::Spacing(); |
8585 | 9167 | |
8586 | 9168 | if (ImGui::TreeNode("Inside a tree..")) |
8587 | 9169 | { |
8588 | 9170 | if (ImGui::TreeNode("node 1 (with borders)")) |
8589 | 9171 | { |
8590 | 9172 | ImGui::Columns(4); |
8591 | | ImGui::Text("aaa"); ImGui::NextColumn(); |
8592 | | ImGui::Text("bbb"); ImGui::NextColumn(); |
8593 | | ImGui::Text("ccc"); ImGui::NextColumn(); |
8594 | | ImGui::Text("ddd"); ImGui::NextColumn(); |
8595 | | ImGui::Text("eee"); ImGui::NextColumn(); |
8596 | | ImGui::Text("fff"); ImGui::NextColumn(); |
8597 | | ImGui::Text("ggg"); ImGui::NextColumn(); |
8598 | | ImGui::Text("hhh"); ImGui::NextColumn(); |
| 9173 | for (int i = 0; i < 8; i++) |
| 9174 | { |
| 9175 | ImGui::Text("%c%c%c", 'a'+i, 'a'+i, 'a'+i); |
| 9176 | ImGui::NextColumn(); |
| 9177 | } |
8599 | 9178 | ImGui::Columns(1); |
8600 | 9179 | ImGui::TreePop(); |
8601 | 9180 | } |
8602 | 9181 | if (ImGui::TreeNode("node 2 (without borders)")) |
8603 | 9182 | { |
8604 | 9183 | ImGui::Columns(4, NULL, false); |
8605 | | ImGui::Text("aaa"); ImGui::NextColumn(); |
8606 | | ImGui::Text("bbb"); ImGui::NextColumn(); |
8607 | | ImGui::Text("ccc"); ImGui::NextColumn(); |
8608 | | ImGui::Text("ddd"); ImGui::NextColumn(); |
8609 | | ImGui::Text("eee"); ImGui::NextColumn(); |
8610 | | ImGui::Text("fff"); ImGui::NextColumn(); |
8611 | | ImGui::Text("ggg"); ImGui::NextColumn(); |
8612 | | ImGui::Text("hhh"); ImGui::NextColumn(); |
| 9184 | for (int i = 0; i < 8; i++) |
| 9185 | { |
| 9186 | ImGui::Text("%c%c%c", 'a'+i, 'a'+i, 'a'+i); |
| 9187 | ImGui::NextColumn(); |
| 9188 | } |
8613 | 9189 | ImGui::Columns(1); |
8614 | 9190 | ImGui::TreePop(); |
8615 | 9191 | } |
r245119 | r245120 | |
8674 | 9250 | ImGui::Text("Item with focus: %d", has_focus); |
8675 | 9251 | else |
8676 | 9252 | ImGui::Text("Item with focus: <none>"); |
| 9253 | ImGui::TextWrapped("Cursor & selection are preserved when refocusing last used item in code."); |
8677 | 9254 | ImGui::TreePop(); |
8678 | 9255 | } |
8679 | 9256 | } |
8680 | 9257 | |
8681 | | static bool show_app_console = false; |
8682 | | static bool show_app_long_text = false; |
8683 | | static bool show_app_auto_resize = false; |
8684 | | static bool show_app_fixed_overlay = false; |
8685 | | static bool show_app_custom_rendering = false; |
8686 | 9258 | if (ImGui::CollapsingHeader("App Examples")) |
8687 | 9259 | { |
8688 | 9260 | ImGui::Checkbox("Console", &show_app_console); |
8689 | 9261 | ImGui::Checkbox("Long text display", &show_app_long_text); |
8690 | 9262 | ImGui::Checkbox("Auto-resizing window", &show_app_auto_resize); |
8691 | 9263 | ImGui::Checkbox("Simple overlay", &show_app_fixed_overlay); |
| 9264 | ImGui::Checkbox("Manipulating window title", &show_app_manipulating_window_title); |
8692 | 9265 | ImGui::Checkbox("Custom rendering", &show_app_custom_rendering); |
8693 | 9266 | } |
8694 | | if (show_app_console) |
8695 | | ShowExampleAppConsole(&show_app_console); |
8696 | | if (show_app_long_text) |
8697 | | ShowExampleAppLongText(&show_app_long_text); |
8698 | | if (show_app_auto_resize) |
8699 | | ShowExampleAppAutoResize(&show_app_auto_resize); |
8700 | | if (show_app_fixed_overlay) |
8701 | | ShowExampleAppFixedOverlay(&show_app_fixed_overlay); |
8702 | | if (show_app_custom_rendering) |
8703 | | ShowExampleAppCustomRendering(&show_app_custom_rendering); |
8704 | 9267 | |
8705 | 9268 | ImGui::End(); |
8706 | 9269 | } |
r245119 | r245120 | |
8738 | 9301 | ImGui::End(); |
8739 | 9302 | } |
8740 | 9303 | |
| 9304 | static void ShowExampleAppManipulatingWindowTitle(bool* /*opened*/) |
| 9305 | { |
| 9306 | // By default, Windows are uniquely identified by their title. |
| 9307 | // You can use the "##" and "###" markers to manipulate the display/ID. Read FAQ at the top of this file! |
| 9308 | |
| 9309 | // Using "##" to display same title but have unique identifier. |
| 9310 | ImGui::SetNextWindowPos(ImVec2(100,100), ImGuiSetCond_FirstUseEver); |
| 9311 | ImGui::Begin("Same title as another window##1"); |
| 9312 | ImGui::Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique."); |
| 9313 | ImGui::End(); |
| 9314 | |
| 9315 | ImGui::SetNextWindowPos(ImVec2(100,200), ImGuiSetCond_FirstUseEver); |
| 9316 | ImGui::Begin("Same title as another window##2"); |
| 9317 | ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique."); |
| 9318 | ImGui::End(); |
| 9319 | |
| 9320 | // Using "###" to display a changing title but keep a static identifier "MyWindow" |
| 9321 | char buf[128]; |
| 9322 | ImFormatString(buf, IM_ARRAYSIZE(buf), "Animated title %c %d###MyWindow", "|/-\\"[(int)(ImGui::GetTime()/0.25f)&3], rand()); |
| 9323 | ImGui::SetNextWindowPos(ImVec2(100,300), ImGuiSetCond_FirstUseEver); |
| 9324 | ImGui::Begin(buf); |
| 9325 | ImGui::Text("This window has a changing title."); |
| 9326 | ImGui::End(); |
| 9327 | } |
| 9328 | |
8741 | 9329 | static void ShowExampleAppCustomRendering(bool* opened) |
8742 | 9330 | { |
| 9331 | ImGui::SetNextWindowSize(ImVec2(300,350), ImGuiSetCond_FirstUseEver); |
8743 | 9332 | if (!ImGui::Begin("Example: Custom Rendering", opened)) |
8744 | 9333 | { |
8745 | 9334 | ImGui::End(); |
r245119 | r245120 | |
8754 | 9343 | static ImVector<ImVec2> points; |
8755 | 9344 | static bool adding_line = false; |
8756 | 9345 | if (ImGui::Button("Clear")) points.clear(); |
8757 | | if (points.size() > 2) { ImGui::SameLine(); if (ImGui::Button("Undo")) points.pop_back(); } |
| 9346 | if (points.size() >= 2) { ImGui::SameLine(); if (ImGui::Button("Undo")) { points.pop_back(); points.pop_back(); } } |
8758 | 9347 | ImGui::Text("Left-click and drag to add lines"); |
8759 | 9348 | ImGui::Text("Right-click to undo"); |
8760 | 9349 | |
r245119 | r245120 | |
8860 | 9449 | if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.size()); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine(); |
8861 | 9450 | if (ImGui::SmallButton("Add Dummy Error")) AddLog("[error] something went wrong"); ImGui::SameLine(); |
8862 | 9451 | if (ImGui::SmallButton("Clear")) ClearLog(); |
| 9452 | //static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); } |
| 9453 | |
8863 | 9454 | ImGui::Separator(); |
8864 | 9455 | |
8865 | 9456 | ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0)); |
r245119 | r245120 | |
8945 | 9536 | } |
8946 | 9537 | } |
8947 | 9538 | |
8948 | | static void TextEditCallbackStub(ImGuiTextEditCallbackData* data) |
| 9539 | static int TextEditCallbackStub(ImGuiTextEditCallbackData* data) |
8949 | 9540 | { |
8950 | 9541 | ExampleAppConsole* console = (ExampleAppConsole*)data->UserData; |
8951 | | console->TextEditCallback(data); |
| 9542 | return console->TextEditCallback(data); |
8952 | 9543 | } |
8953 | 9544 | |
8954 | | void TextEditCallback(ImGuiTextEditCallbackData* data) |
| 9545 | int TextEditCallback(ImGuiTextEditCallbackData* data) |
8955 | 9546 | { |
8956 | 9547 | //AddLog("cursor: %d, selection: %d-%d", data->CursorPos, data->SelectionStart, data->SelectionEnd); |
8957 | | switch (data->EventKey) |
| 9548 | switch (data->EventFlag) |
8958 | 9549 | { |
8959 | | case ImGuiKey_Tab: |
| 9550 | case ImGuiInputTextFlags_CallbackCompletion: |
8960 | 9551 | { |
8961 | 9552 | // Example of TEXT COMPLETION |
8962 | 9553 | |
r245119 | r245120 | |
8966 | 9557 | while (word_start > data->Buf) |
8967 | 9558 | { |
8968 | 9559 | const char c = word_start[-1]; |
8969 | | if (c == ' ' || c == '\t' || c == ',' || c == ';') |
| 9560 | if (ImCharIsSpace(c) || c == ',' || c == ';') |
8970 | 9561 | break; |
8971 | 9562 | word_start--; |
8972 | 9563 | } |
r245119 | r245120 | |
9021 | 9612 | |
9022 | 9613 | break; |
9023 | 9614 | } |
9024 | | case ImGuiKey_UpArrow: |
9025 | | case ImGuiKey_DownArrow: |
| 9615 | case ImGuiInputTextFlags_CallbackHistory: |
9026 | 9616 | { |
9027 | 9617 | // Example of HISTORY |
9028 | 9618 | const int prev_history_pos = HistoryPos; |
r245119 | r245120 | |
9049 | 9639 | } |
9050 | 9640 | } |
9051 | 9641 | } |
| 9642 | return 0; |
9052 | 9643 | } |
9053 | 9644 | }; |
9054 | 9645 | |
trunk/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
r245119 | r245120 | |
1 | | // ImGui library v1.32 wip |
| 1 | // ImGui library v1.35 |
2 | 2 | // See .cpp file for documentation. |
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. |
r245119 | r245120 | |
6 | 6 | |
7 | 7 | #pragma once |
8 | 8 | |
9 | | struct ImDrawCmd; |
10 | | struct ImDrawList; |
11 | | struct ImFont; |
12 | | struct ImFontAtlas; |
13 | | struct ImGuiAabb; |
14 | | struct ImGuiIO; |
15 | | struct ImGuiStorage; |
16 | | struct ImGuiStyle; |
17 | | struct ImGuiWindow; |
18 | | |
19 | | #include "imconfig.h" |
| 9 | #include "imconfig.h" // User-editable configuration file |
20 | 10 | #include <float.h> // FLT_MAX |
21 | 11 | #include <stdarg.h> // va_list |
22 | 12 | #include <stddef.h> // ptrdiff_t |
23 | 13 | #include <stdlib.h> // NULL, malloc |
24 | 14 | #include <string.h> // memset, memmove |
25 | 15 | |
| 16 | // Define assertion handler. |
26 | 17 | #ifndef IM_ASSERT |
27 | 18 | #include <assert.h> |
28 | 19 | #define IM_ASSERT(_EXPR) assert(_EXPR) |
29 | 20 | #endif |
30 | 21 | |
| 22 | // Define attributes of all API symbols declarations, e.g. for DLL under Windows. |
31 | 23 | #ifndef IMGUI_API |
32 | 24 | #define IMGUI_API |
33 | 25 | #endif |
34 | 26 | |
| 27 | // Forward declarations |
| 28 | struct ImDrawCmd; |
| 29 | struct ImDrawList; |
| 30 | struct ImFont; |
| 31 | struct ImFontAtlas; |
| 32 | struct ImGuiIO; |
| 33 | struct ImGuiStorage; |
| 34 | struct ImGuiStyle; |
| 35 | |
35 | 36 | typedef unsigned int ImU32; |
36 | 37 | typedef unsigned short ImWchar; // character for display |
37 | 38 | typedef void* ImTextureID; // user data to refer to a texture (e.g. store your texture handle/id) |
r245119 | r245120 | |
41 | 42 | typedef int ImGuiKey; // enum ImGuiKey_ |
42 | 43 | typedef int ImGuiColorEditMode; // enum ImGuiColorEditMode_ |
43 | 44 | typedef int ImGuiWindowFlags; // enum ImGuiWindowFlags_ |
44 | | typedef int ImGuiSetCondition; // enum ImGuiSetCondition_ |
| 45 | typedef int ImGuiSetCond; // enum ImGuiSetCondition_ |
45 | 46 | typedef int ImGuiInputTextFlags; // enum ImGuiInputTextFlags_ |
46 | | struct ImGuiTextEditCallbackData; // for advanced uses of InputText() |
| 47 | struct ImGuiTextEditCallbackData; // for advanced uses of InputText() |
| 48 | typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data); |
47 | 49 | |
48 | 50 | struct ImVec2 |
49 | 51 | { |
r245119 | r245120 | |
74 | 76 | IMGUI_API void MemFree(void* ptr); |
75 | 77 | } |
76 | 78 | |
77 | | // 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). |
| 79 | // 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). |
78 | 80 | // Use '#define ImVector std::vector' if you want to use the STL type or your own type. |
79 | 81 | // 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. |
80 | 82 | #ifndef ImVector |
r245119 | r245120 | |
115 | 117 | 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; } |
116 | 118 | |
117 | 119 | inline void resize(size_t new_size) { if (new_size > Capacity) reserve(new_size); Size = new_size; } |
118 | | inline void reserve(size_t new_capacity) |
119 | | { |
| 120 | inline void reserve(size_t new_capacity) |
| 121 | { |
120 | 122 | if (new_capacity <= Capacity) return; |
121 | 123 | T* new_data = (value_type*)ImGui::MemAlloc(new_capacity * sizeof(value_type)); |
122 | 124 | memcpy(new_data, Data, Size * sizeof(value_type)); |
123 | 125 | ImGui::MemFree(Data); |
124 | 126 | Data = new_data; |
125 | | Capacity = new_capacity; |
| 127 | Capacity = new_capacity; |
126 | 128 | } |
127 | 129 | |
128 | 130 | inline void push_back(const value_type& v) { if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); Data[Size++] = v; } |
r245119 | r245120 | |
141 | 143 | // - struct ImDrawList // Draw command list |
142 | 144 | // - struct ImFont // TTF font loader, bake glyphs into bitmap |
143 | 145 | |
144 | | // ImGui End-user API |
| 146 | // ImGui end-user API |
145 | 147 | // In a namespace so that user can add extra functions (e.g. Value() helpers for your vector or common types) |
146 | 148 | namespace ImGui |
147 | 149 | { |
r245119 | r245120 | |
156 | 158 | IMGUI_API void ShowTestWindow(bool* open = NULL); |
157 | 159 | |
158 | 160 | // Window |
159 | | IMGUI_API bool Begin(const char* name = "Debug", bool* p_opened = NULL, ImVec2 size = ImVec2(0,0), float fill_alpha = -1.0f, ImGuiWindowFlags flags = 0);// return false when window is collapsed, so you can early out in your code. passing 'bool* p_opened' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed. |
| 161 | // See implementation in .cpp for details |
| 162 | IMGUI_API bool Begin(const char* name = "Debug", bool* p_opened = NULL, const ImVec2& initial_size = ImVec2(0,0), float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0); // return false when window is collapsed, so you can early out in your code. passing 'bool* p_opened' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed. |
160 | 163 | IMGUI_API void End(); |
161 | | IMGUI_API void BeginChild(const char* str_id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). on each axis. |
162 | | IMGUI_API void BeginChild(ImGuiID id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // " |
| 164 | IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). on each axis. |
| 165 | IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // " |
163 | 166 | IMGUI_API void EndChild(); |
164 | 167 | IMGUI_API bool GetWindowIsFocused(); |
165 | 168 | IMGUI_API ImVec2 GetContentRegionMax(); // window or current column boundaries, in windows coordinates |
r245119 | r245120 | |
173 | 176 | IMGUI_API ImVec2 GetWindowSize(); // get current window position. |
174 | 177 | IMGUI_API float GetWindowWidth(); |
175 | 178 | IMGUI_API bool GetWindowCollapsed(); |
176 | | IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0); // set next window position - call before Begin(). |
177 | | IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0); // set next window size. set to ImVec2(0,0) to force an auto-fit. |
178 | | IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0); // set next window collapsed state. |
179 | | IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0); // set current window position - call within Begin()/End(). may incur tearing. |
180 | | IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0); // set current window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing. |
181 | | IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0); // set current window collapsed state. |
182 | 179 | |
| 180 | IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); // set next window position - call before Begin(). |
| 181 | IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); // set next window size. set to ImVec2(0,0) to force an auto-fit. |
| 182 | IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // set next window collapsed state. |
| 183 | IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most |
| 184 | IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); // set current window position - call within Begin()/End(). may incur tearing. |
| 185 | IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); // set current window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing. |
| 186 | IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // set current window collapsed state. |
| 187 | IMGUI_API void SetWindowFocus(); // set current window to be focused / front-most |
| 188 | IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0); // set named window position - call within Begin()/End(). may incur tearing. |
| 189 | IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond = 0); // set named window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing. |
| 190 | IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond = 0); // set named window collapsed state. |
| 191 | IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most |
| 192 | |
| 193 | IMGUI_API float GetScrollPosY(); // get scrolling position (0..GetScrollMaxY()) |
| 194 | IMGUI_API float GetScrollMaxY(); // get maximum scrolling position == ContentSize.Y - WindowSize.Y |
183 | 195 | IMGUI_API void SetScrollPosHere(); // adjust scrolling position to center into the current cursor position. |
184 | 196 | IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. |
185 | 197 | IMGUI_API void SetStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it). |
r245119 | r245120 | |
215 | 227 | IMGUI_API void Spacing(); |
216 | 228 | IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border=true); // setup number of columns |
217 | 229 | IMGUI_API void NextColumn(); // next column |
218 | | IMGUI_API float GetColumnOffset(int column_index = -1); |
219 | | IMGUI_API void SetColumnOffset(int column_index, float offset); |
220 | | IMGUI_API float GetColumnWidth(int column_index = -1); |
| 230 | IMGUI_API int GetColumnIndex(); // get current column index |
| 231 | IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetcolumnsCount() inclusive. column 0 is usually 0.0f and not resizable unless you call this. |
| 232 | IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column. |
| 233 | IMGUI_API float GetColumnWidth(int column_index = -1); // column width (== GetColumnOffset(GetColumnIndex()+1) - GetColumnOffset(GetColumnOffset()) |
| 234 | IMGUI_API int GetColumnsCount(); // number of columns (what was passed to Columns()) |
221 | 235 | IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position |
222 | 236 | IMGUI_API float GetCursorPosX(); // " |
223 | 237 | IMGUI_API float GetCursorPosY(); // " |
r245119 | r245120 | |
231 | 245 | IMGUI_API float GetTextLineHeightWithSpacing(); // spacing (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y |
232 | 246 | |
233 | 247 | // ID scopes |
234 | | // If you are creating repeated widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them. |
235 | | // You can also use ## within your widget name to distinguish them from each others (see 'Programmer Guide') |
| 248 | // If you are creating widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them. |
| 249 | // You can also use "##extra" within your widget name to distinguish them from each others (see 'Programmer Guide') |
236 | 250 | IMGUI_API void PushID(const char* str_id); // push identifier into the ID stack. IDs are hash of the *entire* stack! |
237 | 251 | IMGUI_API void PushID(const void* ptr_id); |
238 | 252 | IMGUI_API void PushID(const int int_id); |
r245119 | r245120 | |
248 | 262 | IMGUI_API void TextWrapped(const char* fmt, ...); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos(); |
249 | 263 | IMGUI_API void TextWrappedV(const char* fmt, va_list args); |
250 | 264 | IMGUI_API 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, recommended for long chunks of text. |
251 | | IMGUI_API void LabelText(const char* label, const char* fmt, ...); // display text+label aligned the same way as value+label widgets |
| 265 | IMGUI_API void LabelText(const char* label, const char* fmt, ...); // display text+label aligned the same way as value+label widgets |
252 | 266 | IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args); |
| 267 | IMGUI_API void Bullet(); |
253 | 268 | IMGUI_API void BulletText(const char* fmt, ...); |
254 | 269 | IMGUI_API void BulletTextV(const char* fmt, va_list args); |
255 | 270 | IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0), bool repeat_when_held = false); |
r245119 | r245120 | |
257 | 272 | IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size); |
258 | 273 | IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0)); |
259 | 274 | IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,1), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no paddnig. |
260 | | IMGUI_API bool CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false); |
| 275 | IMGUI_API bool CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false); |
261 | 276 | IMGUI_API 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. |
262 | 277 | IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); |
263 | 278 | IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); |
r245119 | r245120 | |
275 | 290 | IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value); |
276 | 291 | IMGUI_API bool RadioButton(const char* label, bool active); |
277 | 292 | IMGUI_API bool RadioButton(const char* label, int* v, int v_button); |
278 | | IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, void (*callback)(ImGuiTextEditCallbackData*) = NULL, void* user_data = NULL); |
| 293 | IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL); |
279 | 294 | 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); |
280 | 295 | IMGUI_API bool InputFloat2(const char* label, float v[2], int decimal_precision = -1); |
281 | 296 | IMGUI_API bool InputFloat3(const char* label, float v[3], int decimal_precision = -1); |
r245119 | r245120 | |
288 | 303 | IMGUI_API bool ColorEdit3(const char* label, float col[3]); |
289 | 304 | IMGUI_API bool ColorEdit4(const char* label, float col[4], bool show_alpha = true); |
290 | 305 | IMGUI_API void ColorEditMode(ImGuiColorEditMode mode); |
| 306 | |
| 307 | // Trees |
291 | 308 | IMGUI_API bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop |
292 | 309 | IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...); // " |
293 | 310 | IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...); // " |
r245119 | r245120 | |
296 | 313 | IMGUI_API void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose |
297 | 314 | IMGUI_API void TreePush(const void* ptr_id = NULL); // " |
298 | 315 | IMGUI_API void TreePop(); |
299 | | IMGUI_API void OpenNextNode(bool open); // force open/close the next TreeNode or CollapsingHeader |
| 316 | IMGUI_API void SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond = 0); // set next tree node to be opened. |
300 | 317 | |
301 | 318 | // Selectable / Lists |
302 | 319 | IMGUI_API bool Selectable(const char* label, bool selected, const ImVec2& size = ImVec2(0,0)); |
r245119 | r245120 | |
326 | 343 | // Utilities |
327 | 344 | IMGUI_API bool IsItemHovered(); // was the last item hovered by mouse? |
328 | 345 | IMGUI_API bool IsItemActive(); // was the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false) |
| 346 | IMGUI_API bool IsAnyItemActive(); // |
329 | 347 | IMGUI_API ImVec2 GetItemBoxMin(); // get bounding box of last item |
330 | 348 | IMGUI_API ImVec2 GetItemBoxMax(); // get bounding box of last item |
331 | 349 | IMGUI_API bool IsClipped(const ImVec2& item_size); // to perform coarse clipping on user's side (as an optimization) |
r245119 | r245120 | |
357 | 375 | |
358 | 376 | // Obsolete (will be removed) |
359 | 377 | IMGUI_API void GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size); |
| 378 | static inline void OpenNextNode(bool open) { ImGui::SetNextTreeNodeOpened(open, 0); } |
360 | 379 | |
361 | 380 | } // namespace ImGui |
362 | 381 | |
r245119 | r245120 | |
367 | 386 | ImGuiWindowFlags_NoTitleBar = 1 << 0, // Disable title-bar |
368 | 387 | ImGuiWindowFlags_NoResize = 1 << 1, // Disable user resizing with the lower-right grip |
369 | 388 | ImGuiWindowFlags_NoMove = 1 << 2, // Disable user moving the window |
370 | | ImGuiWindowFlags_NoScrollbar = 1 << 3, // Disable scroll bar (window can still scroll with mouse or programatically) |
| 389 | ImGuiWindowFlags_NoScrollbar = 1 << 3, // Disable scrollbar (window can still scroll with mouse or programatically) |
371 | 390 | ImGuiWindowFlags_NoScrollWithMouse = 1 << 4, // Disable user scrolling with mouse wheel |
372 | 391 | ImGuiWindowFlags_NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it |
373 | 392 | ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame |
r245119 | r245120 | |
387 | 406 | // Default: 0 |
388 | 407 | ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/ |
389 | 408 | ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef |
390 | | ImGuiInputTextFlags_AutoSelectAll = 1 << 2, // Select entire text when first taking focus |
391 | | ImGuiInputTextFlags_EnterReturnsTrue = 1 << 3, // Return 'true' when Enter is pressed (as opposed to when the value was modified) |
392 | | ImGuiInputTextFlags_CallbackCompletion = 1 << 4, // Call user function on pressing TAB (for completion handling) |
393 | | ImGuiInputTextFlags_CallbackHistory = 1 << 5, // Call user function on pressing Up/Down arrows (for history handling) |
394 | | ImGuiInputTextFlags_CallbackAlways = 1 << 6 // Call user function every time |
395 | | //ImGuiInputTextFlags_AlignCenter = 1 << 6, |
| 409 | ImGuiInputTextFlags_CharsUppercase = 1 << 2, // Turn a..z into A..Z |
| 410 | ImGuiInputTextFlags_CharsNoBlank = 1 << 3, // Filter out spaces, tabs |
| 411 | ImGuiInputTextFlags_AutoSelectAll = 1 << 4, // Select entire text when first taking mouse focus |
| 412 | ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to when the value was modified) |
| 413 | ImGuiInputTextFlags_CallbackCompletion = 1 << 6, // Call user function on pressing TAB (for completion handling) |
| 414 | ImGuiInputTextFlags_CallbackHistory = 1 << 7, // Call user function on pressing Up/Down arrows (for history handling) |
| 415 | ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Call user function every time |
| 416 | ImGuiInputTextFlags_CallbackCharFilter = 1 << 9 // Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character. |
396 | 417 | }; |
397 | 418 | |
398 | 419 | // User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array |
r245119 | r245120 | |
488 | 509 | ImGuiColorEditMode_HEX = 2 |
489 | 510 | }; |
490 | 511 | |
491 | | // Condition flags for ImGui::SetWindow***() and SetNextWindow***() functions |
492 | | // Those functions treat 0 as a shortcut to ImGuiSetCondition_Always |
493 | | enum ImGuiSetCondition_ |
| 512 | // Condition flags for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions |
| 513 | // All those functions treat 0 as a shortcut to ImGuiSetCond_Always |
| 514 | enum ImGuiSetCond_ |
494 | 515 | { |
495 | | ImGuiSetCondition_Always = 1 << 0, // Set the variable |
496 | | ImGuiSetCondition_FirstUseThisSession = 1 << 1, // Only set the variable on the first call for this window (once per session) |
497 | | ImGuiSetCondition_FirstUseEver = 1 << 2 // Only set the variable if the window doesn't exist in the .ini file |
| 516 | ImGuiSetCond_Always = 1 << 0, // Set the variable |
| 517 | ImGuiSetCond_Once = 1 << 1, // Only set the variable on the first call per runtime session |
| 518 | ImGuiSetCond_FirstUseEver = 1 << 2 // Only set the variable if the window doesn't exist in the .ini file |
498 | 519 | }; |
499 | 520 | |
500 | 521 | struct ImGuiStyle |
r245119 | r245120 | |
513 | 534 | float WindowFillAlphaDefault; // Default alpha of window background, if not specified in ImGui::Begin() |
514 | 535 | float TreeNodeSpacing; // Horizontal spacing when entering a tree node |
515 | 536 | float ColumnsMinSpacing; // Minimum horizontal spacing between two columns |
516 | | float ScrollBarWidth; // Width of the vertical scroll bar |
| 537 | float ScrollbarWidth; // Width of the vertical scrollbar |
| 538 | float GrabMinSize; // Minimum width/height of a slider or scrollbar grab |
517 | 539 | ImVec4 Colors[ImGuiCol_COUNT]; |
518 | 540 | |
519 | 541 | IMGUI_API ImGuiStyle(); |
r245119 | r245120 | |
529 | 551 | |
530 | 552 | ImVec2 DisplaySize; // <unset> // Display size, in pixels. For clamping windows positions. |
531 | 553 | float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds. |
532 | | float IniSavingRate; // = 5.0f // Maximum time between saving .ini file, in seconds. |
| 554 | float IniSavingRate; // = 5.0f // Maximum time between saving positions/sizes to .ini file, in seconds. |
533 | 555 | const char* IniFilename; // = "imgui.ini" // Path to .ini file. NULL to disable .ini saving. |
534 | 556 | const char* LogFilename; // = "imgui_log.txt" // Path to .log file (default parameter to ImGui::LogToFile when no file is specified). |
535 | 557 | float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds. |
r245119 | r245120 | |
547 | 569 | // User Functions |
548 | 570 | //------------------------------------------------------------------ |
549 | 571 | |
550 | | // REQUIRED: rendering function. |
| 572 | // REQUIRED: rendering function. |
551 | 573 | // See example code if you are unsure of how to implement this. |
552 | | void (*RenderDrawListsFn)(ImDrawList** const draw_lists, int count); |
| 574 | void (*RenderDrawListsFn)(ImDrawList** const draw_lists, int count); |
553 | 575 | |
554 | | // Optional: access OS clipboard (default to use native Win32 clipboard on Windows, otherwise use a ImGui private clipboard) |
555 | | // Override to access OS clipboard on other architectures. |
| 576 | // Optional: access OS clipboard |
| 577 | // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures) |
556 | 578 | const char* (*GetClipboardTextFn)(); |
557 | 579 | void (*SetClipboardTextFn)(const char* text); |
558 | 580 | |
559 | | // Optional: override memory allocations (default to posix malloc/free). MemFreeFn() may be called with a NULL pointer. |
| 581 | // Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer. |
| 582 | // (default to posix malloc/free) |
560 | 583 | void* (*MemAllocFn)(size_t sz); |
561 | 584 | void (*MemFreeFn)(void* ptr); |
562 | 585 | |
563 | | // Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese inputs in Windows) |
| 586 | // Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME in Windows) |
| 587 | // (default to use native imm32 api on Windows) |
564 | 588 | void (*ImeSetInputScreenPosFn)(int x, int y); |
| 589 | void* ImeWindowHandle; // (Windows) Set this to your HWND to get automatic IME cursor positioning. |
565 | 590 | |
566 | 591 | //------------------------------------------------------------------ |
567 | 592 | // Input - Fill before calling NewFrame() |
568 | 593 | //------------------------------------------------------------------ |
569 | 594 | |
570 | 595 | ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.) |
571 | | bool MouseDown[5]; // Mouse buttons. ImGui itself only uses button 0 (left button) but you can use others as storage for convenience. |
572 | | float MouseWheel; // Mouse wheel: 1 unit scrolls about 5 lines text. |
| 596 | bool MouseDown[5]; // Mouse buttons. ImGui itself only uses button 0 (left button). Others buttons allows to track if mouse is being used by your application + available to user as a convenience via IsMouse** API. |
| 597 | float MouseWheel; // Mouse wheel: 1 unit scrolls about 5 lines text. |
573 | 598 | bool MouseDrawCursor; // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). |
574 | 599 | bool KeyCtrl; // Keyboard modifier pressed: Control |
575 | 600 | bool KeyShift; // Keyboard modifier pressed: Shift |
576 | | bool KeysDown[512]; // Keyboard keys that are pressed (in whatever order user naturally has access to keyboard data) |
| 601 | bool KeysDown[512]; // Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data) |
577 | 602 | ImWchar InputCharacters[16+1]; // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper. |
578 | 603 | |
579 | 604 | // Function |
r245119 | r245120 | |
585 | 610 | |
586 | 611 | bool WantCaptureMouse; // Mouse is hovering a window or widget is active (= ImGui will use your mouse input) |
587 | 612 | bool WantCaptureKeyboard; // Widget is active (= ImGui will use your keyboard input) |
| 613 | float Framerate; // Framerate estimation, in frame per second. Rolling average estimation based on IO.DeltaTime over 120 frames |
588 | 614 | |
589 | 615 | //------------------------------------------------------------------ |
590 | 616 | // [Internal] ImGui will maintain those fields for you |
591 | 617 | //------------------------------------------------------------------ |
592 | 618 | |
593 | | ImVec2 MousePosPrev; // |
| 619 | ImVec2 MousePosPrev; // Previous mouse position |
594 | 620 | ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are negative to allow mouse enabling/disabling. |
595 | 621 | bool MouseClicked[5]; // Mouse button went from !Down to Down |
596 | 622 | ImVec2 MouseClickedPos[5]; // Position at time of clicking |
r245119 | r245120 | |
646 | 672 | ImVector<TextRange> Filters; |
647 | 673 | int CountGrep; |
648 | 674 | |
649 | | ImGuiTextFilter(); |
| 675 | ImGuiTextFilter(const char* default_filter = ""); |
650 | 676 | void Clear() { InputBuf[0] = 0; Build(); } |
651 | 677 | void Draw(const char* label = "Filter (inc,-exc)", float width = -1.0f); // Helper calling InputText+Build |
652 | 678 | bool PassFilter(const char* val) const; |
r245119 | r245120 | |
680 | 706 | // - You want to store custom debug data easily without adding or editing structures in your code. |
681 | 707 | struct ImGuiStorage |
682 | 708 | { |
683 | | struct Pair |
684 | | { |
685 | | ImGuiID key; |
686 | | union { int val_i; float val_f; void* val_p; }; |
687 | | Pair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; } |
688 | | Pair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; } |
689 | | Pair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; } |
| 709 | struct Pair |
| 710 | { |
| 711 | ImGuiID key; |
| 712 | union { int val_i; float val_f; void* val_p; }; |
| 713 | Pair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; } |
| 714 | Pair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; } |
| 715 | Pair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; } |
690 | 716 | }; |
691 | 717 | ImVector<Pair> Data; |
692 | 718 | |
r245119 | r245120 | |
701 | 727 | IMGUI_API void* GetVoidPtr(ImGuiID key) const; // default_val is NULL |
702 | 728 | IMGUI_API void SetVoidPtr(ImGuiID key, void* val); |
703 | 729 | |
704 | | // - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set. |
| 730 | // - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set. |
705 | 731 | // - References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer. |
706 | 732 | // - A typical use case where this is convenient: |
707 | 733 | // float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar; |
r245119 | r245120 | |
716 | 742 | // Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used. |
717 | 743 | struct ImGuiTextEditCallbackData |
718 | 744 | { |
719 | | ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only |
720 | | char* Buf; // Current text // Read-write (pointed data only) |
721 | | size_t BufSize; // // Read-only |
722 | | bool BufDirty; // Set if you modify Buf directly // Write |
723 | | ImGuiInputTextFlags Flags; // What user passed to InputText() // Read-only |
724 | | int CursorPos; // // Read-write |
725 | | int SelectionStart; // // Read-write (== to SelectionEnd when no selection) |
726 | | int SelectionEnd; // // Read-write |
727 | | void* UserData; // What user passed to InputText() |
| 745 | ImGuiInputTextFlags EventFlag; // One of ImGuiInputTextFlags_Callback* // Read-only |
| 746 | ImGuiInputTextFlags Flags; // What user passed to InputText() // Read-only |
| 747 | void* UserData; // What user passed to InputText() // Read-only |
728 | 748 | |
| 749 | // CharFilter event: |
| 750 | ImWchar EventChar; // Character input // Read-write (replace character or set to zero) |
| 751 | |
| 752 | // Completion,History,Always events: |
| 753 | ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only |
| 754 | char* Buf; // Current text // Read-write (pointed data only) |
| 755 | size_t BufSize; // // Read-only |
| 756 | bool BufDirty; // Set if you modify Buf directly // Write |
| 757 | int CursorPos; // // Read-write |
| 758 | int SelectionStart; // // Read-write (== to SelectionEnd when no selection) |
| 759 | int SelectionEnd; // // Read-write |
| 760 | |
729 | 761 | // NB: calling those function loses selection. |
730 | 762 | void DeleteChars(int pos, int bytes_count); |
731 | 763 | void InsertChars(int pos, const char* text, const char* text_end = NULL); |
r245119 | r245120 | |
740 | 772 | ImColor(int r, int g, int b, int a = 255) { Value.x = (float)r / 255.0f; Value.y = (float)g / 255.0f; Value.z = (float)b / 255.0f; Value.w = (float)a / 255.0f; } |
741 | 773 | ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; } |
742 | 774 | ImColor(const ImVec4& col) { Value = col; } |
743 | | |
744 | 775 | operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); } |
745 | 776 | operator ImVec4() const { return Value; } |
746 | 777 | |
r245119 | r245120 | |
763 | 794 | // It is up to you to decide if your rendering loop or the callback should be responsible for backup/restoring rendering state. |
764 | 795 | typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd); |
765 | 796 | |
766 | | // Typically, 1 command = 1 gpu draw call |
| 797 | // Typically, 1 command = 1 gpu draw call (unless command is a callback) |
767 | 798 | struct ImDrawCmd |
768 | 799 | { |
769 | 800 | unsigned int vtx_count; // Number of vertices (multiple of 3) to be drawn as triangles. The vertices are stored in the callee ImDrawList's vtx_buffer[] array. |
r245119 | r245120 | |
802 | 833 | |
803 | 834 | // [Internal to ImGui] |
804 | 835 | ImVector<ImVec4> clip_rect_stack; // [Internal] |
805 | | ImVector<ImTextureID> texture_id_stack; // [Internal] |
| 836 | ImVector<ImTextureID> texture_id_stack; // [Internal] |
806 | 837 | ImDrawVert* vtx_write; // [Internal] point within vtx_buffer after each add command (to avoid using the ImVector<> operators too much) |
807 | 838 | |
808 | 839 | ImDrawList() { Clear(); } |
r245119 | r245120 | |
812 | 843 | IMGUI_API void PushTextureID(const ImTextureID& texture_id); |
813 | 844 | IMGUI_API void PopTextureID(); |
814 | 845 | |
815 | | // Primitives |
| 846 | // Primitives |
816 | 847 | IMGUI_API void AddLine(const ImVec2& a, const ImVec2& b, ImU32 col); |
817 | 848 | IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners=0x0F); |
818 | 849 | IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners=0x0F); |
r245119 | r245120 | |
897 | 928 | float FontSize; // <user set> // Height of characters, set during loading (don't change after loading) |
898 | 929 | float Scale; // = 1.0f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale() |
899 | 930 | ImVec2 DisplayOffset; // = (0.0f,0.0f) // Offset font rendering by xx pixels |
900 | | ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. |
| 931 | ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar() |
901 | 932 | |
902 | 933 | // Members: Runtime data |
903 | 934 | struct Glyph |
r245119 | r245120 | |
910 | 941 | }; |
911 | 942 | ImFontAtlas* ContainerAtlas; // What we has been loaded into |
912 | 943 | ImVector<Glyph> Glyphs; |
| 944 | const Glyph* FallbackGlyph; // == FindGlyph(FontFallbackChar) |
| 945 | float FallbackXAdvance; // |
| 946 | ImVector<float> IndexXAdvance; // Glyphs->XAdvance directly indexable (for CalcTextSize functions which are often bottleneck in large UI) |
913 | 947 | ImVector<int> IndexLookup; // Index glyphs by Unicode code-point |
914 | | const Glyph* FallbackGlyph; // == FindGlyph(FontFallbackChar) |
915 | 948 | |
916 | 949 | // Methods |
917 | 950 | IMGUI_API ImFont(); |
r245119 | r245120 | |
919 | 952 | IMGUI_API void Clear(); |
920 | 953 | IMGUI_API void BuildLookupTable(); |
921 | 954 | IMGUI_API const Glyph* FindGlyph(unsigned short c) const; |
| 955 | IMGUI_API void SetFallbackChar(ImWchar c); |
922 | 956 | IMGUI_API bool IsLoaded() const { return ContainerAtlas != NULL; } |
923 | 957 | |
924 | 958 | // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable. |
trunk/3rdparty/bgfx/examples/common/imgui/fs_imgui_latlong.bin.h
r245119 | r245120 | |
1 | | static const uint8_t fs_imgui_latlong_glsl[646] = |
| 1 | static const uint8_t fs_imgui_latlong_glsl[649] = |
2 | 2 | { |
3 | 3 | 0x46, 0x53, 0x48, 0x03, 0x6f, 0x1e, 0x3e, 0x3c, 0x02, 0x00, 0x11, 0x75, 0x5f, 0x69, 0x6d, 0x61, // FSH.o.><...u_ima |
4 | 4 | 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x07, 0x01, 0x00, 0x00, // geLodEnabled.... |
5 | 5 | 0x01, 0x00, 0x0a, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x01, 0x00, // ...s_texColor... |
6 | | 0x00, 0x01, 0x00, 0x4e, 0x02, 0x00, 0x00, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, // ...N...varying h |
| 6 | 0x00, 0x01, 0x00, 0x51, 0x02, 0x00, 0x00, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, // ...Q...varying h |
7 | 7 | 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, // ighp vec2 v_texc |
8 | 8 | 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, // oord0;.uniform h |
9 | 9 | 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x75, 0x5f, 0x69, 0x6d, 0x61, 0x67, // ighp vec4 u_imag |
r245119 | r245120 | |
21 | 21 | 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, // tmpvar_3 = (v_ |
22 | 22 | 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x2e, 0x79, 0x20, 0x2a, 0x20, 0x33, 0x2e, // texcoord0.y * 3. |
23 | 23 | 0x31, 0x34, 0x31, 0x35, 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, // 14159);. result |
24 | | 0x5f, 0x31, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x28, 0x73, 0x69, 0x6e, 0x28, 0x74, 0x6d, 0x70, 0x76, // _1.x = (sin(tmpv |
25 | | 0x61, 0x72, 0x5f, 0x33, 0x29, 0x20, 0x2a, 0x20, 0x63, 0x6f, 0x73, 0x28, 0x74, 0x6d, 0x70, 0x76, // ar_3) * cos(tmpv |
26 | | 0x61, 0x72, 0x5f, 0x32, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, // ar_2));. result |
27 | | 0x5f, 0x31, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x73, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, // _1.y = cos(tmpva |
28 | | 0x72, 0x5f, 0x33, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x31, // r_3);. result_1 |
29 | | 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x2d, 0x28, 0x73, 0x69, 0x6e, 0x28, 0x74, 0x6d, 0x70, 0x76, // .z = (-(sin(tmpv |
30 | | 0x61, 0x72, 0x5f, 0x33, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x73, 0x69, 0x6e, 0x28, 0x74, 0x6d, 0x70, // ar_3)) * sin(tmp |
31 | | 0x76, 0x61, 0x72, 0x5f, 0x32, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, // var_2));. lowp |
32 | | 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x3b, 0x0a, 0x20, // vec4 tmpvar_4;. |
33 | | 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, // tmpvar_4.xyz = |
34 | | 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x43, 0x75, 0x62, 0x65, 0x4c, 0x6f, 0x64, 0x20, 0x20, // textureCubeLod |
35 | | 0x20, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x72, // (s_texColor, r |
36 | | 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x31, 0x2c, 0x20, 0x75, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, // esult_1, u_image |
37 | | 0x4c, 0x6f, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x2e, 0x78, 0x29, 0x2e, 0x78, 0x79, // LodEnabled.x).xy |
38 | | 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x2e, 0x77, 0x20, // z;. tmpvar_4.w |
39 | | 0x3d, 0x20, 0x28, 0x30, 0x2e, 0x32, 0x20, 0x2b, 0x20, 0x28, 0x30, 0x2e, 0x38, 0x20, 0x2a, 0x20, // = (0.2 + (0.8 * |
40 | | 0x75, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, // u_imageLodEnable |
41 | | 0x64, 0x2e, 0x79, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, // d.y));. gl_Frag |
42 | | 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, // Color = tmpvar_4 |
43 | | 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // ;.}... |
| 24 | 0x5f, 0x31, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x28, 0x2d, 0x28, 0x73, 0x69, 0x6e, 0x28, 0x74, 0x6d, // _1.x = (-(sin(tm |
| 25 | 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x73, 0x69, 0x6e, 0x28, 0x74, // pvar_3)) * sin(t |
| 26 | 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x73, // mpvar_2));. res |
| 27 | 0x75, 0x6c, 0x74, 0x5f, 0x31, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x73, 0x28, 0x74, 0x6d, // ult_1.y = cos(tm |
| 28 | 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, // pvar_3);. resul |
| 29 | 0x74, 0x5f, 0x31, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x2d, 0x28, 0x73, 0x69, 0x6e, 0x28, 0x74, // t_1.z = (-(sin(t |
| 30 | 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x63, 0x6f, 0x73, 0x28, // mpvar_3)) * cos( |
| 31 | 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x6c, 0x6f, // tmpvar_2));. lo |
| 32 | 0x77, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, // wp vec4 tmpvar_4 |
| 33 | 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x2e, 0x78, 0x79, 0x7a, // ;. tmpvar_4.xyz |
| 34 | 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x43, 0x75, 0x62, 0x65, 0x4c, 0x6f, // = textureCubeLo |
| 35 | 0x64, 0x20, 0x20, 0x20, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, // d (s_texColor |
| 36 | 0x2c, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x31, 0x2c, 0x20, 0x75, 0x5f, 0x69, 0x6d, // , result_1, u_im |
| 37 | 0x61, 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x2e, 0x78, 0x29, // ageLodEnabled.x) |
| 38 | 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, // .xyz;. tmpvar_4 |
| 39 | 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x28, 0x30, 0x2e, 0x32, 0x20, 0x2b, 0x20, 0x28, 0x30, 0x2e, 0x38, // .w = (0.2 + (0.8 |
| 40 | 0x20, 0x2a, 0x20, 0x75, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x45, 0x6e, 0x61, // * u_imageLodEna |
| 41 | 0x62, 0x6c, 0x65, 0x64, 0x2e, 0x79, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, // bled.y));. gl_F |
| 42 | 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // ragColor = tmpva |
| 43 | 0x72, 0x5f, 0x34, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // r_4;.}... |
44 | 44 | }; |
45 | | static const uint8_t fs_imgui_latlong_dx9[553] = |
| 45 | static const uint8_t fs_imgui_latlong_dx9[537] = |
46 | 46 | { |
47 | 47 | 0x46, 0x53, 0x48, 0x03, 0x6f, 0x1e, 0x3e, 0x3c, 0x01, 0x00, 0x11, 0x75, 0x5f, 0x69, 0x6d, 0x61, // FSH.o.><...u_ima |
48 | 48 | 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x15, 0x01, 0x00, 0x00, // geLodEnabled.... |
49 | | 0x01, 0x00, 0x04, 0x02, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x30, 0x00, 0x43, 0x54, 0x41, 0x42, // ..........0.CTAB |
| 49 | 0x01, 0x00, 0xf4, 0x01, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x30, 0x00, 0x43, 0x54, 0x41, 0x42, // ..........0.CTAB |
50 | 50 | 0x1c, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x02, 0x00, 0x00, 0x00, // ................ |
51 | 51 | 0x1c, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, // ............D... |
52 | 52 | 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........P....... |
r245119 | r245120 | |
71 | 71 | 0x01, 0x00, 0x00, 0xa0, 0x13, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x80, // ................ |
72 | 72 | 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x55, 0xa0, // ..............U. |
73 | 73 | 0x01, 0x00, 0xaa, 0xa0, 0x25, 0x00, 0x00, 0x02, 0x02, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x80, // ....%........... |
74 | | 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0x80, 0x01, 0x00, 0x00, 0x80, 0x02, 0x00, 0x55, 0x80, // ..............U. |
75 | | 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x04, 0x80, 0x01, 0x00, 0x55, 0x80, 0x02, 0x00, 0x55, 0x81, // ..........U...U. |
| 74 | 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x05, 0x80, 0x01, 0x00, 0xc5, 0x80, 0x02, 0x00, 0x55, 0x81, // ..............U. |
76 | 75 | 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x02, 0x80, 0x02, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x02, // ................ |
77 | 76 | 0x00, 0x00, 0x08, 0x80, 0x00, 0x00, 0x00, 0xa0, 0x5f, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, // ........_....... |
78 | 77 | 0x00, 0x00, 0xe4, 0x80, 0x00, 0x08, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x07, 0x80, // ................ |
r245119 | r245120 | |
84 | 83 | { |
85 | 84 | 0x46, 0x53, 0x48, 0x03, 0x6f, 0x1e, 0x3e, 0x3c, 0x01, 0x00, 0x11, 0x75, 0x5f, 0x69, 0x6d, 0x61, // FSH.o.><...u_ima |
86 | 85 | 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x15, 0x00, 0x30, 0x0a, // geLodEnabled..0. |
87 | | 0x01, 0x00, 0x30, 0x02, 0x44, 0x58, 0x42, 0x43, 0x89, 0x11, 0x25, 0xa6, 0xf5, 0x66, 0x12, 0x3f, // ..0.DXBC..%..f.? |
88 | | 0xc0, 0x1f, 0x67, 0x9b, 0x6e, 0x4e, 0xac, 0x03, 0x01, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0x00, // ..g.nN......0... |
| 86 | 0x01, 0x00, 0x30, 0x02, 0x44, 0x58, 0x42, 0x43, 0xbb, 0x3e, 0xd7, 0x3a, 0x63, 0xc9, 0x70, 0x0b, // ..0.DXBC.>.:c.p. |
| 87 | 0xa5, 0x2c, 0x7d, 0xb2, 0x3c, 0x0c, 0x75, 0x44, 0x01, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0x00, // .,}.<.uD....0... |
89 | 88 | 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, // ....,........... |
90 | 89 | 0x49, 0x53, 0x47, 0x4e, 0x50, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, // ISGNP........... |
91 | 90 | 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // 8............... |
r245119 | r245120 | |
101 | 100 | 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x30, 0x00, 0x04, 0x00, 0x70, 0x10, 0x00, // .`......X0...p.. |
102 | 101 | 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, // ....UU..b...2... |
103 | 102 | 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ....e.... ...... |
104 | | 0x68, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, // h.......8...2... |
105 | | 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, // ....F........@.. |
106 | | 0xdb, 0x0f, 0xc9, 0x40, 0xdb, 0x0f, 0x49, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ...@..I@........ |
107 | | 0x4d, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, // M...B........... |
108 | | 0x1a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x06, // ....A.......M... |
109 | | 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x16, 0x05, 0x10, 0x00, // 2............... |
| 103 | 0x68, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, // h.......8...2... |
| 104 | 0x00, 0x00, 0x00, 0x00, 0x16, 0x15, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, // .............@.. |
| 105 | 0xdb, 0x0f, 0x49, 0x40, 0xdb, 0x0f, 0xc9, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ..I@...@........ |
| 106 | 0x4d, 0x00, 0x00, 0x06, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, // M...B........... |
| 107 | 0x1a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, // ........M....... |
| 108 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, // ............A... |
110 | 109 | 0x00, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x06, 0x00, 0xd0, 0x00, 0x00, 0x62, 0x00, 0x10, 0x00, // ....M.......b... |
111 | | 0x02, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, // ............8... |
112 | | 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ........*....... |
113 | | 0x1a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, // ........8....... |
114 | | 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, // ................ |
115 | | 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ....H........... |
116 | | 0x86, 0x03, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ........F~...... |
| 110 | 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, // ............8... |
| 111 | 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ........*....... |
| 112 | 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, // :.......8....... |
| 113 | 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, // ....:.......*... |
| 114 | 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ....H........... |
| 115 | 0x46, 0x03, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // F.......F~...... |
117 | 116 | 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, // .`........ ..... |
118 | 117 | 0xa3, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ....6...r ...... |
119 | 118 | 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x82, 0x20, 0x10, 0x00, // F.......2.... .. |