hachem.wtf
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/ui.cpp48
1 files changed, 45 insertions, 3 deletions
diff --git a/src/ui/ui.cpp b/src/ui/ui.cpp
index 01c1382..6f832ca 100644
--- a/src/ui/ui.cpp
+++ b/src/ui/ui.cpp
@@ -51,6 +51,11 @@ namespace Hsdbg
const ImU32 BREAKPOINT_DISABLED_COLOR = IM_COL32(120, 90, 90, 255);
const ImU32 BREAKPOINT_HOVER_COLOR = IM_COL32(226, 84, 84, 90);
+ const ImU32 SOURCE_FOLDER_COLOR = IM_COL32(150, 178, 214, 255);
+ const ImU32 SOURCE_OPEN_FILE_COLOR = IM_COL32(126, 194, 126, 255);
+
+ const ImU32 SOURCE_TREE_LINE_COLOR = IM_COL32(110, 110, 122, 160);
+
auto breakpoint_at(Debugger& debugger, const Instruction& instruction) -> const Breakpoint*
{
for (const Breakpoint& candidate : debugger.breakpoints())
@@ -1073,6 +1078,8 @@ namespace Hsdbg
const SourceNode tree = build_source_tree(files);
const std::filesystem::path& open = m_source_view.path();
+ ImDrawList* const draw_list = ImGui::GetWindowDrawList();
+
const auto draw_node = [&](this const auto& self, const SourceNode& node) -> void
{
if (!source_node_matches(node, m_source_filter))
@@ -1082,7 +1089,15 @@ namespace Hsdbg
{
const bool selected = node.path == open;
- if (ImGui::Selectable(node.name.c_str(), selected))
+ if (selected)
+ ImGui::PushStyleColor(ImGuiCol_Text, SOURCE_OPEN_FILE_COLOR);
+
+ const bool clicked = ImGui::Selectable(node.name.c_str(), selected);
+
+ if (selected)
+ ImGui::PopStyleColor();
+
+ if (clicked)
{
open_source(node.path);
ImGui::SetWindowFocus(PANEL_SOURCE);
@@ -1095,16 +1110,43 @@ namespace Hsdbg
}
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_SpanAvailWidth |
- ImGuiTreeNodeFlags_OpenOnArrow;
+ ImGuiTreeNodeFlags_OpenOnArrow |
+ ImGuiTreeNodeFlags_OpenOnDoubleClick;
if (m_source_filter.empty())
flags |= ImGuiTreeNodeFlags_DefaultOpen;
- if (!ImGui::TreeNodeEx(node.name.c_str(), flags))
+ ImGui::PushStyleColor(ImGuiCol_Text, SOURCE_FOLDER_COLOR);
+ const bool open_node = ImGui::TreeNodeEx(node.name.c_str(), flags);
+ ImGui::PopStyleColor();
+
+ if (!open_node)
return;
+ const float indent = ImGui::GetStyle().IndentSpacing;
+ const float half_row = ImGui::GetTextLineHeight() * 0.5f;
+ const float spine_x = ImGui::GetCursorScreenPos().x - indent * 0.5f;
+ const float top_y = ImGui::GetCursorScreenPos().y;
+ float last_y = top_y;
+
for (const SourceNode& child : node.children)
+ {
+ if (!source_node_matches(child, m_source_filter))
+ continue;
+
+ const float row_y = ImGui::GetCursorScreenPos().y + half_row;
+
+ draw_list->AddLine(ImVec2(spine_x, row_y),
+ ImVec2(spine_x + indent * 0.5f - 3.0f, row_y),
+ SOURCE_TREE_LINE_COLOR);
+ last_y = row_y;
+
self(child);
+ }
+
+ draw_list->AddLine(ImVec2(spine_x, top_y),
+ ImVec2(spine_x, last_y),
+ SOURCE_TREE_LINE_COLOR);
ImGui::TreePop();
};