mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Merge branch 'master' into viewport
# Conflicts: # examples/example_sdl_vulkan/main.cpp # examples/imgui_impl_dx11.cpp # examples/imgui_impl_dx12.cpp # examples/imgui_impl_glfw.cpp # examples/imgui_impl_sdl.cpp # examples/imgui_impl_vulkan.h # imgui.cpp
This commit is contained in:
44
imgui.h
44
imgui.h
@ -79,7 +79,9 @@ Index of this file:
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wold-style-cast"
|
||||
#if __has_warning("-Wzero-as-null-pointer-constant")
|
||||
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||||
#endif
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 8
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wclass-memaccess"
|
||||
@ -234,11 +236,11 @@ namespace ImGui
|
||||
// Windows
|
||||
// - Begin() = push window to the stack and start appending to it. End() = pop window from the stack.
|
||||
// - You may append multiple times to the same window during the same frame.
|
||||
// - Passing 'bool* p_open != NULL' shows a window-closing widget in the upper-right corner of the window,
|
||||
// - Passing 'bool* p_open != NULL' shows a window-closing widget in the upper-right corner of the window,
|
||||
// which clicking will set the boolean to false when clicked.
|
||||
// - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting
|
||||
// anything to the window. Always call a matching End() for each Begin() call, regardless of its return value!
|
||||
// [this is due to legacy reason and is inconsistent with most other functions such as BeginMenu/EndMenu, BeginPopup/EndPopup, etc.
|
||||
// [this is due to legacy reason and is inconsistent with most other functions such as BeginMenu/EndMenu, BeginPopup/EndPopup, etc.
|
||||
// where the EndXXX call should only be called if the corresponding BeginXXX function returned true.]
|
||||
// - Note that the bottom of window stack always contains a window called "Debug".
|
||||
IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0);
|
||||
@ -331,7 +333,7 @@ namespace ImGui
|
||||
IMGUI_API void PopButtonRepeat();
|
||||
|
||||
// Cursor / Layout
|
||||
// - By "cursor" we mean the current output position.
|
||||
// - By "cursor" we mean the current output position.
|
||||
// - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down.
|
||||
IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator.
|
||||
IMGUI_API void SameLine(float local_pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally. X position given in window coordinates.
|
||||
@ -347,7 +349,7 @@ namespace ImGui
|
||||
IMGUI_API float GetCursorPosY(); // other functions such as GetCursorScreenPos or everything in ImDrawList::
|
||||
IMGUI_API void SetCursorPos(const ImVec2& local_pos); // are using the main, absolute coordinate system.
|
||||
IMGUI_API void SetCursorPosX(float local_x); // GetWindowPos() + GetCursorPos() == GetCursorScreenPos() etc.)
|
||||
IMGUI_API void SetCursorPosY(float local_y); //
|
||||
IMGUI_API void SetCursorPosY(float local_y); //
|
||||
IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position in window coordinates
|
||||
IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates (0..io.DisplaySize) or natural OS coordinates when using multiple viewport. Useful to work with ImDrawList API.
|
||||
IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates (0..io.DisplaySize) or natural OS coordinates when using multiple viewport.
|
||||
@ -495,7 +497,7 @@ namespace ImGui
|
||||
IMGUI_API bool CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags = 0); // when 'p_open' isn't NULL, display an additional small close button on upper right of the header
|
||||
|
||||
// Widgets: Selectables
|
||||
// - A selectable highlights when hovered, and can display another color when selected.
|
||||
// - A selectable highlights when hovered, and can display another color when selected.
|
||||
// - Neighbors selectable extend their highlight bounds in order to leave no gap between them.
|
||||
IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height
|
||||
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
|
||||
@ -514,7 +516,7 @@ namespace ImGui
|
||||
IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float));
|
||||
IMGUI_API void PlotHistogram(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0));
|
||||
|
||||
// Widgets: Value() Helpers.
|
||||
// Widgets: Value() Helpers.
|
||||
// - Those are merely shortcut to calling Text() with a format string. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace)
|
||||
IMGUI_API void Value(const char* prefix, bool b);
|
||||
IMGUI_API void Value(const char* prefix, int v);
|
||||
@ -594,7 +596,7 @@ namespace ImGui
|
||||
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.
|
||||
IMGUI_API void EndDragDropTarget(); // only call EndDragDropTarget() if BeginDragDropTarget() returns true!
|
||||
IMGUI_API const ImGuiPayload* GetDragDropPayload(); // peek directly into the current payload from anywhere. may return NULL. use ImGuiPayload::IsDataType() to test for the payload type.
|
||||
|
||||
|
||||
// Clipping
|
||||
IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect);
|
||||
IMGUI_API void PopClipRect();
|
||||
@ -665,8 +667,8 @@ namespace ImGui
|
||||
IMGUI_API void ResetMouseDragDelta(int button = 0); //
|
||||
IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired cursor type, reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
|
||||
IMGUI_API void SetMouseCursor(ImGuiMouseCursor type); // set desired cursor type
|
||||
IMGUI_API void CaptureKeyboardFromApp(bool want_capture_keyboard_value = true); // attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call.
|
||||
IMGUI_API void CaptureMouseFromApp(bool want_capture_mouse_value = true); // attention: misleading name! manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application to handle). This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse_value;" after the next NewFrame() call.
|
||||
IMGUI_API void CaptureKeyboardFromApp(bool want_capture_keyboard_value = true); // attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call.
|
||||
IMGUI_API void CaptureMouseFromApp(bool want_capture_mouse_value = true); // attention: misleading name! manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application to handle). This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse_value;" after the next NewFrame() call.
|
||||
|
||||
// Clipboard Utilities (also see the LogToClipboard() function to capture or output text data to the clipboard)
|
||||
IMGUI_API const char* GetClipboardText();
|
||||
@ -835,7 +837,7 @@ enum ImGuiTabBarFlags_
|
||||
ImGuiTabBarFlags_FittingPolicyScroll = 1 << 7, // Add scroll buttons when tabs don't fit
|
||||
ImGuiTabBarFlags_FittingPolicyMask_ = ImGuiTabBarFlags_FittingPolicyResizeDown | ImGuiTabBarFlags_FittingPolicyScroll,
|
||||
ImGuiTabBarFlags_FittingPolicyDefault_ = ImGuiTabBarFlags_FittingPolicyResizeDown
|
||||
};
|
||||
};
|
||||
|
||||
// Flags for ImGui::BeginTabItem()
|
||||
enum ImGuiTabItemFlags_
|
||||
@ -1193,7 +1195,7 @@ enum ImGuiCond_
|
||||
// Lightweight std::vector<>-like class to avoid dragging dependencies (also, some implementations of STL with debug enabled are absurdly slow, we bypass it so our code runs fast in debug).
|
||||
// You generally do NOT need to care or use this ever. But we need to make it available in imgui.h because some of our data structures are relying on it.
|
||||
// Important: clear() frees memory, resize(0) keep the allocated buffer. We use resize(0) a lot to intentionally recycle allocated buffers across frames and amortize our costs.
|
||||
// Important: our implementation does NOT call C++ constructors/destructors, we treat everything as raw data! This is intentional but be extra mindful of that,
|
||||
// Important: our implementation does NOT call C++ constructors/destructors, we treat everything as raw data! This is intentional but be extra mindful of that,
|
||||
// do NOT use this class as a std::vector replacement in your own code! Many of the structures used by dear imgui can be safely initialized by a zero-memset.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@ -1253,7 +1255,7 @@ struct ImVector
|
||||
//-----------------------------------------------------------------------------
|
||||
// ImGuiStyle
|
||||
// You may modify the ImGui::GetStyle() main instance during initialization and before NewFrame().
|
||||
// During the frame, use ImGui::PushStyleVar(ImGuiStyleVar_XXXX)/PopStyleVar() to alter the main style values,
|
||||
// During the frame, use ImGui::PushStyleVar(ImGuiStyleVar_XXXX)/PopStyleVar() to alter the main style values,
|
||||
// and ImGui::PushStyleColor(ImGuiCol_XXX)/PopStyleColor() for colors.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@ -1282,7 +1284,7 @@ struct ImGuiStyle
|
||||
float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar.
|
||||
float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
||||
float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
||||
float TabBorderSize; // Thickness of border around tabs.
|
||||
float TabBorderSize; // Thickness of border around tabs.
|
||||
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f,0.5f) for horizontally+vertically centered.
|
||||
ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
|
||||
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly!
|
||||
@ -1298,7 +1300,7 @@ struct ImGuiStyle
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ImGuiIO
|
||||
// Communicate most settings and inputs/outputs to Dear ImGui using this structure.
|
||||
// Communicate most settings and inputs/outputs to Dear ImGui using this structure.
|
||||
// Access via ImGui::GetIO(). Read 'Programmer guide' section in .cpp file for general usage.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@ -1386,7 +1388,7 @@ struct ImGuiIO
|
||||
float NavInputs[ImGuiNavInput_COUNT]; // Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
|
||||
|
||||
// Functions
|
||||
IMGUI_API void AddInputCharacter(ImWchar c); // Queue new character input
|
||||
IMGUI_API void AddInputCharacter(ImWchar c); // Queue new character input
|
||||
IMGUI_API void AddInputCharactersUTF8(const char* str); // Queue new characters input from an UTF-8 string
|
||||
IMGUI_API void ClearInputCharacters(); // Clear the text input buffer manually
|
||||
|
||||
@ -1444,7 +1446,7 @@ struct ImGuiIO
|
||||
// - ImGuiInputTextFlags_CallbackHistory: Callback on pressing Up/Down arrows
|
||||
// - ImGuiInputTextFlags_CallbackAlways: Callback on each iteration
|
||||
// - ImGuiInputTextFlags_CallbackCharFilter: Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard.
|
||||
// - ImGuiInputTextFlags_CallbackResize: Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow.
|
||||
// - ImGuiInputTextFlags_CallbackResize: Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow.
|
||||
struct ImGuiInputTextCallbackData
|
||||
{
|
||||
ImGuiInputTextFlags EventFlag; // One ImGuiInputTextFlags_Callback* // Read-only
|
||||
@ -1760,7 +1762,7 @@ struct ImColor
|
||||
|
||||
// Draw callbacks for advanced uses.
|
||||
// NB: You most likely do NOT need to use draw callbacks just to create your own widget or customized UI rendering,
|
||||
// you can poke into the draw list for that! Draw callback may be useful for example to: A) Change your GPU render state,
|
||||
// you can poke into the draw list for that! Draw callback may be useful for example to: A) Change your GPU render state,
|
||||
// B) render a complex 3D scene inside a UI element without an intermediate texture/render target, etc.
|
||||
// The expected behavior from your rendering function is 'if (cmd.UserCallback != NULL) { cmd.UserCallback(parent_list, cmd); } else { RenderTriangles() }'
|
||||
typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd);
|
||||
@ -2010,13 +2012,13 @@ enum ImFontAtlasFlags_
|
||||
// - Optionally, call any of the AddFont*** functions. If you don't call any, the default font embedded in the code will be loaded for you.
|
||||
// - Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data.
|
||||
// - Upload the pixels data into a texture within your graphics system (see imgui_impl_xxxx.cpp examples)
|
||||
// - Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture in a format natural to your graphics API.
|
||||
// - Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture in a format natural to your graphics API.
|
||||
// This value will be passed back to you during rendering to identify the texture. Read FAQ entry about ImTextureID for more details.
|
||||
// Common pitfalls:
|
||||
// - If you pass a 'glyph_ranges' array to AddFont*** functions, you need to make sure that your array persist up until the
|
||||
// - If you pass a 'glyph_ranges' array to AddFont*** functions, you need to make sure that your array persist up until the
|
||||
// atlas is build (when calling GetTexData*** or Build()). We only copy the pointer, not the data.
|
||||
// - Important: By default, AddFontFromMemoryTTF() takes ownership of the data. Even though we are not writing to it, we will free the pointer on destruction.
|
||||
// You can set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed,
|
||||
// You can set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed,
|
||||
// - Even though many functions are suffixed with "TTF", OTF data is supported just as well.
|
||||
// - This is an old API and it is currently awkward for those and and various other reasons! We will address them in the future!
|
||||
struct ImFontAtlas
|
||||
@ -2037,7 +2039,7 @@ struct ImFontAtlas
|
||||
// Build atlas, retrieve pixel data.
|
||||
// User is in charge of copying the pixels into graphics memory (e.g. create a texture with your engine). Then store your texture handle with SetTexID().
|
||||
// The pitch is always = Width * BytesPerPixels (1 or 4)
|
||||
// Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into
|
||||
// Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into
|
||||
// the texture (e.g. when using the AddCustomRect*** api), then the RGB pixels emitted will always be white (~75% of memory/bandwidth waste.
|
||||
IMGUI_API bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions.
|
||||
IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
|
||||
|
Reference in New Issue
Block a user