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.cpp86
1 files changed, 66 insertions, 20 deletions
diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp
index 163a15f..3264e89 100644
--- a/my_imgui_widgets.cpp
+++ b/my_imgui_widgets.cpp
@@ -96,12 +96,37 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *
property_channel *Property2 = (property_channel *)Memory_Block_AddressAtIndex(Memory, F_Properties, Effect.Block_Property_Index[c+2]);
property_channel *Property3 = (property_channel *)Memory_Block_AddressAtIndex(Memory, F_Properties, Effect.Block_Property_Index[c+3]);
real32 Color[4] = { Property->CurrentValue, Property1->CurrentValue, Property2->CurrentValue, Property3->CurrentValue };
- if (ImGui::ColorEdit4("color", (real32 *)Color, ImGuiColorEditFlags_Float)) {
+ if (ImGui::ColorEdit4("color", (real32 *)Color, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_NoInputs)) {
+ }
+ if (ImGui::IsItemActivated()) {
+ // State->Interact_Offset[0] = Property->CurrentValue;
+ // State->Interact_Offset[1] = Property1->CurrentValue;
+ // State->Interact_Offset[2] = Property2->CurrentValue;
+ // State->Interact_Offset[3] = Property3->CurrentValue;
+ State->Interact_Active = interact_type_slider_scrub;
+ }
+ if (ImGui::IsItemActive()) {
+ State->UpdateFrame = true;
Property->CurrentValue = Color[0];
Property1->CurrentValue = Color[1];
Property2->CurrentValue = Color[2];
Property3->CurrentValue = Color[3];
}
+
+ if (ImGui::IsItemDeactivatedAfterEdit()) {
+ if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
+ Property->CurrentValue = State->Interact_Offset[0];
+ } else if (!Property->Keyframe_Count) {
+ // History_Entry_Commit(Memory, "Property interact");
+ // real32 Temp = Property->CurrentValue;
+ // Property->CurrentValue = State->Interact_Offset[0];
+ // History_Action_Swap(Memory, Table, sizeof(Property->CurrentValue), &Property->CurrentValue);
+ // Property->CurrentValue = Temp;
+ // History_Entry_End(Memory);
+ }
+ State->Interact_Active = interact_type_none;
+ State->UpdateFrame = true;
+ }
c += 3;
} else if (ChannelHeader.DisplayType == property_display_type_blendmode) {
uint32 *item_current_idx = (uint32 *)&(Property->CurrentValue); // Here we store our selection data as an index.
@@ -1049,7 +1074,7 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory,
ImDrawList* draw_list = ImGui::GetWindowDrawList();
draw_list->AddRectFilled(ViewportMin, ViewportMax, IM_COL32(50, 50, 50, 255));
draw_list->AddRect(ViewportMin, ViewportMax, IM_COL32(255, 255, 255, 255));
- // draw_list->AddRect(CompPosMin, CompPosMax, IM_COL32(255, 255, 255, 55));
+ draw_list->AddRect(CompPosMin, CompPosMax, IM_COL32(255, 255, 255, 55));
// Actual composition texture
draw_list->PushClipRect(ViewportMin, ViewportMax, true);
@@ -1073,7 +1098,7 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory,
ImGui::InvisibleButton("canvas", ViewportScale, ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight);
bool32 IsHovered = ImGui::IsItemHovered();
-#if 1
+#if 0
bool32 IsActive = ImGui::IsItemActive();
bool32 IsActivated = ImGui::IsItemActivated();
bool32 IsDeactivated = ImGui::IsItemDeactivated();
@@ -1177,17 +1202,20 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory,
real32 DeltaSlope = MouseDelta.y / MouseDelta.x;
for (real32 i = 0; i < DeltaDistance; i += State->Brush.Spacing) {
ImVec2 MousePos = ImGui_Brush_CalcMousePos(State, io, MouseDelta, i, DeltaDistance, DeltaSlope);
- Brush_Render(State, UI, T_Layer, MainComp, Source, State->Brush.TransientBitmap, ViewportMin, MousePos);
+ v2 PrincipalCompUV = ImGui_ScreenPointToCompUV(ViewportMin, UI->CompPos, UI->CompZoom, io.MousePos);
+ v2 LayerPos = Layer_TraverseForPoint(File, State, Memory, PrincipalCompUV, SortedCompArray, SortedLayerArray);
+ Brush_Render(State, UI, T_Layer, MainComp, Source, State->Brush.TransientBitmap, ViewportMin, LayerPos);
}
} else if (IsActivated) {
ImVec2 MousePos = io.MousePos;
- Brush_Render(State, UI, T_Layer, MainComp, Source, State->Brush.TransientBitmap, ViewportMin, MousePos);
+ v2 PrincipalCompUV = ImGui_ScreenPointToCompUV(ViewportMin, UI->CompPos, UI->CompZoom, io.MousePos);
+ v2 LayerPos = Layer_TraverseForPoint(File, State, Memory, PrincipalCompUV, SortedCompArray, SortedLayerArray);
+ Brush_Render(State, UI, T_Layer, MainComp, Source, State->Brush.TransientBitmap, ViewportMin, LayerPos);
}
State->UpdateFrame = true;
}
if (IsDeactivated) {
-
block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, State->Brush.LayerToPaint_Index);
block_source *Source = (block_source *)Memory_Block_AddressAtIndex(Memory, F_Sources, Layer->Block_Source_Index);
void *SourceBitmapAddress = Memory_Block_AddressAtIndex(Memory, F_PrincipalBitmaps, Source->Bitmap_Index, 0);
@@ -1632,19 +1660,25 @@ ImGui_Timeline_DrawGraph(project_data *File, project_state *State, memory *Memor
static void
-ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io, ImDrawList *draw_list, uint16 CompIndex,
+ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io, ImDrawList *draw_list, int16 RecursionIdx[MAX_PRECOMP_RECURSIONS], uint32 Recursions,
ImVec2 Increment, ImVec2 TimelineAbsolutePos, ImVec2 TimelineMoveSize, ImVec2 TimelineZoomSize,
ImVec2 TimelineSize, ImVec2 TimelineSizeWithBorder, real32 LayerIncrement,
sorted_comp_info *SortedCompArray, sorted_layer *SortedLayerArray, sorted_property_info *SortedPropertyInfo, uint16 *SortedPropertyArray)
{
+ uint16 CompIndex = 0;
+ if (RecursionIdx[Recursions] == -1) {
+ CompIndex = File->PrincipalCompIndex;
+ } else {
+ block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, RecursionIdx[Recursions]);
+ CompIndex = Layer->Block_Source_Index;
+ }
block_composition *Comp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, CompIndex);
sorted_comp_info SortedCompInfo = SortedCompArray[CompIndex];
sorted_layer *SortedLayerInfo = Layer_GetSortedArray(SortedLayerArray, SortedCompArray, CompIndex);
ImGui::PushID(CompIndex);
- // Layers are drawn from top to bottom, so we can account for opened precomps/keyframes
- // without needing another loop.
+ // NOTE(fox): Layer sorting pre-calculates UI positioning, so the order layers are drawn is arbitrary.
real32 DisplayOffset = 0;
for (int i = SortedCompInfo.LayerCount - 1; i >= 0; i--)
{
@@ -1680,15 +1714,21 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem
draw_list->AddRectFilled(Layer_ScreenPos_Min, Layer_ScreenPos_Max, LayerColor);
draw_list->AddRect(Layer_ScreenPos_Min, Layer_ScreenPos_Max, BorderColor, 2);
block_string *String = (block_string *)Memory_Block_AddressAtIndex(Memory, F_Strings, Layer->Block_String_Index);
- char buf[21];
- sprintf(buf, "%.2f, %.2f", Layer->Vertical_Offset, SortEntry.SortedOffset);
- // draw_list->AddText(Layer_ScreenPos_Min, 0xFFFFFFFF, buf);
+ char buf[128];
+#if DEBUG
+ sprintf(buf, "%s, %i", String->Char, Index_Physical);
+#else
+ sprintf(buf, "%s", String->Char);
+#endif
if (UI->TimelinePercentZoomed.y <= 1.0f)
- draw_list->AddText(Layer_ScreenPos_Min, 0xFFFFFFFF, String->Char);
+ draw_list->AddText(Layer_ScreenPos_Min, 0xFFFFFFFF, buf);
- if (Layer->IsSelected) {
+ if (Layer->IsSelected == 1) {
draw_list->AddRectFilled(Layer_ScreenPos_Min, Layer_ScreenPos_Max, ImColor(0.25f, 0.25f, 0.25f, 0.5f), 2);
draw_list->AddRect(Layer_ScreenPos_Min, Layer_ScreenPos_Max, ImColor(1.0f, 1.0f, 1.0f, 0.5f), 2);
+ } else if (Layer->IsSelected == 2) {
+ // draw_list->AddRectFilled(Layer_ScreenPos_Min, Layer_ScreenPos_Max, ImColor(0.25f, 0.25f, 0.25f, 0.5f), 2);
+ draw_list->AddRect(Layer_ScreenPos_Min, Layer_ScreenPos_Max, ImColor(0.0f, 0.9f, 0.0f, 0.9f), 4);
}
//
@@ -1778,6 +1818,7 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem
if (!Layer->IsSelected) {
if (!io.KeyShift) Layer_DeselectAll(File, State, Memory);
Layer_Select(Memory, State, Index_Physical);
+ Layer_Select_RecurseUp(Memory, State, Index_Physical, RecursionIdx, Recursions);
}
}
@@ -1942,7 +1983,9 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem
ImGui::PushClipRect(MinClipPos, MaxClipPos, true);
draw_list->PushClipRect(MinClipPos, MaxClipPos, true);
- ImGui_Timeline_DrawPrecomp(File, State, Memory, UI, io, draw_list, Layer->Block_Source_Index,
+ uint32 RecursionsCount = Recursions+1;
+ RecursionIdx[RecursionsCount] = Index_Physical;
+ ImGui_Timeline_DrawPrecomp(File, State, Memory, UI, io, draw_list, RecursionIdx, RecursionsCount,
Increment, NestedTimelineAbsolutePos, TimelineMoveSize, TimelineZoomSize,
TimelineSize, TimelineSizeWithBorder, LayerIncrement,
SortedCompArray, SortedLayerArray, SortedPropertyInfo, SortedPropertyArray);
@@ -2044,7 +2087,10 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI,
ImGui_Timeline_BGElements(State, UI, draw_list, TimelineSizeWithBorder, TimelineAbsolutePos, *MainComp, TimelineZoomSize, TimelineMoveSize);
- ImGui_Timeline_DrawPrecomp(File, State, Memory, UI, io, draw_list, File->PrincipalCompIndex,
+ int16 RecursionIdx[MAX_PRECOMP_RECURSIONS] = {};
+ int32 Recursions = 0;
+ RecursionIdx[0] = -1;
+ ImGui_Timeline_DrawPrecomp(File, State, Memory, UI, io, draw_list, RecursionIdx, Recursions,
Increment, TimelineAbsolutePos, TimelineMoveSize, TimelineZoomSize,
TimelineSize, TimelineSizeWithBorder, LayerIncrement,
SortedCompArray, SortedLayerArray, SortedPropertyInfo, SortedPropertyArray);
@@ -2715,10 +2761,10 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me
}
#if DEBUG
- if (ImGui::IsKeyPressed(ImGuiKey_3))
- {
- State->ImGuiPopups = popup_keybinds;
- }
+ // if (ImGui::IsKeyPressed(ImGuiKey_3))
+ // {
+ // State->ImGuiPopups = popup_keybinds;
+ // }
if (ImGui::IsKeyPressed(ImGuiKey_F))
{
sprintf(State->DummyName, "test2");