summaryrefslogtreecommitdiff
path: root/my_imgui_widgets.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'my_imgui_widgets.cpp')
-rw-r--r--my_imgui_widgets.cpp136
1 files changed, 112 insertions, 24 deletions
diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp
index 1ee82e9..f93866a 100644
--- a/my_imgui_widgets.cpp
+++ b/my_imgui_widgets.cpp
@@ -71,6 +71,87 @@ ImGui_KeyframeDragging(project_data *File, project_state *State, ui *UI, propert
}
static void
+ImGui_DebugMemoryViewer(project_data *File, memory *Memory)
+{
+ ImGui::SetNextWindowSize(ImVec2(800, 200));
+ ImGui::Begin("memoryviewer");
+ ImVec2 ViewportMin = ImGui::GetCursorScreenPos();
+ ImVec2 ViewportScale = ImGui::GetContentRegionAvail();
+ ImVec2 ViewportMax = ImVec2(ViewportMin.x + ViewportScale.x, ViewportMin.y + ViewportScale.y);
+
+ memory_table *Table = &Memory->Slot[B_LoadedBitmaps];
+
+ real32 TotalMB = Table->Size/1024/1024;
+ real32 LineAmount = 50;
+ real32 IncrementMB = TotalMB / LineAmount;
+ real32 ScreenIncrement = ViewportScale.x / LineAmount;
+
+ real32 CubeHeight = ImGui::GetFontSize();
+ real32 TotalHeight = CubeHeight*4;
+
+ ImDrawList* draw_list = ImGui::GetWindowDrawList();
+ draw_list->AddRectFilled(ViewportMin, ViewportMax, IM_COL32(50, 50, 50, 255));
+
+ for (float x = 0; x < LineAmount; x++) {
+ uint32 LineColor = IM_COL32(200, 200, 200, 40);
+ ImVec2 Min = ImVec2(ViewportMin.x + ScreenIncrement * x, ViewportMin.y);
+ ImVec2 Max = ImVec2(Min.x + 2, ViewportMax.y);
+ draw_list->AddLine(Min, Max, LineColor);
+ }
+
+ for (uint32 i = 0; i < Table->NumberOfPointers; i++) {
+ if (Memory->Bitmap[i].SourceOwner) {
+ void *DataStart = Memory->Bitmap[i].Data;
+ void *NextDataStart;
+ int pp = 1;
+ for (;;) {
+ if (Memory->Bitmap[i+pp].SourceOwner) {
+ NextDataStart = Memory->Bitmap[i+pp].Data;
+ break;
+ }
+ pp++;
+ }
+ uint64 BytesBetween = (uint8 *)NextDataStart - (uint8 *)DataStart;
+ source *Source = Memory->Bitmap[i].SourceOwner;
+ real32 Pos = Memory_NormalizedPosition(&File->Source[0], File->NumberOfSources, sizeof(source), Source);
+
+ ImVec4 col = ImColor::HSV(Pos, 0.3, 0.6, 1.0f);
+ uint64 BitmapSize = Bitmap_CalcTotalBytes(Source->Info.Width, Source->Info.Height, Source->Info.BytesPerPixel);
+ if (BitmapSize > BytesBetween) {
+ col = ImColor::HSV(Pos, 1.0, 1.0, 1.0f);
+ }
+
+ uint64 DataStart2 = (uint8 *)DataStart - (uint8 *)Table->Address;
+ real32 StartReal = ((real32)DataStart2/1024/1024);
+ ImVec2 Min = ImVec2(ViewportMin.x + (StartReal/IncrementMB * ScreenIncrement), ViewportMin.y + (ViewportScale.y / 2) - (TotalHeight / 2) + TotalHeight*Pos);
+ real32 SizeReal = ((real32)BitmapSize/1024/1024);
+ ImVec2 Size = ImVec2(SizeReal/IncrementMB * ScreenIncrement, CubeHeight);
+ ImGui::SetCursorScreenPos(Min);
+ ImGui::PushID(i);
+ ImGui::PushStyleColor(ImGuiCol_Button, col);
+ char buf2[256];
+ sprintf(buf2, "%i##mempos", Memory->Bitmap[i].Frame);
+ ImGui::Button(buf2, Size);
+ ImGui::PopStyleColor();
+ if (ImGui::IsItemHovered()) {
+ char buf[1024];
+ sprintf(buf, "Source owner: %s\nSize: %.02f MB\n Frame number: %i", Memory->Bitmap[i].SourceOwner->Path, SizeReal, Memory->Bitmap[i].Frame);
+ ImGui::BeginTooltip();
+ ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
+ ImGui::TextUnformatted(buf);
+ ImGui::PopTextWrapPos();
+ ImGui::EndTooltip();
+ }
+ ImGui::PopID();
+ ImVec2 Max = ImVec2(ViewportMax.x, Min.y + CubeHeight);
+ // draw_list->AddRectFilled(Min, Max, IM_COL32(200, 200, 200, 255));
+ }
+ }
+
+ ImGui::End();
+}
+
+static void
ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *Memory)
{
if (State->MostRecentlySelectedLayer > -1) {
@@ -130,20 +211,10 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *
ImGui::PopID();
}
} else if (Effect->DisplayType == levels) {
- ImGui::Button("asda");
- // bool ImGui::SliderScalarasda(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags)
- // static int8 p = 0;
- // static int8 m = 10;
- // static int8 c = 2;
- // ImGui::SliderScalarasda("slider s8 full", ImGuiDataType_S8, &c, &p, &m, "%d", ImGuiSliderFlags_None);
- static real32 p = 0;
- static real32 m = 1;
- static real32 c = 2;
- ImGui::SliderScalar("f2", ImGuiDataType_Float, &c, &p, &m, "%f", ImGuiSliderFlags_Logarithmic);
- static real32 Max = 0.8;
- static real32 Min = 0.25;
- static real32 Mid = 0; // NOTE(fox): "Neutral" is zero, negative one is full black, one is full white.
- ImGui::SliderLevels("f", &Mid, &Min, &Max);
+ real32 *Min = &Effect->Property[0].CurrentValue.f;
+ real32 *Mid = &Effect->Property[1].CurrentValue.f;
+ real32 *Max = &Effect->Property[2].CurrentValue.f;
+ ImGui::SliderLevels("f", Mid, Min, Max);
}
}
} else {
@@ -297,10 +368,7 @@ ImGui_File(project_data *File, project_state *State, memory *Memory, ui *UI, ImG
{
ImGui::Begin("Files");
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
- // if (ImGui::Button("Add source")) {
- // }
if (State->DemoButton) {
- ImGui::SameLine();
if (ImGui::Button("Generate demo scene")) {
// CreateDemoScene(File, Memory);
State->UpdateKeyframes = true;
@@ -317,12 +385,23 @@ ImGui_File(project_data *File, project_state *State, memory *Memory, ui *UI, ImG
State->GridButton = false;
}
}
- static char Input[1024];
- ImGui::InputText("##sourceinput", Input, STRING_SIZE);
- ImGui::SameLine();
- if (ImGui::Button("Create Layer")) {
- // AddSource(File, State, Memory, Input);
+ ImGui::Text("Sources:");
+ for (int i = 0; i < File->NumberOfSources; i++) {
+ ImGui::Text(File->Source[i].Path);
+ ImGui::OpenPopupOnItemClick("sourcecontext", ImGuiPopupFlags_MouseButtonRight);
+ if (ImGui::BeginPopup("sourcecontext")) {
+ if (ImGui::MenuItem("Create layer from source")) {
+ Layer_CreateFromSource(File, State, Memory, &File->Source[i]);
+ }
+ ImGui::EndPopup();
+ }
}
+ // static char Input[1024];
+ // ImGui::InputText("##sourceinput", Input, STRING_SIZE);
+ // ImGui::SameLine();
+ // if (ImGui::Button("Create Layer")) {
+ // // AddSource(File, State, Memory, Input);
+ // }
#if DEBUG
for (int i = 0; i < Debug.WatchedProperties; i++) {
if (Debug.DebugPropertyType[i] == d_float) {
@@ -340,7 +419,6 @@ ImGui_File(project_data *File, project_state *State, memory *Memory, ui *UI, ImG
static void
ImGui_EffectsPanel(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io)
{
-#if 0
ImGui::Begin("Effects list", NULL);
if (State->RerouteEffects) {
ImGui::SetKeyboardFocusHere();
@@ -390,7 +468,6 @@ ImGui_EffectsPanel(project_data *File, project_state *State, memory *Memory, ui
}
}
ImGui::End();
-#endif
}
@@ -467,9 +544,12 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI,
ImGui::BeginChild("Topbar", TopbarSize, true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar);
+ ImGui::Text
+ /*
ImGui::Button("V", TopbarButtonSize); ImGui::SameLine();
ImGui::Button("V", TopbarButtonSize); ImGui::SameLine();
ImGui::Button("V", TopbarButtonSize); ImGui::SameLine();
+ */
ImGui::SetCursorScreenPos(PlayheadPos);
ImGui::Button("P", ButtonSize);
@@ -688,6 +768,14 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI,
}
ImGui_SlidingLayer(Layer, &UI->DraggingKeyframeThreshold, io.MouseDelta.x, UI->TimelineZoom, 2);
+ for (int a = Layer->StartFrame; a < Layer->EndFrame; a++) {
+ cached_bitmap *Bitmap = Cache_CheckBitmap(Layer->Source, &Layer->BitmapInfo, Memory, a);
+ if (Bitmap) {
+ ImVec2 MinPos = ImVec2(TimelineStartingPos.x + UI->TimelineZoom * a, ImGui::GetCursorScreenPos().y);
+ draw_list->AddRect(MinPos, ImVec2(MinPos.x + UI->TimelineZoom, MinPos.y + 2.0f), ImColor(0, 255, 0, 255));
+ }
+ }
+
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, ItemSpacing.y * UI->KeyframeSpacing));
ImGui::SetCursorPosY(ImGui::GetCursorPos().y + (ItemSpacing.y * UI->KeyframeSpacing / 2));