mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-25 21:17:01 +00:00
Merge branch 'master' into navigation
This commit is contained in:
commit
3833f1f7a2
49
README.md
49
README.md
@ -55,34 +55,33 @@ _NB: those third-party bindings may be more or less maintained, more or less clo
|
||||
_Integrating Dear ImGui within your custom engine is a matter of wiring mouse/keyboard inputs and providing a render function that can bind a texture and render simple textured triangles. The examples/ folder is populated with applications doing just that. If you are an experienced programmer it should take you less than an hour to integrate Dear ImGui in your custom engine, but make sure to spend time reading the FAQ, the comments and other documentation!_
|
||||
|
||||
Languages:
|
||||
- C - cimgui: thin c-api wrapper for ImGui https://github.com/Extrawurst/cimgui
|
||||
- C#/.Net - ImGui.NET: An ImGui wrapper for .NET Core https://github.com/mellinoe/ImGui.NET
|
||||
- D - DerelictImgui: Dynamic bindings for the D programming language: https://github.com/Extrawurst/DerelictImgui
|
||||
- Go - go-imgui https://github.com/Armored-Dragon/go-imgui
|
||||
- Lua - https://github.com/patrickriordan/imgui_lua_bindings
|
||||
- Pascal - imgui-pas https://github.com/dpethes/imgui-pas
|
||||
- Python - CyImGui: Python bindings for dear imgui using Cython: https://github.com/chromy/cyimgui
|
||||
- Python - pyimgui: Another Python bindings for dear imgui: https://github.com/swistakm/pyimgui
|
||||
- Rust - imgui-rs: Rust bindings for dear imgui https://github.com/Gekkio/imgui-rs
|
||||
- C (cimgui): thin c-api wrapper for ImGui https://github.com/Extrawurst/cimgui
|
||||
- C#/.Net (ImGui.NET): An ImGui wrapper for .NET Core https://github.com/mellinoe/ImGui.NET
|
||||
- D (DerelictImgui): Dynamic bindings for the D programming language: https://github.com/Extrawurst/DerelictImgui
|
||||
- Go (go-imgui): https://github.com/Armored-Dragon/go-imgui
|
||||
- Lua: https://github.com/patrickriordan/imgui_lua_bindings
|
||||
- Pascal (imgui-pas) https://github.com/dpethes/imgui-pas
|
||||
- Python (CyImGui): Python bindings for dear imgui using Cython: https://github.com/chromy/cyimgui
|
||||
- Python (pyimgui): Another Python bindings for dear imgui: https://github.com/swistakm/pyimgui
|
||||
- Rust (imgui-rs): Rust bindings for dear imgui https://github.com/Gekkio/imgui-rs
|
||||
|
||||
Frameworks:
|
||||
- Main ImGui repository include examples for DirectX9, DirectX10, DirectX11, OpenGL2/3, Vulkan, Allegro 5, SDL+GL2/3, iOS and Marmalade: https://github.com/ocornut/imgui/tree/master/examples
|
||||
- Unmerged PR: DirectX12 example (with issues) https://github.com/ocornut/imgui/pull/301
|
||||
- Unmerged PR: SDL2 + OpenGLES + Emscripten example https://github.com/ocornut/imgui/pull/336
|
||||
- Unmerged PR: FreeGlut + OpenGL2 example https://github.com/ocornut/imgui/pull/801
|
||||
- Unmerged PR: Native Win32 and OSX example https://github.com/ocornut/imgui/pull/281
|
||||
- Unmerged PR: Android Example https://github.com/ocornut/imgui/pull/421
|
||||
- Cinder backend for dear imgui https://github.com/simongeilfus/Cinder-ImGui
|
||||
- FlexGUI: Flexium/SFML backend for dear imgui https://github.com/DXsmiley/FlexGUI
|
||||
- IrrIMGUI: Irrlicht backend for dear imgui https://github.com/ZahlGraf/IrrIMGUI
|
||||
- UnrealEngine_ImGui: Unreal Engine 4 backend for dear imgui https://github.com/sronsse/UnrealEngine_ImGui
|
||||
- LÖVE backend for dear imgui https://github.com/slages/love-imgui
|
||||
- Ogre backend for dear imgui https://bitbucket.org/LMCrashy/ogreimgui/src
|
||||
- ofxImGui: openFrameworks backend for dear imgui https://github.com/jvcleave/ofxImGui
|
||||
- SFML backend for dear imgui https://github.com/EliasD/imgui-sfml
|
||||
- SFML backend for dear imgui https://github.com/Mischa-Alff/imgui-backends
|
||||
- cocos2d-x with imgui https://github.com/c0i/imguix https://github.com/ocornut/imgui/issues/551
|
||||
- NanoRT: software raytraced version https://github.com/syoyo/imgui/tree/nanort/examples/raytrace_example
|
||||
- Unmerged PR: DirectX12: https://github.com/ocornut/imgui/pull/301
|
||||
- Unmerged PR: SDL2 + OpenGLES + Emscripten: https://github.com/ocornut/imgui/pull/336
|
||||
- Unmerged PR: FreeGlut + OpenGL2: https://github.com/ocornut/imgui/pull/801
|
||||
- Unmerged PR: Native Win32 and OSX: https://github.com/ocornut/imgui/pull/281
|
||||
- Unmerged PR: Android: https://github.com/ocornut/imgui/pull/421
|
||||
- Cinder: https://github.com/simongeilfus/Cinder-ImGui
|
||||
- cocos2d-x: https://github.com/c0i/imguix https://github.com/ocornut/imgui/issues/551
|
||||
- Flexium/SFML (FlexGUI): https://github.com/DXsmiley/FlexGUI
|
||||
- Irrlicht (IrrIMGUI): https://github.com/ZahlGraf/IrrIMGUI
|
||||
- Ogre: https://bitbucket.org/LMCrashy/ogreimgui/src
|
||||
- openFrameworks (ofxImGui): https://github.com/jvcleave/ofxImGui
|
||||
- LÖVE: https://github.com/slages/love-imgui
|
||||
- NanoRT (software raytraced) https://github.com/syoyo/imgui/tree/nanort/examples/raytrace_example
|
||||
- Unreal Engine 4: https://github.com/segross/UnrealImGui or https://github.com/sronsse/UnrealEngine_ImGui
|
||||
- SFML: https://github.com/EliasD/imgui-sfml or https://github.com/Mischa-Alff/imgui-backends
|
||||
|
||||
For other bindings: see [this page](https://github.com/ocornut/imgui/wiki/Links/).
|
||||
Please contact me with the Issues tracker or Twitter to fix/update this list.
|
||||
|
15
imgui.cpp
15
imgui.cpp
@ -240,6 +240,7 @@
|
||||
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.
|
||||
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2017/10/11 (1.52) - renamed AlignFirstTextHeightToWidgets() to AlignTextToFramePadding(). Kept inline redirection function (will obsolete).
|
||||
- 2017/09/25 (1.52) - removed SetNextWindowPosCenter() because SetNextWindowPos() now has the optional pivot information to do the same and more. Kept redirection function (will obsolete).
|
||||
- 2017/08/25 (1.52) - io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we now accept negative mouse coordinates. In your binding if you need to support unavailable mouse, make sure to replace "io.MousePos = ImVec2(-1,-1)" with "io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX)".
|
||||
- 2017/08/22 (1.51) - renamed IsItemHoveredRect() to IsItemRectHovered(). Kept inline redirection function (will obsolete).
|
||||
@ -6624,7 +6625,7 @@ void ImGui::TextUnformatted(const char* text, const char* text_end)
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::AlignFirstTextHeightToWidgets()
|
||||
void ImGui::AlignTextToFramePadding()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
@ -7122,14 +7123,14 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0;
|
||||
const ImVec2 padding = display_frame ? style.FramePadding : ImVec2(style.FramePadding.x, 0.0f);
|
||||
const ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) ? style.FramePadding : ImVec2(style.FramePadding.x, 0.0f);
|
||||
|
||||
if (!label_end)
|
||||
label_end = FindRenderedTextEnd(label);
|
||||
const ImVec2 label_size = CalcTextSize(label, label_end, false);
|
||||
|
||||
// We vertically grow up to current line height up the typical widget height.
|
||||
const float text_base_offset_y = ImMax(0.0f, window->DC.CurrentLineTextBaseOffset - padding.y); // Latch before ItemSize changes it
|
||||
const float text_base_offset_y = ImMax(padding.y, window->DC.CurrentLineTextBaseOffset); // Latch before ItemSize changes it
|
||||
const float frame_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + style.FramePadding.y*2), label_size.y + padding.y*2);
|
||||
ImRect bb = ImRect(window->DC.CursorPos, ImVec2(window->Pos.x + GetContentRegionMax().x, window->DC.CursorPos.y + frame_height));
|
||||
if (display_frame)
|
||||
@ -7144,7 +7145,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
ItemSize(ImVec2(text_width, frame_height), text_base_offset_y);
|
||||
|
||||
// For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing
|
||||
// (Ideally we'd want to add a flag for the user to specify we want want the hit test to be done up to the right side of the content or not)
|
||||
// (Ideally we'd want to add a flag for the user to specify if we want the hit test to be done up to the right side of the content or not)
|
||||
const ImRect interact_bb = display_frame ? bb : ImRect(bb.Min.x, bb.Min.y, bb.Min.x + text_width + style.ItemSpacing.x*2, bb.Max.y);
|
||||
bool is_open = TreeNodeBehaviorIsOpen(id, flags);
|
||||
if (!ItemAdd(interact_bb, id))
|
||||
@ -7198,12 +7199,12 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
|
||||
// Render
|
||||
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
|
||||
const ImVec2 text_pos = bb.Min + ImVec2(text_offset_x, padding.y + text_base_offset_y);
|
||||
const ImVec2 text_pos = bb.Min + ImVec2(text_offset_x, text_base_offset_y);
|
||||
if (display_frame)
|
||||
{
|
||||
// Framed type
|
||||
RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding);
|
||||
RenderCollapseTriangle(bb.Min + padding + ImVec2(0.0f, text_base_offset_y), is_open, 1.0f);
|
||||
RenderCollapseTriangle(bb.Min + ImVec2(padding.x, text_base_offset_y), is_open, 1.0f);
|
||||
if (g.LogEnabled)
|
||||
{
|
||||
// NB: '##' is normally used to hide text (as a library-wide feature), so we need to specify the text range to make sure the ## aren't stripped out here.
|
||||
@ -10117,7 +10118,7 @@ bool ImGui::BeginMenuBar()
|
||||
window->DC.NavLayerCurrent++;
|
||||
window->DC.NavLayerCurrentMask <<= 1;
|
||||
window->DC.MenuBarAppending = true;
|
||||
AlignFirstTextHeightToWidgets();
|
||||
AlignTextToFramePadding();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
8
imgui.h
8
imgui.h
@ -227,7 +227,7 @@ namespace ImGui
|
||||
IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position
|
||||
IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API)
|
||||
IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize]
|
||||
IMGUI_API void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets
|
||||
IMGUI_API void AlignTextToFramePadding(); // vertically align/lower upcoming text to FramePadding.y so that it will aligns to upcoming widgets (call if you have text on a line before regular widgets)
|
||||
IMGUI_API float GetTextLineHeight(); // height of font == GetWindowFontSize()
|
||||
IMGUI_API float GetTextLineHeightWithSpacing(); // distance (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y
|
||||
IMGUI_API float GetItemsLineHeightWithSpacing(); // distance (in pixels) between 2 consecutive lines of standard height widgets == GetWindowFontSize() + GetStyle().FramePadding.y*2 + GetStyle().ItemSpacing.y
|
||||
@ -498,6 +498,7 @@ namespace ImGui
|
||||
|
||||
// Obsolete functions (Will be removed! Also see 'API BREAKING CHANGES' section in imgui.cpp)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
static inline void AlignFirstTextHeightToWidgets() { AlignTextToFramePadding(); } // OBSOLETE 1.52+
|
||||
void SetNextWindowPosCenter(ImGuiCond cond = 0); // OBSOLETE 1.52+
|
||||
static inline bool IsItemHoveredRect() { return IsItemRectHovered(); } // OBSOLETE 1.51+
|
||||
static inline bool IsPosHoveringAnyWindow(const ImVec2&) { IM_ASSERT(0); return false; } // OBSOLETE 1.51+. This was partly broken. You probably wanted to use ImGui::GetIO().WantCaptureMouse instead.
|
||||
@ -581,8 +582,9 @@ enum ImGuiTreeNodeFlags_
|
||||
ImGuiTreeNodeFlags_OpenOnArrow = 1 << 7, // Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open.
|
||||
ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes).
|
||||
ImGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow
|
||||
//ImGuITreeNodeFlags_SpanAllAvailWidth = 1 << 10, // FIXME: TODO: Extend hit box horizontally even if not framed
|
||||
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 11, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
|
||||
ImGuiTreeNodeFlags_FramePadding = 1 << 10, // Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding().
|
||||
//ImGuITreeNodeFlags_SpanAllAvailWidth = 1 << 11, // FIXME: TODO: Extend hit box horizontally even if not framed
|
||||
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 12, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
|
||||
ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoAutoOpenOnLog
|
||||
};
|
||||
|
||||
|
@ -432,7 +432,8 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
else
|
||||
{
|
||||
// Leaf: The only reason we have a TreeNode at all is to allow selection of the leaf. Otherwise we can use BulletText() or TreeAdvanceToLabelPos()+Text().
|
||||
ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags | ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen, "Selectable Leaf %d", i);
|
||||
node_flags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen; // ImGuiTreeNodeFlags_Bullet
|
||||
ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Leaf %d", i);
|
||||
if (ImGui::IsItemClicked())
|
||||
node_clicked = i;
|
||||
}
|
||||
@ -1056,7 +1057,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
|
||||
|
||||
// Button
|
||||
ImGui::AlignFirstTextHeightToWidgets();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("Normal buttons"); ImGui::SameLine();
|
||||
ImGui::Button("Banana"); ImGui::SameLine();
|
||||
ImGui::Button("Apple"); ImGui::SameLine();
|
||||
@ -1182,7 +1183,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::Text("TEST"); ImGui::SameLine();
|
||||
ImGui::SmallButton("TEST##2");
|
||||
|
||||
ImGui::AlignFirstTextHeightToWidgets(); // If your line starts with text, call this to align it to upcoming widgets.
|
||||
ImGui::AlignTextToFramePadding(); // If your line starts with text, call this to align it to upcoming widgets.
|
||||
ImGui::Text("Text aligned to Widget"); ImGui::SameLine();
|
||||
ImGui::Button("Widget##1"); ImGui::SameLine();
|
||||
ImGui::Text("Widget"); ImGui::SameLine();
|
||||
@ -1195,7 +1196,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
if (ImGui::TreeNode("Node##1")) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
|
||||
|
||||
ImGui::AlignFirstTextHeightToWidgets(); // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. Otherwise you can use SmallButton (smaller fit).
|
||||
ImGui::AlignTextToFramePadding(); // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. Otherwise you can use SmallButton (smaller fit).
|
||||
bool node_open = ImGui::TreeNode("Node##2"); // Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add child content.
|
||||
ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2");
|
||||
if (node_open) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
|
||||
@ -1205,7 +1206,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
ImGui::BulletText("Bullet text");
|
||||
|
||||
ImGui::AlignFirstTextHeightToWidgets();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::BulletText("Node");
|
||||
ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4");
|
||||
|
||||
@ -2752,10 +2753,10 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
|
||||
static void ShowDummyObject(const char* prefix, int uid)
|
||||
{
|
||||
ImGui::PushID(uid); // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID.
|
||||
ImGui::AlignFirstTextHeightToWidgets(); // Text and Tree nodes are less high than regular widgets, here we add vertical spacing to make the tree lines equal high.
|
||||
ImGui::AlignTextToFramePadding(); // Text and Tree nodes are less high than regular widgets, here we add vertical spacing to make the tree lines equal high.
|
||||
bool node_open = ImGui::TreeNode("Object", "%s_%u", prefix, uid);
|
||||
ImGui::NextColumn();
|
||||
ImGui::AlignFirstTextHeightToWidgets();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("my sailor is rich");
|
||||
ImGui::NextColumn();
|
||||
if (node_open)
|
||||
@ -2770,7 +2771,7 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::AlignFirstTextHeightToWidgets();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
// Here we use a Selectable (instead of Text) to highlight on hover
|
||||
//ImGui::Text("Field_%d", i);
|
||||
char label[32];
|
||||
|
Loading…
Reference in New Issue
Block a user