Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions source/editor/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "Widgets/Profiler.h"
#include "Widgets/RenderOptions.h"
#include "Widgets/ScriptEditor.h"
#include "Widgets/Shadows.h"
//===============================================

//= NAMESPACES =====
Expand Down Expand Up @@ -106,6 +107,7 @@ Editor::Editor(const vector<string>& args)
SP_SUBSCRIBE_TO_EVENT(spartan::EventType::Sdl, SP_EVENT_HANDLER_VARIANT_STATIC(process_event));

GeneralWindows::Initialize(this);
Modal::Initialize(this);
}

Editor::~Editor()
Expand Down Expand Up @@ -154,6 +156,13 @@ void Editor::Tick()

// various windows that don't belong to a certain widget
GeneralWindows::Tick();

// Modal popup system (draws on top of everything when shown)
Modal::Tick();

// Draw all pending shadows AFTER widgets queue them, but BEFORE ImGui::Render()
// This draws to the background draw list so shadows appear behind windows

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states "This draws to the background draw list so shadows appear behind windows", but the FlushPendingShadows implementation in Shadows.cpp line 44 actually uses the foreground draw list (ImGui::GetForegroundDrawList()). This comment is incorrect and should be updated to match the actual behavior.

Suggested change
// This draws to the background draw list so shadows appear behind windows
// This draws to the foreground draw list so shadows appear above windows

Copilot uses AI. Check for mistakes.
spartan::Shadow::FlushPendingShadows();
}
}

Expand Down
1 change: 1 addition & 0 deletions source/editor/Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//= INCLUDES ==============
#include <vector>
#include <memory>
#include "Modal.h"
#include "Widgets/Widget.h"
//=========================

Expand Down
1 change: 1 addition & 0 deletions source/editor/GeneralWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//= INCLUDES =====================
#include "pch.h"
#include "GeneralWindows.h"
#include "Widgets/Shadows.h"
#include "Windows/WorldSelector.h"
#include "Windows/Contributors.h"
#include "ImGui/Source/imgui.h"
Expand Down
48 changes: 48 additions & 0 deletions source/editor/ImGui/ImGui_Extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,54 @@ namespace ImGuiSp
ImColor(0, 0, 0, 0) // border
);
}

//= Rectangle =============================================================================

inline ImRect get_item_rect()
{
return {
ImGui::GetItemRectMin(),
ImGui::GetItemRectMax()
};
}

inline ImRect rectangle_expanded(const ImRect& rect, float x, float y)
{
ImRect result = rect;
result.Min.x -= x;
result.Min.y -= y;
result.Max.x += x;
result.Max.y += y;
return result;
}

inline ImRect rectangle_offset(const ImRect& rect, float x, float y)
{
ImRect result = rect;
result.Min.x += x;
result.Min.y += y;
result.Max.x += x;
result.Max.y += y;
return result;
}

inline ImRect rectangle_offset(const ImRect& rect, ImVec2 xy)
{
return rectangle_offset(rect, xy.x, xy.y);
}
Comment on lines +203 to +234

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new rectangle utility functions are declared as 'inline' while the existing pattern in this namespace uses 'static' for inline functions (see lines 77, 86, 96, 112, etc.). For consistency, these should be declared as 'static' instead of 'inline'.

Copilot uses AI. Check for mistakes.

static bool hyper_link(const char* label, ImU32 lineColor = IM_COL32(186, 66, 30, 255), float lineThickness = GImGui->Style.FrameBorderSize)

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hyper_link function accesses GImGui directly (GImGui->Style.FrameBorderSize) without checking if GImGui is null. While this is unlikely to be an issue in normal operation, it would be more defensive to use ImGui::GetStyle().FrameBorderSize instead, which is the standard pattern in ImGui code.

Copilot uses AI. Check for mistakes.
{
ImGui::Text(label);
const ImRect rect = rectangle_expanded(get_item_rect(), lineThickness, lineThickness);
if (ImGui::IsItemHovered())
{
ImGui::GetWindowDrawList()->AddLine({rect.Min.x, rect.Max.y}, rect.Max, lineColor, lineThickness);
ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
return ImGui::IsMouseReleased(ImGuiMouseButton_Left);
}
return false;
}

struct DragDropPayload
{
Expand Down
Loading