1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#if SPECIAL
#include "main.h"
#endif
static void
ImGui_DebugMemoryViewer(memory *Memory, project_state *State)
{
ImGui::Begin("debug_memory");
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();
}
|