Drawing split, fix split left right behaviour

This commit is contained in:
Krzosa Karol
2025-05-10 11:37:03 +02:00
parent a2b081ec15
commit 78ea184868
6 changed files with 35 additions and 7 deletions

View File

@@ -253,6 +253,9 @@ void GenerateConfig() {
colors.add({"TitleBarActiveBackground", "0xfefefefe"}); colors.add({"TitleBarActiveBackground", "0xfefefefe"});
colors.add({"TitleBarSelection", "GruvboxLight3"}); colors.add({"TitleBarSelection", "GruvboxLight3"});
colors.add({"ResizerBackground", "GruvboxLight0Soft"});
colors.add({"ResizerOutline", "GruvboxLight3"});
Array<Var> style = {}; Array<Var> style = {};
style.add({"WaitForEvents", "1"}); style.add({"WaitForEvents", "1"});
style.add({"DrawLineNumbers", "1"}); style.add({"DrawLineNumbers", "1"});

View File

@@ -57,6 +57,8 @@ Color.TitleBarText = GruvboxDark2
Color.TitleBarBackground = GruvboxLight1 Color.TitleBarBackground = GruvboxLight1
Color.TitleBarActiveBackground = 0xfefefefe Color.TitleBarActiveBackground = 0xfefefefe
Color.TitleBarSelection = GruvboxLight3 Color.TitleBarSelection = GruvboxLight3
Color.ResizerBackground = GruvboxLight0Soft
Color.ResizerOutline = GruvboxLight3
Style = {} Style = {}
Style.WaitForEvents = 1 Style.WaitForEvents = 1
Style.DrawLineNumbers = 1 Style.DrawLineNumbers = 1
@@ -391,6 +393,8 @@ void ReloadStyle() {
ColorTitleBarBackground = GetColor("TitleBarBackground", ColorTitleBarBackground); ColorTitleBarBackground = GetColor("TitleBarBackground", ColorTitleBarBackground);
ColorTitleBarActiveBackground = GetColor("TitleBarActiveBackground", ColorTitleBarActiveBackground); ColorTitleBarActiveBackground = GetColor("TitleBarActiveBackground", ColorTitleBarActiveBackground);
ColorTitleBarSelection = GetColor("TitleBarSelection", ColorTitleBarSelection); ColorTitleBarSelection = GetColor("TitleBarSelection", ColorTitleBarSelection);
ColorResizerBackground = GetColor("ResizerBackground", ColorResizerBackground);
ColorResizerOutline = GetColor("ResizerOutline", ColorResizerOutline);
StyleWaitForEvents = GetStyleInt("WaitForEvents", StyleWaitForEvents); StyleWaitForEvents = GetStyleInt("WaitForEvents", StyleWaitForEvents);
StyleDrawLineNumbers = GetStyleInt("DrawLineNumbers", StyleDrawLineNumbers); StyleDrawLineNumbers = GetStyleInt("DrawLineNumbers", StyleDrawLineNumbers);
StyleDrawScrollbar = GetStyleInt("DrawScrollbar", StyleDrawScrollbar); StyleDrawScrollbar = GetStyleInt("DrawScrollbar", StyleDrawScrollbar);

View File

@@ -55,6 +55,8 @@ Color ColorTitleBarText = GruvboxDark2;
Color ColorTitleBarBackground = GruvboxLight1; Color ColorTitleBarBackground = GruvboxLight1;
Color ColorTitleBarActiveBackground = {0xfe, 0xfe, 0xfe, 0xfe}; Color ColorTitleBarActiveBackground = {0xfe, 0xfe, 0xfe, 0xfe};
Color ColorTitleBarSelection = GruvboxLight3; Color ColorTitleBarSelection = GruvboxLight3;
Color ColorResizerBackground = GruvboxLight0Soft;
Color ColorResizerOutline = GruvboxLight3;
Int StyleWaitForEvents = 1; Int StyleWaitForEvents = 1;
Int StyleDrawLineNumbers = 1; Int StyleDrawLineNumbers = 1;
Int StyleDrawScrollbar = 1; Int StyleDrawScrollbar = 1;

View File

@@ -243,8 +243,6 @@ void Update(Event event) {
UpdateDebugBuffer(); UpdateDebugBuffer();
GarbageCollect(); GarbageCollect();
SetMouseCursor(event);
For(IterateInReverse(&order)) { For(IterateInReverse(&order)) {
if (!it->visible) continue; if (!it->visible) continue;
@@ -467,8 +465,11 @@ int main(int argc, char **argv)
} }
Event *event = GetLast(frame_events); Event *event = GetLast(frame_events);
SetMouseCursor(*event);
LayoutWindows(event->xwindow, event->ywindow); // This is here to render changes in title bar size without a frame of delay LayoutWindows(event->xwindow, event->ywindow); // This is here to render changes in title bar size without a frame of delay
BeginFrameRender(event->xwindow, event->ywindow); BeginFrameRender(event->xwindow, event->ywindow);
DrawSplits(&WindowSplits);
Array<Window *> order = GetWindowZOrder(scratch); Array<Window *> order = GetWindowZOrder(scratch);
For(IterateInReverse(&order)) { For(IterateInReverse(&order)) {
if (!it->visible) continue; if (!it->visible) continue;

View File

@@ -173,7 +173,7 @@ void InitWindows() {
WindowSplit *split = &WindowSplits; WindowSplit *split = &WindowSplits;
split->kind = WindowSplitKind_Horizontal; split->kind = WindowSplitKind_Horizontal;
split->value = (double)1.0 - 0.1; split->value = (double)0.9;
{ {
Window *window = CreateWindow(); Window *window = CreateWindow();
@@ -182,7 +182,7 @@ void InitWindows() {
CreateTitlebar(window->id); CreateTitlebar(window->id);
CreateSearchBar(window->id); CreateSearchBar(window->id);
split->left = CreateSplitForWindow(split, window); split->right = CreateSplitForWindow(split, window);
} }
{ {
@@ -194,7 +194,7 @@ void InitWindows() {
CreateSearchBar(window->id); CreateSearchBar(window->id);
ActiveWindow = window->id; ActiveWindow = window->id;
split->right = CreateSplitForWindow(split, window); split->left = CreateSplitForWindow(split, window);
} }
{ {
@@ -258,8 +258,8 @@ void LayoutWindowSplit(WindowSplit *split, Rect2I rect) {
rect2 = CutTop(&rect, (Int)round((double)GetSize(rect).y * split->value)); rect2 = CutTop(&rect, (Int)round((double)GetSize(rect).y * split->value));
split->resizer_rect = CutTop(&rect, (Int)resizer_size); split->resizer_rect = CutTop(&rect, (Int)resizer_size);
LayoutWindowSplit(split->left, rect); LayoutWindowSplit(split->left, rect2);
LayoutWindowSplit(split->right, rect2); LayoutWindowSplit(split->right, rect);
} else { } else {
Assert(!"Invalid codepath"); Assert(!"Invalid codepath");
} }

View File

@@ -274,3 +274,21 @@ void DrawWindow(Window *window, Event &event) {
DrawRect(window->total_rect, ColorInactiveWindow); DrawRect(window->total_rect, ColorInactiveWindow);
} }
} }
void DrawSplits(WindowSplit *split) {
if (split == NULL) {
return;
}
Rect2I rect = split->resizer_rect;
DrawRect(split->resizer_rect, ColorResizerBackground);
if (split->kind == WindowSplitKind_Vertical) {
Rect2I s = CutRight(&rect, 1);
DrawRect(s, ColorResizerOutline);
} else if (split->kind == WindowSplitKind_Horizontal) {
Rect2I s = CutBottom(&rect, 1);
DrawRect(s, ColorResizerOutline);
}
DrawSplits(split->left);
DrawSplits(split->right);
}