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.cpp61
1 files changed, 54 insertions, 7 deletions
diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp
index ac0739e..1ef4d31 100644
--- a/my_imgui_widgets.cpp
+++ b/my_imgui_widgets.cpp
@@ -216,8 +216,10 @@ ImGui_DebugMemoryViewer(project_data *File, memory *Memory)
ImGui::End();
}
+static bool32 FU;
+
static void
-ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *Memory)
+ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io)
{
if (State->MostRecentlySelectedLayer > -1) {
project_layer *Layer = File->Layer[State->MostRecentlySelectedLayer];
@@ -238,20 +240,33 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *
}
for (int h = 0; h < Layer->NumberOfEffects; h++) {
effect *Effect = Layer->Effect[h];
- ImGui::PushID(Effect);
+ ImGui::PushID(Effect->ImGuiID);
+ if (FU && h == 0) {
+ int a = 0;
+ }
// this is stupid
if (Effect->IsActive)
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetColorU32(ImGuiCol_ButtonHovered));
else
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetColorU32(ImGuiCol_Button));
if (ImGui::Button("V")) {
- Effect->IsActive ^= 1;
+ History_Entry_Commit(Memory, action_entry_default, "Toggle effect");
+ History_Action_Change_SwapBool(Memory, &Effect->IsActive);
+ History_Entry_End(Memory);
State->UpdateFrame = true;
}
ImGui::SameLine();
ImGui::PopStyleColor();
ImGui::Button("R"); ImGui::SameLine();
- ImGui::Text(Effect->Name);
+ ImGui::Selectable(Effect->Name, Effect->IsSelected);
+ // NOTE(fox): The logic for effect dragging has to be after we've
+ // done the UI for the rest of the effect!
+ real32 Effect_Top = ImGui::GetCursorScreenPos().y;
+ bool32 IsHovered = ImGui::IsItemHovered();
+ bool32 IsActive = ImGui::IsItemActive();
+ bool32 IsActivated = ImGui::IsItemActivated();
+ bool32 IsDeactivated = ImGui::IsItemDeactivated();
+
if (Effect->DisplayType == standard) {
for (int i = 0; i < Effect->NumberOfProperties; i++) {
property_channel *Property = &Effect->Property[i];
@@ -355,6 +370,36 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *
ImGui::Button("K");
}
ImGui::PopID();
+
+ if (IsActive)
+ {
+ if (!Effect->IsSelected && IsActivated) {
+ Effect->IsSelected ^= 1;
+ }
+ if (ImGui::IsMouseDragging(ImGuiMouseButton_Left, -1))
+ {
+ real32 Effect_Bottom = ImGui::GetCursorScreenPos().y;
+ real32 Effect_Length = Effect_Bottom - Effect_Top;
+ ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
+ UI->DraggingEffectThreshold += io.MouseDelta.y;
+ if (abs(UI->DraggingEffectThreshold) >= Effect_Length) {
+ int16 Increment = UI->DraggingEffectThreshold/Effect_Length;
+ effect *Effect = Layer->Effect[1];
+ Layer->Effect[1] = Layer->Effect[0];
+ Layer->Effect[0] = Effect;
+ // History_Entry_Commit(Memory, action_entry_default, "Change effect order");
+ // History_Entry_End(Memory);
+ FU = true;
+ UI->DraggingEffectThreshold += -1*Increment*Effect_Length;
+ State->UpdateFrame = true;
+ State->UpdateKeyframes = true;
+ }
+ }
+ }
+ if (FU) {
+ FU = false;
+ break;
+ }
}
} else {
char buf[256];
@@ -483,6 +528,10 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, memory *Memory,
if (ImGui::IsItemHovered()) {
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW);
}
+ if (ImGui::IsItemHovered() && ImGui::IsKeyPressed(ImGuiKey_Backspace)) {
+ Mask_DeletePoint(Memory, Mask, p);
+ State->UpdateFrame = true;
+ }
if (ImGui::IsItemActivated() && b == 0) {
if (p == 0 && State->Pen.IsActive) {
History_Entry_Commit(Memory, action_entry_default, "Close mask path");
@@ -491,8 +540,6 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, memory *Memory,
// State->Pen.IsActive = false;
// Mask->IsClosed = true;
History_Entry_End(Memory);
- } else if (io.KeyCtrl) {
- // TODO(fox): Mask delete!
} else if (io.KeyAlt) {
History_Entry_Commit(Memory, action_entry_default, "Switch handles on point");
History_Action_Change_SwapBool(Memory, &Point0->HandleBezier);
@@ -570,7 +617,7 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, memory *Memory,
if (ImGui::IsItemActivated() && io.KeyCtrl) {
v2 LayerPoint = Layer_ScreenSpaceToLocal(Layer, UI, CompBuffer, ViewportMin, io.MousePos);
real32 ratio = Bezier_CubicRatioOfPoint(Point0_Pos, Point0_Pos_Right, Point1_Pos_Left, Point1_Pos, LayerPoint);
- Mask_AddPointToCurve(Mask, p, ratio);
+ Mask_AddPointToCurve(Memory, Mask, p, ratio);
}
}
} else {