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.cpp300
1 files changed, 204 insertions, 96 deletions
diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp
index 2ecdf9e..eaa7eb9 100644
--- a/my_imgui_widgets.cpp
+++ b/my_imgui_widgets.cpp
@@ -62,6 +62,55 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *
ImGui_InteractSliderProperty(State, Memory, Property);
ImGui::PopID();
}
+ for (int i = 0; i < Layer->Block_Effect_Count; i++)
+ {
+ block_effect Effect = *(block_effect *)Memory_Block_AddressAtIndex(Memory, F_Effects, Layer->Block_Effect_Index[i]);
+ header_effect *EffectHeader = Effect_EntryFromID(State, Effect.ID);
+ ImGui::PushID(Effect.Index);
+ ImGui::Text(EffectHeader->Name);
+ ImGui::PopID();
+ if (EffectHeader->DisplayType == effect_display_type_standard) {
+ for (int c = 0; c < EffectHeader->Property_Count; c++) {
+ header_property ChannelHeader = State->Property[EffectHeader->PropertyStartIndex + c];
+ property_channel *Property = (property_channel *)Memory_Block_AddressAtIndex(Memory, F_Properties, Effect.Block_Property_Index[c]);
+ ImGui::PushID(Property);
+ if (ChannelHeader.DisplayType == property_display_type_standard) {
+ ImGui_InteractSliderProperty(State, Memory, Property);
+ } else if (ChannelHeader.DisplayType == property_display_type_color) {
+ property_channel *Property1 = (property_channel *)Memory_Block_AddressAtIndex(Memory, F_Properties, Effect.Block_Property_Index[c+1]);
+ 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))
+ 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.
+ if (ImGui::BeginListBox("Blend mode"))
+ {
+ 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();
+ }
+ ImGui::EndListBox();
+ }
+ } else {
+ Assert(0);
+ }
+ ImGui::PopID();
+ }
+ } else {
+ Assert(0);
+ }
+ }
if (Layer->IsPrecomp) {
block_composition *Comp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, Layer->Block_Source_Index);
ImGui::DragScalar("Width", ImGuiDataType_U16, &Comp->Width);
@@ -1160,11 +1209,22 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory,
}
static void
-ImGui_TimelineHorizontalIncrementDraw(project_state *State, ui *UI, ImDrawList *draw_list, ImVec2 TimelineSizeWithBorder, ImVec2 TimelineAbsolutePos, block_composition MainComp,
+ImGui_Timeline_BGElements(project_state *State, ui *UI, ImDrawList *draw_list, ImVec2 TimelineSizeWithBorder, ImVec2 TimelineAbsolutePos, block_composition MainComp,
+ ImVec2 TimelineZoomSize, ImVec2 TimelineMoveSize)
+{
+ uint32 PreviewAreaColor = IM_COL32(128, 128, 128, 30);
+ ImVec2 Region_Min = ImVec2(TimelineAbsolutePos.x + TimelineMoveSize.x + ((real32)MainComp.Frame_Start / MainComp.Frame_Count)*TimelineZoomSize.x, TimelineAbsolutePos.y);
+ ImVec2 Region_Max = ImVec2(Region_Min.x + ((real32)(MainComp.Frame_End - MainComp.Frame_Start) / MainComp.Frame_Count)*TimelineZoomSize.x, Region_Min.y + TimelineSizeWithBorder.y);
+ draw_list->AddRectFilled(Region_Min, Region_Max, PreviewAreaColor);
+}
+
+static void
+ImGui_Timeline_HorizontalIncrementDraw(project_state *State, ui *UI, ImDrawList *draw_list, ImVec2 TimelineSizeWithBorder, ImVec2 TimelineAbsolutePos, block_composition MainComp,
ImVec2 TimelineZoomSize, ImVec2 TimelineMoveSize)
{
uint32 LineColor = IM_COL32(200, 200, 200, 40);
uint32 PlayheadColor = IM_COL32(000, 000, 200, 160);
+ uint32 PreviewAreaColor = IM_COL32(128, 128, 128, 60);
Assert(TimelineZoomSize.x > 0.0f);
@@ -1199,6 +1259,29 @@ ImGui_TimelineHorizontalIncrementDraw(project_state *State, ui *UI, ImDrawList *
ImVec2 Min = ImVec2(TimelineAbsolutePos.x + TimelineMoveSize.x + ((real32)State->Frame_Current / MainComp.Frame_Count)*TimelineZoomSize.x, TimelineAbsolutePos.y);
ImVec2 Max = ImVec2(Min.x + 2, TimelineAbsolutePos.y + TimelineSizeWithBorder.y);
draw_list->AddLine(Min, Max, PlayheadColor);
+
+ real32 Size = ImGui::GetFontSize() * 2;
+ ImGui::SetCursorScreenPos(Min - ImVec2(Size / 2, 0));
+ ImGui::Button("##playhead", ImVec2(Size, Size));
+ bool32 IsHovered = ImGui::IsItemHovered();
+ bool32 IsItemActive = ImGui::IsItemActive();
+ bool32 IsItemActivated = ImGui::IsItemActivated();
+ bool32 IsItemDeactivated = ImGui::IsItemDeactivated();
+ if (IsItemActivated) {
+ State->Interact_Active = interact_type_timeline_scrub;
+ State->Interact_Offset[0] = State->Frame_Current;
+ }
+ if (IsItemActive) {
+ ImVec2 DragDelta = ImGui::GetMouseDragDelta();
+ int32 NewCurrent = (int32)(State->Interact_Offset[0] + (DragDelta.x / TimelineZoomSize.x * MainComp.Frame_Count) + 0.5);
+ if (NewCurrent != State->Frame_Current) {
+ State->Frame_Current = NewCurrent;
+ State->UpdateFrame = true;
+ }
+ }
+ if (IsItemDeactivated) {
+ State->Interact_Active = interact_type_none;
+ }
}
@@ -1644,7 +1727,15 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem
ImGui::PushStyleColor(ImGuiCol_Button, UI->LayerColors[c]);
real32 Size = ImGui::GetFontSize() * 2;
ImVec2 ColSize(Size, Size);
- ImGui::Button("##test", ColSize);
+ if (ImGui::Button("##test", ColSize)) {
+ int h = 0, z = 0, i = 0;
+ while (Block_Loop(Memory, F_Layers, File->Layer_Count, &h, &z, &i)) {
+ block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, i);
+ if (Layer->IsSelected) {
+ Layer->ColIndex = c;
+ }
+ }
+ }
if ((c+1) % 4) { ImGui::SameLine(); }
ImGui::PopStyleColor();
ImGui::PopID();
@@ -1856,6 +1947,8 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI,
ImVec2 Increment = ImVec2((real32)1 / MainComp->Frame_Count, (real32)1 / LayerIncrement);
+ ImGui_Timeline_BGElements(State, UI, draw_list, TimelineSizeWithBorder, TimelineAbsolutePos, *MainComp, TimelineZoomSize, TimelineMoveSize);
+
ImGui_Timeline_DrawPrecomp(File, State, Memory, UI, io, draw_list, File->PrincipalCompIndex,
Increment, TimelineAbsolutePos, TimelineMoveSize, TimelineZoomSize,
TimelineSize, TimelineSizeWithBorder, LayerIncrement,
@@ -1884,7 +1977,7 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI,
TimelineSize, TimelineSizeWithBorder, LayerIncrement, SortedPropertyInfo, SortedPropertyArray);
}
- ImGui_TimelineHorizontalIncrementDraw(State, UI, draw_list, TimelineSizeWithBorder, TimelineAbsolutePos, *MainComp, TimelineZoomSize, TimelineMoveSize);
+ ImGui_Timeline_HorizontalIncrementDraw(State, UI, draw_list, TimelineSizeWithBorder, TimelineAbsolutePos, *MainComp, TimelineZoomSize, TimelineMoveSize);
ImVec2 MouseDelta = io.MouseDelta / TimelineSize;
@@ -2150,49 +2243,62 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me
if (ImGui::IsKeyPressed(ImGuiKey_B)) {
State->Tool = tool_brush;
}
+ // NOTE(fox): File data not tracked on undo tree!
+ if (ImGui::IsKeyPressed(ImGuiKey_N)) {
+ block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, File->PrincipalCompIndex);
+ if (MainComp->Frame_Start < State->Frame_Current)
+ MainComp->Frame_End = State->Frame_Current;
+ }
+ if (ImGui::IsKeyPressed(ImGuiKey_B)) {
+ block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, File->PrincipalCompIndex);
+ if (MainComp->Frame_End > State->Frame_Current)
+ MainComp->Frame_Start = State->Frame_Current;
+ }
if (ImGui::IsKeyPressed(ImGuiKey_Tab)) {
UI->TimelineMode = (UI->TimelineMode == timeline_mode_default) ? timeline_mode_graph : timeline_mode_default;
UI->GraphZoomSize = ImVec2(0, 0);
UI->GraphMoveSize = ImVec2(0, 0);
}
- if (UI->FocusedWindow == focus_timeline) {
- if (UI->TimelineMode == timeline_mode_default) {
- if (ImGui::IsKeyPressed(ImGuiKey_G)) {
- Layer_ToggleChannel(File, Memory, 0);
- Layer_ToggleChannel(File, Memory, 1);
- } else if (ImGui::IsKeyPressed(ImGuiKey_A)) {
- Layer_ToggleChannel(File, Memory, 2);
- Layer_ToggleChannel(File, Memory, 3);
- } else if (ImGui::IsKeyPressed(ImGuiKey_R)) {
- Layer_ToggleChannel(File, Memory, 4);
- } else if (ImGui::IsKeyPressed(ImGuiKey_S)) {
- Layer_ToggleChannel(File, Memory, 5);
- } else if (ImGui::IsKeyPressed(ImGuiKey_T)) {
- if (io.KeyShift) {
- Layer_ToggleChannel(File, Memory, 6);
- } else {
- Layer_ToggleChannel(File, Memory, 7);
+ if (!io.KeyCtrl) {
+ if (UI->FocusedWindow == focus_timeline) {
+ if (UI->TimelineMode == timeline_mode_default) {
+ if (ImGui::IsKeyPressed(ImGuiKey_G)) {
+ Layer_ToggleChannel(File, Memory, 0);
+ Layer_ToggleChannel(File, Memory, 1);
+ } else if (ImGui::IsKeyPressed(ImGuiKey_A)) {
+ Layer_ToggleChannel(File, Memory, 2);
+ Layer_ToggleChannel(File, Memory, 3);
+ } else if (ImGui::IsKeyPressed(ImGuiKey_R)) {
+ Layer_ToggleChannel(File, Memory, 4);
+ } else if (ImGui::IsKeyPressed(ImGuiKey_S)) {
+ Layer_ToggleChannel(File, Memory, 5);
+ } else if (ImGui::IsKeyPressed(ImGuiKey_T)) {
+ if (io.KeyShift) {
+ Layer_ToggleChannel(File, Memory, 6);
+ } else {
+ Layer_ToggleChannel(File, Memory, 7);
+ }
+ }
+ } else if (UI->TimelineMode == timeline_mode_graph) {
+ if (ImGui::IsKeyPressed(ImGuiKey_G)) {
+ State->Interact_Offset[2] = io.MousePos.x;
+ State->Interact_Offset[3] = io.MousePos.y;
+ State->Interact_Active = interact_type_keyframe_move;
+ } else if (ImGui::IsKeyPressed(ImGuiKey_R)) {
+ // State->Interact_Offset[2] = io.MousePos.x;
+ // State->Interact_Offset[3] = io.MousePos.y;
+ // State->Interact_Active = interact_type_keyframe_rotate;
+ } else if (ImGui::IsKeyPressed(ImGuiKey_S)) {
+ State->Interact_Offset[2] = io.MousePos.x;
+ State->Interact_Offset[3] = io.MousePos.y;
+ State->Interact_Active = interact_type_keyframe_scale;
}
}
- } else if (UI->TimelineMode == timeline_mode_graph) {
- if (ImGui::IsKeyPressed(ImGuiKey_G)) {
- State->Interact_Offset[2] = io.MousePos.x;
- State->Interact_Offset[3] = io.MousePos.y;
- State->Interact_Active = interact_type_keyframe_move;
- } else if (ImGui::IsKeyPressed(ImGuiKey_R)) {
- // State->Interact_Offset[2] = io.MousePos.x;
- // State->Interact_Offset[3] = io.MousePos.y;
- // State->Interact_Active = interact_type_keyframe_rotate;
- } else if (ImGui::IsKeyPressed(ImGuiKey_S)) {
- State->Interact_Offset[2] = io.MousePos.x;
- State->Interact_Offset[3] = io.MousePos.y;
- State->Interact_Active = interact_type_keyframe_scale;
+ } else if (UI->FocusedWindow == focus_viewport) {
+ if (ImGui::IsKeyPressed(ImGuiKey_T)) {
+ State->HotkeyInput = hotkey_transform;
}
}
- } else if (UI->FocusedWindow == focus_viewport) {
- if (ImGui::IsKeyPressed(ImGuiKey_T)) {
- State->HotkeyInput = hotkey_transform;
- }
}
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
if (State->Interact_Active == interact_type_keyframe_move ||
@@ -2206,8 +2312,11 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me
State->UpdateFrame = true;
}
}
- if (ImGui::IsKeyPressed(ImGuiKey_Space)) {
- State->IsPlaying ^= 1;
+ if (ImGui::IsKeyPressed(ImGuiKey_Space) ) {
+ if (io.KeyShift) {
+ State->RerouteEffects = true;
+ } else { State->IsPlaying ^= 1;
+ }
}
if (ImGui::IsKeyPressed(ImGuiKey_2)) {
int h = 0, c = 0, i = 0;
@@ -2383,11 +2492,66 @@ ImGui_Menu(project_data *File, project_state *State, ui *UI, memory *Memory, ImG
}
static void
-ImGui_Popups(project_state *State, ui *UI, memory *Memory, ImGuiIO io)
+ImGui_EffectsPanel(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io)
{
+ ImGui::Begin("Effects list", NULL);
+ if (State->RerouteEffects) {
+ ImGui::SetKeyboardFocusHere();
+ State->RerouteEffects = 0;
+ }
+ int value_changed = ImGui::InputText("Effect name...", State->filter.InputBuf, IM_ARRAYSIZE(State->filter.InputBuf),
+ ImGuiInputTextFlags_CallbackCompletion, EffectConsoleCallback);
+
+ if (Hacko) {
+ if (!io.KeyShift)
+ EffectSel++;
+ else
+ EffectSel--;
+ Hacko = 0;
+ }
+ if (value_changed) {
+ 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 < State->Playhead_Effect; i++) {
+ header_effect *EffectHeader = &State->Effect[i];
+ if (State->filter.PassFilter(EffectHeader->Name)) {
+ if (EffectSel == p && State->MostRecentlySelectedLayer != -1) {
+ Assert(0);
+ // AddEffect(File->Layer[State->MostRecentlySelectedLayer], Memory, i);
+ State->UpdateFrame = true;
+ }
+ p++;
+ }
+ }
+ EffectSel = -1;
+ }
+ int32 p = 0;
+ for (int32 i = 0; i < State->Playhead_Effect; i++) {
+ header_effect *EffectHeader = &State->Effect[i];
+ if (State->filter.PassFilter(EffectHeader->Name)) {
+ bool t = false;
+ if (EffectSel == p) {
+ t = true;
+ }
+ ImGui::Selectable(EffectHeader->Name, &t);
+ if (ImGui::IsItemClicked()) {
+ if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) && State->MostRecentlySelectedLayer != -1) {
+ Assert(0);
+ State->UpdateFrame = true;
+ }
+ }
+ p++;
+ }
+ }
+ ImGui::End();
}
+
#if 0
real32 MaxVal_Y = -10000;
real32 MinVal_Y = 10000;
@@ -3698,62 +3862,6 @@ ImGui_SlidingLayer(project_layer *Layer, real32 *DraggingThreshold, real32 Delta
return Result;
}
-static void
-ImGui_EffectsPanel(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io)
-{
- ImGui::Begin("Effects list", NULL);
- if (State->RerouteEffects) {
- ImGui::SetKeyboardFocusHere();
- State->RerouteEffects = 0;
- }
- int value_changed = ImGui::InputText("Effect name...", State->filter.InputBuf, IM_ARRAYSIZE(State->filter.InputBuf),
- ImGuiInputTextFlags_CallbackCompletion, EffectConsoleCallback);
-
- if (Hacko) {
- if (!io.KeyShift)
- EffectSel++;
- else
- EffectSel--;
- Hacko = 0;
- }
- if (value_changed) {
- 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);
- State->UpdateFrame = true;
- }
- p++;
- }
- }
- EffectSel = -1;
- }
- int32 p = 0;
- for (int32 i = 0; i < AmountOf(EffectList); i++) {
- if (State->filter.PassFilter(EffectList[i].Name)) {
- bool t = false;
- if (EffectSel == p) {
- t = true;
- }
- ImGui::Selectable(EffectList[i].Name, &t);
- if (ImGui::IsItemClicked()) {
- if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) && State->MostRecentlySelectedLayer != -1) {
- AddEffect(File->Layer[State->MostRecentlySelectedLayer], Memory, i);
- State->UpdateFrame = true;
- }
- }
- p++;
- }
- }
- ImGui::End();
-}
-
static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]"