mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-04 14:29:04 +08:00
Merge branch 'master' into docking
# Conflicts: # imgui.cpp # imgui.h
This commit is contained in:
commit
ff0c6c2bde
@ -97,12 +97,22 @@ Other changes:
|
||||
VERSION 1.69 (In Progress)
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
Breaking Changes:
|
||||
|
||||
- Renamed ColorEdit/ColorPicker's ImGuiColorEditFlags_RGB/_HSV/_HEX flags to respectively
|
||||
ImGuiColorEditFlags_DisplayRGB/_DisplayHSV/_DisplayHex. This is anticipation of adding new
|
||||
flags to ColorEdit/ColorPicker functions which would make those ambiguous. (#2384) [@haldean]
|
||||
|
||||
Other Changes:
|
||||
|
||||
- Nav: Fixed a tap on AltGR (e.g. German keyboard) from navigation to the menu layer.
|
||||
- DragScalar, InputScalar, SliderScalar: Added support for u8/s8/u16/s16 data types.
|
||||
We are reusing function instances for larger types to reduce code size. (#643, #320, #708, #1011)
|
||||
- InputInt, InputFloat, InputScalar: Fix to keep the label of the +/- buttons centered when
|
||||
style.FramePadding.x is abnormally larger than style.FramePadding.y. Since the buttons are
|
||||
meant to be square (to align with e.g. color button) we always use FramePadding.y. (#2367)
|
||||
- InputInt, InputScalar: +/- buttons now respects the natural type limits instead of
|
||||
overflowing or underflowing the value.
|
||||
- InputText: Fixed an edge case crash that would happen if another widget sharing the same ID
|
||||
is being swapped with an InputText that has yet to be activated.
|
||||
- InputText: Fixed various display corruption related to swapping the underlying buffer while
|
||||
@ -111,6 +121,7 @@ Other Changes:
|
||||
- TabBar: Fixed a crash when using BeginTabBar() recursively (didn't affect docking). (#2371)
|
||||
- TabBar: Added extra mis-usage error recovery. Past the assert, common mis-usage don't lead to
|
||||
hard crashes any more, facilitating integration with scripting languages. (#1651)
|
||||
- Plot: Fixed divide-by-zero in PlotLines() when passing a count of 1. (#2387) [@Lectem]
|
||||
- Log/Capture: Fixed extraneous leading carriage return.
|
||||
- Log/Capture: Fixed an issue when empty string on a new line would not emit a carriage return.
|
||||
- Log/Capture: Fixed LogXXX functions 'auto_open_depth' parameter being treated as an absolute
|
||||
@ -118,6 +129,7 @@ Other Changes:
|
||||
- Log/Capture: Fixed CollapsingHeader trailing ascii representation being "#" instead of "##".
|
||||
- Examples: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN
|
||||
even if the OpenGL headers/loader happens to define the value. (#2366, #2186)
|
||||
- Examples: Allegro: Added support for touch events (emulating mouse). (#2219) [@dos1]
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
@ -145,7 +145,8 @@ Frameworks:
|
||||
- Ogre: [ogreimgui](https://bitbucket.org/LMCrashy/ogreimgui/src)
|
||||
- OpenFrameworks: [ofxImGui](https://github.com/jvcleave/ofxImGui)
|
||||
- OpenSceneGraph/OSG: [gist](https://gist.github.com/fulezi/d2442ca7626bf270226014501357042c)
|
||||
- ORX: [#1843](https://github.com/ocornut/imgui/pull/1843)
|
||||
- ORX: [ImGuiOrx](https://github.com/thegwydd/ImGuiOrx), [#1843](https://github.com/ocornut/imgui/pull/1843)
|
||||
- px_render: [px_render_imgui.h](https://github.com/pplux/px/blob/master/px_render_imgui.h), [#1935](https://github.com/ocornut/imgui/pull/1935)
|
||||
- LÖVE+Lua: [love-imgui](https://github.com/slages/love-imgui)
|
||||
- Magnum: [ImGuiIntegration](https://doc.magnum.graphics/magnum/namespaceMagnum_1_1ImGuiIntegration.html) ([example](https://doc.magnum.graphics/magnum/examples-imgui.html))
|
||||
- NanoRT: [syoyo/imgui](https://github.com/syoyo/imgui/tree/nanort)
|
||||
|
@ -12,7 +12,7 @@ Note that the back-end supports _BOTH_ 16-bit and 32-bit indices, but 32-bit ind
|
||||
- On Ubuntu 14.04+
|
||||
|
||||
```bash
|
||||
g++ -DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" -I .. -I ../.. main.cpp ..\imgui_impl_allegro5.cpp ../../imgui*.cpp -lallegro -lallegro_primitives -o allegro5_example
|
||||
g++ -DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" -I .. -I ../.. main.cpp ../imgui_impl_allegro5.cpp ../../imgui*.cpp -lallegro -lallegro_primitives -o allegro5_example
|
||||
```
|
||||
|
||||
- On Windows with Visual Studio's CLI
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2018-11-30: Platform: Added touchscreen support.
|
||||
// 2018-11-30: Misc: Setting up io.BackendPlatformName/io.BackendRendererName so they can be displayed in the About Window.
|
||||
// 2018-06-13: Platform: Added clipboard support (from Allegro 5.1.12).
|
||||
// 2018-06-13: Renderer: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
|
||||
@ -268,6 +269,7 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
|
||||
io.KeyMap[ImGuiKey_X] = ALLEGRO_KEY_X;
|
||||
io.KeyMap[ImGuiKey_Y] = ALLEGRO_KEY_Y;
|
||||
io.KeyMap[ImGuiKey_Z] = ALLEGRO_KEY_Z;
|
||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
|
||||
#if ALLEGRO_HAS_CLIPBOARD
|
||||
io.SetClipboardTextFn = ImGui_ImplAllegro5_SetClipboardText;
|
||||
@ -305,8 +307,31 @@ bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT *ev)
|
||||
switch (ev->type)
|
||||
{
|
||||
case ALLEGRO_EVENT_MOUSE_AXES:
|
||||
io.MouseWheel += ev->mouse.dz;
|
||||
io.MouseWheelH += ev->mouse.dw;
|
||||
if (ev->mouse.display == g_Display)
|
||||
{
|
||||
io.MouseWheel += ev->mouse.dz;
|
||||
io.MouseWheelH += ev->mouse.dw;
|
||||
io.MousePos = ImVec2(ev->mouse.x, ev->mouse.y);
|
||||
}
|
||||
return true;
|
||||
case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
|
||||
case ALLEGRO_EVENT_MOUSE_BUTTON_UP:
|
||||
if (ev->mouse.display == g_Display && ev->mouse.button <= 5)
|
||||
io.MouseDown[ev->mouse.button - 1] = (ev->type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN);
|
||||
return true;
|
||||
case ALLEGRO_EVENT_TOUCH_MOVE:
|
||||
if (ev->touch.display == g_Display)
|
||||
io.MousePos = ImVec2(ev->touch.x, ev->touch.y);
|
||||
return true;
|
||||
case ALLEGRO_EVENT_TOUCH_BEGIN:
|
||||
case ALLEGRO_EVENT_TOUCH_END:
|
||||
case ALLEGRO_EVENT_TOUCH_CANCEL:
|
||||
if (ev->touch.display == g_Display && ev->touch.primary)
|
||||
io.MouseDown[0] = (ev->type == ALLEGRO_EVENT_TOUCH_BEGIN);
|
||||
return true;
|
||||
case ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY:
|
||||
if (ev->mouse.display == g_Display)
|
||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
return true;
|
||||
case ALLEGRO_EVENT_KEY_CHAR:
|
||||
if (ev->keyboard.display == g_Display)
|
||||
@ -376,21 +401,5 @@ void ImGui_ImplAllegro5_NewFrame()
|
||||
io.KeyAlt = al_key_down(&keys, ALLEGRO_KEY_ALT) || al_key_down(&keys, ALLEGRO_KEY_ALTGR);
|
||||
io.KeySuper = al_key_down(&keys, ALLEGRO_KEY_LWIN) || al_key_down(&keys, ALLEGRO_KEY_RWIN);
|
||||
|
||||
ALLEGRO_MOUSE_STATE mouse;
|
||||
if (keys.display == g_Display)
|
||||
{
|
||||
al_get_mouse_state(&mouse);
|
||||
io.MousePos = ImVec2((float)mouse.x, (float)mouse.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
}
|
||||
|
||||
al_get_mouse_state(&mouse);
|
||||
io.MouseDown[0] = mouse.buttons & (1 << 0);
|
||||
io.MouseDown[1] = mouse.buttons & (1 << 1);
|
||||
io.MouseDown[2] = mouse.buttons & (1 << 2);
|
||||
|
||||
ImGui_ImplAllegro5_UpdateMouseCursor();
|
||||
}
|
||||
|
@ -375,6 +375,7 @@ CODE
|
||||
- 2018/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
|
||||
|
||||
|
||||
- 2019/02/26 (1.69) - renamed ImGuiColorEditFlags_RGB/ImGuiColorEditFlags_HSV/ImGuiColorEditFlags_HEX to ImGuiColorEditFlags_DisplayRGB/ImGuiColorEditFlags_DisplayHSV/ImGuiColorEditFlags_DisplayHex. Kept redirection enums (will obsolete).
|
||||
- 2019/02/14 (1.68) - made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame). If for some reason your time step calculation gives you a zero value, replace it with a dummy small value!
|
||||
- 2019/02/01 (1.68) - removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already).
|
||||
- 2019/01/06 (1.67) - renamed io.InputCharacters[], marked internal as was always intended. Please don't access directly, and use AddInputCharacter() instead!
|
||||
|
66
imgui.h
66
imgui.h
@ -3,7 +3,7 @@
|
||||
|
||||
// See imgui.cpp file for documentation.
|
||||
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
|
||||
// Newcomers, read 'Programmer guide' below for notes on how to setup Dear ImGui in your codebase.
|
||||
// Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
||||
// Get latest version at https://github.com/ocornut/imgui
|
||||
|
||||
/*
|
||||
@ -27,7 +27,7 @@ Index of this file:
|
||||
|
||||
#pragma once
|
||||
|
||||
// Configuration file (edit imconfig.h or define IMGUI_USER_CONFIG to your own filename)
|
||||
// Configuration file with compile-time options (edit imconfig.h or define IMGUI_USER_CONFIG to your own filename)
|
||||
#ifdef IMGUI_USER_CONFIG
|
||||
#include IMGUI_USER_CONFIG
|
||||
#endif
|
||||
@ -45,7 +45,7 @@ Index of this file:
|
||||
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
||||
|
||||
// Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY00 then bounced up to XYY01 when release tagging happens)
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||
#define IMGUI_VERSION "1.69 WIP"
|
||||
#define IMGUI_VERSION_NUM 16899
|
||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert))
|
||||
@ -159,6 +159,10 @@ typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData *data);
|
||||
typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data);
|
||||
|
||||
// Scalar data types
|
||||
typedef char ImS8; // 8-bit signed integer == char
|
||||
typedef unsigned char ImU8; // 8-bit unsigned integer
|
||||
typedef short ImS16; // 16-bit signed integer
|
||||
typedef unsigned short ImU16; // 16-bit unsigned integer
|
||||
typedef signed int ImS32; // 32-bit signed integer == int
|
||||
typedef unsigned int ImU32; // 32-bit unsigned integer (often used to store packed colors)
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
@ -224,12 +228,12 @@ namespace ImGui
|
||||
// Demo, Debug, Information
|
||||
IMGUI_API void ShowDemoWindow(bool* p_open = NULL); // create demo/test window (previously called ShowTestWindow). demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application!
|
||||
IMGUI_API void ShowAboutWindow(bool* p_open = NULL); // create about window. display Dear ImGui version, credits and build/system information.
|
||||
IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create metrics window. display Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc.
|
||||
IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create metrics/debug window. display Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc.
|
||||
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)
|
||||
IMGUI_API bool ShowStyleSelector(const char* label); // add style selector block (not a window), essentially a combo listing the default styles.
|
||||
IMGUI_API void ShowFontSelector(const char* label); // add font selector block (not a window), essentially a combo listing the loaded fonts.
|
||||
IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls).
|
||||
IMGUI_API const char* GetVersion(); // get the compiled version string e.g. "1.23"
|
||||
IMGUI_API const char* GetVersion(); // get the compiled version string e.g. "1.23" (essentially the compiled value for IMGUI_VERSION)
|
||||
|
||||
// Styles
|
||||
IMGUI_API void StyleColorsDark(ImGuiStyle* dst = NULL); // new, recommended style (default)
|
||||
@ -397,7 +401,7 @@ namespace ImGui
|
||||
// - Most widgets return true when the value has been changed or when pressed/selected
|
||||
IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); // button
|
||||
IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text
|
||||
IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size); // button behavior without the visuals, useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
|
||||
IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size); // button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
|
||||
IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape
|
||||
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));
|
||||
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,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding
|
||||
@ -607,7 +611,7 @@ namespace ImGui
|
||||
// Drag and Drop
|
||||
// [BETA API] API may evolve!
|
||||
IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); // call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource()
|
||||
IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t size, ImGuiCond cond = 0);// type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui.
|
||||
IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t sz, ImGuiCond cond = 0); // type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui.
|
||||
IMGUI_API void EndDragDropSource(); // only call EndDragDropSource() if BeginDragDropSource() returns true!
|
||||
IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive a payload. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget()
|
||||
IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released.
|
||||
@ -635,9 +639,9 @@ namespace ImGui
|
||||
IMGUI_API bool IsItemActivated(); // was the last item just made active (item was previously inactive).
|
||||
IMGUI_API bool IsItemDeactivated(); // was the last item just made inactive (item was previously active). Useful for Undo/Redo patterns with widgets that requires continuous editing.
|
||||
IMGUI_API bool IsItemDeactivatedAfterEdit(); // was the last item just made inactive and made a value change when it was active? (e.g. Slider/Drag moved). Useful for Undo/Redo patterns with widgets that requires continuous editing. Note that you may get false positives (some widgets such as Combo()/ListBox()/Selectable() will return true even when clicking an already selected item).
|
||||
IMGUI_API bool IsAnyItemHovered();
|
||||
IMGUI_API bool IsAnyItemActive();
|
||||
IMGUI_API bool IsAnyItemFocused();
|
||||
IMGUI_API bool IsAnyItemHovered(); // is any item hovered?
|
||||
IMGUI_API bool IsAnyItemActive(); // is any item active?
|
||||
IMGUI_API bool IsAnyItemFocused(); // is any item focused?
|
||||
IMGUI_API ImVec2 GetItemRectMin(); // get upper-left bounding rectangle of the last item (screen space)
|
||||
IMGUI_API ImVec2 GetItemRectMax(); // get lower-right bounding rectangle of the last item (screen space)
|
||||
IMGUI_API ImVec2 GetItemRectSize(); // get size of last item
|
||||
@ -651,7 +655,7 @@ namespace ImGui
|
||||
IMGUI_API ImDrawList* GetOverlayDrawList(); // get overlay draw list for the viewport associated to the current window. this draw list will be the last rendered. useful to quickly draw overlays shapes/text.
|
||||
IMGUI_API ImDrawList* GetOverlayDrawList(ImGuiViewport* viewport); // get overlay draw list for the given viewport.
|
||||
IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); // you may use this when creating your own ImDrawList instances
|
||||
IMGUI_API const char* GetStyleColorName(ImGuiCol idx);
|
||||
IMGUI_API const char* GetStyleColorName(ImGuiCol idx); // get a string corresponding to the enum value (for display, saving, etc.).
|
||||
IMGUI_API void SetStateStorage(ImGuiStorage* storage); // replace current window storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
|
||||
IMGUI_API ImGuiStorage* GetStateStorage();
|
||||
IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
|
||||
@ -678,7 +682,7 @@ namespace ImGui
|
||||
IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down)
|
||||
IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
|
||||
IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block.
|
||||
IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); //
|
||||
IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse
|
||||
IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
||||
IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve backup of mouse position at the time of opening popup we have BeginPopup() into
|
||||
IMGUI_API ImVec2 GetMouseDragDelta(int button = 0, float lock_threshold = -1.0f); // return the delta from the initial clicking position. This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lock_threshold < -1.0f uses io.MouseDraggingThreshold
|
||||
@ -697,12 +701,12 @@ namespace ImGui
|
||||
// - Set io.IniFilename to NULL to load/save manually. Read io.WantSaveIniSettings description about handling .ini saving manually.
|
||||
IMGUI_API void LoadIniSettingsFromDisk(const char* ini_filename); // call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename).
|
||||
IMGUI_API void LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size=0); // call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source.
|
||||
IMGUI_API void SaveIniSettingsToDisk(const char* ini_filename);
|
||||
IMGUI_API void SaveIniSettingsToDisk(const char* ini_filename); // this is automatically called (if io.IniFilename is not empty) a few seconds after any modification that should be reflected in the .ini file (and also by DestroyContext).
|
||||
IMGUI_API const char* SaveIniSettingsToMemory(size_t* out_ini_size = NULL); // return a zero-terminated string with the .ini data which you can save by your own mean. call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings.
|
||||
|
||||
// Memory Utilities
|
||||
// Memory Allocators
|
||||
// - All those functions are not reliant on the current context.
|
||||
// - If you reload the contents of imgui.cpp at runtime, you may need to call SetCurrentContext() + SetAllocatorFunctions() again.
|
||||
// - If you reload the contents of imgui.cpp at runtime, you may need to call SetCurrentContext() + SetAllocatorFunctions() again because we use global storage for those.
|
||||
IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data = NULL);
|
||||
IMGUI_API void* MemAlloc(size_t size);
|
||||
IMGUI_API void MemFree(void* ptr);
|
||||
@ -776,7 +780,7 @@ enum ImGuiInputTextFlags_
|
||||
ImGuiInputTextFlags_CharsUppercase = 1 << 2, // Turn a..z into A..Z
|
||||
ImGuiInputTextFlags_CharsNoBlank = 1 << 3, // Filter out spaces, tabs
|
||||
ImGuiInputTextFlags_AutoSelectAll = 1 << 4, // Select entire text when first taking mouse focus
|
||||
ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to when the value was modified)
|
||||
ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to every time the value was modified). Consider looking at the IsItemDeactivatedAfterEdit() function.
|
||||
ImGuiInputTextFlags_CallbackCompletion = 1 << 6, // Callback on pressing TAB (for completion handling)
|
||||
ImGuiInputTextFlags_CallbackHistory = 1 << 7, // Callback on pressing Up/Down arrows (for history handling)
|
||||
ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Callback on each iteration. User code may query cursor position, modify text buffer.
|
||||
@ -937,10 +941,14 @@ enum ImGuiDragDropFlags_
|
||||
// A primary data type
|
||||
enum ImGuiDataType_
|
||||
{
|
||||
ImGuiDataType_S8, // char
|
||||
ImGuiDataType_U8, // unsigned char
|
||||
ImGuiDataType_S16, // short
|
||||
ImGuiDataType_U16, // unsigned short
|
||||
ImGuiDataType_S32, // int
|
||||
ImGuiDataType_U32, // unsigned int
|
||||
ImGuiDataType_S64, // long long, __int64
|
||||
ImGuiDataType_U64, // unsigned long long, unsigned __int64
|
||||
ImGuiDataType_S64, // long long / __int64
|
||||
ImGuiDataType_U64, // unsigned long long / unsigned __int64
|
||||
ImGuiDataType_Float, // float
|
||||
ImGuiDataType_Double, // double
|
||||
ImGuiDataType_COUNT
|
||||
@ -1128,7 +1136,7 @@ enum ImGuiCol_
|
||||
// NB: if changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type.
|
||||
enum ImGuiStyleVar_
|
||||
{
|
||||
// Enum name ......................// Member in ImGuiStyle structure (see ImGuiStyle for descriptions)
|
||||
// Enum name --------------------- // Member in ImGuiStyle structure (see ImGuiStyle for descriptions)
|
||||
ImGuiStyleVar_Alpha, // float Alpha
|
||||
ImGuiStyleVar_WindowPadding, // ImVec2 WindowPadding
|
||||
ImGuiStyleVar_WindowRounding, // float WindowRounding
|
||||
@ -1164,7 +1172,7 @@ enum ImGuiStyleVar_
|
||||
enum ImGuiColorEditFlags_
|
||||
{
|
||||
ImGuiColorEditFlags_None = 0,
|
||||
ImGuiColorEditFlags_NoAlpha = 1 << 1, // // ColorEdit, ColorPicker, ColorButton: ignore Alpha component (read 3 components from the input pointer).
|
||||
ImGuiColorEditFlags_NoAlpha = 1 << 1, // // ColorEdit, ColorPicker, ColorButton: ignore Alpha component (will only read 3 components from the input pointer).
|
||||
ImGuiColorEditFlags_NoPicker = 1 << 2, // // ColorEdit: disable picker when clicking on colored square.
|
||||
ImGuiColorEditFlags_NoOptions = 1 << 3, // // ColorEdit: disable toggling options menu when right-clicking on inputs/small preview.
|
||||
ImGuiColorEditFlags_NoSmallPreview = 1 << 4, // // ColorEdit, ColorPicker: disable colored square preview next to the inputs. (e.g. to show only the inputs)
|
||||
@ -1174,24 +1182,30 @@ enum ImGuiColorEditFlags_
|
||||
ImGuiColorEditFlags_NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small colored square preview instead.
|
||||
ImGuiColorEditFlags_NoDragDrop = 1 << 9, // // ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source.
|
||||
|
||||
// User Options (right-click on widget to change some of them). You can set application defaults using SetColorEditOptions(). The idea is that you probably don't want to override them in most of your calls, let the user choose and/or call SetColorEditOptions() during startup.
|
||||
// User Options (right-click on widget to change some of them). You can set application defaults using SetColorEditOptions().
|
||||
// The intent is that you probably don't want to override them in most of your calls, let the user choose via the option menu and/or call SetColorEditOptions() during startup.
|
||||
ImGuiColorEditFlags_AlphaBar = 1 << 16, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
|
||||
ImGuiColorEditFlags_AlphaPreview = 1 << 17, // // ColorEdit, ColorPicker, ColorButton: display preview as a transparent color over a checkerboard, instead of opaque.
|
||||
ImGuiColorEditFlags_AlphaPreviewHalf= 1 << 18, // // ColorEdit, ColorPicker, ColorButton: display half opaque / half checkerboard, instead of opaque.
|
||||
ImGuiColorEditFlags_HDR = 1 << 19, // // (WIP) ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use ImGuiColorEditFlags_Float flag as well).
|
||||
ImGuiColorEditFlags_RGB = 1 << 20, // [Inputs] // ColorEdit: choose one among RGB/HSV/HEX. ColorPicker: choose any combination using RGB/HSV/HEX.
|
||||
ImGuiColorEditFlags_HSV = 1 << 21, // [Inputs] // "
|
||||
ImGuiColorEditFlags_HEX = 1 << 22, // [Inputs] // "
|
||||
ImGuiColorEditFlags_DisplayRGB = 1 << 20, // [Display] // ColorEdit: override _display_ type among RGB/HSV/Hex. ColorPicker: select any combination using one or more of RGB/HSV/Hex.
|
||||
ImGuiColorEditFlags_DisplayHSV = 1 << 21, // [Display] // "
|
||||
ImGuiColorEditFlags_DisplayHex = 1 << 22, // [Display] // "
|
||||
ImGuiColorEditFlags_Uint8 = 1 << 23, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0..255.
|
||||
ImGuiColorEditFlags_Float = 1 << 24, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0.0f..1.0f floats instead of 0..255 integers. No round-trip of value via integers.
|
||||
ImGuiColorEditFlags_PickerHueBar = 1 << 25, // [PickerMode] // ColorPicker: bar for Hue, rectangle for Sat/Value.
|
||||
ImGuiColorEditFlags_PickerHueWheel = 1 << 26, // [PickerMode] // ColorPicker: wheel for Hue, triangle for Sat/Value.
|
||||
|
||||
// [Internal] Masks
|
||||
ImGuiColorEditFlags__InputsMask = ImGuiColorEditFlags_RGB|ImGuiColorEditFlags_HSV|ImGuiColorEditFlags_HEX,
|
||||
ImGuiColorEditFlags__DisplayMask = ImGuiColorEditFlags_DisplayRGB|ImGuiColorEditFlags_DisplayHSV|ImGuiColorEditFlags_DisplayHex,
|
||||
ImGuiColorEditFlags__DataTypeMask = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_Float,
|
||||
ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel|ImGuiColorEditFlags_PickerHueBar,
|
||||
ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_RGB|ImGuiColorEditFlags_PickerHueBar // Change application default using SetColorEditOptions()
|
||||
ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_DisplayRGB|ImGuiColorEditFlags_PickerHueBar // Change application default using SetColorEditOptions()
|
||||
|
||||
// Obsolete names (will be removed)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
, ImGuiColorEditFlags_RGB = ImGuiColorEditFlags_DisplayRGB, ImGuiColorEditFlags_HSV = ImGuiColorEditFlags_DisplayHSV, ImGuiColorEditFlags_HEX = ImGuiColorEditFlags_DisplayHex
|
||||
#endif
|
||||
};
|
||||
|
||||
// Enumeration for GetMouseCursor()
|
||||
|
@ -1100,7 +1100,7 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::ColorEdit3("MyColor##1", (float*)&color, misc_flags);
|
||||
|
||||
ImGui::Text("Color widget HSV with Alpha:");
|
||||
ImGui::ColorEdit4("MyColor##2", (float*)&color, ImGuiColorEditFlags_HSV | misc_flags);
|
||||
ImGui::ColorEdit4("MyColor##2", (float*)&color, ImGuiColorEditFlags_DisplayHSV | misc_flags);
|
||||
|
||||
ImGui::Text("Color widget with Float Display:");
|
||||
ImGui::ColorEdit4("MyColor##2f", (float*)&color, ImGuiColorEditFlags_Float | misc_flags);
|
||||
@ -1182,7 +1182,7 @@ static void ShowDemoWindowWidgets()
|
||||
static bool side_preview = true;
|
||||
static bool ref_color = false;
|
||||
static ImVec4 ref_color_v(1.0f,0.0f,1.0f,0.5f);
|
||||
static int inputs_mode = 2;
|
||||
static int display_mode = 0;
|
||||
static int picker_mode = 0;
|
||||
ImGui::Checkbox("With Alpha", &alpha);
|
||||
ImGui::Checkbox("With Alpha Bar", &alpha_bar);
|
||||
@ -1197,25 +1197,26 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::ColorEdit4("##RefColor", &ref_color_v.x, ImGuiColorEditFlags_NoInputs | misc_flags);
|
||||
}
|
||||
}
|
||||
ImGui::Combo("Inputs Mode", &inputs_mode, "All Inputs\0No Inputs\0RGB Input\0HSV Input\0HEX Input\0");
|
||||
ImGui::Combo("Display Mode", &display_mode, "Auto/Current\0None\0RGB Only\0HSV Only\0Hex Only\0");
|
||||
ImGui::SameLine(); ShowHelpMarker("ColorEdit defaults to displaying RGB inputs if you don't specify a display mode, but the user can change it with a right-click.\n\nColorPicker defaults to displaying RGB+HSV+Hex if you don't specify a display mode.\n\nYou can change the defaults using SetColorEditOptions().");
|
||||
ImGui::Combo("Picker Mode", &picker_mode, "Auto/Current\0Hue bar + SV rect\0Hue wheel + SV triangle\0");
|
||||
ImGui::SameLine(); ShowHelpMarker("User can right-click the picker to change mode.");
|
||||
ImGuiColorEditFlags flags = misc_flags;
|
||||
if (!alpha) flags |= ImGuiColorEditFlags_NoAlpha; // This is by default if you call ColorPicker3() instead of ColorPicker4()
|
||||
if (alpha_bar) flags |= ImGuiColorEditFlags_AlphaBar;
|
||||
if (!side_preview) flags |= ImGuiColorEditFlags_NoSidePreview;
|
||||
if (picker_mode == 1) flags |= ImGuiColorEditFlags_PickerHueBar;
|
||||
if (picker_mode == 2) flags |= ImGuiColorEditFlags_PickerHueWheel;
|
||||
if (inputs_mode == 1) flags |= ImGuiColorEditFlags_NoInputs;
|
||||
if (inputs_mode == 2) flags |= ImGuiColorEditFlags_RGB;
|
||||
if (inputs_mode == 3) flags |= ImGuiColorEditFlags_HSV;
|
||||
if (inputs_mode == 4) flags |= ImGuiColorEditFlags_HEX;
|
||||
if (!alpha) flags |= ImGuiColorEditFlags_NoAlpha; // This is by default if you call ColorPicker3() instead of ColorPicker4()
|
||||
if (alpha_bar) flags |= ImGuiColorEditFlags_AlphaBar;
|
||||
if (!side_preview) flags |= ImGuiColorEditFlags_NoSidePreview;
|
||||
if (picker_mode == 1) flags |= ImGuiColorEditFlags_PickerHueBar;
|
||||
if (picker_mode == 2) flags |= ImGuiColorEditFlags_PickerHueWheel;
|
||||
if (display_mode == 1) flags |= ImGuiColorEditFlags_NoInputs; // Disable all RGB/HSV/Hex displays
|
||||
if (display_mode == 2) flags |= ImGuiColorEditFlags_DisplayRGB; // Override display mode
|
||||
if (display_mode == 3) flags |= ImGuiColorEditFlags_DisplayHSV;
|
||||
if (display_mode == 4) flags |= ImGuiColorEditFlags_DisplayHex;
|
||||
ImGui::ColorPicker4("MyColor##4", (float*)&color, flags, ref_color ? &ref_color_v.x : NULL);
|
||||
|
||||
ImGui::Text("Programmatically set defaults:");
|
||||
ImGui::SameLine(); ShowHelpMarker("SetColorEditOptions() is designed to allow you to set boot-time default.\nWe don't have Push/Pop functions because you can force options on a per-widget basis if needed, and the user can change non-forced ones with the options menu.\nWe don't have a getter to avoid encouraging you to persistently save values that aren't forward-compatible.");
|
||||
if (ImGui::Button("Default: Uint8 + HSV + Hue Bar"))
|
||||
ImGui::SetColorEditOptions(ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_HSV | ImGuiColorEditFlags_PickerHueBar);
|
||||
ImGui::SetColorEditOptions(ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_PickerHueBar);
|
||||
if (ImGui::Button("Default: Float + HDR + Hue Wheel"))
|
||||
ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel);
|
||||
|
||||
@ -1252,6 +1253,10 @@ static void ShowDemoWindowWidgets()
|
||||
ImS64 LLONG_MAX = 9223372036854775807LL;
|
||||
ImU64 ULLONG_MAX = (2ULL * 9223372036854775807LL + 1);
|
||||
#endif
|
||||
const char s8_zero = 0, s8_one = 1, s8_fifty = 50, s8_min = -128, s8_max = 127;
|
||||
const ImU8 u8_zero = 0, u8_one = 1, u8_fifty = 50, u8_min = 0, u8_max = 255;
|
||||
const short s16_zero = 0, s16_one = 1, s16_fifty = 50, s16_min = -32768, s16_max = 32767;
|
||||
const ImU16 u16_zero = 0, u16_one = 1, u16_fifty = 50, u16_min = 0, u16_max = 65535;
|
||||
const ImS32 s32_zero = 0, s32_one = 1, s32_fifty = 50, s32_min = INT_MIN/2, s32_max = INT_MAX/2, s32_hi_a = INT_MAX/2 - 100, s32_hi_b = INT_MAX/2;
|
||||
const ImU32 u32_zero = 0, u32_one = 1, u32_fifty = 50, u32_min = 0, u32_max = UINT_MAX/2, u32_hi_a = UINT_MAX/2 - 100, u32_hi_b = UINT_MAX/2;
|
||||
const ImS64 s64_zero = 0, s64_one = 1, s64_fifty = 50, s64_min = LLONG_MIN/2, s64_max = LLONG_MAX/2, s64_hi_a = LLONG_MAX/2 - 100, s64_hi_b = LLONG_MAX/2;
|
||||
@ -1260,6 +1265,10 @@ static void ShowDemoWindowWidgets()
|
||||
const double f64_zero = 0., f64_one = 1., f64_lo_a = -1000000000000000.0, f64_hi_a = +1000000000000000.0;
|
||||
|
||||
// State
|
||||
static char s8_v = 127;
|
||||
static ImU8 u8_v = 255;
|
||||
static short s16_v = 32767;
|
||||
static ImU16 u16_v = 65535;
|
||||
static ImS32 s32_v = -1;
|
||||
static ImU32 u32_v = (ImU32)-1;
|
||||
static ImS64 s64_v = -1;
|
||||
@ -1271,6 +1280,10 @@ static void ShowDemoWindowWidgets()
|
||||
static bool drag_clamp = false;
|
||||
ImGui::Text("Drags:");
|
||||
ImGui::Checkbox("Clamp integers to 0..50", &drag_clamp); ImGui::SameLine(); ShowHelpMarker("As with every widgets in dear imgui, we never modify values unless there is a user interaction.\nYou can override the clamping limits by using CTRL+Click to input a value.");
|
||||
ImGui::DragScalar("drag s8", ImGuiDataType_S8, &s8_v, drag_speed, drag_clamp ? &s8_zero : NULL, drag_clamp ? &s8_fifty : NULL);
|
||||
ImGui::DragScalar("drag u8", ImGuiDataType_U8, &u8_v, drag_speed, drag_clamp ? &u8_zero : NULL, drag_clamp ? &u8_fifty : NULL, "%u ms");
|
||||
ImGui::DragScalar("drag s16", ImGuiDataType_S16, &s16_v, drag_speed, drag_clamp ? &s16_zero : NULL, drag_clamp ? &s16_fifty : NULL);
|
||||
ImGui::DragScalar("drag u16", ImGuiDataType_U16, &u16_v, drag_speed, drag_clamp ? &u16_zero : NULL, drag_clamp ? &u16_fifty : NULL, "%u ms");
|
||||
ImGui::DragScalar("drag s32", ImGuiDataType_S32, &s32_v, drag_speed, drag_clamp ? &s32_zero : NULL, drag_clamp ? &s32_fifty : NULL);
|
||||
ImGui::DragScalar("drag u32", ImGuiDataType_U32, &u32_v, drag_speed, drag_clamp ? &u32_zero : NULL, drag_clamp ? &u32_fifty : NULL, "%u ms");
|
||||
ImGui::DragScalar("drag s64", ImGuiDataType_S64, &s64_v, drag_speed, drag_clamp ? &s64_zero : NULL, drag_clamp ? &s64_fifty : NULL);
|
||||
@ -1281,6 +1294,10 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::DragScalar("drag double ^2", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, &f64_one, "0 < %.10f < 1", 2.0f);
|
||||
|
||||
ImGui::Text("Sliders");
|
||||
ImGui::SliderScalar("slider s8 full", ImGuiDataType_S8, &s8_v, &s8_min, &s8_max, "%d");
|
||||
ImGui::SliderScalar("slider u8 full", ImGuiDataType_U8, &u8_v, &u8_min, &u8_max, "%u");
|
||||
ImGui::SliderScalar("slider s16 full", ImGuiDataType_S16, &s16_v, &s16_min, &s16_max, "%d");
|
||||
ImGui::SliderScalar("slider u16 full", ImGuiDataType_U16, &u16_v, &u16_min, &u16_max, "%u");
|
||||
ImGui::SliderScalar("slider s32 low", ImGuiDataType_S32, &s32_v, &s32_zero, &s32_fifty,"%d");
|
||||
ImGui::SliderScalar("slider s32 high", ImGuiDataType_S32, &s32_v, &s32_hi_a, &s32_hi_b, "%d");
|
||||
ImGui::SliderScalar("slider s32 full", ImGuiDataType_S32, &s32_v, &s32_min, &s32_max, "%d");
|
||||
@ -1303,6 +1320,10 @@ static void ShowDemoWindowWidgets()
|
||||
static bool inputs_step = true;
|
||||
ImGui::Text("Inputs");
|
||||
ImGui::Checkbox("Show step buttons", &inputs_step);
|
||||
ImGui::InputScalar("input s8", ImGuiDataType_S8, &s8_v, inputs_step ? &s8_one : NULL, NULL, "%d");
|
||||
ImGui::InputScalar("input u8", ImGuiDataType_U8, &u8_v, inputs_step ? &u8_one : NULL, NULL, "%u");
|
||||
ImGui::InputScalar("input s16", ImGuiDataType_S16, &s16_v, inputs_step ? &s16_one : NULL, NULL, "%d");
|
||||
ImGui::InputScalar("input u16", ImGuiDataType_U16, &u16_v, inputs_step ? &u16_one : NULL, NULL, "%u");
|
||||
ImGui::InputScalar("input s32", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%d");
|
||||
ImGui::InputScalar("input s32 hex", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
|
||||
ImGui::InputScalar("input u32", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%u");
|
||||
|
@ -233,12 +233,15 @@ static inline double ImAtof(const char* s)
|
||||
static inline float ImFloorStd(float x) { return floorf(x); } // we already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by stb_truetype)
|
||||
static inline float ImCeil(float x) { return ceilf(x); }
|
||||
#endif
|
||||
// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support for variety of types: signed/unsigned int/long long float/double, using templates here but we could also redefine them 6 times
|
||||
// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support for variety of types: signed/unsigned int/long long float/double
|
||||
// (Exceptionally using templates here but we could also redefine them for variety of types)
|
||||
template<typename T> static inline T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; }
|
||||
template<typename T> static inline T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; }
|
||||
template<typename T> static inline T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
||||
template<typename T> static inline T ImLerp(T a, T b, float t) { return (T)(a + (b - a) * t); }
|
||||
template<typename T> static inline void ImSwap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
|
||||
template<typename T> static inline T ImAddClampOverflow(T a, T b, T mn, T mx) { if (b < 0 && (a < mn - b)) return mn; if (b > 0 && (a > mx - b)) return mx; return a + b; }
|
||||
template<typename T> static inline T ImSubClampOverflow(T a, T b, T mn, T mx) { if (b > 0 && (a < mn + b)) return mn; if (b < 0 && (a > mx + b)) return mx; return a - b; }
|
||||
// - Misc maths helpers
|
||||
static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); }
|
||||
static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); }
|
||||
|
@ -74,22 +74,30 @@ Index of this file:
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// Those MIN/MAX values are not define because we need to point to them
|
||||
static const ImS32 IM_S32_MIN = INT_MIN; // (-2147483647 - 1), (0x80000000);
|
||||
static const ImS32 IM_S32_MAX = INT_MAX; // (2147483647), (0x7FFFFFFF)
|
||||
static const ImU32 IM_U32_MIN = 0;
|
||||
static const ImU32 IM_U32_MAX = UINT_MAX; // (0xFFFFFFFF)
|
||||
static const char IM_S8_MIN = -128;
|
||||
static const char IM_S8_MAX = 127;
|
||||
static const unsigned char IM_U8_MIN = 0;
|
||||
static const unsigned char IM_U8_MAX = 0xFF;
|
||||
static const short IM_S16_MIN = -32768;
|
||||
static const short IM_S16_MAX = 32767;
|
||||
static const unsigned short IM_U16_MIN = 0;
|
||||
static const unsigned short IM_U16_MAX = 0xFFFF;
|
||||
static const ImS32 IM_S32_MIN = INT_MIN; // (-2147483647 - 1), (0x80000000);
|
||||
static const ImS32 IM_S32_MAX = INT_MAX; // (2147483647), (0x7FFFFFFF)
|
||||
static const ImU32 IM_U32_MIN = 0;
|
||||
static const ImU32 IM_U32_MAX = UINT_MAX; // (0xFFFFFFFF)
|
||||
#ifdef LLONG_MIN
|
||||
static const ImS64 IM_S64_MIN = LLONG_MIN; // (-9223372036854775807ll - 1ll);
|
||||
static const ImS64 IM_S64_MAX = LLONG_MAX; // (9223372036854775807ll);
|
||||
static const ImS64 IM_S64_MIN = LLONG_MIN; // (-9223372036854775807ll - 1ll);
|
||||
static const ImS64 IM_S64_MAX = LLONG_MAX; // (9223372036854775807ll);
|
||||
#else
|
||||
static const ImS64 IM_S64_MIN = -9223372036854775807LL - 1;
|
||||
static const ImS64 IM_S64_MAX = 9223372036854775807LL;
|
||||
static const ImS64 IM_S64_MIN = -9223372036854775807LL - 1;
|
||||
static const ImS64 IM_S64_MAX = 9223372036854775807LL;
|
||||
#endif
|
||||
static const ImU64 IM_U64_MIN = 0;
|
||||
static const ImU64 IM_U64_MIN = 0;
|
||||
#ifdef ULLONG_MAX
|
||||
static const ImU64 IM_U64_MAX = ULLONG_MAX; // (0xFFFFFFFFFFFFFFFFull);
|
||||
static const ImU64 IM_U64_MAX = ULLONG_MAX; // (0xFFFFFFFFFFFFFFFFull);
|
||||
#else
|
||||
static const ImU64 IM_U64_MAX = (2ULL * 9223372036854775807LL + 1);
|
||||
static const ImU64 IM_U64_MAX = (2ULL * 9223372036854775807LL + 1);
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -1526,17 +1534,21 @@ struct ImGuiDataTypeInfo
|
||||
|
||||
static const ImGuiDataTypeInfo GDataTypeInfo[] =
|
||||
{
|
||||
{ sizeof(int), "%d", "%d" },
|
||||
{ sizeof(unsigned int), "%u", "%u" },
|
||||
{ sizeof(char), "%d", "%d" }, // ImGuiDataType_S8
|
||||
{ sizeof(unsigned char), "%u", "%u" },
|
||||
{ sizeof(short), "%d", "%d" }, // ImGuiDataType_S16
|
||||
{ sizeof(unsigned short), "%u", "%u" },
|
||||
{ sizeof(int), "%d", "%d" }, // ImGuiDataType_S32
|
||||
{ sizeof(unsigned int), "%u", "%u" },
|
||||
#ifdef _MSC_VER
|
||||
{ sizeof(ImS64), "%I64d","%I64d" },
|
||||
{ sizeof(ImU64), "%I64u","%I64u" },
|
||||
{ sizeof(ImS64), "%I64d","%I64d" }, // ImGuiDataType_S64
|
||||
{ sizeof(ImU64), "%I64u","%I64u" },
|
||||
#else
|
||||
{ sizeof(ImS64), "%lld", "%lld" },
|
||||
{ sizeof(ImU64), "%llu", "%llu" },
|
||||
{ sizeof(ImS64), "%lld", "%lld" }, // ImGuiDataType_S64
|
||||
{ sizeof(ImU64), "%llu", "%llu" },
|
||||
#endif
|
||||
{ sizeof(float), "%f", "%f" }, // float are promoted to double in va_arg
|
||||
{ sizeof(double), "%f", "%lf" },
|
||||
{ sizeof(float), "%f", "%f" }, // ImGuiDataType_Float (float are promoted to double in va_arg)
|
||||
{ sizeof(double), "%f", "%lf" }, // ImGuiDataType_Double
|
||||
};
|
||||
IM_STATIC_ASSERT(IM_ARRAYSIZE(GDataTypeInfo) == ImGuiDataType_COUNT);
|
||||
|
||||
@ -1566,47 +1578,71 @@ static const char* PatchFormatStringFloatToInt(const char* fmt)
|
||||
|
||||
static inline int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* data_ptr, const char* format)
|
||||
{
|
||||
if (data_type == ImGuiDataType_S32 || data_type == ImGuiDataType_U32) // Signedness doesn't matter when pushing the argument
|
||||
// Signedness doesn't matter when pushing integer arguments
|
||||
if (data_type == ImGuiDataType_S32 || data_type == ImGuiDataType_U32)
|
||||
return ImFormatString(buf, buf_size, format, *(const ImU32*)data_ptr);
|
||||
if (data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64) // Signedness doesn't matter when pushing the argument
|
||||
if (data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64)
|
||||
return ImFormatString(buf, buf_size, format, *(const ImU64*)data_ptr);
|
||||
if (data_type == ImGuiDataType_Float)
|
||||
return ImFormatString(buf, buf_size, format, *(const float*)data_ptr);
|
||||
if (data_type == ImGuiDataType_Double)
|
||||
return ImFormatString(buf, buf_size, format, *(const double*)data_ptr);
|
||||
if (data_type == ImGuiDataType_S8)
|
||||
return ImFormatString(buf, buf_size, format, *(const ImS8*)data_ptr);
|
||||
if (data_type == ImGuiDataType_U8)
|
||||
return ImFormatString(buf, buf_size, format, *(const ImU8*)data_ptr);
|
||||
if (data_type == ImGuiDataType_S16)
|
||||
return ImFormatString(buf, buf_size, format, *(const ImS16*)data_ptr);
|
||||
if (data_type == ImGuiDataType_U16)
|
||||
return ImFormatString(buf, buf_size, format, *(const ImU16*)data_ptr);
|
||||
IM_ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// FIXME: Adding support for clamping on boundaries of the data type would be nice.
|
||||
static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void* arg1, const void* arg2)
|
||||
{
|
||||
IM_ASSERT(op == '+' || op == '-');
|
||||
switch (data_type)
|
||||
{
|
||||
case ImGuiDataType_S8:
|
||||
if (op == '+') { *(ImS8*)output = ImAddClampOverflow(*(const ImS8*)arg1, *(const ImS8*)arg2, IM_S8_MIN, IM_S8_MAX); }
|
||||
if (op == '-') { *(ImS8*)output = ImSubClampOverflow(*(const ImS8*)arg1, *(const ImS8*)arg2, IM_S8_MIN, IM_S8_MAX); }
|
||||
return;
|
||||
case ImGuiDataType_U8:
|
||||
if (op == '+') { *(ImU8*)output = ImAddClampOverflow(*(const ImU8*)arg1, *(const ImU8*)arg2, IM_U8_MIN, IM_U8_MAX); }
|
||||
if (op == '-') { *(ImU8*)output = ImSubClampOverflow(*(const ImU8*)arg1, *(const ImU8*)arg2, IM_U8_MIN, IM_U8_MAX); }
|
||||
return;
|
||||
case ImGuiDataType_S16:
|
||||
if (op == '+') { *(ImS16*)output = ImAddClampOverflow(*(const ImS16*)arg1, *(const ImS16*)arg2, IM_S16_MIN, IM_S16_MAX); }
|
||||
if (op == '-') { *(ImS16*)output = ImSubClampOverflow(*(const ImS16*)arg1, *(const ImS16*)arg2, IM_S16_MIN, IM_S16_MAX); }
|
||||
return;
|
||||
case ImGuiDataType_U16:
|
||||
if (op == '+') { *(ImU16*)output = ImAddClampOverflow(*(const ImU16*)arg1, *(const ImU16*)arg2, IM_U16_MIN, IM_U16_MAX); }
|
||||
if (op == '-') { *(ImU16*)output = ImSubClampOverflow(*(const ImU16*)arg1, *(const ImU16*)arg2, IM_U16_MIN, IM_U16_MAX); }
|
||||
return;
|
||||
case ImGuiDataType_S32:
|
||||
if (op == '+') *(int*)output = *(const int*)arg1 + *(const int*)arg2;
|
||||
else if (op == '-') *(int*)output = *(const int*)arg1 - *(const int*)arg2;
|
||||
if (op == '+') { *(ImS32*)output = ImAddClampOverflow(*(const ImS32*)arg1, *(const ImS32*)arg2, IM_S32_MIN, IM_S32_MAX); }
|
||||
if (op == '-') { *(ImS32*)output = ImSubClampOverflow(*(const ImS32*)arg1, *(const ImS32*)arg2, IM_S32_MIN, IM_S32_MAX); }
|
||||
return;
|
||||
case ImGuiDataType_U32:
|
||||
if (op == '+') *(unsigned int*)output = *(const unsigned int*)arg1 + *(const ImU32*)arg2;
|
||||
else if (op == '-') *(unsigned int*)output = *(const unsigned int*)arg1 - *(const ImU32*)arg2;
|
||||
if (op == '+') { *(ImU32*)output = ImAddClampOverflow(*(const ImU32*)arg1, *(const ImU32*)arg2, IM_U32_MIN, IM_U32_MAX); }
|
||||
if (op == '-') { *(ImU32*)output = ImSubClampOverflow(*(const ImU32*)arg1, *(const ImU32*)arg2, IM_U32_MIN, IM_U32_MAX); }
|
||||
return;
|
||||
case ImGuiDataType_S64:
|
||||
if (op == '+') *(ImS64*)output = *(const ImS64*)arg1 + *(const ImS64*)arg2;
|
||||
else if (op == '-') *(ImS64*)output = *(const ImS64*)arg1 - *(const ImS64*)arg2;
|
||||
if (op == '+') { *(ImS64*)output = ImAddClampOverflow(*(const ImS64*)arg1, *(const ImS64*)arg2, IM_S64_MIN, IM_S64_MAX); }
|
||||
if (op == '-') { *(ImS64*)output = ImSubClampOverflow(*(const ImS64*)arg1, *(const ImS64*)arg2, IM_S64_MIN, IM_S64_MAX); }
|
||||
return;
|
||||
case ImGuiDataType_U64:
|
||||
if (op == '+') *(ImU64*)output = *(const ImU64*)arg1 + *(const ImU64*)arg2;
|
||||
else if (op == '-') *(ImU64*)output = *(const ImU64*)arg1 - *(const ImU64*)arg2;
|
||||
if (op == '+') { *(ImU64*)output = ImAddClampOverflow(*(const ImU64*)arg1, *(const ImU64*)arg2, IM_U64_MIN, IM_U64_MAX); }
|
||||
if (op == '-') { *(ImU64*)output = ImSubClampOverflow(*(const ImU64*)arg1, *(const ImU64*)arg2, IM_U64_MIN, IM_U64_MAX); }
|
||||
return;
|
||||
case ImGuiDataType_Float:
|
||||
if (op == '+') *(float*)output = *(const float*)arg1 + *(const float*)arg2;
|
||||
else if (op == '-') *(float*)output = *(const float*)arg1 - *(const float*)arg2;
|
||||
if (op == '+') { *(float*)output = *(const float*)arg1 + *(const float*)arg2; }
|
||||
if (op == '-') { *(float*)output = *(const float*)arg1 - *(const float*)arg2; }
|
||||
return;
|
||||
case ImGuiDataType_Double:
|
||||
if (op == '+') *(double*)output = *(const double*)arg1 + *(const double*)arg2;
|
||||
else if (op == '-') *(double*)output = *(const double*)arg1 - *(const double*)arg2;
|
||||
if (op == '+') { *(double*)output = *(const double*)arg1 + *(const double*)arg2; }
|
||||
if (op == '-') { *(double*)output = *(const double*)arg1 - *(const double*)arg2; }
|
||||
return;
|
||||
case ImGuiDataType_COUNT: break;
|
||||
}
|
||||
@ -1645,6 +1681,7 @@ static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
if (format == NULL)
|
||||
format = GDataTypeInfo[data_type].ScanFmt;
|
||||
|
||||
// FIXME-LEGACY: The aim is to remove those operators and write a proper expression evaluator at some point..
|
||||
int arg1i = 0;
|
||||
if (data_type == ImGuiDataType_S32)
|
||||
{
|
||||
@ -1659,12 +1696,6 @@ static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
else if (op == '/') { if (sscanf(buf, "%f", &arg1f) && arg1f != 0.0f) *v = (int)(arg0i / arg1f); } // Divide
|
||||
else { if (sscanf(buf, format, &arg1i) == 1) *v = arg1i; } // Assign constant
|
||||
}
|
||||
else if (data_type == ImGuiDataType_U32 || data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64)
|
||||
{
|
||||
// Assign constant
|
||||
// FIXME: We don't bother handling support for legacy operators since they are a little too crappy. Instead we may implement a proper expression evaluator in the future.
|
||||
sscanf(buf, format, data_ptr);
|
||||
}
|
||||
else if (data_type == ImGuiDataType_Float)
|
||||
{
|
||||
// For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in
|
||||
@ -1694,6 +1725,29 @@ static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide
|
||||
else { *v = arg1f; } // Assign constant
|
||||
}
|
||||
else if (data_type == ImGuiDataType_U32 || data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64)
|
||||
{
|
||||
// All other types assign constant
|
||||
// We don't bother handling support for legacy operators since they are a little too crappy. Instead we will later implement a proper expression evaluator in the future.
|
||||
sscanf(buf, format, data_ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Small types need a 32-bit buffer to receive the result from scanf()
|
||||
int v32;
|
||||
sscanf(buf, format, &v32);
|
||||
if (data_type == ImGuiDataType_S8)
|
||||
*(ImS8*)data_ptr = (ImS8)ImClamp(v32, (int)IM_S8_MIN, (int)IM_S8_MAX);
|
||||
else if (data_type == ImGuiDataType_U8)
|
||||
*(ImU8*)data_ptr = (ImU8)ImClamp(v32, (int)IM_U8_MIN, (int)IM_U8_MAX);
|
||||
else if (data_type == ImGuiDataType_S16)
|
||||
*(ImS16*)data_ptr = (ImS16)ImClamp(v32, (int)IM_S16_MIN, (int)IM_S16_MAX);
|
||||
else if (data_type == ImGuiDataType_U16)
|
||||
*(ImU16*)data_ptr = (ImU16)ImClamp(v32, (int)IM_U16_MIN, (int)IM_U16_MAX);
|
||||
else
|
||||
IM_ASSERT(0);
|
||||
}
|
||||
|
||||
return memcmp(data_backup, data_ptr, GDataTypeInfo[data_type].Size) != 0;
|
||||
}
|
||||
|
||||
@ -1876,6 +1930,10 @@ bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* v, float v_s
|
||||
|
||||
switch (data_type)
|
||||
{
|
||||
case ImGuiDataType_S8: { ImS32 v32 = (ImS32)*(ImS8*)v; bool r = DragBehaviorT<ImS32, ImS32, float >(ImGuiDataType_S32, &v32, v_speed, v_min ? *(const ImS8*) v_min : IM_S8_MIN, v_max ? *(const ImS8*)v_max : IM_S8_MAX, format, power, flags); if (r) *(ImS8*)v = (ImS8)v32; return r; }
|
||||
case ImGuiDataType_U8: { ImU32 v32 = (ImU32)*(ImU8*)v; bool r = DragBehaviorT<ImU32, ImS32, float >(ImGuiDataType_U32, &v32, v_speed, v_min ? *(const ImU8*) v_min : IM_U8_MIN, v_max ? *(const ImU8*)v_max : IM_U8_MAX, format, power, flags); if (r) *(ImU8*)v = (ImU8)v32; return r; }
|
||||
case ImGuiDataType_S16: { ImS32 v32 = (ImS32)*(ImS16*)v; bool r = DragBehaviorT<ImS32, ImS32, float >(ImGuiDataType_S32, &v32, v_speed, v_min ? *(const ImS16*)v_min : IM_S16_MIN, v_max ? *(const ImS16*)v_max : IM_S16_MAX, format, power, flags); if (r) *(ImS16*)v = (ImS16)v32; return r; }
|
||||
case ImGuiDataType_U16: { ImU32 v32 = (ImU32)*(ImU16*)v; bool r = DragBehaviorT<ImU32, ImS32, float >(ImGuiDataType_U32, &v32, v_speed, v_min ? *(const ImU16*)v_min : IM_U16_MIN, v_max ? *(const ImU16*)v_max : IM_U16_MAX, format, power, flags); if (r) *(ImU16*)v = (ImU16)v32; return r; }
|
||||
case ImGuiDataType_S32: return DragBehaviorT<ImS32, ImS32, float >(data_type, (ImS32*)v, v_speed, v_min ? *(const ImS32* )v_min : IM_S32_MIN, v_max ? *(const ImS32* )v_max : IM_S32_MAX, format, power, flags);
|
||||
case ImGuiDataType_U32: return DragBehaviorT<ImU32, ImS32, float >(data_type, (ImU32*)v, v_speed, v_min ? *(const ImU32* )v_min : IM_U32_MIN, v_max ? *(const ImU32* )v_max : IM_U32_MAX, format, power, flags);
|
||||
case ImGuiDataType_S64: return DragBehaviorT<ImS64, ImS64, double>(data_type, (ImS64*)v, v_speed, v_min ? *(const ImS64* )v_min : IM_S64_MIN, v_max ? *(const ImS64* )v_max : IM_S64_MAX, format, power, flags);
|
||||
@ -2300,6 +2358,10 @@ bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type
|
||||
{
|
||||
switch (data_type)
|
||||
{
|
||||
case ImGuiDataType_S8: { ImS32 v32 = (ImS32)*(ImS8*)v; bool r = SliderBehaviorT<ImS32, ImS32, float >(bb, id, ImGuiDataType_S32, &v32, *(const ImS8*)v_min, *(const ImS8*)v_max, format, power, flags, out_grab_bb); if (r) *(ImS8*)v = (ImS8)v32; return r; }
|
||||
case ImGuiDataType_U8: { ImU32 v32 = (ImU32)*(ImU8*)v; bool r = SliderBehaviorT<ImU32, ImS32, float >(bb, id, ImGuiDataType_U32, &v32, *(const ImU8*)v_min, *(const ImU8*)v_max, format, power, flags, out_grab_bb); if (r) *(ImU8*)v = (ImU8)v32; return r; }
|
||||
case ImGuiDataType_S16: { ImS32 v32 = (ImS32)*(ImS16*)v; bool r = SliderBehaviorT<ImS32, ImS32, float >(bb, id, ImGuiDataType_S32, &v32, *(const ImS16*)v_min, *(const ImS16*)v_max, format, power, flags, out_grab_bb); if (r) *(ImS16*)v = (ImS16)v32; return r; }
|
||||
case ImGuiDataType_U16: { ImU32 v32 = (ImU32)*(ImU16*)v; bool r = SliderBehaviorT<ImU32, ImS32, float >(bb, id, ImGuiDataType_U32, &v32, *(const ImU16*)v_min, *(const ImU16*)v_max, format, power, flags, out_grab_bb); if (r) *(ImU16*)v = (ImU16)v32; return r; }
|
||||
case ImGuiDataType_S32:
|
||||
IM_ASSERT(*(const ImS32*)v_min >= IM_S32_MIN/2 && *(const ImS32*)v_max <= IM_S32_MAX/2);
|
||||
return SliderBehaviorT<ImS32, ImS32, float >(bb, id, data_type, (ImS32*)v, *(const ImS32*)v_min, *(const ImS32*)v_max, format, power, flags, out_grab_bb);
|
||||
@ -3315,7 +3377,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
ClearActiveID();
|
||||
|
||||
// Release focus when we click outside
|
||||
if (g.ActiveId == id && io.MouseClicked[0] && !init_state && !init_make_active)
|
||||
if (g.ActiveId == id && io.MouseClicked[0] && !init_state && !init_make_active) //-V560
|
||||
clear_active_id = true;
|
||||
|
||||
bool value_changed = false;
|
||||
@ -3326,8 +3388,8 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
// FIXME-OPT: Because our selection/cursor code currently needs the wide text we need to convert it when active, which is not ideal :(
|
||||
if (is_readonly && state != NULL)
|
||||
{
|
||||
const bool will_render_cursor = (g.ActiveId == id) || (state && user_scroll_active);
|
||||
const bool will_render_selection = state && state->HasSelection() && (RENDER_SELECTION_WHEN_INACTIVE || will_render_cursor);
|
||||
const bool will_render_cursor = (g.ActiveId == id) || (user_scroll_active);
|
||||
const bool will_render_selection = state->HasSelection() && (RENDER_SELECTION_WHEN_INACTIVE || will_render_cursor);
|
||||
if (will_render_cursor || will_render_selection)
|
||||
{
|
||||
const char* buf_end = NULL;
|
||||
@ -3932,20 +3994,20 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
// If we're not showing any slider there's no point in doing any HSV conversions
|
||||
const ImGuiColorEditFlags flags_untouched = flags;
|
||||
if (flags & ImGuiColorEditFlags_NoInputs)
|
||||
flags = (flags & (~ImGuiColorEditFlags__InputsMask)) | ImGuiColorEditFlags_RGB | ImGuiColorEditFlags_NoOptions;
|
||||
flags = (flags & (~ImGuiColorEditFlags__DisplayMask)) | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_NoOptions;
|
||||
|
||||
// Context menu: display and modify options (before defaults are applied)
|
||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||
ColorEditOptionsPopup(col, flags);
|
||||
|
||||
// Read stored options
|
||||
if (!(flags & ImGuiColorEditFlags__InputsMask))
|
||||
flags |= (g.ColorEditOptions & ImGuiColorEditFlags__InputsMask);
|
||||
if (!(flags & ImGuiColorEditFlags__DisplayMask))
|
||||
flags |= (g.ColorEditOptions & ImGuiColorEditFlags__DisplayMask);
|
||||
if (!(flags & ImGuiColorEditFlags__DataTypeMask))
|
||||
flags |= (g.ColorEditOptions & ImGuiColorEditFlags__DataTypeMask);
|
||||
if (!(flags & ImGuiColorEditFlags__PickerMask))
|
||||
flags |= (g.ColorEditOptions & ImGuiColorEditFlags__PickerMask);
|
||||
flags |= (g.ColorEditOptions & ~(ImGuiColorEditFlags__InputsMask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask));
|
||||
flags |= (g.ColorEditOptions & ~(ImGuiColorEditFlags__DisplayMask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask));
|
||||
|
||||
const bool alpha = (flags & ImGuiColorEditFlags_NoAlpha) == 0;
|
||||
const bool hdr = (flags & ImGuiColorEditFlags_HDR) != 0;
|
||||
@ -3953,14 +4015,14 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
|
||||
// Convert to the formats we need
|
||||
float f[4] = { col[0], col[1], col[2], alpha ? col[3] : 1.0f };
|
||||
if (flags & ImGuiColorEditFlags_HSV)
|
||||
if (flags & ImGuiColorEditFlags_DisplayHSV)
|
||||
ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]);
|
||||
int i[4] = { IM_F32_TO_INT8_UNBOUND(f[0]), IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]) };
|
||||
|
||||
bool value_changed = false;
|
||||
bool value_changed_as_float = false;
|
||||
|
||||
if ((flags & (ImGuiColorEditFlags_RGB | ImGuiColorEditFlags_HSV)) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
||||
if ((flags & (ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV)) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
||||
{
|
||||
// RGB/HSV 0..255 Sliders
|
||||
const float w_item_one = ImMax(1.0f, (float)(int)((w_items_all - (style.ItemInnerSpacing.x) * (components-1)) / (float)components));
|
||||
@ -3980,7 +4042,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
{ "R:%0.3f", "G:%0.3f", "B:%0.3f", "A:%0.3f" }, // Long display for RGBA
|
||||
{ "H:%0.3f", "S:%0.3f", "V:%0.3f", "A:%0.3f" } // Long display for HSVA
|
||||
};
|
||||
const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_HSV) ? 2 : 1;
|
||||
const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_DisplayHSV) ? 2 : 1;
|
||||
|
||||
PushItemWidth(w_item_one);
|
||||
for (int n = 0; n < components; n++)
|
||||
@ -4004,7 +4066,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
PopItemWidth();
|
||||
PopItemWidth();
|
||||
}
|
||||
else if ((flags & ImGuiColorEditFlags_HEX) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
||||
else if ((flags & ImGuiColorEditFlags_DisplayHex) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
||||
{
|
||||
// RGB Hexadecimal Input
|
||||
char buf[64];
|
||||
@ -4059,7 +4121,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
Spacing();
|
||||
}
|
||||
ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar;
|
||||
ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags__InputsMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||
ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags__DisplayMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||
PushItemWidth(square_sz * 12.0f); // Use 256 + bar sizes?
|
||||
value_changed |= ColorPicker4("##picker", col, picker_flags, &g.ColorPickerRef.x);
|
||||
PopItemWidth();
|
||||
@ -4079,7 +4141,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
if (!value_changed_as_float)
|
||||
for (int n = 0; n < 4; n++)
|
||||
f[n] = i[n] / 255.0f;
|
||||
if (flags & ImGuiColorEditFlags_HSV)
|
||||
if (flags & ImGuiColorEditFlags_DisplayHSV)
|
||||
ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]);
|
||||
if (value_changed)
|
||||
{
|
||||
@ -4364,18 +4426,18 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
PushItemWidth((alpha_bar ? bar1_pos_x : bar0_pos_x) + bars_width - picker_pos.x);
|
||||
ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||
ImGuiColorEditFlags sub_flags = (flags & sub_flags_to_forward) | ImGuiColorEditFlags_NoPicker;
|
||||
if (flags & ImGuiColorEditFlags_RGB || (flags & ImGuiColorEditFlags__InputsMask) == 0)
|
||||
if (ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_RGB))
|
||||
if (flags & ImGuiColorEditFlags_DisplayRGB || (flags & ImGuiColorEditFlags__DisplayMask) == 0)
|
||||
if (ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_DisplayRGB))
|
||||
{
|
||||
// FIXME: Hackily differenciating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget.
|
||||
// For the later we don't want to run the hue-wrap canceling code. If you are well versed in HSV picker please provide your input! (See #2050)
|
||||
value_changed_fix_hue_wrap = (g.ActiveId != 0 && !g.ActiveIdAllowOverlap);
|
||||
value_changed = true;
|
||||
}
|
||||
if (flags & ImGuiColorEditFlags_HSV || (flags & ImGuiColorEditFlags__InputsMask) == 0)
|
||||
value_changed |= ColorEdit4("##hsv", col, sub_flags | ImGuiColorEditFlags_HSV);
|
||||
if (flags & ImGuiColorEditFlags_HEX || (flags & ImGuiColorEditFlags__InputsMask) == 0)
|
||||
value_changed |= ColorEdit4("##hex", col, sub_flags | ImGuiColorEditFlags_HEX);
|
||||
if (flags & ImGuiColorEditFlags_DisplayHSV || (flags & ImGuiColorEditFlags__DisplayMask) == 0)
|
||||
value_changed |= ColorEdit4("##hsv", col, sub_flags | ImGuiColorEditFlags_DisplayHSV);
|
||||
if (flags & ImGuiColorEditFlags_DisplayHex || (flags & ImGuiColorEditFlags__DisplayMask) == 0)
|
||||
value_changed |= ColorEdit4("##hex", col, sub_flags | ImGuiColorEditFlags_DisplayHex);
|
||||
PopItemWidth();
|
||||
}
|
||||
|
||||
@ -4570,16 +4632,17 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
|
||||
return pressed;
|
||||
}
|
||||
|
||||
// Initialize/override default color options
|
||||
void ImGui::SetColorEditOptions(ImGuiColorEditFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if ((flags & ImGuiColorEditFlags__InputsMask) == 0)
|
||||
flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__InputsMask;
|
||||
if ((flags & ImGuiColorEditFlags__DisplayMask) == 0)
|
||||
flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__DisplayMask;
|
||||
if ((flags & ImGuiColorEditFlags__DataTypeMask) == 0)
|
||||
flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__DataTypeMask;
|
||||
if ((flags & ImGuiColorEditFlags__PickerMask) == 0)
|
||||
flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__PickerMask;
|
||||
IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__InputsMask))); // Check only 1 option is selected
|
||||
IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__DisplayMask))); // Check only 1 option is selected
|
||||
IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__DataTypeMask))); // Check only 1 option is selected
|
||||
IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__PickerMask))); // Check only 1 option is selected
|
||||
g.ColorEditOptions = flags;
|
||||
@ -4612,7 +4675,7 @@ void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags
|
||||
|
||||
void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
|
||||
{
|
||||
bool allow_opt_inputs = !(flags & ImGuiColorEditFlags__InputsMask);
|
||||
bool allow_opt_inputs = !(flags & ImGuiColorEditFlags__DisplayMask);
|
||||
bool allow_opt_datatype = !(flags & ImGuiColorEditFlags__DataTypeMask);
|
||||
if ((!allow_opt_inputs && !allow_opt_datatype) || !BeginPopup("context"))
|
||||
return;
|
||||
@ -4620,9 +4683,9 @@ void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
|
||||
ImGuiColorEditFlags opts = g.ColorEditOptions;
|
||||
if (allow_opt_inputs)
|
||||
{
|
||||
if (RadioButton("RGB", (opts & ImGuiColorEditFlags_RGB) != 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_RGB;
|
||||
if (RadioButton("HSV", (opts & ImGuiColorEditFlags_HSV) != 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_HSV;
|
||||
if (RadioButton("HEX", (opts & ImGuiColorEditFlags_HEX) != 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_HEX;
|
||||
if (RadioButton("RGB", (opts & ImGuiColorEditFlags_DisplayRGB) != 0)) opts = (opts & ~ImGuiColorEditFlags__DisplayMask) | ImGuiColorEditFlags_DisplayRGB;
|
||||
if (RadioButton("HSV", (opts & ImGuiColorEditFlags_DisplayHSV) != 0)) opts = (opts & ~ImGuiColorEditFlags__DisplayMask) | ImGuiColorEditFlags_DisplayHSV;
|
||||
if (RadioButton("Hex", (opts & ImGuiColorEditFlags_DisplayHex) != 0)) opts = (opts & ~ImGuiColorEditFlags__DisplayMask) | ImGuiColorEditFlags_DisplayHex;
|
||||
}
|
||||
if (allow_opt_datatype)
|
||||
{
|
||||
@ -5377,7 +5440,8 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
|
||||
|
||||
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
|
||||
if (values_count > 0)
|
||||
const int values_count_min = (plot_type == ImGuiPlotType_Lines) ? 2 : 1;
|
||||
if (values_count >= values_count_min)
|
||||
{
|
||||
int res_w = ImMin((int)frame_size.x, values_count) + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0);
|
||||
int item_count = values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0);
|
||||
|
Loading…
Reference in New Issue
Block a user