Moved node view over to mode system!

This commit is contained in:
Peter Slattery 2019-11-01 07:38:44 -07:00
parent a889deaa98
commit 613be64f41
9 changed files with 170 additions and 142 deletions

View File

@ -354,8 +354,7 @@ RELOAD_STATIC_DATA(ReloadStaticData)
CameraMouseControl); CameraMouseControl);
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_U, false, KeyCode_Invalid, OpenUniverseView); RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_U, false, KeyCode_Invalid, OpenUniverseView);
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_A, false, KeyCode_Invalid, OpenNodeLister); RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_A, false, KeyCode_Invalid, OpenNodeLister);
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_Tab, false, KeyCode_Invalid, ToggleNodeDisplay); RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_Tab, false, KeyCode_Invalid, OpenNodeView);
// Node Lister // Node Lister
RegisterKeyPressCommand(&State->NodeListerCommandRegistry, KeyCode_DownArrow, false, KeyCode_Invalid, NodeListerNextItem); RegisterKeyPressCommand(&State->NodeListerCommandRegistry, KeyCode_DownArrow, false, KeyCode_Invalid, NodeListerNextItem);
@ -478,14 +477,6 @@ INITIALIZE_APPLICATION(InitializeApplication)
State->NodeList = AllocateNodeList(State->Permanent, Kilobytes(64)); State->NodeList = AllocateNodeList(State->Permanent, Kilobytes(64));
State->NodeInteraction = NewEmptyNodeInteraction();
State->NodeRenderSettings.PortDim = v2{20, 15};
State->NodeRenderSettings.PortStep = State->NodeRenderSettings.PortDim.y + 10;
State->NodeRenderSettings.PortColors[MemberType_r32] = RedV4;
State->NodeRenderSettings.PortColors[MemberType_s32] = GreenV4;
State->NodeRenderSettings.PortColors[MemberType_v4] = BlueV4;
State->NodeRenderSettings.Font = State->Font;
State->OutputNode = PushOutputNodeOnList(State->NodeList, v2{500, 250}, State->Permanent); State->OutputNode = PushOutputNodeOnList(State->NodeList, v2{500, 250}, State->Permanent);
InitializeEmptyString(&State->GeneralPurposeSearchString, PushArray(State->Permanent, char, 256), 256); InitializeEmptyString(&State->GeneralPurposeSearchString, PushArray(State->Permanent, char, 256), 256);
@ -511,13 +502,6 @@ UPDATE_AND_RENDER(UpdateAndRender)
// incorrect to clear the arena, and then access the memory later. // incorrect to clear the arena, and then access the memory later.
ClearArena(State->Transient); ClearArena(State->Transient);
// NOTE(Peter): Input Handling
gui_mouse GuiMouse = {};
GuiMouse.Pos = Mouse.Pos;
GuiMouse.OldPos = Mouse.OldPos;
GuiMouse.DeltaPos = Mouse.DeltaPos;
GuiMouse.DownPos = Mouse.DownPos;
{ {
input_command_registry* ActiveCommands = State->ActiveCommands; input_command_registry* ActiveCommands = State->ActiveCommands;
if (State->Modes.ActiveModesCount > 0) if (State->Modes.ActiveModesCount > 0)
@ -552,18 +536,18 @@ UPDATE_AND_RENDER(UpdateAndRender)
if (Event.Key == KeyCode_MouseLeftButton) if (Event.Key == KeyCode_MouseLeftButton)
{ {
GuiMouse.LeftButtonTransitionedDown = KeyTransitionedDown(Event); Mouse.LeftButtonTransitionedDown = KeyTransitionedDown(Event);
GuiMouse.LeftButtonTransitionedUp = KeyTransitionedUp(Event); Mouse.LeftButtonTransitionedUp = KeyTransitionedUp(Event);
} }
else if (Event.Key == KeyCode_MouseMiddleButton) else if (Event.Key == KeyCode_MouseMiddleButton)
{ {
GuiMouse.MiddleButtonTransitionedDown = KeyTransitionedDown(Event); Mouse.MiddleButtonTransitionedDown = KeyTransitionedDown(Event);
GuiMouse.MiddleButtonTransitionedUp = KeyTransitionedUp(Event); Mouse.MiddleButtonTransitionedUp = KeyTransitionedUp(Event);
} }
else if (Event.Key == KeyCode_MouseRightButton) else if (Event.Key == KeyCode_MouseRightButton)
{ {
GuiMouse.RightButtonTransitionedDown = KeyTransitionedDown(Event); Mouse.RightButtonTransitionedDown = KeyTransitionedDown(Event);
GuiMouse.RightButtonTransitionedUp = KeyTransitionedUp(Event); Mouse.RightButtonTransitionedUp = KeyTransitionedUp(Event);
} }
} }
@ -730,7 +714,7 @@ UPDATE_AND_RENDER(UpdateAndRender)
v2 ButtonPos = v2{State->Interface.Margin.x, Context.WindowHeight - (ButtonDim.y + 10)}; v2 ButtonPos = v2{State->Interface.Margin.x, Context.WindowHeight - (ButtonDim.y + 10)};
button_result LoadAssemblyBtn = EvaluateButton(RenderBuffer, ButtonPos, ButtonPos + ButtonDim, button_result LoadAssemblyBtn = EvaluateButton(RenderBuffer, ButtonPos, ButtonPos + ButtonDim,
MakeStringLiteral("Load Assembly"), MakeStringLiteral("Load Assembly"),
State->Interface, GuiMouse); State->Interface, Mouse);
string InterfaceString = MakeString(PushArray(State->Transient, char, 256), 256); string InterfaceString = MakeString(PushArray(State->Transient, char, 256), 256);
for (int i = 0; i < State->AssembliesUsed; i++) for (int i = 0; i < State->AssembliesUsed; i++)
@ -739,7 +723,7 @@ UPDATE_AND_RENDER(UpdateAndRender)
ButtonPos.x += ButtonDim.x + 10; ButtonPos.x += ButtonDim.x + 10;
button_result UnloadAssemblyBtn = EvaluateButton(RenderBuffer, ButtonPos, ButtonPos + ButtonDim, button_result UnloadAssemblyBtn = EvaluateButton(RenderBuffer, ButtonPos, ButtonPos + ButtonDim,
InterfaceString, State->Interface, GuiMouse); InterfaceString, State->Interface, Mouse);
if (UnloadAssemblyBtn.Pressed) if (UnloadAssemblyBtn.Pressed)
{ {
@ -762,75 +746,21 @@ UPDATE_AND_RENDER(UpdateAndRender)
// Figuring Out Nodes // Figuring Out Nodes
////////////////////////////////////// //////////////////////////////////////
if (GuiMouse.LeftButtonTransitionedDown) //NodeViewMousePickNode(State, {}, Mouse);
{ //RenderNodeView(State, RenderBuffer, {}, Mouse);
node_offset Node = GetNodeUnderPoint(State->NodeList, GuiMouse.Pos, State->NodeRenderSettings);
if (Node.Node)
{
State->NodeInteraction = GetNodeInteractionType(Node.Node, Node.Offset, GuiMouse.Pos, State->NodeRenderSettings);
}
}
else if (GuiMouse.LeftButtonTransitionedUp)
{
if (IsDraggingNodePort(State->NodeInteraction))
{
TryConnectNodes(State->NodeInteraction, GuiMouse.Pos, State->NodeList, State->NodeRenderSettings);
State->NodeInteraction = NewEmptyNodeInteraction();
}
else if(IsDraggingNodeValue(State->NodeInteraction))
{
// This is just a click
if (Mag(Mouse.DeltaPos) < 10)
{
node_interaction Interaction = State->NodeInteraction;
interface_node* Node = GetNodeAtOffset(State->NodeList, Interaction.NodeOffset);
node_connection* Connection = Node->Connections + Interaction.InputValue;
struct_member_type InputType = Connection->Type;
if (InputType == MemberType_r32)
{
SetTextInputDestinationToFloat(&State->ActiveTextEntry, &Connection->R32Value);
// TODO(Peter): This is wrong, should be something to do with capturing text input
State->ActiveCommands = &State->NodeListerCommandRegistry;
}
State->NodeInteraction = NewEmptyNodeInteraction();
}
else // This is the case where you dragged the value
{
State->NodeInteraction = NewEmptyNodeInteraction();
}
}
else
{
State->NodeInteraction = NewEmptyNodeInteraction();
}
}
UpdateDraggingNode(Mouse.Pos, State->NodeInteraction, State->NodeList,
State->NodeRenderSettings);
UpdateDraggingNodePort(Mouse.Pos, State->NodeInteraction, State->NodeList,
State->NodeRenderSettings, RenderBuffer);
UpdateDraggingNodeValue(Mouse.Pos, Mouse.OldPos, State->NodeInteraction, State->NodeList, State->NodeRenderSettings, State);
ResetNodesUpdateState(State->NodeList);
if (State->NodeRenderSettings.Display)
{
RenderNodeList(State->NodeList, State->NodeRenderSettings, RenderBuffer);
}
for (s32 m = 0; m < State->Modes.ActiveModesCount; m++) for (s32 m = 0; m < State->Modes.ActiveModesCount; m++)
{ {
operation_mode OperationMode = State->Modes.ActiveModes[m]; operation_mode OperationMode = State->Modes.ActiveModes[m];
if (OperationMode.Render != 0) if (OperationMode.Render != 0)
{ {
OperationMode.Render(State, RenderBuffer, OperationMode, GuiMouse); OperationMode.Render(State, RenderBuffer, OperationMode, Mouse);
} }
} }
DrawDebugInterface(RenderBuffer, 25, DrawDebugInterface(RenderBuffer, 25,
State->Interface, Context.WindowWidth, Context.WindowHeight - TopBarHeight, State->Interface, Context.WindowWidth, Context.WindowHeight - TopBarHeight,
Context.DeltaTime, State, State->Camera, GuiMouse, State->Transient); Context.DeltaTime, State, State->Camera, Mouse, State->Transient);
} }
EndDebugFrame(GlobalDebugServices); EndDebugFrame(GlobalDebugServices);

View File

@ -98,10 +98,12 @@ struct app_state
v4 Camera_StartDragPos; v4 Camera_StartDragPos;
node_list* NodeList; node_list* NodeList;
node_interaction NodeInteraction;
node_render_settings NodeRenderSettings;
interface_node* OutputNode; interface_node* OutputNode;
node_render_settings NodeRenderSettings;
string GeneralPurposeSearchString; string GeneralPurposeSearchString;
}; };

View File

@ -1,5 +1,5 @@
internal void internal void
DrawDebugInterface (render_command_buffer* RenderBuffer, r32 StartX, interface_config Interface, r32 WindowWidth, r32 WindowHeight, r32 DeltaTime, app_state* State, camera Camera, gui_mouse Mouse, memory_arena* Transient) DrawDebugInterface (render_command_buffer* RenderBuffer, r32 StartX, interface_config Interface, r32 WindowWidth, r32 WindowHeight, r32 DeltaTime, app_state* State, camera Camera, mouse_state Mouse, memory_arena* Transient)
{ {
DEBUG_TRACK_SCOPE(DrawDebugInterface); DEBUG_TRACK_SCOPE(DrawDebugInterface);

View File

@ -1,7 +1,5 @@
FOLDHAUS_INPUT_COMMAND_PROC(CameraMouseControl) FOLDHAUS_INPUT_COMMAND_PROC(CameraMouseControl)
{ {
if (State->NodeInteraction.NodeOffset >= 0) { return; }
if (KeyTransitionedDown(Event)) if (KeyTransitionedDown(Event))
{ {
State->Camera_StartDragPos = V4(State->Camera.Position, 1); State->Camera_StartDragPos = V4(State->Camera.Position, 1);
@ -16,11 +14,6 @@ FOLDHAUS_INPUT_COMMAND_PROC(CameraMouseControl)
State->Camera.Position = V3(Combined * State->Camera_StartDragPos); State->Camera.Position = V3(Combined * State->Camera_StartDragPos);
} }
FOLDHAUS_INPUT_COMMAND_PROC(ToggleNodeDisplay)
{
State->NodeRenderSettings.Display = !State->NodeRenderSettings.Display;
}
//////////////////////////////////////// ////////////////////////////////////////
// //
// Universe View // Universe View
@ -38,8 +31,7 @@ OPERATION_RENDER_PROC(RenderUniverseView)
DEBUG_TRACK_SCOPE(DrawUniverseOutputDisplay); DEBUG_TRACK_SCOPE(DrawUniverseOutputDisplay);
// TODO(Peter): Pass this in as a parameter // TODO(Peter): Pass this in as a parameter
operation_mode Mode = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1]; universe_view_operation_state* OpState = (universe_view_operation_state*)Operation.OpStateMemory;
universe_view_operation_state* OpState = (universe_view_operation_state*)Mode.OpStateMemory;
string TitleBarString = InitializeEmptyString(PushArray(State->Transient, char, 64), 64); string TitleBarString = InitializeEmptyString(PushArray(State->Transient, char, 64), 64);
@ -162,7 +154,7 @@ OPERATION_RENDER_PROC(RenderNodeLister)
OpState->SearchLister.HotItem, OpState->SearchLister.HotItem,
&State->ActiveTextEntry.Buffer, &State->ActiveTextEntry.Buffer,
State->ActiveTextEntry.CursorPosition, State->ActiveTextEntry.CursorPosition,
State->Font, State->Interface, GuiMouse); State->Font, State->Interface, Mouse);
} }
FOLDHAUS_INPUT_COMMAND_PROC(NodeListerNextItem) FOLDHAUS_INPUT_COMMAND_PROC(NodeListerNextItem)
@ -195,7 +187,7 @@ FOLDHAUS_INPUT_COMMAND_PROC(SelectAndCloseNodeLister)
s32 FilteredNodeIndex = OpState->SearchLister.HotItem; s32 FilteredNodeIndex = OpState->SearchLister.HotItem;
s32 NodeIndex = OpState->SearchLister.FilteredIndexLUT[FilteredNodeIndex]; s32 NodeIndex = OpState->SearchLister.FilteredIndexLUT[FilteredNodeIndex];
PushNodeOnListFromSpecification(State->NodeList, NodeSpecifications[NodeIndex], PushNodeOnListFromSpecification(State->NodeList, NodeSpecifications[NodeIndex],
Mouse.Pos, State->NodeRenderSettings, State->Permanent); Mouse.Pos, State->Permanent);
CloseNodeLister(State, Event, Mouse); CloseNodeLister(State, Event, Mouse);
} }
@ -262,12 +254,11 @@ CloseColorPicker(app_state* State)
OPERATION_RENDER_PROC(RenderColorPicker) OPERATION_RENDER_PROC(RenderColorPicker)
{ {
// TODO(Peter): Pass this in as a parameter // TODO(Peter): Pass this in as a parameter
operation_mode Mode = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1]; color_picker_operation_state* OpState = (color_picker_operation_state*)Operation.OpStateMemory;
color_picker_operation_state* OpState = (color_picker_operation_state*)Mode.OpStateMemory;
b32 ShouldClose = EvaluateColorPicker(RenderBuffer, OpState->ValueAddr, b32 ShouldClose = EvaluateColorPicker(RenderBuffer, OpState->ValueAddr,
v2{200, 200}, State->Interface, GuiMouse); v2{200, 200}, State->Interface, Mouse);
if (ShouldClose) if (ShouldClose)
{ {
@ -287,3 +278,113 @@ OpenColorPicker(app_state* State, v4* ValueAddr)
color_picker_operation_state); color_picker_operation_state);
OpState->ValueAddr = ValueAddr; OpState->ValueAddr = ValueAddr;
} }
////////////////////////////////////////
//
// Node View
//
///////////////////////////////////////
struct node_view_operation_state
{
node_interaction Interaction;
node_render_settings RenderSettings;
};
FOLDHAUS_INPUT_COMMAND_PROC(NodeViewMousePickNode)
{
// TODO(Peter): Pass this in as a parameter
operation_mode Mode = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1];
node_view_operation_state* OpState = (node_view_operation_state*)Mode.OpStateMemory;
if (Mouse.LeftButtonTransitionedDown)
{
node_offset Node = GetNodeUnderPoint(State->NodeList, Mouse.Pos, OpState->RenderSettings);
if (Node.Node)
{
OpState->Interaction = GetNodeInteractionType(Node.Node, Node.Offset, Mouse.Pos, OpState->RenderSettings);
}
}
else if (Mouse.LeftButtonTransitionedUp)
{
if (IsDraggingNodePort(OpState->Interaction))
{
TryConnectNodes(OpState->Interaction, Mouse.Pos, State->NodeList, OpState->RenderSettings);
OpState->Interaction = NewEmptyNodeInteraction();
}
else if(IsDraggingNodeValue(OpState->Interaction))
{
// This is just a click
if (Mag(Mouse.DeltaPos) < 10)
{
node_interaction Interaction = OpState->Interaction;
interface_node* Node = GetNodeAtOffset(State->NodeList, Interaction.NodeOffset);
node_connection* Connection = Node->Connections + Interaction.InputValue;
struct_member_type InputType = Connection->Type;
if (InputType == MemberType_r32)
{
SetTextInputDestinationToFloat(&State->ActiveTextEntry, &Connection->R32Value);
// TODO(Peter): This is wrong, should be something to do with capturing text input
State->ActiveCommands = &State->NodeListerCommandRegistry;
}
OpState->Interaction = NewEmptyNodeInteraction();
}
else // This is the case where you dragged the value
{
OpState->Interaction = NewEmptyNodeInteraction();
}
}
else
{
OpState->Interaction = NewEmptyNodeInteraction();
}
}
}
OPERATION_RENDER_PROC(RenderNodeView)
{
// TODO(Peter): Pass this in as a parameter
node_view_operation_state* OpState = (node_view_operation_state*)Operation.OpStateMemory;
UpdateDraggingNode(Mouse.Pos, OpState->Interaction, State->NodeList,
OpState->RenderSettings);
UpdateDraggingNodePort(Mouse.Pos, OpState->Interaction, State->NodeList,
OpState->RenderSettings, RenderBuffer);
UpdateDraggingNodeValue(Mouse.Pos, Mouse.OldPos, OpState->Interaction, State->NodeList, OpState->RenderSettings, State);
ResetNodesUpdateState(State->NodeList);
RenderNodeList(State->NodeList, OpState->RenderSettings, RenderBuffer);
}
FOLDHAUS_INPUT_COMMAND_PROC(CloseNodeView)
{
DeactivateCurrentOperationMode(&State->Modes);
}
FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeView)
{
// TODO(Peter): This won't work with hot code reloading
operation_mode* NodeViewMode = ActivateOperationMode(&State->Modes);
NodeViewMode->Render = RenderNodeView;
{ // Mode Commands
InitializeInputCommandRegistry(&NodeViewMode->Commands, 3, &State->Modes.Arena);
RegisterKeyPressCommand(&NodeViewMode->Commands, KeyCode_Tab, false, KeyCode_Invalid, CloseNodeView);
RegisterKeyPressCommand(&NodeViewMode->Commands, KeyCode_A, false, KeyCode_Invalid, OpenNodeLister);
RegisterKeyPressCommand(&NodeViewMode->Commands, KeyCode_MouseLeftButton, true, KeyCode_Invalid,
NodeViewMousePickNode);
}
node_view_operation_state* OpState = CreateOperationState(NodeViewMode,
&State->Modes,
node_view_operation_state);
OpState->Interaction = NewEmptyNodeInteraction();
OpState->RenderSettings.PortColors[MemberType_r32] = RedV4;
OpState->RenderSettings.PortColors[MemberType_s32] = GreenV4;
OpState->RenderSettings.PortColors[MemberType_v4] = BlueV4;
OpState->RenderSettings.Font = State->Font;
}

View File

@ -126,17 +126,17 @@ InitializeNodeConnection (node_connection* Connection, struct_member_type Type,
} }
} }
internal r32 inline r32
CalculateNodeHeight (s32 Members, node_render_settings RenderSettings) CalculateNodeHeight (s32 Members)
{ {
r32 Result = (RenderSettings.PortStep * Members) + NODE_HEADER_HEIGHT; r32 Result = (NODE_PORT_STEP * Members) + NODE_HEADER_HEIGHT;
return Result; return Result;
} }
internal void internal void
PushNodeOnListFromSpecification (node_list* List, node_specification Spec, v2 Min, node_render_settings RenderSettings, memory_arena* Storage) PushNodeOnListFromSpecification (node_list* List, node_specification Spec, v2 Min, memory_arena* Storage)
{ {
r32 NodeHeight = CalculateNodeHeight (Spec.MemberListLength, RenderSettings); r32 NodeHeight = CalculateNodeHeight (Spec.MemberListLength);
interface_node* Node = PushNodeOnList(List, interface_node* Node = PushNodeOnList(List,
Spec.NameLength, Spec.NameLength,
Spec.MemberListLength, Spec.MemberListLength,
@ -207,8 +207,8 @@ CalculateNodeInputPortBounds (interface_node* Node, s32 Index, node_render_setti
Result.Min = v2{ Result.Min = v2{
Node->Min.x, Node->Min.x,
Node->Min.y + Node->Dim.y - ((RenderSettings.PortStep * (Index + 1)) + NODE_HEADER_HEIGHT)}; Node->Min.y + Node->Dim.y - ((NODE_PORT_STEP * (Index + 1)) + NODE_HEADER_HEIGHT)};
Result.Max = Result.Min + RenderSettings.PortDim; Result.Max = Result.Min + NODE_PORT_DIM;
return Result; return Result;
} }
@ -219,7 +219,7 @@ CalculateNodeInputValueBounds (interface_node* Node, s32 Index, node_render_sett
rect Result = {}; rect Result = {};
rect Port = CalculateNodeInputPortBounds(Node, Index, RenderSettings); rect Port = CalculateNodeInputPortBounds(Node, Index, RenderSettings);
Result.Min = v2{Port.Max.x, Port.Min.y}; Result.Min = v2{Port.Max.x, Port.Min.y};
Result.Max = Result.Min + v2{RenderSettings.PortDim.x * 2, RenderSettings.PortDim.y}; Result.Max = Result.Min + v2{NODE_PORT_DIM.x * 2, NODE_PORT_DIM.y};
return Result; return Result;
} }
@ -228,9 +228,9 @@ CalculateNodeOutputPortBounds (interface_node* Node, s32 Index, node_render_sett
{ {
rect Result = {}; rect Result = {};
Result.Min = v2{ Result.Min = v2{
Node->Min.x + Node->Dim.x - RenderSettings.PortDim.x, Node->Min.x + Node->Dim.x - NODE_PORT_DIM.x,
Node->Min.y + Node->Dim.y - ((RenderSettings.PortStep * (Index + 1)) + NODE_HEADER_HEIGHT)}; Node->Min.y + Node->Dim.y - ((NODE_PORT_STEP * (Index + 1)) + NODE_HEADER_HEIGHT)};
Result.Max = Result.Min + RenderSettings.PortDim; Result.Max = Result.Min + NODE_PORT_DIM;
return Result; return Result;
} }
@ -239,7 +239,7 @@ CalculateNodeOutputValueBounds (interface_node* Node, s32 Index, node_render_set
{ {
rect Result = {}; rect Result = {};
rect Port = CalculateNodeOutputPortBounds(Node, Index, RenderSettings); rect Port = CalculateNodeOutputPortBounds(Node, Index, RenderSettings);
Result.Min = v2{Port.Min.x - (RenderSettings.PortDim.x * 2), Port.Min.y}; Result.Min = v2{Port.Min.x - (NODE_PORT_DIM.x * 2), Port.Min.y};
Result.Max = v2{Port.Min.x, Port.Max.y}; Result.Max = v2{Port.Min.x, Port.Max.y};
return Result; return Result;
} }

View File

@ -154,8 +154,6 @@ struct node_specification
struct node_render_settings struct node_render_settings
{ {
v2 PortDim;
r32 PortStep;
v4 PortColors[MemberTypeCount]; v4 PortColors[MemberTypeCount];
bitmap_font* Font; bitmap_font* Font;
b32 Display; b32 Display;
@ -169,6 +167,11 @@ v4 DragButtonColors[] = {
#define NODE_HEADER_HEIGHT 20 #define NODE_HEADER_HEIGHT 20
#define NODE_PORT_X 20
#define NODE_PORT_Y 15
#define NODE_PORT_DIM v2{NODE_PORT_X, NODE_PORT_Y}
#define NODE_PORT_STEP NODE_PORT_Y + 20
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Pre Processor Macros // Pre Processor Macros
/////////////////////////////////////////////// ///////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
typedef struct operation_mode operation_mode; typedef struct operation_mode operation_mode;
#define OPERATION_RENDER_PROC(name) void name(app_state* State, render_command_buffer* RenderBuffer, operation_mode Operation, gui_mouse GuiMouse) #define OPERATION_RENDER_PROC(name) void name(app_state* State, render_command_buffer* RenderBuffer, operation_mode Operation, mouse_state Mouse)
typedef OPERATION_RENDER_PROC(operation_render_proc); typedef OPERATION_RENDER_PROC(operation_render_proc);
struct operation_mode struct operation_mode

View File

@ -28,8 +28,14 @@ struct mouse_state
v2 Pos; v2 Pos;
v2 OldPos; v2 OldPos;
v2 DeltaPos; v2 DeltaPos;
v2 DownPos; v2 DownPos;
b32 LeftButtonTransitionedDown;
b32 LeftButtonTransitionedUp;
b32 MiddleButtonTransitionedDown;
b32 MiddleButtonTransitionedUp;
b32 RightButtonTransitionedDown;
b32 RightButtonTransitionedUp;
}; };
internal input_queue internal input_queue

View File

@ -1,17 +1,3 @@
struct gui_mouse
{
v2 Pos;
v2 OldPos;
v2 DeltaPos;
v2 DownPos;
b32 LeftButtonTransitionedDown;
b32 LeftButtonTransitionedUp;
b32 MiddleButtonTransitionedDown;
b32 MiddleButtonTransitionedUp;
b32 RightButtonTransitionedDown;
b32 RightButtonTransitionedUp;
};
internal v2 internal v2
DrawCharacter (render_quad_batch_constructor* BatchConstructor, char C, bitmap_font Font, v2 Position, v4 Color, r32 FontScale) DrawCharacter (render_quad_batch_constructor* BatchConstructor, char C, bitmap_font Font, v2 Position, v4 Color, r32 FontScale)
{ {
@ -129,7 +115,7 @@ internal button_result
EvaluateButton (render_command_buffer* RenderBuffer, EvaluateButton (render_command_buffer* RenderBuffer,
v2 Min, v2 Max, v2 Margin, string Label, v2 Min, v2 Max, v2 Margin, string Label,
v4 IdleBGColor, v4 HotBGColor, v4 IdleTextColor, v4 HotTextColor, v4 IdleBGColor, v4 HotBGColor, v4 IdleTextColor, v4 HotTextColor,
bitmap_font* Font, gui_mouse Mouse) bitmap_font* Font, mouse_state Mouse)
{ {
button_result Result = {}; button_result Result = {};
Result.Pressed = false; Result.Pressed = false;
@ -158,7 +144,7 @@ EvaluateButton (render_command_buffer* RenderBuffer,
} }
internal button_result internal button_result
EvaluateButton (render_command_buffer* RenderBuffer, v2 Min, v2 Max, string Label, interface_config Config, gui_mouse Mouse) EvaluateButton (render_command_buffer* RenderBuffer, v2 Min, v2 Max, string Label, interface_config Config, mouse_state Mouse)
{ {
button_result Result = EvaluateButton(RenderBuffer, button_result Result = EvaluateButton(RenderBuffer,
Min, Max, Config.Margin, Label, Min, Max, Config.Margin, Label,
@ -169,7 +155,7 @@ EvaluateButton (render_command_buffer* RenderBuffer, v2 Min, v2 Max, string Labe
} }
internal button_result internal button_result
EvaluateSelectableButton (render_command_buffer* RenderBuffer, v2 Min, v2 Max, string Label, interface_config Config, gui_mouse Mouse, b32 Selected) EvaluateSelectableButton (render_command_buffer* RenderBuffer, v2 Min, v2 Max, string Label, interface_config Config, mouse_state Mouse, b32 Selected)
{ {
v4 BGColor = Config.ButtonColor_Inactive; v4 BGColor = Config.ButtonColor_Inactive;
if (Selected) if (Selected)
@ -195,7 +181,7 @@ struct multi_option_label_result
internal multi_option_label_result internal multi_option_label_result
EvaluateMultiOptionLabel (render_command_buffer* RenderBuffer, EvaluateMultiOptionLabel (render_command_buffer* RenderBuffer,
v2 Min, v2 Max, string Label, string Options[], v2 Min, v2 Max, string Label, string Options[],
interface_config Config, gui_mouse Mouse) interface_config Config, mouse_state Mouse)
{ {
multi_option_label_result Result = {}; multi_option_label_result Result = {};
Result.Pressed = false; Result.Pressed = false;
@ -225,7 +211,7 @@ EvaluateMultiOptionLabel (render_command_buffer* RenderBuffer,
// to one of its options // to one of its options
internal multi_option_label_result internal multi_option_label_result
EvaluateMultiOptionButton (render_command_buffer* RenderBuffer, v2 Min, v2 Max, string Text, string Options[], b32 Selected, EvaluateMultiOptionButton (render_command_buffer* RenderBuffer, v2 Min, v2 Max, string Text, string Options[], b32 Selected,
interface_config Config, gui_mouse Mouse) interface_config Config, mouse_state Mouse)
{ {
multi_option_label_result Result = {}; multi_option_label_result Result = {};
Result.Pressed = false; Result.Pressed = false;
@ -268,7 +254,7 @@ struct slider_result
}; };
internal slider_result internal slider_result
EvaluateSlider (render_command_buffer* RenderBuffer, v2 Min, v2 Max, string Label, r32 Percent, interface_config Config, gui_mouse Mouse) EvaluateSlider (render_command_buffer* RenderBuffer, v2 Min, v2 Max, string Label, r32 Percent, interface_config Config, mouse_state Mouse)
{ {
slider_result Result = {}; slider_result Result = {};
@ -374,7 +360,7 @@ struct scroll_list_result
internal scroll_list_result internal scroll_list_result
DrawOptionsList(render_command_buffer* RenderBuffer, v2 Min, v2 Max, DrawOptionsList(render_command_buffer* RenderBuffer, v2 Min, v2 Max,
string* Options, s32 OptionsCount, string* Options, s32 OptionsCount,
s32 Start, interface_config Config, gui_mouse Mouse) s32 Start, interface_config Config, mouse_state Mouse)
{ {
scroll_list_result Result = {}; scroll_list_result Result = {};
Result.IndexSelected = -1; Result.IndexSelected = -1;
@ -431,7 +417,7 @@ DrawOptionsList(render_command_buffer* RenderBuffer, v2 Min, v2 Max,
internal scroll_list_result internal scroll_list_result
DrawSelectableOptionsList(render_command_buffer* RenderBuffer, v2 Min, v2 Max, DrawSelectableOptionsList(render_command_buffer* RenderBuffer, v2 Min, v2 Max,
string* Options, s32 OptionsCount, string* Options, s32 OptionsCount,
s32 Start, s32 Selected, interface_config Config, gui_mouse Mouse) s32 Start, s32 Selected, interface_config Config, mouse_state Mouse)
{ {
scroll_list_result Result = {}; scroll_list_result Result = {};
Result.IndexSelected = Selected; Result.IndexSelected = Selected;
@ -499,7 +485,7 @@ DrawSelectableOptionsList(render_command_buffer* RenderBuffer, v2 Min, v2 Max,
} }
internal r32 internal r32
EvaluateColorChannelSlider (render_command_buffer* RenderBuffer, v4 ChannelMask, v2 Min, v2 Max, r32 Current, gui_mouse Mouse) EvaluateColorChannelSlider (render_command_buffer* RenderBuffer, v4 ChannelMask, v2 Min, v2 Max, r32 Current, mouse_state Mouse)
{ {
r32 Result = Current; r32 Result = Current;
@ -532,7 +518,7 @@ EvaluateColorChannelSlider (render_command_buffer* RenderBuffer, v4 ChannelMask,
} }
internal b32 internal b32
EvaluateColorPicker (render_command_buffer* RenderBuffer, v4* Value, v2 PanelMin, interface_config Config, gui_mouse Mouse) EvaluateColorPicker (render_command_buffer* RenderBuffer, v4* Value, v2 PanelMin, interface_config Config, mouse_state Mouse)
{ {
b32 ShouldClose = false; b32 ShouldClose = false;
@ -582,7 +568,7 @@ EvaluateSearchLister (render_command_buffer* RenderBuffer, v2 TopLeft, v2 Dimens
string* ItemList, s32* ListLUT, s32 ListLength, string* ItemList, s32* ListLUT, s32 ListLength,
s32 HotItem, s32 HotItem,
string* SearchString, s32 SearchStringCursorPosition, string* SearchString, s32 SearchStringCursorPosition,
bitmap_font* Font, interface_config Config, gui_mouse Mouse) bitmap_font* Font, interface_config Config, mouse_state Mouse)
{ {
search_lister_result Result = {}; search_lister_result Result = {};
Result.ShouldRemainOpen = true; Result.ShouldRemainOpen = true;