Hot panel is passed to input event handlers
This commit is contained in:
parent
6193af2555
commit
f53becef5b
|
@ -5,7 +5,7 @@
|
||||||
//
|
//
|
||||||
#ifndef FOLDHAUS_COMMAND_DISPATCH_H
|
#ifndef FOLDHAUS_COMMAND_DISPATCH_H
|
||||||
|
|
||||||
#define FOLDHAUS_INPUT_COMMAND_PROC(name) void name(app_state* State, input_entry Event, mouse_state Mouse, context Context)
|
#define FOLDHAUS_INPUT_COMMAND_PROC(name) void name(app_state* State, input_entry Event, mouse_state Mouse, context Context, panel* Panel)
|
||||||
typedef FOLDHAUS_INPUT_COMMAND_PROC(input_command_proc);
|
typedef FOLDHAUS_INPUT_COMMAND_PROC(input_command_proc);
|
||||||
|
|
||||||
// NOTE(Peter): Helper function so I don't have to remember the parameters to this define
|
// NOTE(Peter): Helper function so I don't have to remember the parameters to this define
|
||||||
|
|
|
@ -10,10 +10,13 @@ Editor_HandleInput (app_state* State, rect2 WindowBounds, input_queue InputQueue
|
||||||
{
|
{
|
||||||
DEBUG_TRACK_FUNCTION;
|
DEBUG_TRACK_FUNCTION;
|
||||||
|
|
||||||
|
panel* ActivePanel = PanelSystem_GetPanelContainingPoint(&State->PanelSystem, Mouse.Pos);
|
||||||
b32 PanelSystemHandledInput = HandleMousePanelInteraction(&State->PanelSystem, State->WindowBounds, Mouse, State);
|
b32 PanelSystemHandledInput = HandleMousePanelInteraction(&State->PanelSystem, State->WindowBounds, Mouse, State);
|
||||||
|
|
||||||
if (!PanelSystemHandledInput)
|
if (!PanelSystemHandledInput && ActivePanel)
|
||||||
{
|
{
|
||||||
|
panel_definition ActiveDef = State->PanelSystem.PanelDefs[ActivePanel->TypeIndex];
|
||||||
|
|
||||||
input_command_registry ActiveCommands = {};
|
input_command_registry ActiveCommands = {};
|
||||||
if (State->Modes.ActiveModesCount > 0)
|
if (State->Modes.ActiveModesCount > 0)
|
||||||
{
|
{
|
||||||
|
@ -21,19 +24,15 @@ Editor_HandleInput (app_state* State, rect2 WindowBounds, input_queue InputQueue
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
panel* PanelWithMouseOverIt = PanelSystem_GetPanelContainingPoint(&State->PanelSystem, Mouse.Pos);
|
if (ActiveDef.InputCommands)
|
||||||
if (!PanelWithMouseOverIt) { return; }
|
{
|
||||||
State->HotPanel = PanelWithMouseOverIt;
|
ActiveCommands.Commands = ActiveDef.InputCommands;
|
||||||
|
ActiveCommands.Size = sizeof(*ActiveDef.InputCommands) / sizeof(ActiveDef.InputCommands[0]);
|
||||||
s32 PanelTypeIndex = PanelWithMouseOverIt->TypeIndex;
|
|
||||||
panel_definition PanelDefinition = State->PanelSystem.PanelDefs[PanelTypeIndex];
|
|
||||||
if (!PanelDefinition.InputCommands) { return; }
|
|
||||||
|
|
||||||
ActiveCommands.Commands = PanelDefinition.InputCommands;
|
|
||||||
ActiveCommands.Size = sizeof(*PanelDefinition.InputCommands) / sizeof(PanelDefinition.InputCommands[0]);
|
|
||||||
ActiveCommands.Used = ActiveCommands.Size;
|
ActiveCommands.Used = ActiveCommands.Size;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill up the command queue
|
||||||
for (s32 EventIdx = 0; EventIdx < InputQueue.QueueUsed; EventIdx++)
|
for (s32 EventIdx = 0; EventIdx < InputQueue.QueueUsed; EventIdx++)
|
||||||
{
|
{
|
||||||
input_entry Event = InputQueue.Entries[EventIdx];
|
input_entry Event = InputQueue.Entries[EventIdx];
|
||||||
|
@ -60,7 +59,14 @@ Editor_HandleInput (app_state* State, rect2 WindowBounds, input_queue InputQueue
|
||||||
for (s32 CommandIdx = State->CommandQueue.Used - 1; CommandIdx >= 0; CommandIdx--)
|
for (s32 CommandIdx = State->CommandQueue.Used - 1; CommandIdx >= 0; CommandIdx--)
|
||||||
{
|
{
|
||||||
command_queue_entry* Entry = &State->CommandQueue.Commands[CommandIdx];
|
command_queue_entry* Entry = &State->CommandQueue.Commands[CommandIdx];
|
||||||
Entry->Command.Proc(State, Entry->Event, Mouse, Context);
|
if (Entry->Command.Proc)
|
||||||
|
{
|
||||||
|
Entry->Command.Proc(State, Entry->Event, Mouse, Context, ActivePanel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EndCurrentOperationMode(State);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearCommandQueue(&State->CommandQueue);
|
ClearCommandQueue(&State->CommandQueue);
|
||||||
|
|
|
@ -94,7 +94,6 @@ OPERATION_RENDER_PROC(UpdateAndRenderDragPanelBorder)
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(EndDragPanelBorderOperation)
|
FOLDHAUS_INPUT_COMMAND_PROC(EndDragPanelBorderOperation)
|
||||||
{
|
{
|
||||||
drag_panel_border_operation_state* OpState = GetCurrentOperationState(State->Modes, drag_panel_border_operation_state);
|
drag_panel_border_operation_state* OpState = GetCurrentOperationState(State->Modes, drag_panel_border_operation_state);
|
||||||
panel* Panel = OpState->Panel;
|
|
||||||
rect2 PanelBounds = OpState->InitialPanelBounds;
|
rect2 PanelBounds = OpState->InitialPanelBounds;
|
||||||
|
|
||||||
if (OpState->PanelEditMode == PanelEdit_Modify)
|
if (OpState->PanelEditMode == PanelEdit_Modify)
|
||||||
|
@ -224,7 +223,6 @@ OPERATION_RENDER_PROC(UpdateAndRenderSplitPanel)
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(EndSplitPanelOperation)
|
FOLDHAUS_INPUT_COMMAND_PROC(EndSplitPanelOperation)
|
||||||
{
|
{
|
||||||
split_panel_operation_state* OpState = GetCurrentOperationState(State->Modes, split_panel_operation_state);
|
split_panel_operation_state* OpState = GetCurrentOperationState(State->Modes, split_panel_operation_state);
|
||||||
panel* Panel = OpState->Panel;
|
|
||||||
rect2 PanelBounds = OpState->InitialPanelBounds;
|
rect2 PanelBounds = OpState->InitialPanelBounds;
|
||||||
|
|
||||||
r32 XDistance = Abs(Mouse.Pos.x - Mouse.DownPos.x);
|
r32 XDistance = Abs(Mouse.Pos.x - Mouse.DownPos.x);
|
||||||
|
|
|
@ -45,7 +45,6 @@ AddAnimationBlockAtCurrentTime (u32 AnimationProcHandle, u32 LayerHandle, animat
|
||||||
|
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(DeleteAnimationBlockCommand)
|
FOLDHAUS_INPUT_COMMAND_PROC(DeleteAnimationBlockCommand)
|
||||||
{
|
{
|
||||||
panel* Panel = PanelSystem_GetPanelContainingPoint(&State->PanelSystem, Context.Mouse.Pos);
|
|
||||||
animation_timeline_state* PanelState = Panel_GetStateStruct(Panel, animation_timeline_state);
|
animation_timeline_state* PanelState = Panel_GetStateStruct(Panel, animation_timeline_state);
|
||||||
|
|
||||||
handle SelectedBlockHandle = PanelState->SelectedBlockHandle;
|
handle SelectedBlockHandle = PanelState->SelectedBlockHandle;
|
||||||
|
@ -153,7 +152,7 @@ OPERATION_RENDER_PROC(UpdateDragAnimationClip)
|
||||||
animation_block* AnimationBlock = Animation_GetBlockFromHandle(ActiveAnim, OpState->BlockHandle);
|
animation_block* AnimationBlock = Animation_GetBlockFromHandle(ActiveAnim, OpState->BlockHandle);
|
||||||
if (!AnimationBlock)
|
if (!AnimationBlock)
|
||||||
{
|
{
|
||||||
EndCurrentOperationMode(State, {}, Mouse, Context);
|
EndCurrentOperationMode(State);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +229,7 @@ OPERATION_RENDER_PROC(UpdateDragAnimationClip)
|
||||||
}
|
}
|
||||||
|
|
||||||
input_command DragAnimationClipCommands [] = {
|
input_command DragAnimationClipCommands [] = {
|
||||||
{ KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Ended, EndCurrentOperationMode },
|
{ KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Ended, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
|
@ -255,7 +254,6 @@ SelectAndBeginDragAnimationBlock(animation_timeline_state* TimelineState, handle
|
||||||
|
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(AddAnimationBlockCommand)
|
FOLDHAUS_INPUT_COMMAND_PROC(AddAnimationBlockCommand)
|
||||||
{
|
{
|
||||||
panel* Panel = PanelSystem_GetPanelContainingPoint(&State->PanelSystem, Context.Mouse.Pos);
|
|
||||||
animation_timeline_state* TimelineState = Panel_GetStateStruct(Panel, animation_timeline_state);
|
animation_timeline_state* TimelineState = Panel_GetStateStruct(Panel, animation_timeline_state);
|
||||||
|
|
||||||
animation* ActiveAnim = AnimationSystem_GetActiveAnimation(&State->AnimationSystem);
|
animation* ActiveAnim = AnimationSystem_GetActiveAnimation(&State->AnimationSystem);
|
||||||
|
|
|
@ -42,7 +42,6 @@ input_command MouseRotateViewCommands [] = {
|
||||||
|
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(Begin3DViewMouseRotate)
|
FOLDHAUS_INPUT_COMMAND_PROC(Begin3DViewMouseRotate)
|
||||||
{
|
{
|
||||||
panel* Panel = PanelSystem_GetPanelContainingPoint(&State->PanelSystem, Context.Mouse.DownPos);
|
|
||||||
sculpture_view_panel_state* PanelState = Panel_GetStateStruct(Panel, sculpture_view_panel_state);
|
sculpture_view_panel_state* PanelState = Panel_GetStateStruct(Panel, sculpture_view_panel_state);
|
||||||
|
|
||||||
operation_mode* RotateViewMode = ActivateOperationModeWithCommands(&State->Modes, MouseRotateViewCommands, Update3DViewMouseRotate);
|
operation_mode* RotateViewMode = ActivateOperationModeWithCommands(&State->Modes, MouseRotateViewCommands, Update3DViewMouseRotate);
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
typedef struct app_state app_state;
|
typedef struct app_state app_state;
|
||||||
|
|
||||||
|
typedef struct panel panel;
|
||||||
|
|
||||||
#include "editor/foldhaus_command_dispatch.h"
|
#include "editor/foldhaus_command_dispatch.h"
|
||||||
#include "editor/foldhaus_operation_mode.h"
|
#include "editor/foldhaus_operation_mode.h"
|
||||||
|
|
||||||
|
@ -201,7 +203,8 @@ TestPatternThree(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena*
|
||||||
|
|
||||||
// END TEMPORARY PATTERNS
|
// END TEMPORARY PATTERNS
|
||||||
|
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(EndCurrentOperationMode)
|
internal void
|
||||||
|
EndCurrentOperationMode(app_state* State)
|
||||||
{
|
{
|
||||||
DeactivateCurrentOperationMode(&State->Modes);
|
DeactivateCurrentOperationMode(&State->Modes);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue