Pulled the color picker into the new modes system

This commit is contained in:
Peter Slattery 2019-11-01 06:46:06 -07:00
parent b2579a45b7
commit a889deaa98
5 changed files with 68 additions and 34 deletions

View File

@ -789,12 +789,11 @@ UPDATE_AND_RENDER(UpdateAndRender)
if (InputType == MemberType_r32) if (InputType == MemberType_r32)
{ {
SetTextInputDestinationToFloat(&State->ActiveTextEntry, &Connection->R32Value); SetTextInputDestinationToFloat(&State->ActiveTextEntry, &Connection->R32Value);
}
State->NodeInteraction = NewEmptyNodeInteraction();
// TODO(Peter): This is wrong, should be something to do with capturing text input // TODO(Peter): This is wrong, should be something to do with capturing text input
State->ActiveCommands = &State->NodeListerCommandRegistry; State->ActiveCommands = &State->NodeListerCommandRegistry;
} }
State->NodeInteraction = NewEmptyNodeInteraction();
}
else // This is the case where you dragged the value else // This is the case where you dragged the value
{ {
State->NodeInteraction = NewEmptyNodeInteraction(); State->NodeInteraction = NewEmptyNodeInteraction();
@ -820,22 +819,14 @@ UPDATE_AND_RENDER(UpdateAndRender)
RenderNodeList(State->NodeList, State->NodeRenderSettings, RenderBuffer); RenderNodeList(State->NodeList, State->NodeRenderSettings, RenderBuffer);
} }
if (State->ColorPickerEditValue != 0)
{
b32 ShouldClose = EvaluateColorPicker(RenderBuffer, State->ColorPickerEditValue,
v2{200, 200}, State->Interface, GuiMouse);
if (ShouldClose)
{
State->ColorPickerEditValue = 0;
}
}
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)
{
OperationMode.Render(State, RenderBuffer, OperationMode, GuiMouse); OperationMode.Render(State, RenderBuffer, OperationMode, GuiMouse);
} }
}
DrawDebugInterface(RenderBuffer, 25, DrawDebugInterface(RenderBuffer, 25,
State->Interface, Context.WindowWidth, Context.WindowHeight - TopBarHeight, State->Interface, Context.WindowWidth, Context.WindowHeight - TopBarHeight,

View File

@ -84,7 +84,7 @@ struct app_state
s32 TotalLEDsCount; s32 TotalLEDsCount;
led_buffer* LEDBufferList; led_buffer* LEDBufferList;
// TODO(Peter): Make this dynamic. WE want them contiguous in memory since we'll be accessing them // TODO(Peter): Make this dynamic. We want them contiguous in memory since we'll be accessing them
// mostly by looping through them. On the other hand, I don't expect there to ever be more than 100 // mostly by looping through them. On the other hand, I don't expect there to ever be more than 100
// of them at once. // of them at once.
#define ASSEMBLY_LIST_LENGTH 32 #define ASSEMBLY_LIST_LENGTH 32
@ -102,11 +102,12 @@ struct app_state
node_render_settings NodeRenderSettings; node_render_settings NodeRenderSettings;
interface_node* OutputNode; interface_node* OutputNode;
v4* ColorPickerEditValue;
string GeneralPurposeSearchString; 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_debug_visuals.h"
#include "foldhaus_sacn_view.cpp" #include "foldhaus_sacn_view.cpp"
#include "foldhaus_command_dispatch.cpp" #include "foldhaus_command_dispatch.cpp"

View File

@ -241,3 +241,49 @@ FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeLister)
OpState->ListPosition = Mouse.Pos; OpState->ListPosition = Mouse.Pos;
SetTextInputDestinationToString(&State->ActiveTextEntry, &State->GeneralPurposeSearchString); SetTextInputDestinationToString(&State->ActiveTextEntry, &State->GeneralPurposeSearchString);
} }
////////////////////////////////////////
//
// Node Color Picker
//
///////////////////////////////////////
struct color_picker_operation_state
{
v4* ValueAddr;
};
internal void
CloseColorPicker(app_state* State)
{
DeactivateCurrentOperationMode(&State->Modes);
}
OPERATION_RENDER_PROC(RenderColorPicker)
{
// 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*)Mode.OpStateMemory;
b32 ShouldClose = EvaluateColorPicker(RenderBuffer, OpState->ValueAddr,
v2{200, 200}, State->Interface, GuiMouse);
if (ShouldClose)
{
CloseColorPicker(State);
}
}
internal void
OpenColorPicker(app_state* State, v4* ValueAddr)
{
// TODO(Peter): This won't work with hot code reloading
operation_mode* ColorPickerMode = ActivateOperationMode(&State->Modes);
ColorPickerMode->Render = RenderColorPicker;
color_picker_operation_state* OpState = CreateOperationState(ColorPickerMode,
&State->Modes,
color_picker_operation_state);
OpState->ValueAddr = ValueAddr;
}

View File

@ -775,7 +775,11 @@ UpdateDraggingNodeValue (v2 MousePos, v2 LastFrameMousePos, node_interaction Int
case MemberType_v4: case MemberType_v4:
{ {
State->ColorPickerEditValue = &Connection->V4Value; // TODO(Peter): This is a problem. We seem to be calling this several times
if (MagSqr(MouseDelta) < 10)
{
OpenColorPicker(State, &Connection->V4Value);
}
}break; }break;
case MemberType_NODE_COLOR_BUFFER: {} break; // NOTE(Peter): Unused for now case MemberType_NODE_COLOR_BUFFER: {} break; // NOTE(Peter): Unused for now

View File

@ -2,26 +2,18 @@ TODO FOLDHAUS
Intermediate Lifetime Memory & Operations Intermediate Lifetime Memory & Operations
x Intermediate lifetime memory arena x Intermediate lifetime memory arena
- Temporary memory region = a multi frame operation x Temporary memory region = a multi frame operation
- Concept of an operation - temporary memory + interface command registry x Concept of an operation - temporary memory + interface command registry
- Allow one operation at a time at first x Allow one operation at a time at first
- Push/pop operations on a list? x Push/pop operations on a list?
- Current Operations: - Current Operations:
- - View Sculpture - - View Sculpture (this might be an exception since its so central)
- - View/Edit Nodes - - View/Edit Nodes
- x Add Node (needs nesting) - x Add Node (needs nesting)
- - View SACN - x View SACN
- Why does backspacing in text entry not save when you close and reopen the node lister? - 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
Plan
x start with adding nodes
x push/pop an operation
x create operation structure
x static size of operations list
x move command registry out of search lister and text entry into operation
x initialize/cleanup add node operation
- extend to other operations
Hardening Hardening
- memory visualization - memory visualization