Cleaned up panel event handling

This commit is contained in:
PS 2020-11-07 23:50:41 -08:00
parent f53becef5b
commit a42d2e81c5
1 changed files with 15 additions and 10 deletions

View File

@ -10,10 +10,10 @@ Editor_HandleInput (app_state* State, rect2 WindowBounds, input_queue InputQueue
{
DEBUG_TRACK_FUNCTION;
panel* ActivePanel = PanelSystem_GetPanelContainingPoint(&State->PanelSystem, Mouse.Pos);
b32 PanelSystemHandledInput = HandleMousePanelInteraction(&State->PanelSystem, State->WindowBounds, Mouse, State);
b32 MouseInputHandled = HandleMousePanelInteraction(&State->PanelSystem, State->WindowBounds, Mouse, State);
if (!PanelSystemHandledInput && ActivePanel)
panel* ActivePanel = PanelSystem_GetPanelContainingPoint(&State->PanelSystem, Mouse.Pos);
if (ActivePanel)
{
panel_definition ActiveDef = State->PanelSystem.PanelDefs[ActivePanel->TypeIndex];
@ -22,14 +22,11 @@ Editor_HandleInput (app_state* State, rect2 WindowBounds, input_queue InputQueue
{
ActiveCommands = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1].Commands;
}
else
else if (ActiveDef.InputCommands)
{
if (ActiveDef.InputCommands)
{
ActiveCommands.Commands = ActiveDef.InputCommands;
ActiveCommands.Size = sizeof(*ActiveDef.InputCommands) / sizeof(ActiveDef.InputCommands[0]);
ActiveCommands.Used = ActiveCommands.Size;
}
ActiveCommands.Commands = ActiveDef.InputCommands;
ActiveCommands.Size = sizeof(*ActiveDef.InputCommands) / sizeof(ActiveDef.InputCommands[0]);
ActiveCommands.Used = ActiveCommands.Size;
}
// Fill up the command queue
@ -37,6 +34,14 @@ Editor_HandleInput (app_state* State, rect2 WindowBounds, input_queue InputQueue
{
input_entry Event = InputQueue.Entries[EventIdx];
bool IsMouseEvent = (Event.Key == KeyCode_MouseLeftButton ||
Event.Key == KeyCode_MouseMiddleButton ||
Event.Key == KeyCode_MouseRightButton);
if (IsMouseEvent && MouseInputHandled)
{
continue;
}
// NOTE(Peter): These are in the order Down, Up, Held because we want to privalege
// Down and Up over Held. In other words, we don't want to call a Held command on the
// frame when the button was released, even if the command is registered to both events