Made modes work with hot code reloading, dealt with a bug in the search lister that allowed you to select an item from an empty list, pulled NodeRenderSettings back out into app_state, and generally filled out the operation mode system.

This commit is contained in:
Peter Slattery 2019-11-02 10:29:51 -07:00
parent d90b275cff
commit 6c71c5a89d
13 changed files with 518 additions and 248 deletions

View File

@ -342,21 +342,13 @@ RELOAD_STATIC_DATA(ReloadStaticData)
GlobalDebugServices = DebugServices;
if (State->InputCommandRegistry.Size > 0)
if (State->DefaultInputCommandRegistry.Size > 0)
{
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_MouseLeftButton, Command_Began | Command_Held | Command_Ended, KeyCode_Invalid,
CameraMouseControl);
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_U, Command_Began, KeyCode_Invalid, OpenUniverseView);
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_A, Command_Began, KeyCode_Invalid, OpenNodeLister);
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_Tab, Command_Began, KeyCode_Invalid, OpenNodeView);
// Node Lister
RegisterKeyPressCommand(&State->NodeListerCommandRegistry, KeyCode_DownArrow, Command_Began, KeyCode_Invalid, NodeListerNextItem);
RegisterKeyPressCommand(&State->NodeListerCommandRegistry, KeyCode_UpArrow, Command_Began, KeyCode_Invalid, NodeListerPrevItem);
RegisterKeyPressCommand(&State->NodeListerCommandRegistry, KeyCode_Enter, Command_Began, KeyCode_Invalid, SelectAndCloseNodeLister);
RegisterKeyPressCommand(&State->NodeListerCommandRegistry, KeyCode_MouseLeftButton, Command_Began, KeyCode_Invalid, CloseNodeLister);
RegisterKeyPressCommand(&State->NodeListerCommandRegistry, KeyCode_Esc, Command_Began, KeyCode_Invalid, CloseNodeLister);
InitializeTextInputCommands(&State->NodeListerCommandRegistry, State->Permanent);
RegisterKeyPressCommand(&State->DefaultInputCommandRegistry, KeyCode_MouseLeftButton, Command_Began, KeyCode_Invalid,
Begin3DViewMouseRotate);
RegisterKeyPressCommand(&State->DefaultInputCommandRegistry, KeyCode_U, Command_Began, KeyCode_Invalid, OpenUniverseView);
RegisterKeyPressCommand(&State->DefaultInputCommandRegistry, KeyCode_A, Command_Began, KeyCode_Invalid, OpenNodeLister);
RegisterKeyPressCommand(&State->DefaultInputCommandRegistry, KeyCode_Tab, Command_Began, KeyCode_Invalid, OpenNodeView);
}
}
@ -371,9 +363,7 @@ INITIALIZE_APPLICATION(InitializeApplication)
InitMemoryArena(&State->SACNMemory, 0, 0, Context.PlatformAlloc);
InitializeInputCommandRegistry(&State->InputCommandRegistry, 32, State->Permanent);
InitializeInputCommandRegistry(&State->NodeListerCommandRegistry, 128, State->Permanent);
State->ActiveCommands = &State->InputCommandRegistry;
InitializeInputCommandRegistry(&State->DefaultInputCommandRegistry, 32, State->Permanent);
s32 CommandQueueSize = 32;
command_queue_entry* CommandQueueMemory = PushArray(State->Permanent,
@ -458,7 +448,6 @@ INITIALIZE_APPLICATION(InitializeApplication)
State->Camera.Far = 100.0f;
State->Camera.Position = v3{0, 0, -250};
State->Camera.LookAt = v3{0, 0, 0};
State->Camera_StartDragPos = V4(State->Camera.Position, 1);
#if 1
char Path[] = "radialumia.fold";
@ -470,11 +459,13 @@ INITIALIZE_APPLICATION(InitializeApplication)
GlobalDebugServices->Interface.RenderSculpture = true;
State->NodeList = AllocateNodeList(State->Permanent, Kilobytes(64));
State->OutputNode = PushOutputNodeOnList(State->NodeList, v2{500, 250}, State->Permanent);
InitializeEmptyString(&State->GeneralPurposeSearchString, PushArray(State->Permanent, char, 256), 256);
{
State->NodeRenderSettings.PortColors[MemberType_r32] = RedV4;
State->NodeRenderSettings.PortColors[MemberType_s32] = GreenV4;
State->NodeRenderSettings.PortColors[MemberType_v4] = BlueV4;
State->NodeRenderSettings.Font = State->Font;
}
ReloadStaticData(Context, GlobalDebugServices);
{ // MODES PLAYGROUND
@ -497,14 +488,12 @@ UPDATE_AND_RENDER(UpdateAndRender)
ClearArena(State->Transient);
{
input_command_registry* ActiveCommands = State->ActiveCommands;
input_command_registry ActiveCommands = State->DefaultInputCommandRegistry;
if (State->Modes.ActiveModesCount > 0)
{
ActiveCommands = &State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1].Commands;
ActiveCommands = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1].Commands;
}
ActivateQueuedCommandRegistry(State);
for (s32 EventIdx = 0; EventIdx < InputQueue.QueueUsed; EventIdx++)
{
input_entry Event = InputQueue.Entries[EventIdx];
@ -514,15 +503,15 @@ UPDATE_AND_RENDER(UpdateAndRender)
// frame when the button was released, even if the command is registered to both events
if (KeyTransitionedDown(Event))
{
FindAndPushExistingCommand(State->ActiveCommands, Event, Command_Began, &State->CommandQueue);
FindAndPushExistingCommand(ActiveCommands, Event, Command_Began, &State->CommandQueue);
}
else if (KeyTransitionedUp(Event))
{
FindAndPushExistingCommand(State->ActiveCommands, Event, Command_Ended, &State->CommandQueue);
FindAndPushExistingCommand(ActiveCommands, Event, Command_Ended, &State->CommandQueue);
}
else if (KeyHeldDown(Event))
{
FindAndPushExistingCommand(State->ActiveCommands, Event, Command_Held, &State->CommandQueue);
FindAndPushExistingCommand(ActiveCommands, Event, Command_Held, &State->CommandQueue);
}
if (Event.Key == KeyCode_MouseLeftButton)
@ -549,7 +538,7 @@ UPDATE_AND_RENDER(UpdateAndRender)
Entry->Command.Proc(State, Entry->Event, Mouse);
}
RemoveNonPersistantCommandsFromQueueAndUpdatePersistentEvents(&State->CommandQueue);
ClearCommandQueue(&State->CommandQueue);
}
if (State->LEDBufferList)

View File

@ -49,6 +49,7 @@ struct assembly
typedef struct app_state app_state;
#include "foldhaus_command_dispatch.h"
#include "foldhaus_command_dispatch.cpp"
#include "foldhaus_operation_mode.h"
#include "foldhaus_text_entry.h"
@ -67,15 +68,7 @@ struct app_state
operation_mode_system Modes;
input_command_registry InputCommandRegistry;
// TODO(Peter): At the moment this is only still here because text input into nodes utilizes it.
// Get rid of this once Modes are working and you can switch all text input over to various modes
input_command_registry NodeListerCommandRegistry;
// NOTE(Peter): stores the address of the command registry to be activated next frame.
// was having a problem where switching command registry's in the middle of the loop trying to
// execute commands was causing problems.
input_command_registry* NextCommandRegistry;
input_command_registry* ActiveCommands;
input_command_registry DefaultInputCommandRegistry;
input_command_queue CommandQueue;
text_entry ActiveTextEntry;
@ -95,22 +88,18 @@ struct app_state
interface_config Interface;
r32 PixelsToWorldScale;
v4 Camera_StartDragPos;
node_list* NodeList;
interface_node* OutputNode;
node_render_settings NodeRenderSettings;
string GeneralPurposeSearchString;
};
// TODO(Peter): Once rendering nodes becomes an operation_mode you can get rid of this pre-declaration
internal void OpenColorPicker(app_state* State, v4* Address);
#include "foldhaus_debug_visuals.h"
#include "foldhaus_sacn_view.cpp"
#include "foldhaus_command_dispatch.cpp"
#include "foldhaus_node.cpp"
#include "foldhaus_text_entry.cpp"
#include "foldhaus_search_lister.cpp"

View File

@ -42,29 +42,9 @@ InitializeCommandQueue(command_queue_entry* Memory, s32 MemorySize)
}
internal void
RemoveNonPersistantCommandsFromQueueAndUpdatePersistentEvents(input_command_queue* Queue)
ClearCommandQueue(input_command_queue* Queue)
{
#if 0
s32 PersistantCommandsCount = 0;
for (s32 i = 0; i < Queue->Used; i++)
{
command_queue_entry* Entry = Queue->Commands + i;
if (!Entry->RemoveOnExecute)
{
Entry->Event.State |= KeyState_WasDown;
// NOTE(Peter): If i == PersistantCommandsCount, then we don't need to copy the
// command anywhere
if (i != PersistantCommandsCount)
{
Queue->Commands[PersistantCommandsCount] = *Entry;
}
PersistantCommandsCount++;
}
}
Queue->Used = PersistantCommandsCount;
#else
Queue->Used = 0;
#endif
}
internal void
@ -110,30 +90,14 @@ RemoveCommandFromQueue(input_command_queue* Queue, input_command Command, input_
RemoveCommandFromQueue(Queue, CommandIndex);
}
internal void
QueueNextFrameCommandRegistry (input_command_registry* NewRegistry, app_state* State)
{
State->NextCommandRegistry = NewRegistry;
}
internal void
ActivateQueuedCommandRegistry (app_state* State)
{
if (State->NextCommandRegistry)
{
State->ActiveCommands = State->NextCommandRegistry;
State->NextCommandRegistry = 0;
}
}
internal input_command*
FindExistingCommand (input_command_registry* CommandRegistry, key_code Key, key_code Mdfr, b32 Flags)
FindExistingCommand (input_command_registry CommandRegistry, key_code Key, key_code Mdfr, b32 Flags)
{
input_command* Result = 0;
for (s32 Cmd = 0; Cmd < CommandRegistry->Used; Cmd++)
for (s32 Cmd = 0; Cmd < CommandRegistry.Used; Cmd++)
{
input_command* Command = CommandRegistry->Commands + Cmd;
input_command* Command = CommandRegistry.Commands + Cmd;
if (Command->Key == Key && Command->Mdfr == Mdfr)
{
b32 FlagsOverlap = Flags & Command->Flags;
@ -149,7 +113,7 @@ FindExistingCommand (input_command_registry* CommandRegistry, key_code Key, key_
}
internal b32
FindAndPushExistingCommand(input_command_registry* CommandRegistry, input_entry Event, b32 Flags, input_command_queue* CommandQueue)
FindAndPushExistingCommand(input_command_registry CommandRegistry, input_entry Event, b32 Flags, input_command_queue* CommandQueue)
{
b32 CommandFound = false;
input_command* Command = FindExistingCommand(CommandRegistry, Event.Key, (key_code)0, Flags);
@ -168,7 +132,7 @@ RegisterKeyPressCommand (input_command_registry* CommandRegistry,
key_code Mdfr,
input_command_proc* Proc)
{
input_command* Command = FindExistingCommand(CommandRegistry, Key, Mdfr, Flags);
input_command* Command = FindExistingCommand(*CommandRegistry, Key, Mdfr, Flags);
if (!Command)
{

View File

@ -1,6 +1,9 @@
#define FOLDHAUS_INPUT_COMMAND_PROC(name) void name(app_state* State, input_entry Event, mouse_state Mouse)
typedef FOLDHAUS_INPUT_COMMAND_PROC(input_command_proc);
// NOTE(Peter): Helper function so I don't have to remember the parameters to this define
#define ExecFoldhausCommand(cmd) cmd(State, Event, Mouse)
enum input_command_flags
{
Command_Began = 1 << 0,
@ -15,8 +18,8 @@ enum input_command_flags
struct input_command
{
key_code Key;
b32 Flags;
key_code Mdfr;
b32 Flags;
input_command_proc* Proc;
};

View File

@ -20,9 +20,17 @@ DrawDebugInterface (render_command_buffer* RenderBuffer, r32 StartX, interface_c
r32 FramesPerSecond = 1.0f / DeltaTime;
PrintF(&DebugString, "Framerate: %.*f s %d fps | Modes: %d Memory Used: %d / %d | Commands: %d",
string ModeName = MakeStringLiteral("Base Mode");
if (State->Modes.ActiveModesCount > 0 &&
State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1].Name.Length > 0)
{
ModeName = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1].Name;
}
PrintF(&DebugString, "Framerate: %.*f s %d fps | Current Mode: %.*s Modes: %d Memory Used: %d / %d | Commands: %d",
5, DeltaTime,
(u32)FramesPerSecond,
ModeName.Length, ModeName.Memory,
State->Modes.ActiveModesCount,
State->Modes.Arena.CurrentRegion->Used,
State->Modes.Arena.CurrentRegion->Size,

View File

@ -1,19 +1,3 @@
FOLDHAUS_INPUT_COMMAND_PROC(CameraMouseControl)
{
if (KeyTransitionedDown(Event))
{
State->Camera_StartDragPos = V4(State->Camera.Position, 1);
}
v2 TotalDeltaPos = Mouse.Pos - Mouse.DownPos;
m44 XRotation = GetXRotation(-TotalDeltaPos.y * State->PixelsToWorldScale);
m44 YRotation = GetYRotation(TotalDeltaPos.x * State->PixelsToWorldScale);
m44 Combined = XRotation * YRotation;
State->Camera.Position = V3(Combined * State->Camera_StartDragPos);
}
////////////////////////////////////////
//
// Universe View
@ -22,6 +6,7 @@ FOLDHAUS_INPUT_COMMAND_PROC(CameraMouseControl)
struct universe_view_operation_state
{
b32 MouseDown;
v2 DisplayOffset;
r32 Zoom;
};
@ -30,13 +15,26 @@ OPERATION_RENDER_PROC(RenderUniverseView)
{
DEBUG_TRACK_SCOPE(DrawUniverseOutputDisplay);
// TODO(Peter): Pass this in as a parameter
universe_view_operation_state* OpState = (universe_view_operation_state*)Operation.OpStateMemory;
string TitleBarString = InitializeEmptyString(PushArray(State->Transient, char, 64), 64);
v2 DisplayArea_Dimension = v2{600, 600};
v2 DisplayContents_Offset = OpState->DisplayOffset;
//
// TODO(Peter): I don't like this. Dragging the Universe view should be an operation mode, just
// like rotating the 3D view, but modes don't have access to the state of modes above them in the stack
// (and attempting to cast those states to the appropriate type seems risky)
//
// :NeedToPassStateDownModeChain
//
if (OpState->MouseDown)
{
DisplayContents_Offset += (Mouse.Pos - Mouse.DownPos);
}
v2 DisplayArea_TopLeft = v2{300, (r32)RenderBuffer->ViewHeight - 50} + DisplayContents_Offset;
v2 UniverseDisplayDimension = v2{100, 100} * OpState->Zoom;
v2 Padding = v2{25, 50} * OpState->Zoom;
@ -82,19 +80,24 @@ OPERATION_RENDER_PROC(RenderUniverseView)
// TODO(Peter): Something isn't working with my laptop trackpad's zoom
FOLDHAUS_INPUT_COMMAND_PROC(UniverseZoom)
{
// 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*)Mode.OpStateMemory;
universe_view_operation_state* OpState = GetCurrentOperationState(State->Modes, universe_view_operation_state);
r32 DeltaZoom = (r32)(Mouse.Scroll) / 120;
OpState->Zoom = GSClamp(0.1f, OpState->Zoom + DeltaZoom, 4.f);
}
FOLDHAUS_INPUT_COMMAND_PROC(UniverseViewPan)
FOLDHAUS_INPUT_COMMAND_PROC(UniverseViewEndPan)
{
// 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*)Mode.OpStateMemory;
OpState->DisplayOffset += Mouse.DeltaPos;
// :NeedToPassStateDownModeChain
universe_view_operation_state* OpState = GetCurrentOperationState(State->Modes, universe_view_operation_state);
OpState->MouseDown = false;
OpState->DisplayOffset = OpState->DisplayOffset + (Mouse.Pos - Mouse.DownPos);
}
FOLDHAUS_INPUT_COMMAND_PROC(UniverseViewBeginPan)
{
// :NeedToPassStateDownModeChain
universe_view_operation_state* OpState = GetCurrentOperationState(State->Modes, universe_view_operation_state);
OpState->MouseDown = true;
}
FOLDHAUS_INPUT_COMMAND_PROC(CloseUniverseView)
@ -102,18 +105,17 @@ FOLDHAUS_INPUT_COMMAND_PROC(CloseUniverseView)
DeactivateCurrentOperationMode(&State->Modes);
}
input_command UniverseViewCommands [] = {
{ KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Began, UniverseViewBeginPan },
{ KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Ended, UniverseViewEndPan },
{ KeyCode_U, KeyCode_Invalid, Command_Began, CloseUniverseView },
};
FOLDHAUS_INPUT_COMMAND_PROC(OpenUniverseView)
{
operation_mode* UniverseViewMode = ActivateOperationMode(&State->Modes);
operation_mode* UniverseViewMode = ActivateOperationModeWithCommands(&State->Modes, "Universe View", UniverseViewCommands);
UniverseViewMode->Render = RenderUniverseView;
{ // Mode Commands
InitializeInputCommandRegistry(&UniverseViewMode->Commands, 3, &State->Modes.Arena);
RegisterKeyPressCommand(&UniverseViewMode->Commands, KeyCode_MouseLeftButton, Command_Began | Command_Ended, KeyCode_Invalid, UniverseViewPan);
RegisterKeyPressCommand(&UniverseViewMode->Commands, KeyCode_U, Command_Began, KeyCode_Invalid, CloseUniverseView);
RegisterMouseWheelCommand(&UniverseViewMode->Commands, UniverseZoom);
}
// State Setup
universe_view_operation_state* OpState = CreateOperationState(UniverseViewMode,
&State->Modes,
@ -159,17 +161,13 @@ OPERATION_RENDER_PROC(RenderNodeLister)
FOLDHAUS_INPUT_COMMAND_PROC(NodeListerNextItem)
{
// TODO(Peter): Pass this in as a parameter
operation_mode Mode = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1];
node_lister_operation_state* OpState = (node_lister_operation_state*)Mode.OpStateMemory;
node_lister_operation_state* OpState = GetCurrentOperationState(State->Modes, node_lister_operation_state);
OpState->SearchLister.HotItem = GetNextFilteredItem(OpState->SearchLister);
}
FOLDHAUS_INPUT_COMMAND_PROC(NodeListerPrevItem)
{
// TODO(Peter): Pass this in as a parameter
operation_mode Mode = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1];
node_lister_operation_state* OpState = (node_lister_operation_state*)Mode.OpStateMemory;
node_lister_operation_state* OpState = GetCurrentOperationState(State->Modes, node_lister_operation_state);
OpState->SearchLister.HotItem = GetPrevFilteredItem(OpState->SearchLister);
}
@ -180,31 +178,29 @@ FOLDHAUS_INPUT_COMMAND_PROC(CloseNodeLister)
FOLDHAUS_INPUT_COMMAND_PROC(SelectAndCloseNodeLister)
{
// TODO(Peter): Pass this in as a parameter
operation_mode Mode = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1];
node_lister_operation_state* OpState = (node_lister_operation_state*)Mode.OpStateMemory;
node_lister_operation_state* OpState = GetCurrentOperationState(State->Modes, node_lister_operation_state);
s32 FilteredNodeIndex = OpState->SearchLister.HotItem;
s32 NodeIndex = OpState->SearchLister.FilteredIndexLUT[FilteredNodeIndex];
PushNodeOnListFromSpecification(State->NodeList, NodeSpecifications[NodeIndex],
Mouse.Pos, State->Permanent);
if (FilteredNodeIndex >= 0)
{
s32 NodeIndex = OpState->SearchLister.FilteredIndexLUT[FilteredNodeIndex];
PushNodeOnListFromSpecification(State->NodeList, NodeSpecifications[NodeIndex],
Mouse.Pos, State->Permanent);
}
CloseNodeLister(State, Event, Mouse);
}
input_command UniverseViewCommads [] = {
{ KeyCode_DownArrow, KeyCode_Invalid, Command_Began, NodeListerNextItem },
{ KeyCode_UpArrow, KeyCode_Invalid, Command_Began, NodeListerPrevItem },
{ KeyCode_Enter, KeyCode_Invalid, Command_Began, SelectAndCloseNodeLister },
{ KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Began, CloseNodeLister },
{ KeyCode_Esc, KeyCode_Invalid, Command_Began, CloseNodeLister },
DEFAULT_TEXT_ENTRY_INPUT_COMMANDS_ARRAY_ENTRY,
};
FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeLister)
{
// TODO(Peter): This won't work with hot code reloading
operation_mode* AddNodeOperation = ActivateOperationMode(&State->Modes);
{ // Mode Commands
InitializeInputCommandRegistry(&AddNodeOperation->Commands, 128, &State->Modes.Arena);
RegisterKeyPressCommand(&AddNodeOperation->Commands, KeyCode_DownArrow, Command_Began, KeyCode_Invalid, NodeListerNextItem);
RegisterKeyPressCommand(&AddNodeOperation->Commands, KeyCode_UpArrow, Command_Began, KeyCode_Invalid, NodeListerPrevItem);
RegisterKeyPressCommand(&AddNodeOperation->Commands, KeyCode_Enter, Command_Began, KeyCode_Invalid, SelectAndCloseNodeLister);
RegisterKeyPressCommand(&AddNodeOperation->Commands, KeyCode_MouseLeftButton, Command_Began, KeyCode_Invalid, CloseNodeLister);
RegisterKeyPressCommand(&AddNodeOperation->Commands, KeyCode_Esc, Command_Began, KeyCode_Invalid, CloseNodeLister);
InitializeTextInputCommands(&AddNodeOperation->Commands, &State->Modes.Arena);
}
operation_mode* AddNodeOperation = ActivateOperationModeWithCommands(&State->Modes, "Node Lister", UniverseViewCommads);
AddNodeOperation->Render = RenderNodeLister;
@ -222,8 +218,7 @@ FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeLister)
NodeSpecifications[i].NameLength);
}
}
OpState->SearchLister.Filter = State->ActiveTextEntry.Buffer;
OpState->SearchLister.Filter = MakeString(PushArray(&State->Modes.Arena, char, 64), 0, 64);
OpState->SearchLister.FilteredListMax = OpState->SearchLister.SourceListCount;
OpState->SearchLister.FilteredListCount = 0;
@ -231,7 +226,7 @@ FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeLister)
}
OpState->ListPosition = Mouse.Pos;
SetTextInputDestinationToString(&State->ActiveTextEntry, &State->GeneralPurposeSearchString);
SetTextInputDestinationToString(&State->ActiveTextEntry, &OpState->SearchLister.Filter);
}
////////////////////////////////////////
@ -253,7 +248,6 @@ CloseColorPicker(app_state* State)
OPERATION_RENDER_PROC(RenderColorPicker)
{
// TODO(Peter): Pass this in as a parameter
color_picker_operation_state* OpState = (color_picker_operation_state*)Operation.OpStateMemory;
@ -269,8 +263,7 @@ OPERATION_RENDER_PROC(RenderColorPicker)
internal void
OpenColorPicker(app_state* State, v4* ValueAddr)
{
// TODO(Peter): This won't work with hot code reloading
operation_mode* ColorPickerMode = ActivateOperationMode(&State->Modes);
operation_mode* ColorPickerMode = ActivateOperationMode(&State->Modes, "Color Picker");
ColorPickerMode->Render = RenderColorPicker;
color_picker_operation_state* OpState = CreateOperationState(ColorPickerMode,
@ -280,6 +273,142 @@ OpenColorPicker(app_state* State, v4* ValueAddr)
}
////////////////////////////////////////
//
// Node Field Text Edit
//
///////////////////////////////////////
FOLDHAUS_INPUT_COMMAND_PROC(EndNodeFieldTextEdit)
{
DeactivateCurrentOperationMode(&State->Modes);
}
input_command NodeFieldTextEditCommands [] = {
{ KeyCode_Enter, KeyCode_Invalid, Command_Began, EndNodeFieldTextEdit},
DEFAULT_TEXT_ENTRY_INPUT_COMMANDS_ARRAY_ENTRY,
};
internal void
BeginNodeFieldTextEdit(app_state* State, interface_node* Node, node_interaction Interaction)
{
operation_mode* NodeFieldTextEditMode = ActivateOperationModeWithCommands(&State->Modes,
"Node Field Text Edit",
NodeFieldTextEditCommands);
node_connection* Connection = Node->Connections + Interaction.InputValue;
struct_member_type InputType = Connection->Type;
if (InputType == MemberType_r32)
{
SetTextInputDestinationToFloat(&State->ActiveTextEntry, &Connection->R32Value);
}
}
////////////////////////////////////////
//
// Node Port Mouse Drag
//
///////////////////////////////////////
struct drag_node_port_operation_state
{
node_interaction Interaction;
};
OPERATION_RENDER_PROC(RenderDraggingNodePort)
{
drag_node_port_operation_state* OpState = (drag_node_port_operation_state*)Operation.OpStateMemory;
UpdateDraggingNodePort(Mouse.Pos, OpState->Interaction, State->NodeList,
State->NodeRenderSettings, RenderBuffer);
}
FOLDHAUS_INPUT_COMMAND_PROC(EndDraggingNodePort)
{
drag_node_port_operation_state* OpState = GetCurrentOperationState(State->Modes, drag_node_port_operation_state);
TryConnectNodes(OpState->Interaction, Mouse.Pos, State->NodeList, State->NodeRenderSettings);
DeactivateCurrentOperationMode(&State->Modes);
}
input_command DragNodePortInputCommands[] = {
{ KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Ended, EndDraggingNodePort },
};
internal void
BeginDraggingNodePort(app_state* State, node_interaction Interaction)
{
operation_mode* DragNodePortMode = ActivateOperationModeWithCommands(
&State->Modes,
"Drag Node Port",
DragNodePortInputCommands);
DragNodePortMode->Render = RenderDraggingNodePort;
drag_node_port_operation_state* OpState = CreateOperationState(DragNodePortMode,
&State->Modes,
drag_node_port_operation_state);
OpState->Interaction = Interaction;
}
////////////////////////////////////////
//
// Node Field Mouse Drag
//
///////////////////////////////////////
OPERATION_RENDER_PROC(RenderDragNodeField)
{
// TODO(Peter):
//UpdateDraggingNodeValue(Mouse.Pos, Mouse.OldPos, OpState->Interaction, State->NodeList, State->NodeRenderSettings, State);
}
internal void
BeginInteractWithNodeField(app_state* State, node_interaction Interaction)
{
// TODO(Peter):
}
////////////////////////////////////////
//
// Node Field Mouse Drag
//
///////////////////////////////////////
struct drag_node_operation_state
{
node_interaction Interaction;
};
OPERATION_RENDER_PROC(RenderDraggingNode)
{
drag_node_operation_state* OpState = GetCurrentOperationState(State->Modes, drag_node_operation_state);
UpdateDraggingNode(Mouse.Pos, OpState->Interaction, State->NodeList,
State->NodeRenderSettings);
}
FOLDHAUS_INPUT_COMMAND_PROC(EndDraggingNode)
{
DeactivateCurrentOperationMode(&State->Modes);
}
input_command DragNodeInputCommands[] = {
{ KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Ended, EndDraggingNode },
};
internal void
BeginDraggingNode(app_state* State, node_interaction Interaction)
{
operation_mode* DragNodeMode = ActivateOperationModeWithCommands(
&State->Modes,
"Drag Node",
DragNodeInputCommands);
DragNodeMode->Render = RenderDraggingNode;
drag_node_operation_state* OpState = CreateOperationState(DragNodeMode,
&State->Modes,
drag_node_operation_state);
OpState->Interaction = Interaction;
}
////////////////////////////////////////
//
// Node View
@ -288,75 +417,65 @@ OpenColorPicker(app_state* State, v4* ValueAddr)
struct node_view_operation_state
{
node_interaction Interaction;
node_render_settings RenderSettings;
};
FOLDHAUS_INPUT_COMMAND_PROC(NodeViewMousePickNode)
FOLDHAUS_INPUT_COMMAND_PROC(NodeViewBeginMouseDragInteraction)
{
// 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;
node_view_operation_state* OpState = GetCurrentOperationState(State->Modes, node_view_operation_state);
if (Mouse.LeftButtonTransitionedDown)
node_offset Node = GetNodeUnderPoint(State->NodeList, Mouse.DownPos, State->NodeRenderSettings);
if (Node.Node)
{
node_offset Node = GetNodeUnderPoint(State->NodeList, Mouse.Pos, OpState->RenderSettings);
if (Node.Node)
node_interaction NewInteraction = GetNodeInteractionType(Node.Node,
Node.Offset,
Mouse.Pos,
State->NodeRenderSettings);
if (IsDraggingNodePort(NewInteraction))
{
OpState->Interaction = GetNodeInteractionType(Node.Node, Node.Offset, Mouse.Pos, OpState->RenderSettings);
BeginDraggingNodePort(State, NewInteraction);
}
else if(IsDraggingNodeValue(NewInteraction))
{
// TODO(Peter): This probably wants to live in a mouse held action
// the first frame we realize we're held over a field, just transition to
// drag node field
//BeginInteractWithNodeField(State, NewInteraction, State->NodeRenderSettings);
}
else // IsDraggingNode
{
BeginDraggingNode(State, NewInteraction);
}
}
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();
}
}
FOLDHAUS_INPUT_COMMAND_PROC(NodeViewBeginMouseSelectInteraction)
{
node_view_operation_state* OpState = GetCurrentOperationState(State->Modes, node_view_operation_state);
node_offset NodeOffset = GetNodeUnderPoint(State->NodeList, Mouse.Pos, State->NodeRenderSettings);
if (NodeOffset.Node)
{
node_interaction NewInteraction = GetNodeInteractionType(NodeOffset.Node,
NodeOffset.Offset,
Mouse.Pos,
State->NodeRenderSettings);
if(IsDraggingNodeValue(NewInteraction))
{
BeginNodeFieldTextEdit(State, NodeOffset.Node, NewInteraction);
}
}
}
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);
// TODO(Peter): Not sure we want to be doing Node Functionality updates in a mode. This should happen every
// frame regardless of whether or not we're viewing the nodes.
// TODO(Peter): Make sure that RenderNodeList isn't also updating them!!
ResetNodesUpdateState(State->NodeList);
RenderNodeList(State->NodeList, OpState->RenderSettings, RenderBuffer);
RenderNodeList(State->NodeList, State->NodeRenderSettings, RenderBuffer);
}
FOLDHAUS_INPUT_COMMAND_PROC(CloseNodeView)
@ -364,27 +483,63 @@ FOLDHAUS_INPUT_COMMAND_PROC(CloseNodeView)
DeactivateCurrentOperationMode(&State->Modes);
}
input_command NodeViewCommands [] = {
{ KeyCode_Tab, KeyCode_Invalid, Command_Began, CloseNodeView},
{ KeyCode_A, KeyCode_Invalid, Command_Began, OpenNodeLister},
{ KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Began, NodeViewBeginMouseDragInteraction},
{ KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Ended, NodeViewBeginMouseSelectInteraction},
};
FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeView)
{
// TODO(Peter): This won't work with hot code reloading
operation_mode* NodeViewMode = ActivateOperationMode(&State->Modes);
operation_mode* NodeViewMode = ActivateOperationModeWithCommands(&State->Modes, "Node View", NodeViewCommands);
NodeViewMode->Render = RenderNodeView;
{ // Mode Commands
InitializeInputCommandRegistry(&NodeViewMode->Commands, 3, &State->Modes.Arena);
RegisterKeyPressCommand(&NodeViewMode->Commands, KeyCode_Tab, Command_Began, KeyCode_Invalid, CloseNodeView);
RegisterKeyPressCommand(&NodeViewMode->Commands, KeyCode_A, Command_Began, KeyCode_Invalid, OpenNodeLister);
RegisterKeyPressCommand(&NodeViewMode->Commands, KeyCode_MouseLeftButton, Command_Began | Command_Ended, 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;
}
////////////////////////////////////////
//
// 3D View Mouse Rotate
//
///////////////////////////////////////
struct mouse_rotate_view_operation_state
{
v4 CameraStartPos;
};
OPERATION_RENDER_PROC(Update3DViewMouseRotate)
{
mouse_rotate_view_operation_state* OpState = (mouse_rotate_view_operation_state*)Operation.OpStateMemory;
v2 TotalDeltaPos = Mouse.Pos - Mouse.DownPos;
m44 XRotation = GetXRotation(-TotalDeltaPos.y * State->PixelsToWorldScale);
m44 YRotation = GetYRotation(TotalDeltaPos.x * State->PixelsToWorldScale);
m44 Combined = XRotation * YRotation;
State->Camera.Position = V3(Combined * OpState->CameraStartPos);
}
FOLDHAUS_INPUT_COMMAND_PROC(End3DViewMouseRotate)
{
DeactivateCurrentOperationMode(&State->Modes);
}
input_command MouseRotateViewCommands [] = {
{ KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Ended, End3DViewMouseRotate},
};
FOLDHAUS_INPUT_COMMAND_PROC(Begin3DViewMouseRotate)
{
operation_mode* RotateViewMode = ActivateOperationModeWithCommands(&State->Modes, "Rotate 3D View", MouseRotateViewCommands);
RotateViewMode->Render = Update3DViewMouseRotate;
mouse_rotate_view_operation_state* OpState = CreateOperationState(RotateViewMode,
&State->Modes,
mouse_rotate_view_operation_state);
OpState->CameraStartPos = V4(State->Camera.Position, 1);
}

View File

@ -8,6 +8,8 @@ struct operation_mode
input_command_registry Commands;
operation_render_proc* Render;
u8* OpStateMemory;
string Name;
};
#define OPERATION_MODES_MAX 32
@ -23,15 +25,40 @@ struct operation_mode_system
};
internal operation_mode*
ActivateOperationMode (operation_mode_system* System)
ActivateOperationMode (operation_mode_system* System, char* ModeName)
{
Assert(System->ActiveModesCount < OPERATION_MODES_MAX);
s32 ModeIndex = System->ActiveModesCount++;
System->ActiveModes[ModeIndex] = {};
System->ModeMemorySnapshots[ModeIndex] = TakeSnapshotOfArena(System->Arena);
operation_mode NewMode = {};
s32 NameLength = CharArrayLength(ModeName);
NewMode.Name = MakeString(PushArray(&System->Arena, char, NameLength), 0, NameLength);
CopyCharArrayToString(ModeName, &NewMode.Name);
System->ActiveModes[ModeIndex] = NewMode;
return &System->ActiveModes[ModeIndex];
}
#define ActivateOperationModeWithCommands(sys, name, cmds) \
ActivateOperationModeWithCommands_(sys, name, cmds, (s32)(sizeof(cmds) / sizeof(cmds[0])));
internal operation_mode*
ActivateOperationModeWithCommands_(operation_mode_system* System, char* ModeName, input_command* Commands, s32 CommandsCount)
{
operation_mode* NewMode = ActivateOperationMode(System, ModeName);
InitializeInputCommandRegistry(&NewMode->Commands, CommandsCount, &System->Arena);
for (s32 i = 0; i < CommandsCount; i++)
{
input_command Command = Commands[i];
RegisterKeyPressCommand(&NewMode->Commands, Command.Key, Command.Flags, Command.Mdfr, Command.Proc);
}
return NewMode;
}
internal void
DeactivateCurrentOperationMode (operation_mode_system* System)
{
@ -43,6 +70,10 @@ DeactivateCurrentOperationMode (operation_mode_system* System)
#define CreateOperationState(mode, modeSystem, stateType) \
(stateType*)CreateOperationState_(mode, modeSystem, sizeof(stateType))
#define GetCurrentOperationState(modeSystem, stateType) \
(stateType*)State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1].OpStateMemory;
internal u8*
CreateOperationState_ (operation_mode* Mode, operation_mode_system* System, s32 StateSize)
{

View File

@ -14,6 +14,11 @@ FilterSearchLister (search_lister* SearchLister)
SearchLister->FilteredIndexLUT[SearchLister->FilteredListCount++] = i;
}
}
if (SearchLister->FilteredListCount == 0)
{
SearchLister->HotItem = -1;
}
}
internal s32

View File

@ -83,7 +83,6 @@ FOLDHAUS_INPUT_COMMAND_PROC(TextEntryInsertChar)
InsertChar(&State->ActiveTextEntry.Buffer, Char, State->ActiveTextEntry.CursorPosition);
State->ActiveTextEntry.CursorPosition++;
// TODO(Peter): Do we want to do this after every single character?
PipeSearchStringToDestination(&State->ActiveTextEntry);
}
@ -107,14 +106,123 @@ InitializeTextInputCommands (input_command_registry* Commands, memory_arena* Per
{
if (Commands->Size > 0)
{
RegisterKeyPressCommand(Commands, KeyCode_Backspace, Command_Began, KeyCode_Invalid, RemoveCharacterFromEntryString);
RegisterKeyPressCommand(Commands, KeyCode_LeftArrow, Command_Began, KeyCode_Invalid, TextEntryMoveCursorLeft);
RegisterKeyPressCommand(Commands, KeyCode_RightArrow, Command_Began, KeyCode_Invalid, TextEntryMoveCursorRight);
RegisterKeyPressCommand(Commands, KeyCode_Backspace, Command_Began | Command_Held, KeyCode_Invalid, RemoveCharacterFromEntryString);
RegisterKeyPressCommand(Commands, KeyCode_LeftArrow, Command_Began | Command_Held, KeyCode_Invalid, TextEntryMoveCursorLeft);
RegisterKeyPressCommand(Commands, KeyCode_RightArrow, Command_Began | Command_Held, KeyCode_Invalid, TextEntryMoveCursorRight);
for (s32 i = KeyCode_a; i < KeyCode_UpArrow; i++)
{
RegisterKeyPressCommand(Commands, (key_code)i, Command_Began, KeyCode_Invalid, TextEntryInsertChar);
RegisterKeyPressCommand(Commands, (key_code)i, Command_Began | Command_Held, KeyCode_Invalid, TextEntryInsertChar);
}
}
}
#define DEFAULT_TEXT_ENTRY_INPUT_COMMANDS_ARRAY_ENTRY \
{ KeyCode_Backspace, KeyCode_Invalid, Command_Began | Command_Held, RemoveCharacterFromEntryString }, \
{ KeyCode_LeftArrow, KeyCode_Invalid, Command_Began | Command_Held, TextEntryMoveCursorLeft }, \
{ KeyCode_RightArrow, KeyCode_Invalid, Command_Began | Command_Held, TextEntryMoveCursorRight }, \
{ KeyCode_a, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_b, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_c, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_d, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_e, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_f, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_g, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_h, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_i, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_j, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_k, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_l, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_m, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_n, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_o, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_p, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_q, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_r, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_s, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_t, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_u, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_v, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_w, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_x, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_y, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_z, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_A, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_B, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_C, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_D, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_E, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_F, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_G, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_H, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_I, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_J, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_K, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_L, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_M, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_N, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_O, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_P, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Q, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_R, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_S, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_T, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_U, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_V, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_W, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_X, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Y, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Z, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_0, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_1, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_2, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_3, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_4, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_5, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_6, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_7, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_8, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_9, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Num0, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Num1, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Num2, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Num3, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Num4, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Num5, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Num6, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Num7, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Num8, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Num9, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Bang, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_At, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Pound, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Dollar, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Percent, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Carrot, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Ampersand, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Star, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_LeftParen, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_RightParen, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Minus, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Plus, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Equals, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Underscore, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_LeftBrace, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_RightBrace, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_LeftBracket, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_RightBracket, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Colon, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_SemiColon, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_SingleQuote, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_DoubleQuote, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_ForwardSlash, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Backslash, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Pipe, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Comma, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Period, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_QuestionMark, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_LessThan, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_GreaterThan, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_Tilde, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }, \
{ KeyCode_BackQuote, KeyCode_Invalid, Command_Began | Command_Held, TextEntryInsertChar }

View File

@ -1046,6 +1046,7 @@ CopyCharArrayToString (char* Source, string* Dest)
*Dst++ = *Src++;
Copied++;
}
*Dst++ = 0;
Dest->Length = Copied;
}
@ -1060,6 +1061,7 @@ CopyCharArrayToString (char* Source, s32 SourceLength, string* Dest)
{
*Dst++ = *Src++;
}
*Dst++ = 0;
Dest->Length = SourceLength;
}

View File

@ -579,7 +579,7 @@ EvaluateSearchLister (render_command_buffer* RenderBuffer, v2 TopLeft, v2 Dimens
DrawString(RenderBuffer, Title, Font, 14, v2{TopLeft.x, TopLeft.y - 25}, WhiteV4);
MakeStringBuffer(DebugString, 256);
PrintF(&DebugString, "Hot Item: %d", HotItem);
PrintF(&DebugString, "Hot Item: %d | Filtered Items: %d", HotItem, ListLength);
DrawString(RenderBuffer, DebugString, Font, 14, v2{TopLeft.x + 256, TopLeft.y - 25}, WhiteV4);
TopLeft.y -= 30;

View File

@ -1,38 +1,27 @@
TODO FOLDHAUS
Intermediate Lifetime Memory & Operations
x Intermediate lifetime memory arena
x Temporary memory region = a multi frame operation
x Concept of an operation - temporary memory + interface command registry
x Allow one operation at a time at first
x Push/pop operations on a list?
- Current Operations:
- - View Sculpture (this might be an exception since its so central)
- x View/Edit Nodes
- x Add Node (needs nesting)
- x View SACN
- Why does backspacing in text entry not save when you close and reopen the node lister?
- Typing a period into a float value doesn't register
BUGS
- Typing a period into a float value doesn't register. Problem here is that we arent' translating key presses into characters at the win32 layer. Need to do that.
Hardening
- turn the default sculpture view into an operation mode ? (have to think about this)
- Then we want to think about separating out mode render functions from mode update functions. Not sure its necessary but having something that operates like an update funciton but is called render is weird. Might want some sort of coroutine functionality in place, where modes can add and remove optional, parallel
update functions
- memory visualization
- separate rendering thread
- cache led positions. Only update if they are moving
x input context changes
- - shift drag to 10x drag speed
- select nodes -> delete nodes
- remove node connections
UI Improvements
- highlight node field under active edit
Name
- Splash screen (like blender) (thisll be fun)
- - Image importer (stb image? or find a png > bmp converter for the image you have)
- - Display on startup
/Debug
x Make debug scope tracking thread safe - was throwing an error in stringsequal but that stopped.
x Keep an eye out.
Application
- More efficient HSV <-> RGB
@ -55,9 +44,8 @@ Interface
- Update the text system - use system fonts
Switch To Nodes
x basic node elements
- - evaluation step (one node at a time)
- - selector node (has a list of connections that it can switch between)
- evaluation step (one node at a time)
- selector node (has a list of connections that it can switch between)
- serialize
- delete nodes

28
todo_done.txt Normal file
View File

@ -0,0 +1,28 @@
BUGS
x if there is nothing in the filtered list when searching for a node, hitting enter still selects one
Intermediate Lifetime Memory & Operations
x Intermediate lifetime memory arena
x Temporary memory region = a multi frame operation
x Concept of an operation - temporary memory + interface command registry
x Allow one operation at a time at first
x Push/pop operations on a list?
- Current Operations:
- - View Sculpture (this might be an exception since its so central)
- x View/Edit Nodes
- x Add Node (needs nesting)
- x View SACN
x make modes work with hot code reloading: rather than do the whole series of initialize command registry,
x and manually adding each command, store the commands as an array, and auto iterate over them when you
x push the mode on the mode stack
x decided I don't like storing NodeRenderSettings in each operation mode. Probably want to put it back in x app_state
/Debug
x Make debug scope tracking thread safe - was throwing an error in stringsequal but that stopped.
x Keep an eye out.
Switch To Nodes
x basic node elements
Hardening
x input context changes