summaryrefslogtreecommitdiff
path: root/src/imgui_ui_debug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/imgui_ui_debug.cpp')
-rw-r--r--src/imgui_ui_debug.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/imgui_ui_debug.cpp b/src/imgui_ui_debug.cpp
new file mode 100644
index 0000000..f79fb88
--- /dev/null
+++ b/src/imgui_ui_debug.cpp
@@ -0,0 +1,76 @@
+static void
+ImGui_DebugMemoryViewer(memory *Memory, project_state *State)
+{
+ ImGui::Begin("Memory viewer");
+
+ ImVec2 ViewportMin = ImGui::GetCursorScreenPos();
+ ImVec2 ViewportScale = ImGui::GetContentRegionAvail();
+ ImVec2 ViewportMax = ImVec2(ViewportMin.x + ViewportScale.x, ViewportMin.y + ViewportScale.y);
+
+ // ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
+ // ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
+
+ cache_entry *EntryArray = State->Render.Entry;
+ char *Type[4] = { "unassigned", "comp", "source", "layer" };
+ uint32 Blocks_Total = Memory->Slot[B_CachedBitmaps].Size / BitmapBlockSize;
+ uint32 PerRow = sqrt(Blocks_Total);
+ real32 BlockSize = ViewportScale.x / PerRow;
+ for (int c = 0; c < Memory->EntryCount; c++) {
+ ImGui::PushID(c);
+ cache_entry Entry = EntryArray[c];
+ uint32 BlockSpan;
+ if (c+1 != Memory->EntryCount) {
+ cache_entry NextEntry = EntryArray[c+1];
+ BlockSpan = NextEntry.Block_StartIndex - Entry.Block_StartIndex;
+ } else {
+ BlockSpan = 1;
+ }
+ ImVec2 ButtonPos = ViewportMin + ImVec2((Entry.Block_StartIndex % PerRow) * BlockSize, BlockSize * (Entry.Block_StartIndex / PerRow));
+ ImVec2 ButtonSize = ImVec2(BlockSpan * BlockSize, BlockSize);
+ ImGui::SetCursorScreenPos(ButtonPos);
+ char size[20];
+ sprintf(size, "%lu##uimemoryblock", EntryArray[c].CycleTime);
+ if (ButtonPos.x + ButtonSize.x > ViewportMax.x) {
+ real32 ButtonSizeSplit = ViewportMax.x - ButtonPos.x;
+ ImGui::Button(size, ImVec2(ButtonSizeSplit, ButtonSize.y));
+ ImVec2 ButtonPos2 = ImVec2(ViewportMin.x, ButtonPos.y + BlockSize);
+ ImGui::SetCursorScreenPos(ButtonPos2);
+ ImGui::Button("##uimemoryblockpad", ImVec2(ButtonSize.x - ButtonSizeSplit, ButtonSize.y));
+ } else {
+ ImGui::Button(size, ButtonSize);
+ }
+ if (ImGui::IsItemHovered()) {
+ ImGui::BeginTooltip();
+ ImGui::Text("Type - %s, Start - %i, Info - %i, %i", Type[EntryArray[c].Type], EntryArray[c].Block_StartIndex, EntryArray[c].TypeInfo, EntryArray[c].TypeInfo_Sub);
+ ImGui::EndTooltip();
+ }
+ ImGui::PopID();
+ }
+ // ImGui::PopStyleVar(2);
+ ImGui::End();
+}
+
+static void
+ImGui_DebugRenderQueue(project_state *State)
+{
+ ImGui::Begin("debug_queue");
+ for (int i = 0; i < State->Queue.CurrentIdx; i++) {
+ v2 Pos = State->Queue.Item[i].Pos;
+ char size[20];
+ sprintf(size, "Type %i: %.2f, %.2f", State->Queue.Item[i].Type, Pos.x, Pos.y);
+ ImGui::MenuItem(size, NULL, (i == State->Queue.Playhead));
+ }
+ ImGui::End();
+}
+
+static void
+ImGui_DebugUndoTree(memory *Memory, project_state *State)
+{
+ ImGui::Begin("debug_undotree");
+ for (int i = 0; i < Memory->History.NumberOfEntries; i++) {
+ history_entry Entry = Memory->History.Entry[i];
+ bool32 CurrentPos = (i < Memory->History.EntryPlayhead);
+ ImGui::MenuItem(Entry.Name, NULL, CurrentPos);
+ }
+ ImGui::End();
+}