summaryrefslogtreecommitdiff
path: root/my_imgui_widgets.cpp
diff options
context:
space:
mode:
authorFox Caminiti <fox@foxcam.net>2022-08-01 20:03:12 -0400
committerFox Caminiti <fox@foxcam.net>2022-08-01 20:04:43 -0400
commitb26f27d9e3fd44ec5775accdc3666a339684be4c (patch)
treee5c7b8b48f5597904190529f90d71a8526ca9800 /my_imgui_widgets.cpp
parent7d3dcee5b370c05065eb409ad5c21d0bc64790b1 (diff)
large changes to bitmap structure
Diffstat (limited to 'my_imgui_widgets.cpp')
-rw-r--r--my_imgui_widgets.cpp160
1 files changed, 95 insertions, 65 deletions
diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp
index f94e47c..1ee82e9 100644
--- a/my_imgui_widgets.cpp
+++ b/my_imgui_widgets.cpp
@@ -1,8 +1,9 @@
#include "imgui/imgui.h"
+#include "my_imgui_internal_widgets.h"
#include "imgui_ops.h"
// 0 for timeline keyframe, 1 for graph keyframe, 2 for left graph handle, 3 for right graph handle
-internal void
+static void
ImGui_KeyframeDragging(project_data *File, project_state *State, ui *UI, property_channel *Property, int32 b, ImGuiIO io, int16 Type)
{
keyframe *Keyframe = KeyframeLookupMemory(Property, b);
@@ -69,7 +70,7 @@ ImGui_KeyframeDragging(project_data *File, project_state *State, ui *UI, propert
}
}
-internal void
+static void
ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *Memory)
{
if (State->MostRecentlySelectedLayer > -1) {
@@ -97,35 +98,52 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *
effect *Effect = Layer->Effect[h];
ImGui::Button("V"); ImGui::SameLine();
ImGui::Text(Effect->Name);
- for (int i = 0; i < Effect->NumberOfProperties; i++) {
- property_channel *Property = &Effect->Property[i];
- ImGui::PushID(Property);
- if (Property->VarType == type_real)
- ImGui::DragScalar(Property->Name, ImGuiDataType_Float, &Property->CurrentValue.f, 0.005f, &Property->MaxVal.f, &Property->MaxVal.f, "%f");
- if (Property->VarType == type_color)
- if (ImGui::ColorEdit4("color 1", &Property->CurrentValue.f, ImGuiColorEditFlags_Float))
- State->UpdateFrame = true;
- if (Property->VarType == type_blendmode)
- {
- uint32 *item_current_idx = (uint32 *)&Property->CurrentValue.blendmode; // Here we store our selection data as an index.
- if (ImGui::BeginListBox("Blend mode"))
+ if (Effect->DisplayType == standard) {
+ for (int i = 0; i < Effect->NumberOfProperties; i++) {
+ property_channel *Property = &Effect->Property[i];
+ ImGui::PushID(Property);
+ if (Property->VarType == type_real)
+ ImGui::DragScalar(Property->Name, ImGuiDataType_Float, &Property->CurrentValue.f, 0.005f, &Property->MaxVal.f, &Property->MaxVal.f, "%f");
+ if (Property->VarType == type_color)
+ if (ImGui::ColorEdit4("color 1", &Property->CurrentValue.f, ImGuiColorEditFlags_Float))
+ State->UpdateFrame = true;
+ if (Property->VarType == type_blendmode)
{
- for (int n = 0; n < IM_ARRAYSIZE(BlendmodeNames); n++)
+ uint32 *item_current_idx = (uint32 *)&Property->CurrentValue.blendmode; // Here we store our selection data as an index.
+ if (ImGui::BeginListBox("Blend mode"))
{
- const bool is_selected = (*item_current_idx == n);
- if (ImGui::Selectable(BlendmodeNames[n], is_selected)) {
- *item_current_idx = n;
- State->UpdateFrame = true;
+ for (int n = 0; n < IM_ARRAYSIZE(BlendmodeNames); n++)
+ {
+ const bool is_selected = (*item_current_idx == n);
+ if (ImGui::Selectable(BlendmodeNames[n], is_selected)) {
+ *item_current_idx = n;
+ State->UpdateFrame = true;
+ }
+
+ // Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
+ if (is_selected)
+ ImGui::SetItemDefaultFocus();
}
-
- // Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
- if (is_selected)
- ImGui::SetItemDefaultFocus();
+ ImGui::EndListBox();
}
- ImGui::EndListBox();
}
+ ImGui::PopID();
}
- 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);
}
}
} else {
@@ -138,11 +156,11 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *
ImGui::End();
}
-internal v2
-CalculateAnchorPointUV(project_layer *Layer, pixel_buffer *Buffer);
+static v2
+CalculateAnchorPointUV(project_layer *Layer, comp_buffer *Buffer);
-internal void
-ImGui_Viewport(project_data File, project_state *State, ui *UI, pixel_buffer CompBuffer,
+static void
+ImGui_Viewport(project_data File, project_state *State, ui *UI, comp_buffer CompBuffer,
ImGuiIO io, GLuint textureID)
{
ImGui::Begin("Viewport");
@@ -202,9 +220,9 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, pixel_buffer Com
// }
ImGui::OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonMiddle);
if (ImGui::BeginPopup("context")) {
- if (ImGui::MenuItem("Scalar", NULL, false, InstructionMode != scalar_only)) { InstructionMode = scalar_only; State->UpdateFrame = true; }
- if (ImGui::MenuItem("SSE", NULL, false, InstructionMode != sse_enabled)) { InstructionMode = sse_enabled; State->UpdateFrame = true; }
- if (ImGui::MenuItem("AVX2", NULL, false, InstructionMode != avx_enabled)) { InstructionMode = avx_enabled; State->UpdateFrame = true; }
+ if (ImGui::MenuItem("Scalar", NULL, false, InstructionMode != instruction_mode_scalar)) { InstructionMode = instruction_mode_scalar; State->UpdateFrame = true; }
+ if (ImGui::MenuItem("SSE", NULL, false, InstructionMode != instruction_mode_sse)) { InstructionMode = instruction_mode_sse; State->UpdateFrame = true; }
+ if (ImGui::MenuItem("AVX2", NULL, false, InstructionMode != instruction_mode_avx)) { InstructionMode = instruction_mode_avx; State->UpdateFrame = true; }
ImGui::EndPopup();
}
if (IsActive && ImGui::IsMouseDragging(ImGuiMouseButton_Left, -1.0f) && ImGui::IsKeyDown(ImGuiKey_Z))
@@ -241,7 +259,7 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, pixel_buffer Com
}
// 1 for left, 2 for right, 3 for both
-internal bool32
+static bool32
ImGui_SlidingLayer(project_layer *Layer, real32 *DraggingThreshold, real32 Delta, int16 TimelineZoom, int16 Side)
{
bool32 Result = 0;
@@ -262,9 +280,8 @@ ImGui_SlidingLayer(project_layer *Layer, real32 *DraggingThreshold, real32 Delta
Layer->EndFrame += Increment;
if (Side == 3) {
IncrementKeyframesInLayer(Layer, Increment);
- if (Layer->SourceType == source_video) {
- video_source *Source = (video_source *)Layer->RenderInfo;
- Source->VideoFrameOffset += Increment;
+ if (Layer->Source->SourceType == source_type_video) {
+ Layer->BitmapInfo.FrameOffset += Increment;
}
}
}
@@ -275,21 +292,17 @@ ImGui_SlidingLayer(project_layer *Layer, real32 *DraggingThreshold, real32 Delta
return Result;
}
-internal void
-AddSource(project_data *File, memory *Memory, char * = NULL);
-
-internal void
+static void
ImGui_File(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io)
{
ImGui::Begin("Files");
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
- if (ImGui::Button("Add source")) {
- AddSource(File, Memory);
- }
+ // if (ImGui::Button("Add source")) {
+ // }
if (State->DemoButton) {
ImGui::SameLine();
if (ImGui::Button("Generate demo scene")) {
- CreateDemoScene(File, Memory);
+ // CreateDemoScene(File, Memory);
State->UpdateKeyframes = true;
State->UpdateFrame = true;
State->DemoButton = false;
@@ -298,20 +311,17 @@ ImGui_File(project_data *File, project_state *State, memory *Memory, ui *UI, ImG
if (State->GridButton) {
ImGui::SameLine();
if (ImGui::Button("Generate square grid")) {
- CreateGrid(File, Memory);
+ // CreateGrid(File, Memory);
State->UpdateKeyframes = true;
State->UpdateFrame = true;
State->GridButton = false;
}
}
- for (int16 i = 0; i < File->NumberOfSources; i++) {
- ImGui::PushID(i);
- ImGui::InputText("##source", File->Source[i], STRING_SIZE);
- ImGui::SameLine();
- if (ImGui::Button("Create Layer")) {
- CreateLayerFromSource(File, State, Memory, File->Source[i]);
- }
- ImGui::PopID();
+ 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++) {
@@ -327,9 +337,10 @@ ImGui_File(project_data *File, project_state *State, memory *Memory, ui *UI, ImG
ImGui::End();
}
-internal void
+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();
@@ -349,23 +360,41 @@ ImGui_EffectsPanel(project_data *File, project_state *State, memory *Memory, ui
State->filter.Build();
EffectSel = -1;
}
+ // Enter conveniently deactivates the InputText field
+ if (ImGui::IsItemDeactivated() && ImGui::IsKeyPressed(ImGuiKey_Enter)) {
+ int32 p = 0;
+ for (int32 i = 0; i < AmountOf(EffectList); i++) {
+ if (State->filter.PassFilter(EffectList[i].Name)) {
+ if (EffectSel == p && State->MostRecentlySelectedLayer != -1) {
+ AddEffect(File->Layer[State->MostRecentlySelectedLayer], Memory, i);
+ }
+ p++;
+ }
+ }
+ EffectSel = -1;
+ }
+ int32 p = 0;
for (int32 i = 0; i < AmountOf(EffectList); i++) {
if (State->filter.PassFilter(EffectList[i].Name)) {
- if (EffectSel == i) {
- bool t = true;
- ImGui::Selectable(EffectList[i].Name, &t);
- } else {
- bool s = false;
- ImGui::Selectable(EffectList[i].Name, &s);
+ bool t = false;
+ if (EffectSel == p) {
+ t = true;
}
- // ImGui::Text(EffectList[i].Name);
+ ImGui::Selectable(EffectList[i].Name, &t);
+ if (ImGui::IsItemClicked()) {
+ if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) && State->MostRecentlySelectedLayer != -1) {
+ AddEffect(File->Layer[State->MostRecentlySelectedLayer], Memory, i);
+ }
+ }
+ p++;
}
}
ImGui::End();
+#endif
}
-internal void
+static void
ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io)
{
ImVec2 FramePadding = ImGui::GetStyle().FramePadding;
@@ -991,6 +1020,7 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI,
UI->BoxStart = {0, 0};
UI->BoxEnd = {0, 0};
UI->BoxSelectActive = false;
+ if (!io.KeyShift) DeselectAllLayers(File, State);
}
ImGui::EndChild();
@@ -1018,8 +1048,8 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI,
}
-internal void
-ImGui_ProcessInputs(project_data *File, project_state *State, pixel_buffer *CompBuffer, memory *Memory, ui *UI, ImGuiIO io)
+static void
+ImGui_ProcessInputs(project_data *File, project_state *State, comp_buffer *CompBuffer, memory *Memory, ui *UI, ImGuiIO io)
{
if (io.KeysData[ImGuiKey_Q].Down)
State->IsRunning = false;
@@ -1132,7 +1162,7 @@ ImGui_ProcessInputs(project_data *File, project_state *State, pixel_buffer *Comp
}
}
-global_variable char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]"
+static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]"
"\nPos=0,0"
"\nSize=3200,1800"
"\nCollapsed=0"