Improved Workspace Navigation.
parent
44f5f66b9f
commit
b2be6558e7
|
@ -90,7 +90,7 @@ struct glyph
|
||||||
r32 Advance;
|
r32 Advance;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_GLYPH_ATLAS_DIM 1024*4
|
#define DEFAULT_GLYPH_ATLAS_DIM 1024*2
|
||||||
#define MAX_GLYPH_SIZE 128
|
#define MAX_GLYPH_SIZE 128
|
||||||
|
|
||||||
#define STB_TRUETYPE_IMPLEMENTATION
|
#define STB_TRUETYPE_IMPLEMENTATION
|
||||||
|
|
|
@ -93,6 +93,7 @@ enum platform_key
|
||||||
Key_PageUp, Key_PageDown,
|
Key_PageUp, Key_PageDown,
|
||||||
Key_Home, Key_End,
|
Key_Home, Key_End,
|
||||||
Key_Plus, Key_Minus,
|
Key_Plus, Key_Minus,
|
||||||
|
Key_Period, Key_Comma,
|
||||||
|
|
||||||
Key_Backspace, Key_Delete,
|
Key_Backspace, Key_Delete,
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,13 @@ static workspace_keybind Workspace_Keybinds[] =
|
||||||
{Key_P, PlatformModifier_Ctrl, W_Command_SplitPanelHorizontal},
|
{Key_P, PlatformModifier_Ctrl, W_Command_SplitPanelHorizontal},
|
||||||
{Key_L, PlatformModifier_Ctrl, W_Command_SplitPanelVertical},
|
{Key_L, PlatformModifier_Ctrl, W_Command_SplitPanelVertical},
|
||||||
|
|
||||||
|
{Key_W, PlatformModifier_Ctrl, W_Command_CloseView, 0},
|
||||||
|
{Key_P, PlatformModifier_Ctrl|PlatformModifier_Shift, W_Command_ClosePanel},
|
||||||
|
|
||||||
|
{Key_Comma, PlatformModifier_Ctrl, W_Command_CyclePanel},
|
||||||
|
{Key_Comma, PlatformModifier_Ctrl|PlatformModifier_Shift, W_Command_CyclePanelReverse},
|
||||||
|
|
||||||
{Key_O, PlatformModifier_Ctrl, W_Command_OpenView, W_ViewKind_FileLister},
|
{Key_O, PlatformModifier_Ctrl, W_Command_OpenView, W_ViewKind_FileLister},
|
||||||
{Key_P, PlatformModifier_Ctrl|PlatformModifier_Shift, W_Command_OpenView, W_ViewKind_Settings},
|
|
||||||
|
|
||||||
#if VN_INTERNAL
|
#if VN_INTERNAL
|
||||||
{Key_U, PlatformModifier_Ctrl|PlatformModifier_Shift, W_Command_ToggleRenderUIDebugRects},
|
{Key_U, PlatformModifier_Ctrl|PlatformModifier_Shift, W_Command_ToggleRenderUIDebugRects},
|
||||||
|
|
|
@ -21,8 +21,8 @@ WORKSPACE_COMMAND(W_Command_ClosePanel)
|
||||||
}
|
}
|
||||||
|
|
||||||
workspace_panel *Parent = Panel->Parent;
|
workspace_panel *Parent = Panel->Parent;
|
||||||
|
if(Parent)
|
||||||
Assert(Parent);
|
{
|
||||||
Assert(Panel != Workspace->RootPanel);
|
Assert(Panel != Workspace->RootPanel);
|
||||||
|
|
||||||
DLLRemove(Parent->First, Parent->Last, Panel);
|
DLLRemove(Parent->First, Parent->Last, Panel);
|
||||||
|
@ -88,6 +88,7 @@ WORKSPACE_COMMAND(W_Command_ClosePanel)
|
||||||
|
|
||||||
W_DeletePanel(Panel);
|
W_DeletePanel(Panel);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WORKSPACE_COMMAND(W_Command_OpenView)
|
WORKSPACE_COMMAND(W_Command_OpenView)
|
||||||
{
|
{
|
||||||
|
@ -97,7 +98,19 @@ WORKSPACE_COMMAND(W_Command_OpenView)
|
||||||
|
|
||||||
WORKSPACE_COMMAND(W_Command_CloseView)
|
WORKSPACE_COMMAND(W_Command_CloseView)
|
||||||
{
|
{
|
||||||
workspace_view *View = (workspace_view *)U64ToPointer(Argument);
|
workspace_view *View = 0;
|
||||||
|
if(Argument)
|
||||||
|
{
|
||||||
|
View = (workspace_view *)U64ToPointer(Argument);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
workspace *Workspace = W_GetState();
|
||||||
|
View = Workspace->CurrentPanel->CurrentView;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(View)
|
||||||
|
{
|
||||||
workspace_panel *Panel = View->Parent;
|
workspace_panel *Panel = View->Parent;
|
||||||
|
|
||||||
DLLRemove(Panel->FirstView, Panel->LastView, View);
|
DLLRemove(Panel->FirstView, Panel->LastView, View);
|
||||||
|
@ -108,7 +121,7 @@ WORKSPACE_COMMAND(W_Command_CloseView)
|
||||||
|
|
||||||
W_DestroyView(View);
|
W_DestroyView(View);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
WORKSPACE_COMMAND(W_Command_OpenFile)
|
WORKSPACE_COMMAND(W_Command_OpenFile)
|
||||||
{
|
{
|
||||||
temp Scratch = GetScratch();
|
temp Scratch = GetScratch();
|
||||||
|
@ -190,6 +203,68 @@ WORKSPACE_COMMAND(W_Command_OpenFile)
|
||||||
ReleaseScratch(Scratch);
|
ReleaseScratch(Scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static workspace_panel *W_FindFirstLeaf(workspace_panel *Panel)
|
||||||
|
{
|
||||||
|
for(;Panel->First;) Panel = Panel->First;
|
||||||
|
return(Panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
static workspace_panel *W_FindNextPanelParent(workspace_panel *Panel)
|
||||||
|
{
|
||||||
|
workspace_panel *Result = 0;
|
||||||
|
if(Panel->Next)
|
||||||
|
{
|
||||||
|
Result = Panel->Next;
|
||||||
|
}
|
||||||
|
else if(Panel->Parent)
|
||||||
|
{
|
||||||
|
Result = W_FindNextPanelParent(Panel->Parent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Result = Panel;
|
||||||
|
}
|
||||||
|
return(Result);
|
||||||
|
}
|
||||||
|
|
||||||
|
WORKSPACE_COMMAND(W_Command_CyclePanel)
|
||||||
|
{
|
||||||
|
workspace *Workspace = W_GetState();
|
||||||
|
workspace_panel *Panel = W_FindFirstLeaf(W_FindNextPanelParent(Workspace->CurrentPanel));
|
||||||
|
Workspace->CurrentPanel = Panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
static workspace_panel *W_FindLastLeaf(workspace_panel *Panel)
|
||||||
|
{
|
||||||
|
for(;Panel->Last;) Panel = Panel->Last;
|
||||||
|
return(Panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
static workspace_panel *W_FindPrevPanelParent(workspace_panel *Panel)
|
||||||
|
{
|
||||||
|
workspace_panel *Result = 0;
|
||||||
|
if(Panel->Prev)
|
||||||
|
{
|
||||||
|
Result = Panel->Prev;
|
||||||
|
}
|
||||||
|
else if(Panel->Parent)
|
||||||
|
{
|
||||||
|
Result = W_FindPrevPanelParent(Panel->Parent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Result = Panel;
|
||||||
|
}
|
||||||
|
return(Result);
|
||||||
|
}
|
||||||
|
|
||||||
|
WORKSPACE_COMMAND(W_Command_CyclePanelReverse)
|
||||||
|
{
|
||||||
|
workspace *Workspace = W_GetState();
|
||||||
|
workspace_panel *Panel = W_FindLastLeaf(W_FindPrevPanelParent(Workspace->CurrentPanel));
|
||||||
|
Workspace->CurrentPanel = Panel;
|
||||||
|
}
|
||||||
|
|
||||||
#if VN_INTERNAL
|
#if VN_INTERNAL
|
||||||
WORKSPACE_COMMAND(W_Command_ToggleRenderUIDebugRects)
|
WORKSPACE_COMMAND(W_Command_ToggleRenderUIDebugRects)
|
||||||
{
|
{
|
||||||
|
|
|
@ -235,6 +235,7 @@ static void W_BuildTextEditorErrorList(workspace_view_text_editor *Editor)
|
||||||
if(Signal.Hovering)
|
if(Signal.Hovering)
|
||||||
{
|
{
|
||||||
UI_TooltipLabel(StrLit("Goto in source"), UI_MouseP());
|
UI_TooltipLabel(StrLit("Goto in source"), UI_MouseP());
|
||||||
|
// sixten(TODO): ACTUALLY GO TO THE SOURCE LOCATION
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UI_Spacer(UI_Em(0.5, 1));
|
UI_Spacer(UI_Em(0.5, 1));
|
||||||
|
@ -316,6 +317,17 @@ UI_CUSTOM_DRAW_CALLBACK(W_TextEditorDrawCallback)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
//- sixten: render gradient on current line
|
||||||
|
{
|
||||||
|
v4_r32 ColorBegin = SetAlpha(Theme_HighlightBorderColor, 0.5);
|
||||||
|
v4_r32 ColorEnd = SetAlpha(Theme_HighlightBorderColor, 0.0);
|
||||||
|
range2_r32 LineDest = Range2R32(Box->Rect.Min+V2R32(0, (CursorTextP.Line-1)*LineHeight), Box->Rect.Min+V2R32(400, CursorTextP.Line*LineHeight));
|
||||||
|
PushQuad(Group, LineDest, ColorBegin, ColorEnd, ColorBegin, ColorEnd, 0, 0, 0);
|
||||||
|
PushQuad(Group, LineDest, Theme_BackgroundColor, Theme_BackgroundColor, Theme_BackgroundColor, Theme_BackgroundColor, 4.0f, 14, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//- sixten: render tokens
|
//- sixten: render tokens
|
||||||
v2_r32 TokenP = StartTokenP;
|
v2_r32 TokenP = StartTokenP;
|
||||||
for(token *Token = VisibleTokensBegin; Token < VisibleTokensEnd; Token += 1)
|
for(token *Token = VisibleTokensBegin; Token < VisibleTokensEnd; Token += 1)
|
||||||
|
@ -324,7 +336,7 @@ UI_CUSTOM_DRAW_CALLBACK(W_TextEditorDrawCallback)
|
||||||
|
|
||||||
//- sixten: get color & font from token
|
//- sixten: get color & font from token
|
||||||
font_id Font = Font_Monospace;
|
font_id Font = Font_Monospace;
|
||||||
v4 Color = Color_Magenta;
|
v4 Color = Color_Cyan;
|
||||||
if(Token->Kind == TokenKind_Comment) { Color = Color_Grey; Font = Font_MonospaceOblique; }
|
if(Token->Kind == TokenKind_Comment) { Color = Color_Grey; Font = Font_MonospaceOblique; }
|
||||||
else if(Token->Kind > TokenKind_SymbolsBegin && Token->Kind < TokenKind_SymbolsEnd) { Color = Color_Grey; }
|
else if(Token->Kind > TokenKind_SymbolsBegin && Token->Kind < TokenKind_SymbolsEnd) { Color = Color_Grey; }
|
||||||
else if(Token->Kind == TokenKind_StringLiteral) { Color = ColorFromHex(0xffa900ff); }
|
else if(Token->Kind == TokenKind_StringLiteral) { Color = ColorFromHex(0xffa900ff); }
|
||||||
|
@ -552,7 +564,6 @@ static void W_BuildTextEditor(workspace_view *View)
|
||||||
s64 ColumnIndex = UTF8IndexFromOffset(Line, ColumnOffset);
|
s64 ColumnIndex = UTF8IndexFromOffset(Line, ColumnOffset);
|
||||||
|
|
||||||
CursorHasBeenModified = true;
|
CursorHasBeenModified = true;
|
||||||
Editor->DropdownActive = false;
|
|
||||||
|
|
||||||
text_point Point = {LineIndex + 1, ColumnIndex + 1};
|
text_point Point = {LineIndex + 1, ColumnIndex + 1};
|
||||||
Editor->EditState.Cursor = OffsetFromTextPoint(Editor->Text.String, Editor->Lines, Point);
|
Editor->EditState.Cursor = OffsetFromTextPoint(Editor->Text.String, Editor->Lines, Point);
|
||||||
|
@ -776,6 +787,15 @@ static void W_BuildTextEditor(workspace_view *View)
|
||||||
Editor->Offset.y = CursorP.y - VisibleRegionDim.y + LineHeight;
|
Editor->Offset.y = CursorP.y - VisibleRegionDim.y + LineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(CursorP.x < Editor->Offset.x)
|
||||||
|
{
|
||||||
|
Editor->Offset.x = CursorP.x;
|
||||||
|
}
|
||||||
|
if(CursorP.x > Editor->Offset.x + VisibleRegionDim.x - LineHeight)
|
||||||
|
{
|
||||||
|
Editor->Offset.x = CursorP.x - VisibleRegionDim.x + LineHeight;
|
||||||
|
}
|
||||||
|
|
||||||
if(Editor->LastTextPoint.Line == Point.Line)
|
if(Editor->LastTextPoint.Line == Point.Line)
|
||||||
{
|
{
|
||||||
Editor->LastTextPoint = Point;
|
Editor->LastTextPoint = Point;
|
||||||
|
|
|
@ -72,12 +72,7 @@ struct workspace_view_text_editor
|
||||||
history_node *SavePoint;
|
history_node *SavePoint;
|
||||||
|
|
||||||
// sixten: ui building & rendering
|
// sixten: ui building & rendering
|
||||||
ui_box *ContainerBox;
|
|
||||||
v2 TextDim;
|
|
||||||
v2 Offset;
|
v2 Offset;
|
||||||
b32 DropdownActive;
|
|
||||||
v2 DropdownP;
|
|
||||||
r32 DropdownTransition;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
|
@ -40,7 +40,7 @@ inline workspace_view *W_CreateNewView(workspace_view_kind Kind, workspace_panel
|
||||||
Editor->Tokens = TextData.Tokens;
|
Editor->Tokens = TextData.Tokens;
|
||||||
Editor->Lines = TextData.Lines;
|
Editor->Lines = TextData.Lines;
|
||||||
|
|
||||||
Editor->FontSize = 13.0f;
|
Editor->FontSize = 15.0f;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case W_ViewKind_NavEditor:
|
case W_ViewKind_NavEditor:
|
||||||
|
|
|
@ -575,6 +575,8 @@ static LRESULT Win32_WindowCallback(HWND Window, UINT Message, WPARAM WParam, LP
|
||||||
else if(VKCode == VK_END) { Key = Key_End; }
|
else if(VKCode == VK_END) { Key = Key_End; }
|
||||||
else if(VKCode == VK_OEM_PLUS) { Key = Key_Plus; }
|
else if(VKCode == VK_OEM_PLUS) { Key = Key_Plus; }
|
||||||
else if(VKCode == VK_OEM_MINUS) { Key = Key_Minus; }
|
else if(VKCode == VK_OEM_MINUS) { Key = Key_Minus; }
|
||||||
|
else if(VKCode == VK_OEM_PERIOD) { Key = Key_Period; }
|
||||||
|
else if(VKCode == VK_OEM_COMMA) { Key = Key_Comma; }
|
||||||
else if(VKCode == VK_BACK) { Key = Key_Backspace; }
|
else if(VKCode == VK_BACK) { Key = Key_Backspace; }
|
||||||
else if(VKCode == VK_DELETE) { Key = Key_Delete; }
|
else if(VKCode == VK_DELETE) { Key = Key_Delete; }
|
||||||
else if(VKCode == VK_ESCAPE) { Key = Key_Escape; }
|
else if(VKCode == VK_ESCAPE) { Key = Key_Escape; }
|
||||||
|
@ -794,7 +796,7 @@ int WinMain(HINSTANCE Instance, HINSTANCE PreviousInstance, LPSTR CommandLine, i
|
||||||
// sixten: Setup OpenGL
|
// sixten: Setup OpenGL
|
||||||
HDC DeviceContext = GetDC(Window);
|
HDC DeviceContext = GetDC(Window);
|
||||||
Win32_CreateOpenGLContext(DeviceContext);
|
Win32_CreateOpenGLContext(DeviceContext);
|
||||||
opengl_context OpenGLContext = OpenGL_SetupContext(&RenderCommands, 16*1024);
|
opengl_context OpenGLContext = OpenGL_SetupContext(&RenderCommands, 64*1024);
|
||||||
|
|
||||||
vn_memory Memory = {};
|
vn_memory Memory = {};
|
||||||
Memory.PlatformAPI = Platform;
|
Memory.PlatformAPI = Platform;
|
||||||
|
|
Loading…
Reference in New Issue