2023-06-17 17:00:55 +00:00
|
|
|
//- sixten: Views
|
|
|
|
inline workspace_view *Workspace_CreateNewView(workspace_view_type Type, workspace_panel *Parent)
|
|
|
|
{
|
2023-07-19 15:09:41 +00:00
|
|
|
memory_arena *Arena = ArenaAllocate(Gigabytes(1));
|
|
|
|
workspace_view *View = PushStruct(Arena, workspace_view);
|
|
|
|
View->Arena = Arena;
|
2023-06-17 17:00:55 +00:00
|
|
|
View->Type = Type;
|
|
|
|
View->Parent = Parent;
|
|
|
|
|
|
|
|
switch(View->Type)
|
|
|
|
{
|
|
|
|
case Workspace_View_Editor:
|
2023-07-24 13:50:57 +00:00
|
|
|
{
|
|
|
|
View->Data = PushStruct(View->Arena, workspace_view_editor);
|
|
|
|
} break;
|
|
|
|
|
2023-06-17 17:00:55 +00:00
|
|
|
case Workspace_View_CommandPalette:
|
2023-07-24 13:50:57 +00:00
|
|
|
{
|
|
|
|
View->Data = PushStruct(View->Arena, workspace_view_command_palette);
|
|
|
|
} break;
|
|
|
|
|
2023-06-17 17:00:55 +00:00
|
|
|
case Workspace_View_Settings:
|
2023-07-24 13:50:57 +00:00
|
|
|
{
|
|
|
|
View->Data = PushStruct(View->Arena, workspace_view_settings);
|
|
|
|
} break;
|
|
|
|
|
2023-07-19 15:09:41 +00:00
|
|
|
case Workspace_View_TextEditor:
|
|
|
|
{
|
|
|
|
View->Data = PushStruct(View->Arena, workspace_view_text_editor);
|
2023-07-24 13:50:57 +00:00
|
|
|
|
2023-07-19 15:09:41 +00:00
|
|
|
workspace_view_text_editor *Editor = (workspace_view_text_editor *)View->Data;
|
|
|
|
Editor->ProcessingArena = ArenaAllocate(Gigabytes(1));
|
2023-07-24 13:50:57 +00:00
|
|
|
Editor->Text = MutableStringAllocate(Gigabytes(1));
|
|
|
|
Editor->HistoryArena = ArenaAllocate(Gigabytes(1));
|
|
|
|
|
|
|
|
SenDLLInit(&Editor->History.Sentinel);
|
|
|
|
Editor->History.At = &Editor->History.Sentinel;
|
|
|
|
|
|
|
|
workspace_text_data TextData = Workspace_TextDataFromStringChunkList(Editor->ProcessingArena, Editor->Text.String);
|
|
|
|
Editor->Tokens = TextData.Tokens;
|
|
|
|
Editor->Lines = TextData.Lines;
|
2023-07-19 15:09:41 +00:00
|
|
|
} break;
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
|
2023-06-17 21:06:25 +00:00
|
|
|
DLLInsertLast(Parent->FirstView, Parent->LastView, View);
|
|
|
|
|
|
|
|
if(View->Parent)
|
|
|
|
{
|
|
|
|
Parent->CurrentView = View;
|
|
|
|
}
|
|
|
|
|
2023-06-17 17:00:55 +00:00
|
|
|
return(View);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Workspace_DestroyView(workspace_view *View)
|
|
|
|
{
|
2023-07-24 13:50:57 +00:00
|
|
|
switch(View->Type)
|
|
|
|
{
|
|
|
|
case Workspace_View_TextEditor:
|
|
|
|
{
|
|
|
|
workspace_view_text_editor *Editor = (workspace_view_text_editor *)View->Data;
|
|
|
|
ArenaRelease(Editor->ProcessingArena);
|
|
|
|
MutableStringRelease(&Editor->Text);
|
|
|
|
ArenaRelease(Editor->HistoryArena);
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
|
2023-06-17 17:00:55 +00:00
|
|
|
// sixten(NOTE): This function does not ensure that the view is not being used anywhere else.
|
2023-07-19 15:09:41 +00:00
|
|
|
ArenaRelease(View->Arena);
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
|
2023-07-19 15:09:41 +00:00
|
|
|
inline b32 Workspace_ViewIsCurrent(workspace_view *View)
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
2023-07-19 15:09:41 +00:00
|
|
|
workspace *Workspace = Workspace_GetState();
|
|
|
|
|
2023-06-17 17:00:55 +00:00
|
|
|
b32 Result = (Workspace->CurrentPanel && Workspace->CurrentPanel->CurrentView == View);
|
|
|
|
return(Result);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline string Workspace_GetViewName(workspace_view *View)
|
|
|
|
{
|
|
|
|
string Result = StrLit("Unnamed view");
|
|
|
|
switch(View->Type)
|
|
|
|
{
|
|
|
|
case Workspace_View_Startup: { Result = StrLit("Welcome"); } break;
|
|
|
|
case Workspace_View_Editor: { Result = StrLit("Editor"); } break;
|
|
|
|
case Workspace_View_Settings: { Result = StrLit("Settings"); } break;
|
2023-08-06 10:35:09 +00:00
|
|
|
case Workspace_View_TextEditor:
|
|
|
|
{
|
|
|
|
workspace_view_text_editor *Editor = (workspace_view_text_editor *)View->Data;
|
|
|
|
if(AreEqual(Editor->FileName, StrLit("")))
|
|
|
|
{
|
|
|
|
Result = StrLit("Open File");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(Editor->History.At == &Editor->History.Sentinel)
|
|
|
|
{
|
|
|
|
Result = PushString(Workspace_FrameArena(), Editor->FileName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Result = PushFormat(Workspace_FrameArena(), "* %S", Editor->FileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} break;
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(Result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//- sixten: Builder code
|
|
|
|
static void Workspace_ViewListerInputCallback(render_group *Group, glyph_atlas *Atlas, ui_box *Box, void *Data)
|
|
|
|
{
|
|
|
|
workspace_view_command_palette *CommandPalette = (workspace_view_command_palette *)Data;
|
2023-06-21 16:59:36 +00:00
|
|
|
string ToCursor = MakeString(Box->String.Data, CommandPalette->ListerInputEditState.Cursor);
|
|
|
|
string ToMark = MakeString(Box->String.Data, CommandPalette->ListerInputEditState.Mark);
|
2023-06-17 17:00:55 +00:00
|
|
|
|
|
|
|
r32 TargetCursorX = CalculateRasterizedTextWidth(Atlas, Box->Font, Box->FontSize, ToCursor);
|
|
|
|
r32 TargetMarkerX = CalculateRasterizedTextWidth(Atlas, Box->Font, Box->FontSize, ToMark);
|
|
|
|
|
|
|
|
r32 CursorX = AnimationCurve_AnimateValueF(TargetCursorX, 0, 0.175, "Workspace View Input Cursor %p", Box);
|
|
|
|
r32 MarkerX = AnimationCurve_AnimateValueF(TargetMarkerX, 0, 0.175, "Workspace View Input Mark %p", Box);
|
|
|
|
|
|
|
|
v2 BoxDim = DimOfRange(Box->Rect);
|
|
|
|
|
|
|
|
// sixten: Draw selection
|
|
|
|
{
|
|
|
|
v2 Offset = V2(7.5, (BoxDim.y - Box->FontSize) / 2);
|
|
|
|
v2 Dim = V2(0, Box->FontSize);
|
|
|
|
if(CursorX > MarkerX)
|
|
|
|
{
|
|
|
|
Offset.x += MarkerX;
|
|
|
|
Dim.x = CursorX - MarkerX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Offset.x += CursorX;
|
|
|
|
Dim.x = MarkerX - CursorX;
|
|
|
|
}
|
|
|
|
|
|
|
|
v2 P = Box->Rect.Min + Offset;
|
|
|
|
v4 Color = V4(0.4, 0.7, 0.8, 0.3);
|
2023-07-19 15:09:41 +00:00
|
|
|
PushQuad(Group, Range2R32(P, P+Dim), Color, 0, 0, 0);
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// sixten: Draw cursor
|
|
|
|
if(CommandPalette->ListerFieldSelected)
|
|
|
|
{
|
2023-06-21 16:59:36 +00:00
|
|
|
range1_r32 CursorSpan = Range1R32(CursorX, TargetCursorX);
|
2023-06-17 17:00:55 +00:00
|
|
|
r32 Height = Box->FontSize + 4;
|
|
|
|
v2 Offset = V2(7.5F + CursorSpan.Min, (BoxDim.y - Height) / 2);
|
|
|
|
v2 Dim = V2(1.25F + CursorSpan.Max - CursorSpan.Min, Height);
|
|
|
|
|
|
|
|
v2 P = Box->Rect.Min + Offset;
|
|
|
|
v4 Color = V4(0.3, 1, 0.3, 0.7);
|
2023-07-19 15:09:41 +00:00
|
|
|
PushQuad(Group, Range2R32(P, P+Dim), Color, 0, 0, 0);
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-19 15:09:41 +00:00
|
|
|
static void Workspace_BuildViewTypeLister(workspace_view *View)
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
|
|
|
workspace_view_command_palette *CommandPalette = (workspace_view_command_palette *)View->Data;
|
|
|
|
|
2023-07-19 15:09:41 +00:00
|
|
|
workspace *Workspace = Workspace_GetState();
|
|
|
|
|
2023-06-17 17:00:55 +00:00
|
|
|
temporary_memory Scratch = GetScratch(0, 0);
|
|
|
|
|
|
|
|
UI_Size(UI_Percent(1, 1), UI_Percent(1, 1))
|
|
|
|
UI_Parent(UI_MakeBox(0, StrLit("")))
|
|
|
|
{
|
|
|
|
UI_Spacer(UI_Pixels(1.25, 1));
|
|
|
|
UI_CornerRadius(4)
|
|
|
|
UI_BackgroundColor(V4(0.5, 0.2, 0.3, 1.0))
|
|
|
|
UI_LayoutAxis(Axis2_X)
|
|
|
|
UI_Height(UI_Pixels(30, 1))
|
|
|
|
UI_Parent(UI_MakeBoxF(UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawDropShadow, "Workspace View Lister Header"))
|
|
|
|
{
|
|
|
|
UI_Spacer(UI_Pixels(5, 1));
|
|
|
|
|
|
|
|
UI_Width(UI_TextContent(10, 1)) UI_LabelF("Open View:");
|
|
|
|
|
|
|
|
UI_Spacer(UI_Pixels(15, 1));
|
|
|
|
|
|
|
|
// sixten: Input Field.
|
|
|
|
{
|
|
|
|
r32 SelectedTransition = AnimationCurve_AnimateValueF(CommandPalette->ListerFieldSelected ? 1.0 : 0.0,
|
|
|
|
0, 0.125, "View Input Field %p", View);
|
|
|
|
|
|
|
|
v4 BorderColor = UI_TopBackgroundColor()*2;
|
|
|
|
BorderColor.w = SelectedTransition;
|
|
|
|
|
|
|
|
UI_SetNextBorderColor(BorderColor);
|
|
|
|
|
|
|
|
UI_SetNextBackgroundColor(LinearBlend(V4(0, 0, 0, 1), UI_TopBackgroundColor(), 0.5));
|
|
|
|
UI_SetNextWidth(UI_Percent(1, 0));
|
|
|
|
|
|
|
|
ui_box *InputBox = UI_MakeBoxF(UI_BoxFlag_DrawBackground |
|
|
|
|
UI_BoxFlag_Clickable |
|
|
|
|
UI_BoxFlag_DrawBorder,
|
|
|
|
"View Type Lister Input");
|
|
|
|
|
|
|
|
UI_Parent(InputBox)
|
|
|
|
{
|
|
|
|
UI_SetNextWidth(UI_TextContent(15, 1));
|
|
|
|
|
|
|
|
ui_box *InputTextBox = UI_MakeBox(UI_BoxFlag_DrawText, StrLit("Workspace View Lister"));
|
|
|
|
InputTextBox->String = MakeString(CommandPalette->ListerInput, CommandPalette->ListerInputUsed);
|
|
|
|
InputTextBox->DrawCallback = Workspace_ViewListerInputCallback;
|
2023-06-27 14:14:28 +00:00
|
|
|
InputTextBox->DrawCallbackData = CommandPalette;
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UI_Spacer(UI_Pixels(4, 1));
|
|
|
|
|
|
|
|
if(CommandPalette->ListerFieldSelected)
|
|
|
|
{
|
|
|
|
for(platform_event *Event = Workspace->EventList->First;
|
|
|
|
Event != 0;
|
|
|
|
Event = Event->Next)
|
|
|
|
{
|
|
|
|
if(Event->Type == PlatformEvent_Press || Event->Type == PlatformEvent_Text)
|
|
|
|
{
|
|
|
|
text_action Action = SingleLineTextActionFromEvent(Event);
|
|
|
|
if(IsValid(&Action))
|
|
|
|
{
|
|
|
|
text_op Op = TextOpFromAction(Scratch.Arena, MakeString(CommandPalette->ListerInput, CommandPalette->ListerInputUsed),
|
|
|
|
&CommandPalette->ListerInputEditState, &Action);
|
|
|
|
|
|
|
|
string Left = MakeString(CommandPalette->ListerInput, Op.Range.Min);
|
|
|
|
string Right = MakeString(CommandPalette->ListerInput + Op.Range.Max, CommandPalette->ListerInputUsed - Op.Range.Max);
|
|
|
|
|
|
|
|
u64 NewStringSize = Left.Count + Right.Count + Op.ReplaceString.Count;
|
|
|
|
char *NewString = PushArray(Scratch.Arena, char, NewStringSize);
|
|
|
|
Copy(NewString, Left.Data, Left.Count);
|
|
|
|
Copy(NewString + Left.Count, Op.ReplaceString.Data, Op.ReplaceString.Count);
|
|
|
|
Copy(NewString + Left.Count + Op.ReplaceString.Count, Right.Data, Right.Count);
|
|
|
|
|
|
|
|
CommandPalette->ListerInputUsed = Minimum(ArrayCount(CommandPalette->ListerInput), NewStringSize);
|
|
|
|
Copy(CommandPalette->ListerInput, NewString, CommandPalette->ListerInputUsed);
|
|
|
|
|
|
|
|
CommandPalette->ListerInputEditState.Cursor = Minimum(Op.NewCursor, CommandPalette->ListerInputUsed);
|
|
|
|
CommandPalette->ListerInputEditState.Mark = Minimum(Op.NewMark, CommandPalette->ListerInputUsed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(UI_SignalFromBox(InputBox).Pressed)
|
|
|
|
{
|
|
|
|
CommandPalette->ListerFieldSelected = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui *UI = UI_GetState();
|
|
|
|
|
|
|
|
if(!(AreEqual(UI->Active, UI_EmptyKey()) || AreEqual(UI->Active, InputBox->Key)))
|
|
|
|
{
|
|
|
|
CommandPalette->ListerFieldSelected = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UI_Spacer(UI_Pixels(15, 1));
|
|
|
|
|
|
|
|
{
|
|
|
|
UI_SetNextCornerRadius(10);
|
|
|
|
UI_SetNextBackgroundColor(V4(0.15, 0.15, 0.15, 1.0));
|
|
|
|
UI_SetNextBorderColor(V4(0.35, 0.35, 0.35, 1.0));
|
|
|
|
UI_SetNextSize(UI_Percent(1, 1), UI_Pixels(100, 1));
|
|
|
|
UI_SetNextLayoutAxis(Axis2_Y);
|
|
|
|
|
|
|
|
ui_box *ButtonBox = UI_MakeBox(UI_BoxFlag_DrawBackground |
|
|
|
|
UI_BoxFlag_DrawBorder |
|
|
|
|
UI_BoxFlag_HotAnimation |
|
|
|
|
UI_BoxFlag_ActiveAnimation |
|
|
|
|
UI_BoxFlag_Clickable,
|
|
|
|
StrLit("Type Lister Box"));
|
|
|
|
|
|
|
|
UI_SignalFromBox(ButtonBox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReleaseScratch(Scratch);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Workspace_BuildSettingsTabButton(workspace_view_settings *Settings, char *Name, workspace_settings_category Category)
|
|
|
|
{
|
|
|
|
b32 IsSelected = (Settings->Category == Category);
|
|
|
|
|
2023-06-19 17:12:26 +00:00
|
|
|
v4 Color = LinearBlend(Theme_TextColor, Theme_HighlightBorderColor, AnimationCurve_AnimateValueF(IsSelected, IsSelected, 0.3, "Workspace Settings %s %p", Name, Settings));
|
2023-06-17 17:00:55 +00:00
|
|
|
|
|
|
|
UI_SetNextFont(Font_Bold);
|
|
|
|
UI_SetNextHeight(UI_TextContent(0, 1));
|
|
|
|
UI_SetNextTextColor(Color);
|
|
|
|
|
|
|
|
ui_box *Box = UI_MakeBoxF(UI_BoxFlag_DrawText |
|
|
|
|
UI_BoxFlag_Clickable,
|
|
|
|
Name);
|
|
|
|
|
|
|
|
ui_signal Signal = UI_SignalFromBox(Box);
|
|
|
|
if(Signal.Hovering)
|
|
|
|
{
|
|
|
|
Platform.SetCursor(PlatformCursor_Hand);
|
|
|
|
}
|
2023-06-18 10:09:36 +00:00
|
|
|
if(Signal.Pressed)
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
|
|
|
Settings->Category = Category;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-17 21:06:25 +00:00
|
|
|
static b32 UI_DropdownSelection(char **Alternatives, s32 AlternativeCount, b32 *Open, s32 *Selected)
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
2023-06-17 21:06:25 +00:00
|
|
|
b32 Result = false;
|
|
|
|
|
2023-06-17 17:00:55 +00:00
|
|
|
UI_SetNextLayoutAxis(Axis2_X);
|
|
|
|
UI_Parent(UI_MakeBoxF(0, ""))
|
|
|
|
{
|
|
|
|
UI_LabelF("Refresh Rate:");
|
|
|
|
UI_Spacer(UI_Pixels(10, 1));
|
|
|
|
|
2023-06-17 21:06:25 +00:00
|
|
|
b32 ActiveInDropdown = false;
|
|
|
|
|
2023-06-17 17:00:55 +00:00
|
|
|
UI_SetNextWidth(UI_Pixels(200, 1));
|
|
|
|
UI_SetNextCornerRadius(4);
|
|
|
|
UI_SetNextLayoutAxis(Axis2_X);
|
|
|
|
ui_box *DropdownBox = UI_MakeBoxF(UI_BoxFlag_DrawBackground |
|
|
|
|
UI_BoxFlag_DrawBorder |
|
|
|
|
UI_BoxFlag_HotAnimation |
|
|
|
|
UI_BoxFlag_ActiveAnimation |
|
|
|
|
UI_BoxFlag_Clickable,
|
|
|
|
"Dropdown");
|
|
|
|
UI_Parent(DropdownBox)
|
|
|
|
{
|
|
|
|
UI_Width(UI_Percent(1, 0)) UI_LabelF(Alternatives[*Selected]);
|
|
|
|
UI_BackgroundColor(Theme_BorderColor) UI_Width(UI_Pixels(1, 1)) UI_MakeBoxF(UI_BoxFlag_DrawBackground, "");
|
|
|
|
UI_Width(UI_Pixels(25, 1)) UI_Font(Font_Icons) UI_LabelF("%U", FontIcon_DownDir);
|
|
|
|
}
|
|
|
|
|
2023-06-17 21:06:25 +00:00
|
|
|
ui_signal DropdownSignal = UI_SignalFromBox(DropdownBox);
|
|
|
|
if(DropdownSignal.Pressed)
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
2023-06-17 21:06:25 +00:00
|
|
|
*Open = !(*Open);
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
|
2023-06-17 21:06:25 +00:00
|
|
|
if(AreEqual(UI_GetActive(), DropdownBox->Key))
|
|
|
|
{
|
|
|
|
ActiveInDropdown = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
r32 OpenTransition = AnimationCurve_AnimateValueF(*Open, 0, 0.175, "UI Dropdown %p%p", Alternatives, Open);
|
|
|
|
|
|
|
|
if(OpenTransition > 0.1)
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
|
|
|
UI_Tooltip
|
|
|
|
{
|
|
|
|
UI_SetNextFixedP(V2(DropdownBox->Rect.Min.x, DropdownBox->Rect.Max.y));
|
|
|
|
UI_SetNextCornerRadius(4);
|
|
|
|
UI_SetNextWidth(UI_Pixels(200, 1));
|
2023-06-17 21:06:25 +00:00
|
|
|
UI_SetNextHeight(UI_ChildrenSum(OpenTransition, 1));
|
2023-06-17 17:00:55 +00:00
|
|
|
UI_Parent(UI_MakeBoxF(UI_BoxFlag_Clip |
|
|
|
|
UI_BoxFlag_DrawDropShadow |
|
|
|
|
UI_BoxFlag_FloatingX |
|
|
|
|
UI_BoxFlag_FloatingY, "Dropdown Contents"))
|
|
|
|
{
|
2023-06-17 21:06:25 +00:00
|
|
|
UI_PushWidth(UI_Percent(1, 1));
|
|
|
|
|
2023-06-17 17:00:55 +00:00
|
|
|
for(s64 Index = 0;
|
2023-06-17 21:06:25 +00:00
|
|
|
Index < Round(AlternativeCount*OpenTransition);
|
2023-06-17 17:00:55 +00:00
|
|
|
++Index)
|
|
|
|
{
|
2023-06-17 21:06:25 +00:00
|
|
|
ui_signal ButtonSignal = UI_ButtonF(Alternatives[Index]);
|
|
|
|
if(AreEqual(UI_GetActive(), ButtonSignal.Box->Key))
|
|
|
|
{
|
|
|
|
ActiveInDropdown = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ButtonSignal.Pressed)
|
|
|
|
{
|
|
|
|
*Selected = Index;
|
|
|
|
Result = true;
|
|
|
|
}
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
2023-06-17 21:06:25 +00:00
|
|
|
|
|
|
|
UI_PopWidth();
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-06-17 21:06:25 +00:00
|
|
|
|
|
|
|
if(!ActiveInDropdown && !AreEqual(UI_GetActive(), UI_EmptyKey()))
|
|
|
|
{
|
|
|
|
*Open = false;
|
|
|
|
}
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
2023-06-17 21:06:25 +00:00
|
|
|
|
|
|
|
return(Result);
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
|
2023-07-19 15:09:41 +00:00
|
|
|
static void Workspace_BuildSettings(workspace_view *View)
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
|
|
|
workspace_view_settings *Settings = (workspace_view_settings *)View->Data;
|
|
|
|
|
2023-07-19 15:09:41 +00:00
|
|
|
workspace *Workspace = Workspace_GetState();
|
|
|
|
|
2023-06-17 17:00:55 +00:00
|
|
|
UI_Height(UI_ChildrenSum(1, 1))
|
2023-06-27 14:14:28 +00:00
|
|
|
UI_Column() UI_Padding(UI_Pixels(50, 0))
|
|
|
|
UI_Row() UI_Padding(UI_Pixels(50, 0))
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
|
|
|
UI_Size(UI_TextContent(0, 1), UI_TextContent(10, 1))
|
|
|
|
UI_Font(Font_Bold) UI_FontSize(36)
|
|
|
|
UI_LabelF("Settings");
|
|
|
|
}
|
|
|
|
|
|
|
|
UI_LayoutAxis(Axis2_X)
|
|
|
|
UI_Size(UI_Percent(1, 0), UI_Percent(1, 0))
|
|
|
|
UI_Parent(UI_MakeBoxF(0, ""))
|
|
|
|
{
|
|
|
|
UI_Width(UI_Pixels(300, 1))
|
|
|
|
UI_Parent(UI_MakeBoxF(0, "Navigation"))
|
|
|
|
{
|
2023-06-27 14:14:28 +00:00
|
|
|
UI_Row() UI_Padding(UI_Pixels(50, 1))
|
|
|
|
UI_Width(UI_Percent(1, 0)) UI_Column() UI_Padding(UI_Percent(1, 0))
|
2023-06-17 17:00:55 +00:00
|
|
|
UI_Height(UI_ChildrenSum(1, 1)) UI_LayoutAxis(Axis2_Y) UI_Parent(UI_MakeBoxF(0, ""))
|
|
|
|
{
|
|
|
|
Workspace_BuildSettingsTabButton(Settings, "All", Workspace_Settings_All);
|
|
|
|
UI_Spacer(UI_Pixels(30, 1));
|
|
|
|
Workspace_BuildSettingsTabButton(Settings, "General", Workspace_Settings_General);
|
|
|
|
UI_Spacer(UI_Pixels(30, 1));
|
2023-06-23 12:38:15 +00:00
|
|
|
Workspace_BuildSettingsTabButton(Settings, "Theme", Workspace_Settings_Theme);
|
|
|
|
UI_Spacer(UI_Pixels(30, 1));
|
2023-06-17 17:00:55 +00:00
|
|
|
Workspace_BuildSettingsTabButton(Settings, "Developer", Workspace_Settings_Developer);
|
|
|
|
|
|
|
|
UI_Spacer(UI_Pixels(150, 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UI_CornerRadius(5)
|
|
|
|
UI_Width(UI_Pixels(1.25, 1))
|
|
|
|
UI_BackgroundColor(Color_Grey)
|
|
|
|
UI_MakeBoxF(UI_BoxFlag_DrawBackground, "Separator");
|
|
|
|
|
|
|
|
UI_Padding(UI_Pixels(70, 0))
|
|
|
|
UI_LayoutAxis(Axis2_Y)
|
|
|
|
UI_Width(UI_Percent(1, 0))
|
|
|
|
UI_Parent(UI_MakeBoxF(0, "Tab"))
|
|
|
|
UI_Size(UI_TextContent(0, 1), UI_TextContent(10, 1))
|
|
|
|
{
|
|
|
|
workspace_settings_category Category = Settings->Category;
|
|
|
|
if(!Category || (Category == Workspace_Settings_General))
|
|
|
|
{
|
|
|
|
UI_Font(Font_Bold) UI_FontSize(36) UI_LabelF("General");
|
|
|
|
|
|
|
|
char *Alternatives[] = {"60 Hz", "120 Hz", "144 Hz", "Uncapped", "V-Sync"};
|
2023-06-23 12:38:15 +00:00
|
|
|
s64 AlternativeMapping[] = {60, 120, 144, -1, 0};
|
|
|
|
|
|
|
|
s32 DropdownSelected;
|
|
|
|
FindIndexOfElement(DropdownSelected, AlternativeMapping, 0, Workspace->Input->RefreshRate);
|
2023-06-17 17:00:55 +00:00
|
|
|
|
2023-06-27 14:14:28 +00:00
|
|
|
if(UI_DropdownSelection(Alternatives, ArrayCount(Alternatives),
|
|
|
|
&Settings->GeneralDropdownOpen, &DropdownSelected))
|
2023-06-19 17:12:26 +00:00
|
|
|
{
|
2023-06-23 12:38:15 +00:00
|
|
|
Workspace->Input->RefreshRate = AlternativeMapping[DropdownSelected];
|
2023-06-27 14:14:28 +00:00
|
|
|
Settings->GeneralDropdownOpen = false;
|
2023-06-19 17:12:26 +00:00
|
|
|
}
|
2023-06-17 21:06:25 +00:00
|
|
|
|
2023-06-23 12:38:15 +00:00
|
|
|
UI_Spacer(UI_Pixels(50, 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!Category || (Category == Workspace_Settings_Theme))
|
|
|
|
{
|
|
|
|
UI_Font(Font_Bold) UI_FontSize(36) UI_LabelF("Theme");
|
|
|
|
|
2023-06-27 14:14:28 +00:00
|
|
|
UI_SetNextSize(UI_Percent(1, 1), UI_Em(13, 1));
|
2023-06-23 12:38:15 +00:00
|
|
|
|
2023-06-27 14:14:28 +00:00
|
|
|
UI_Scroll(0, &Settings->ThemeScroll)
|
2023-06-17 21:06:25 +00:00
|
|
|
{
|
2023-06-27 14:14:28 +00:00
|
|
|
UI_Size(UI_Percent(1, 1), UI_Em(2, 1))
|
|
|
|
{
|
|
|
|
for(s32 Index = 0;
|
|
|
|
Index < 2;
|
|
|
|
++Index)
|
|
|
|
{
|
|
|
|
UI_ButtonF("Hello#%i", Index);
|
|
|
|
UI_ButtonF("Line#%i", Index);
|
|
|
|
UI_ButtonF("Paint#%i", Index);
|
|
|
|
UI_ButtonF("Color#%i", Index);
|
|
|
|
UI_ButtonF("Design#%i", Index);
|
|
|
|
UI_ButtonF("Address#%i", Index);
|
|
|
|
UI_ButtonF("Brightness#%i", Index);
|
|
|
|
}
|
|
|
|
}
|
2023-06-17 21:06:25 +00:00
|
|
|
}
|
2023-06-17 17:00:55 +00:00
|
|
|
|
|
|
|
UI_Spacer(UI_Pixels(50, 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!Category || (Category == Workspace_Settings_Developer))
|
|
|
|
{
|
|
|
|
UI_Font(Font_Bold) UI_FontSize(36) UI_LabelF("Developer");
|
2023-06-27 14:14:28 +00:00
|
|
|
UI_Checkbox(&DEBUG_DebugSettings->RenderUIDebugRects, StrLit("Render UI Debug Rects"));
|
|
|
|
UI_Spacer(UI_Pixels(5, 1));
|
|
|
|
UI_Checkbox(&DEBUG_DebugSettings->RenderFPSCounter, StrLit("Render FPS Counter"));
|
2023-06-19 17:12:26 +00:00
|
|
|
UI_Spacer(UI_Pixels(5, 1));
|
2023-06-27 14:14:28 +00:00
|
|
|
UI_Checkbox(&DEBUG_DebugSettings->ListHotAndActive, StrLit("List Hot & Active"));
|
2023-06-17 17:00:55 +00:00
|
|
|
|
|
|
|
UI_Spacer(UI_Pixels(50, 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UI_Spacer(UI_Pixels(50, 1));
|
|
|
|
}
|
|
|
|
|
2023-07-19 15:09:41 +00:00
|
|
|
static void Workspace_BuildView(workspace_view *View)
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
|
|
|
r32 ViewHighlightTransition =
|
2023-07-19 15:09:41 +00:00
|
|
|
AnimationCurve_AnimateValueF(Workspace_ViewIsCurrent(View), 0, 0.25, "Workspace View Highlight %p", View);
|
2023-06-17 17:00:55 +00:00
|
|
|
UI_SetNextBorderColor(LinearBlend(Theme_BorderColor, Theme_HighlightBorderColor, ViewHighlightTransition));
|
2023-06-23 12:38:15 +00:00
|
|
|
UI_PushBackgroundColor(Theme_BackgroundColor);
|
2023-06-17 17:00:55 +00:00
|
|
|
UI_SetNextCornerRadius(3);
|
|
|
|
|
|
|
|
ui_box *ViewBox = UI_MakeBoxF(UI_BoxFlag_Clickable |
|
|
|
|
UI_BoxFlag_DrawBackground |
|
|
|
|
UI_BoxFlag_DrawBorder |
|
|
|
|
UI_BoxFlag_Clip,
|
|
|
|
"Workspace View %p", View);
|
|
|
|
|
|
|
|
UI_Parent(ViewBox)
|
|
|
|
UI_Size(UI_Percent(1, 0), UI_Percent(1, 0))
|
|
|
|
{
|
|
|
|
if(View->Type == Workspace_View_Startup)
|
|
|
|
{
|
2023-06-27 14:14:28 +00:00
|
|
|
UI_Row() UI_Padding(UI_Pixels(50, 0))
|
|
|
|
UI_Width(UI_ChildrenSum(1, 1)) UI_Column() UI_Padding(UI_Pixels(50, 0))
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
|
|
|
UI_Size(UI_TextContent(0, 1), UI_TextContent(10, 1))
|
|
|
|
{
|
|
|
|
UI_Font(Font_Bold) UI_FontSize(36)
|
|
|
|
UI_LabelF("Welcome to VN");
|
|
|
|
UI_TextColor(Theme_BorderColor) UI_LabelF("An impractical way to make a game");
|
2023-07-19 15:09:41 +00:00
|
|
|
|
|
|
|
UI_Spacer(UI_Percent(1, 0));
|
|
|
|
|
|
|
|
UI_Checkbox(&DEBUG_DebugSettings->ShowWelcomeMessage, StrLit("Show this message on startup"));
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(View->Type == Workspace_View_CommandPalette)
|
|
|
|
{
|
2023-07-19 15:09:41 +00:00
|
|
|
Workspace_BuildViewTypeLister(View);
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
else if(View->Type == Workspace_View_Editor)
|
|
|
|
{
|
2023-07-19 15:09:41 +00:00
|
|
|
Workspace_BuildEditor(View);
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
else if(View->Type == Workspace_View_Settings)
|
|
|
|
{
|
2023-07-19 15:09:41 +00:00
|
|
|
Workspace_BuildSettings(View);
|
|
|
|
}
|
|
|
|
else if(View->Type == Workspace_View_TextEditor)
|
|
|
|
{
|
|
|
|
Workspace_BuildTextEditor(View);
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-23 12:38:15 +00:00
|
|
|
UI_PopBackgroundColor();
|
|
|
|
|
2023-06-17 17:00:55 +00:00
|
|
|
UI_SignalFromBox(ViewBox);
|
|
|
|
}
|