Made dragging the time slider an operation mode.
This commit is contained in:
parent
a973054c17
commit
19727da391
|
@ -60,6 +60,48 @@ FOLDHAUS_INPUT_COMMAND_PROC(DeleteAnimationBlockCommand)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Drag Time Marker
|
||||||
|
//
|
||||||
|
|
||||||
|
OPERATION_STATE_DEF(drag_time_marker_operation_state)
|
||||||
|
{
|
||||||
|
rect TimelineBounds;
|
||||||
|
s32 StartFrame;
|
||||||
|
s32 EndFrame;
|
||||||
|
};
|
||||||
|
|
||||||
|
OPERATION_RENDER_PROC(UpdateDragTimeMarker)
|
||||||
|
{
|
||||||
|
drag_time_marker_operation_state* OpState = (drag_time_marker_operation_state*)Operation.OpStateMemory;
|
||||||
|
r32 TimeAtMouseX = GetTimeFromPointInAnimationPanel(Mouse.Pos, OpState->TimelineBounds, OpState->StartFrame, OpState->EndFrame, State->AnimationSystem.SecondsPerFrame);
|
||||||
|
State->AnimationSystem.Time = TimeAtMouseX;
|
||||||
|
}
|
||||||
|
|
||||||
|
FOLDHAUS_INPUT_COMMAND_PROC(EndDragTimeMarker)
|
||||||
|
{
|
||||||
|
DeactivateCurrentOperationMode(&State->Modes);
|
||||||
|
}
|
||||||
|
|
||||||
|
input_command DragTimeMarkerCommands [] = {
|
||||||
|
{ KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Ended, EndDragTimeMarker },
|
||||||
|
};
|
||||||
|
|
||||||
|
internal void
|
||||||
|
StartDragTimeMarker(rect TimelineBounds, s32 PanelStartFrame, s32 PanelEndFrame, app_state* State)
|
||||||
|
{
|
||||||
|
operation_mode* DragTimeMarkerMode = ActivateOperationModeWithCommands(&State->Modes, DragTimeMarkerCommands, UpdateDragTimeMarker);
|
||||||
|
|
||||||
|
drag_time_marker_operation_state* OpState = CreateOperationState(DragTimeMarkerMode,
|
||||||
|
&State->Modes,
|
||||||
|
drag_time_marker_operation_state);
|
||||||
|
OpState->StartFrame = PanelStartFrame;
|
||||||
|
OpState->EndFrame = PanelEndFrame ;
|
||||||
|
OpState->TimelineBounds = TimelineBounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------
|
||||||
|
|
||||||
//
|
//
|
||||||
// Drag Animation Clip
|
// Drag Animation Clip
|
||||||
//
|
//
|
||||||
|
@ -167,7 +209,7 @@ PANEL_CLEANUP_PROC(AnimationTimeline_Cleanup)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal r32
|
internal r32
|
||||||
DrawFrameBar (animation_system* AnimationSystem, render_command_buffer* RenderBuffer, s32 StartFrame, s32 EndFrame, rect PanelBounds, interface_config Interface, mouse_state Mouse)
|
DrawFrameBar (animation_system* AnimationSystem, render_command_buffer* RenderBuffer, s32 StartFrame, s32 EndFrame, rect PanelBounds, mouse_state Mouse, app_state* State)
|
||||||
{
|
{
|
||||||
MakeStringBuffer(TempString, 256);
|
MakeStringBuffer(TempString, 256);
|
||||||
|
|
||||||
|
@ -180,11 +222,10 @@ DrawFrameBar (animation_system* AnimationSystem, render_command_buffer* RenderBu
|
||||||
PushRenderQuad2D(RenderBuffer, FrameBarMin, FrameBarMax, v4{.16f, .16f, .16f, 1.f});
|
PushRenderQuad2D(RenderBuffer, FrameBarMin, FrameBarMax, v4{.16f, .16f, .16f, 1.f});
|
||||||
|
|
||||||
// Mouse clicked inside frame nubmer bar -> change current frame on timeline
|
// Mouse clicked inside frame nubmer bar -> change current frame on timeline
|
||||||
if (MouseButtonHeldDown(Mouse.LeftButtonState)
|
if (MouseButtonTransitionedDown(Mouse.LeftButtonState)
|
||||||
&& PointIsInRange(Mouse.DownPos, FrameBarMin, FrameBarMax))
|
&& PointIsInRange(Mouse.DownPos, FrameBarMin, FrameBarMax))
|
||||||
{
|
{
|
||||||
r32 TimeAtMouseX = GetTimeFromPointInAnimationPanel(Mouse.DownPos, PanelBounds, StartFrame, EndFrame, AnimationSystem->SecondsPerFrame);
|
StartDragTimeMarker(rect{FrameBarMin, FrameBarMax}, StartFrame, EndFrame, State);
|
||||||
AnimationSystem->Time = TimeAtMouseX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Frame Ticks
|
// Frame Ticks
|
||||||
|
@ -196,7 +237,7 @@ DrawFrameBar (animation_system* AnimationSystem, render_command_buffer* RenderBu
|
||||||
r32 FramePercent = (r32)f / (r32)FrameCount;
|
r32 FramePercent = (r32)f / (r32)FrameCount;
|
||||||
r32 FrameX = GSLerp(PanelBounds.Min.x, PanelBounds.Max.x, FramePercent);
|
r32 FrameX = GSLerp(PanelBounds.Min.x, PanelBounds.Max.x, FramePercent);
|
||||||
v2 FrameTextPos = v2{FrameX, FrameBarMin.y + 2};
|
v2 FrameTextPos = v2{FrameX, FrameBarMin.y + 2};
|
||||||
DrawString(RenderBuffer, TempString, Interface.Font, FrameTextPos, WhiteV4);
|
DrawString(RenderBuffer, TempString, State->Interface.Font, FrameTextPos, WhiteV4);
|
||||||
|
|
||||||
// Frame Vertical Slices
|
// Frame Vertical Slices
|
||||||
v2 LineTop = v2{FrameX, FrameBarMin.y};
|
v2 LineTop = v2{FrameX, FrameBarMin.y};
|
||||||
|
@ -256,7 +297,7 @@ DrawAnimationTimeline (animation_system* AnimationSystem, s32 StartFrame, s32 En
|
||||||
PushRenderQuad2D(RenderBuffer, PlayableMin, PlayableMax, v4{.22f, .22f, .22f, 1.f});
|
PushRenderQuad2D(RenderBuffer, PlayableMin, PlayableMax, v4{.22f, .22f, .22f, 1.f});
|
||||||
}
|
}
|
||||||
|
|
||||||
r32 FrameBarBottom = DrawFrameBar(AnimationSystem, RenderBuffer, StartFrame, EndFrame, PanelBounds, State->Interface, Mouse);
|
r32 FrameBarBottom = DrawFrameBar(AnimationSystem, RenderBuffer, StartFrame, EndFrame, PanelBounds, Mouse, State);
|
||||||
|
|
||||||
// Animation Blocks
|
// Animation Blocks
|
||||||
v2 TimelineMin = PanelBounds.Min;
|
v2 TimelineMin = PanelBounds.Min;
|
||||||
|
|
5
todo.txt
5
todo.txt
|
@ -1,10 +1,5 @@
|
||||||
TODO FOLDHAUS
|
TODO FOLDHAUS
|
||||||
|
|
||||||
Animation Timeline
|
|
||||||
- click to drag time marker
|
|
||||||
- drag ends of animation clips to change start and end times
|
|
||||||
-
|
|
||||||
|
|
||||||
Reimplement Node View
|
Reimplement Node View
|
||||||
- probably want to take a fresh pass at nodes all together
|
- probably want to take a fresh pass at nodes all together
|
||||||
|
|
||||||
|
|
|
@ -43,4 +43,8 @@ x go back to calling SpecificationIndex Type
|
||||||
- x connections shouldn't store their own values, they should just point into permanent storage
|
- x connections shouldn't store their own values, they should just point into permanent storage
|
||||||
|
|
||||||
Hardening
|
Hardening
|
||||||
x input context changes
|
x input context changes
|
||||||
|
|
||||||
|
Animation Timeline
|
||||||
|
x drag ends of animation clips to change start and end times
|
||||||
|
x click to drag time marker
|
Loading…
Reference in New Issue