-
Notifications
You must be signed in to change notification settings - Fork 7
feat: cmake + bring up to date with working commits #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: hazel
Are you sure you want to change the base?
Changes from all commits
7267fc1
a8dcee0
bbdb64e
deac40a
10fc3f4
405786f
c69c53a
8a73dbe
d82ead8
0531a43
19ced66
869cddf
6fb69f8
86e47a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [submodule "implot"] | ||
| path = implot | ||
| url = https://github.com/StudioCherno/implot |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| add_library(ImGui STATIC | ||
| imconfig.h | ||
| imgui.h | ||
| imgui.cpp | ||
| imgui_draw.cpp | ||
| imgui_internal.h | ||
| imgui_tables.cpp | ||
| imgui_widgets.cpp | ||
| imgui_demo.cpp | ||
| imstb_rectpack.h | ||
| imstb_textedit.h | ||
| imstb_truetype.h | ||
|
|
||
| # ImPlot lives in this fork (added on the SimpleUX/Wayland lineage); compiled | ||
| # into ImGui to match the premake source split. implot_demo.cpp is excluded. | ||
| implot/implot.cpp | ||
| implot/implot_items.cpp | ||
| ) | ||
|
|
||
| # Bare <imgui.h> / "imgui.h" and implot's relative "implot.h". The <imgui/...> | ||
| # style used across the engine is a vendor-layout convention and is exposed by | ||
| # Hazel/vendor/CMakeLists.txt, not assumed by this fork. | ||
| target_include_directories(ImGui SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) | ||
| target_compile_features(ImGui PUBLIC cxx_std_20) | ||
|
|
||
| target_compile_definitions(ImGui PUBLIC IMGUI_USE_WCHAR32) | ||
| target_compile_definitions(ImGui PUBLIC | ||
| $<$<CONFIG:Dist>:NDEBUG IMGUI_DISABLE_DEMO_WINDOWS IMGUI_DISABLE_DEBUG_TOOLS> | ||
| ) | ||
|
|
||
| set_target_properties(ImGui PROPERTIES POSITION_INDEPENDENT_CODE ON FOLDER "Dependencies") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1637,6 +1637,7 @@ ImGuiIO::ImGuiIO() | |
| ConfigViewportsNoTaskBarIcon = false; | ||
| ConfigViewportsNoDecoration = true; | ||
| ConfigViewportsNoDefaultParent = true; | ||
| ConfigViewportsNoFloatingWindows = false; | ||
| ConfigViewportsPlatformFocusSetsImGuiFocus = true; | ||
|
|
||
| // Miscellaneous options | ||
|
|
@@ -5418,10 +5419,28 @@ void ImGui::UpdateMouseMovingWindowNewFrame() | |
| ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset; | ||
| if (moving_window->Pos.x != pos.x || moving_window->Pos.y != pos.y) | ||
| { | ||
| SetWindowPos(moving_window, pos, ImGuiCond_Always); | ||
| // Use the actual window location returned by the window system if possible, | ||
| // since windows can snap to borders and things like that which result in a final | ||
| // window location that is not exactly the same as what was requested. | ||
| ImVec2 actual = pos; | ||
| if (moving_window->Viewport && moving_window->ViewportOwned | ||
| && g.PlatformIO.Platform_SetWindowPos && g.PlatformIO.Platform_GetWindowPos) | ||
| { | ||
| g.PlatformIO.Platform_SetWindowPos(moving_window->Viewport, pos); | ||
| actual = g.PlatformIO.Platform_GetWindowPos(moving_window->Viewport); | ||
| } | ||
| SetWindowPos(moving_window, actual, ImGuiCond_Always); | ||
| if (moving_window->Viewport && moving_window->ViewportOwned) // Synchronize viewport immediately because some overlays may relies on clipping rectangle before we Begin() into the window. | ||
| { | ||
| moving_window->Viewport->Pos = pos; | ||
| // Use moving_window->Pos (which SetWindowPos truncated via | ||
| // ImTrunc) rather than raw `actual`. If viewport->Pos kept | ||
| // the untruncated value, a later sync site would overwrite it | ||
| // with window->Pos (truncated), and UpdatePlatformWindows | ||
| // would see the mismatch against LastPlatformPos and push the | ||
| // truncated position to the OS — which maps to a different | ||
| // OS-pixel than what we just set, causing oscillation. | ||
| moving_window->Viewport->Pos = moving_window->Pos; | ||
| moving_window->Viewport->LastPlatformPos = moving_window->Pos; | ||
|
Comment on lines
+5422
to
+5443
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🌐 Web query:
💡 Result: The observation that glfwGetWindowPos returns a stale value immediately after calling glfwSetWindowPos is a known consequence of the asynchronous nature of window management on X11 and the structural limitations on Wayland [1][2][3]. On X11, window positioning requests are asynchronous [2][4]. When you call glfwSetWindowPos, GLFW sends a request to the X Window Manager (WM) [2][4]. The application does not immediately move; instead, it must wait for the WM to process the request and send a ConfigureNotify event back to the application to confirm the new position [2][5]. Because glfwGetWindowPos reads the state currently tracked by the GLFW window object, it will report the "old" position until that event is received and processed, which typically happens during the next event-polling cycle (e.g., glfwPollEvents or glfwWaitEvents) [2][3]. Additionally, window managers may clamp, override, or ignore these requests (e.g., if a window is snapped to an edge or if decorations interfere), causing the "actual" final position to differ from what you requested [1][5][4]. On Wayland, this behavior is fundamentally different because the Wayland protocol restricts an application's ability to control its own position [6]. Applications generally cannot set their global screen position, and attempting to do so is often unsupported [7][6]. Consequently, glfwGetWindowPos and glfwSetWindowPos may be effectively non-functional or report static/default values depending on the specific compositor implementation [7][6]. To mitigate these issues in your application: 1. Allow the event loop to process: Ensure you call glfwPollEvents or glfwWaitEvents after calling glfwSetWindowPos to allow the platform to update the window state [3]. 2. Account for WM interference: Recognize that the window manager is the final authority on window placement [1][4]. If you are implementing features like draggable windows, consider tracking position changes relative to cursor input rather than relying on querying the window position after a set command [3]. 3. Use window callbacks: Instead of querying the position immediately, rely on the GLFW window position callback (glfwSetWindowPosCallback) to receive the authoritative, updated position once the window manager has finished the move [1][2]. Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
# Map the relevant symbols and find their usages/backends.
printf '\n== imgui.cpp outline ==\n'
ast-grep outline imgui.cpp --view expanded | sed -n '1,220p'
printf '\n== Platform_SetWindowPos / Platform_GetWindowPos usages ==\n'
rg -n "Platform_SetWindowPos|Platform_GetWindowPos|LastPlatformPos|SetWindowPos\\(" -S . --glob '!**/build/**' --glob '!**/dist/**'
printf '\n== Candidate backend files mentioning glfwGetWindowPos / glfwSetWindowPos ==\n'
rg -n "glfwGetWindowPos|glfwSetWindowPos|Platform_GetWindowPos|Platform_SetWindowPos" -S . --glob '!**/build/**' --glob '!**/dist/**'Repository: StudioCherno/imgui Length of output: 29464 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Read the relevant region of imgui.cpp with line numbers.
sed -n '5400,5465p' imgui.cpp | cat -nRepository: StudioCherno/imgui Length of output: 4455 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== imgui.cpp outline ==\n'
ast-grep outline imgui.cpp --view expanded | sed -n '1,220p'
printf '\n== Platform_SetWindowPos / Platform_GetWindowPos usages ==\n'
rg -n "Platform_SetWindowPos|Platform_GetWindowPos|LastPlatformPos|SetWindowPos\\(" -S . --glob '!**/build/**' --glob '!**/dist/**'
printf '\n== Candidate backend files mentioning glfwGetWindowPos / glfwSetWindowPos ==\n'
rg -n "glfwGetWindowPos|glfwSetWindowPos|Platform_GetWindowPos|Platform_SetWindowPos" -S . --glob '!**/build/**' --glob '!**/dist/**'
printf '\n== imgui.cpp region ==\n'
sed -n '5400,5465p' imgui.cpp | cat -nRepository: StudioCherno/imgui Length of output: 33787 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect the GLFW backend implementation around the platform position handlers.
sed -n '1200,1555p' backends/imgui_impl_glfw.cpp | cat -nRepository: StudioCherno/imgui Length of output: 18770 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect the GLFW header docs for the semantics around window position callbacks.
sed -n '1970,2555p' examples/libs/glfw/include/GLFW/glfw3.h | cat -n | sed -n '1,180p'Repository: StudioCherno/imgui Length of output: 8240 Avoid the immediate 🤖 Prompt for AI Agents |
||
| moving_window->Viewport->UpdateWorkRect(); | ||
| } | ||
| } | ||
|
|
@@ -8052,7 +8071,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | |
| // Lock menu offset so size calculation can use it as menu-bar windows need a minimum size. | ||
| window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x); | ||
| window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y; | ||
| window->TitleBarHeight = (flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : g.FontSize + g.Style.FramePadding.y * 2.0f; | ||
| const float title_bar_padding = (window->DockIsActive) ? 8.0f : g.Style.FramePadding.y; | ||
| window->TitleBarHeight = (flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : g.FontSize + title_bar_padding * 2.0f; | ||
| window->MenuBarHeight = (flags & ImGuiWindowFlags_MenuBar) ? window->DC.MenuBarOffset.y + g.FontSize + g.Style.FramePadding.y * 2.0f : 0.0f; | ||
| window->FontRefSize = g.FontSize; // Lock this to discourage calling window->CalcFontSize() outside of current window. | ||
|
|
||
|
|
@@ -17837,6 +17857,18 @@ static void ImGui::WindowSelectViewport(ImGuiWindow* window) | |
| SetWindowViewport(window, main_viewport); | ||
| return; | ||
| } | ||
|
|
||
| // When ConfigViewportsNoFloatingWindows is set, only popups/tooltips/menus | ||
| // may create their own viewport. All other windows stay in the main viewport. | ||
| if (g.IO.ConfigViewportsNoFloatingWindows) | ||
| { | ||
| if ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_ChildMenu)) == 0) | ||
| { | ||
| SetWindowViewport(window, main_viewport); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| window->ViewportOwned = false; | ||
|
|
||
| // Appearing popups reset their viewport so they can inherit again | ||
|
|
@@ -20011,12 +20043,16 @@ static void ImGui::DockNodeWindowMenuUpdate(ImGuiDockNode* node, ImGuiTabBar* ta | |
| SetNextWindowPos(ImVec2(node->Pos.x, node->Pos.y + GetFrameHeight()), ImGuiCond_Always, ImVec2(0.0f, 0.0f)); | ||
| else | ||
| SetNextWindowPos(ImVec2(node->Pos.x + node->Size.x, node->Pos.y + GetFrameHeight()), ImGuiCond_Always, ImVec2(1.0f, 0.0f)); | ||
| ImVec4 popupBg = g.Style.Colors[ImGuiCol_PopupBg]; | ||
| popupBg.w = 1.0f; | ||
| PushStyleColor(ImGuiCol_PopupBg, popupBg); | ||
| if (BeginPopup("#WindowMenu")) | ||
| { | ||
| node->IsFocused = true; | ||
| g.DockNodeWindowMenuHandler(&g, node, tab_bar); | ||
| EndPopup(); | ||
| } | ||
| PopStyleColor(); | ||
| } | ||
|
|
||
| // User helper to append/amend into a dock node tab bar. Most commonly used to add e.g. a "+" button. | ||
|
|
@@ -20414,28 +20450,30 @@ static void ImGui::DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* o | |
| ImGuiContext& g = *GImGui; | ||
| ImGuiStyle& style = g.Style; | ||
|
|
||
| ImRect r = ImRect(node->Pos.x, node->Pos.y, node->Pos.x + node->Size.x, node->Pos.y + g.FontSize + g.Style.FramePadding.y * 2.0f); | ||
| const float tab_padding_y = 8.0f; | ||
| ImRect r = ImRect(node->Pos.x, node->Pos.y, node->Pos.x + node->Size.x, node->Pos.y + g.FontSize + tab_padding_y * 2.0f); | ||
| if (out_title_rect) { *out_title_rect = r; } | ||
|
|
||
| r.Min.x += style.WindowBorderSize; | ||
| r.Max.x -= style.WindowBorderSize; | ||
|
|
||
| float button_sz = g.FontSize; | ||
| float button_y = r.Min.y + (r.GetHeight() - button_sz) * 0.5f; | ||
| r.Min.x += style.FramePadding.x; | ||
| r.Max.x -= style.FramePadding.x; | ||
| ImVec2 window_menu_button_pos = ImVec2(r.Min.x, r.Min.y + style.FramePadding.y); | ||
| ImVec2 window_menu_button_pos = ImVec2(r.Min.x, button_y); | ||
| if (node->HasCloseButton) | ||
| { | ||
| if (out_close_button_pos) *out_close_button_pos = ImVec2(r.Max.x - button_sz, r.Min.y + style.FramePadding.y); | ||
| if (out_close_button_pos) *out_close_button_pos = ImVec2(r.Max.x - button_sz, button_y); | ||
| r.Max.x -= button_sz + style.ItemInnerSpacing.x; | ||
| } | ||
| if (node->HasWindowMenuButton && style.WindowMenuButtonPosition == ImGuiDir_Left) | ||
| { | ||
| r.Min.x += button_sz + style.ItemInnerSpacing.x; | ||
| r.Min.x += button_sz + style.FramePadding.x; | ||
| } | ||
| else if (node->HasWindowMenuButton && style.WindowMenuButtonPosition == ImGuiDir_Right) | ||
| { | ||
| window_menu_button_pos = ImVec2(r.Max.x - button_sz, r.Min.y + style.FramePadding.y); | ||
| window_menu_button_pos = ImVec2(r.Max.x - button_sz, button_y); | ||
| r.Max.x -= button_sz + style.ItemInnerSpacing.x; | ||
| } | ||
| if (out_tab_bar_rect) { *out_tab_bar_rect = r; } | ||
|
|
@@ -21955,7 +21993,11 @@ void ImGui::BeginDockableDragDropSource(ImGuiWindow* window) | |
| g.LastItemData.ID = window->MoveId; | ||
| window = window->RootWindowDockTree; | ||
| IM_ASSERT((window->Flags & ImGuiWindowFlags_NoDocking) == 0); | ||
| bool is_drag_docking = (g.IO.ConfigDockingWithShift) || ImRect(0, 0, window->SizeFull.x, GetFrameHeight()).Contains(g.ActiveIdClickOffset); // FIXME-DOCKING: Need to make this stateful and explicit | ||
| // LuckyEngine: mirrors the custom tab_padding_y in TabItemCalcSize - without this, | ||
| // clicks in the lower half of a tall tab fall outside GetFrameHeight() and tear-away | ||
| // drags never turn into a drag-drop source (no docking overlay until re-grab). | ||
| const float tab_drag_height = ImMax(GetFrameHeight(), g.FontSize + 8.0f * 2.0f); | ||
| bool is_drag_docking = (g.IO.ConfigDockingWithShift) || ImRect(0, 0, window->SizeFull.x, tab_drag_height).Contains(g.ActiveIdClickOffset); // FIXME-DOCKING: Need to make this stateful and explicit | ||
| ImGuiDragDropFlags drag_drop_flags = ImGuiDragDropFlags_SourceNoPreviewTooltip | ImGuiDragDropFlags_SourceNoHoldToOpenOthers | ImGuiDragDropFlags_PayloadAutoExpire | ImGuiDragDropFlags_PayloadNoCrossContext | ImGuiDragDropFlags_PayloadNoCrossProcess; | ||
| if (is_drag_docking && BeginDragDropSource(drag_drop_flags)) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: StudioCherno/imgui
Length of output: 227
🏁 Script executed:
Repository: StudioCherno/imgui
Length of output: 844
Quote the generator expression and use semicolons
target_compile_definitions()splits unquoted spaces before generator-expression evaluation, so this becomes broken arguments. Wrap it in quotes and keep the macros in a semicolon list:Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents