Basic splitting, column concept
This commit is contained in:
@@ -266,13 +266,12 @@ bool GlobalCommand(Event event) {
|
||||
ProfileFunction();
|
||||
bool run_window_command = true;
|
||||
{
|
||||
Vec2I mouse = MouseVec2I();
|
||||
Window *window = GetActiveWindow();
|
||||
bool mouse_in_document = CheckCollisionPointRec(mouse, window->document_rect);
|
||||
bool mouse_in_scrollbar = CheckCollisionPointRec(mouse, window->scrollbar_rect);
|
||||
bool mouse_in_line_numbers = CheckCollisionPointRec(mouse, window->line_numbers_rect);
|
||||
bool mouse_in_total = CheckCollisionPointRec(mouse, window->total_rect);
|
||||
window->mouse_in_scrollbar = mouse_in_scrollbar;
|
||||
Vec2I mouse = MouseVec2I();
|
||||
Window *window = GetActiveWindow();
|
||||
bool mouse_in_document = CheckCollisionPointRec(mouse, window->document_rect);
|
||||
bool mouse_in_total = CheckCollisionPointRec(mouse, window->total_rect);
|
||||
bool mouse_in_scrollbar = CheckCollisionPointRec(mouse, window->scrollbar_rect);
|
||||
window->mouse_in_scrollbar = mouse_in_scrollbar;
|
||||
|
||||
static SDL_Cursor *SDL_MouseCursor;
|
||||
if (SDL_MouseCursor) SDL_DestroyCursor(SDL_MouseCursor);
|
||||
@@ -283,9 +282,6 @@ bool GlobalCommand(Event event) {
|
||||
} else if (mouse_in_scrollbar || window->mouse_selecting_scrollbar) {
|
||||
SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT);
|
||||
SDL_SetCursor(SDL_MouseCursor);
|
||||
} else if (mouse_in_line_numbers) {
|
||||
SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_EW_RESIZE);
|
||||
SDL_SetCursor(SDL_MouseCursor);
|
||||
} else {
|
||||
SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_POINTER);
|
||||
SDL_SetCursor(SDL_MouseCursor);
|
||||
@@ -301,18 +297,6 @@ bool GlobalCommand(Event event) {
|
||||
Window *window = &Windows[it];
|
||||
if (!window->visible) continue;
|
||||
bool mouse_in_window = CheckCollisionPointRec(mouse, window->total_rect);
|
||||
if (ActiveWindow.id == window->id.id) {
|
||||
bool mouse_in_line_numbers = CheckCollisionPointRec(mouse, window->line_numbers_rect);
|
||||
if (mouse_in_line_numbers) {
|
||||
// if (Mouse(LEFT)) {
|
||||
// window->layout_value.x += 0.1f;
|
||||
// } else if (Mouse(RIGHT)) {
|
||||
// window->layout_value.x -= 0.1f;
|
||||
// }
|
||||
// window->layout_value.x = Clamp(window->layout_value.x, 0.05f, 0.95f);
|
||||
}
|
||||
}
|
||||
|
||||
if (mouse_in_window) {
|
||||
SetActiveWindow(window->id);
|
||||
break;
|
||||
@@ -339,6 +323,12 @@ bool GlobalCommand(Event event) {
|
||||
}
|
||||
}
|
||||
|
||||
if (CtrlShift(SDLK_BACKSLASH)) {
|
||||
AddRowWindow();
|
||||
} else if (Ctrl(SDLK_BACKSLASH)) {
|
||||
AddColumnWindow();
|
||||
}
|
||||
|
||||
if (Ctrl(SDLK_0)) {
|
||||
Window *window = GetWindow(DebugWindowID);
|
||||
window->visible = !window->visible;
|
||||
|
||||
@@ -75,27 +75,20 @@ struct Window {
|
||||
|
||||
bool draw_scrollbar : 1;
|
||||
bool draw_line_numbers : 1;
|
||||
|
||||
bool visible : 1;
|
||||
bool absolute_position : 1;
|
||||
bool is_title_bar : 1;
|
||||
bool is_column : 1;
|
||||
|
||||
bool fuzzy_search : 1; // @todo: consider moving this to view and introducing view commands
|
||||
bool execute_line : 1;
|
||||
bool invisible_when_inactive : 1;
|
||||
bool dont_save_in_active_window_history : 1;
|
||||
bool deactivate_on_escape : 1;
|
||||
bool is_title_bar : 1;
|
||||
};
|
||||
};
|
||||
|
||||
struct VisualRow {
|
||||
float value;
|
||||
WindowID window;
|
||||
};
|
||||
|
||||
struct VisualColumn {
|
||||
float value;
|
||||
Array<VisualRow> rows;
|
||||
};
|
||||
|
||||
struct Scroller {
|
||||
Rect2 rect;
|
||||
double begin;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
- bugs:
|
||||
- scrolling in fullscreen is busted because no space outside of window
|
||||
- scrolling when clicking on scroller is busted
|
||||
|
||||
- simulation:
|
||||
@@ -17,7 +18,6 @@
|
||||
- this would allow to create new windows just like that to inform user and so on
|
||||
- window borders as flag
|
||||
- Implement console buffer mimicking vscode with ctrl+~ etc.
|
||||
- Reverse order of append in console buffer - it should be appending from top to bottom and scrolling
|
||||
- Modify error popups to not focus, introduce a interaction timer which after some time will make window invisible
|
||||
- Implement shell interaction in a console buffer
|
||||
|
||||
@@ -51,4 +51,4 @@
|
||||
- Search all buffers
|
||||
- Search and replace
|
||||
- Search result buffer
|
||||
|
||||
- yeet sheet
|
||||
|
||||
@@ -1,4 +1,24 @@
|
||||
Array<VisualColumn> VisualColumns = {};
|
||||
struct VisualColumn {
|
||||
Window *window;
|
||||
Array<Window *> rows;
|
||||
};
|
||||
|
||||
Array<VisualColumn> GetVisualColumns(Allocator allocator) {
|
||||
Array<VisualColumn> columns = {allocator};
|
||||
ForItem(window, Windows) {
|
||||
if (!window.visible || window.absolute_position || window.is_title_bar) continue;
|
||||
|
||||
if (window.is_column) {
|
||||
Add(&columns, {&window, {allocator}});
|
||||
VisualColumn *col = GetLast(columns);
|
||||
Add(&col->rows, &window);
|
||||
} else if (columns.len) {
|
||||
VisualColumn *col = GetLast(columns);
|
||||
Add(&col->rows, &window);
|
||||
}
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
|
||||
Array<Int> GetWindowZOrder(Allocator allocator) {
|
||||
Array<Int> order = {allocator};
|
||||
@@ -39,11 +59,37 @@ Int GetTitleBarSize(Window *window) {
|
||||
return (Int)result;
|
||||
}
|
||||
|
||||
void AddColumnWindow() {
|
||||
Window *window = CreateWindow();
|
||||
window->is_column = true;
|
||||
View *view = OpenBufferView("*scratch*");
|
||||
SetActiveView(window, view->id);
|
||||
CreateInfobar(window);
|
||||
}
|
||||
|
||||
void AddRowWindow() {
|
||||
Window *window = CreateWindow();
|
||||
WindowID window_id = window->id;
|
||||
|
||||
View *view = OpenBufferView("*scratch*");
|
||||
SetActiveView(window, view->id);
|
||||
CreateInfobar(window);
|
||||
|
||||
Window *active_window = GetActiveWindow();
|
||||
int64_t active_window_index = GetIndex(Windows, *active_window);
|
||||
|
||||
window = GetWindow(window_id);
|
||||
Window window_copy = *window;
|
||||
Remove(&Windows, *window);
|
||||
Insert(&Windows, window_copy, active_window_index + 1);
|
||||
}
|
||||
|
||||
void InitWindows(View *null_view) {
|
||||
Allocator sys_allocator = GetSystemAllocator();
|
||||
|
||||
{
|
||||
Window *window = CreateWindow();
|
||||
Window *window = CreateWindow();
|
||||
window->is_column = true;
|
||||
// window->draw_line_numbers = false;
|
||||
Buffer *buffer = CreateBuffer(sys_allocator, "*load_text_a*");
|
||||
View *view = CreateView(buffer->id);
|
||||
@@ -56,17 +102,23 @@ void InitWindows(View *null_view) {
|
||||
}
|
||||
|
||||
{
|
||||
Window *window = CreateWindow();
|
||||
Buffer *buffer = CreateBuffer(sys_allocator, "*console*");
|
||||
View *view = CreateView(buffer->id);
|
||||
Window *window = CreateWindow();
|
||||
window->is_column = true;
|
||||
Buffer *buffer = CreateBuffer(sys_allocator, "*console*");
|
||||
View *view = CreateView(buffer->id);
|
||||
SetActiveView(window, view->id);
|
||||
CreateInfobar(window);
|
||||
}
|
||||
|
||||
// AddRowWindow();
|
||||
// AddRowWindow();
|
||||
// AddRowWindow();
|
||||
|
||||
{
|
||||
Window *window = CreateWindow();
|
||||
window->draw_line_numbers = false;
|
||||
Buffer *buffer = CreateBuffer(sys_allocator, "*debug*");
|
||||
window->absolute_position = true;
|
||||
window->draw_line_numbers = false;
|
||||
window->draw_scrollbar = false;
|
||||
window->dont_save_in_active_window_history = true;
|
||||
@@ -86,6 +138,7 @@ void InitWindows(View *null_view) {
|
||||
w->fuzzy_search = true;
|
||||
w->execute_line = true;
|
||||
w->invisible_when_inactive = true;
|
||||
w->absolute_position = true;
|
||||
w->dont_save_in_active_window_history = true;
|
||||
w->deactivate_on_escape = true;
|
||||
Buffer *b = CreateBuffer(sys_allocator, "*commands*");
|
||||
@@ -101,6 +154,7 @@ void InitWindows(View *null_view) {
|
||||
w->draw_scrollbar = false;
|
||||
w->draw_line_numbers = false;
|
||||
w->visible = false;
|
||||
w->absolute_position = true;
|
||||
w->dont_save_in_active_window_history = true;
|
||||
w->invisible_when_inactive = true;
|
||||
w->deactivate_on_escape = true;
|
||||
@@ -118,6 +172,7 @@ void InitWindows(View *null_view) {
|
||||
w->visible = false;
|
||||
w->dont_save_in_active_window_history = true;
|
||||
w->invisible_when_inactive = true;
|
||||
w->absolute_position = true;
|
||||
w->deactivate_on_escape = true;
|
||||
Buffer *b = CreateBuffer(sys_allocator, "*popup*");
|
||||
b->no_history = true;
|
||||
@@ -131,39 +186,44 @@ void InitWindows(View *null_view) {
|
||||
}
|
||||
|
||||
void LayoutWindows() {
|
||||
float ScrollBarSize = (10.f * DPIScale);
|
||||
Rect2I screen_rect = GetScreenRectI();
|
||||
float line_numbers_size = (float)FontCharSpacing * 10;
|
||||
double sizex = (double)GetSize(screen_rect).x;
|
||||
{
|
||||
Window *window = GetWindow(SearchWindowID);
|
||||
Rect2I sr = screen_rect;
|
||||
Rect2I rect = CutBottom(&sr, FontLineSpacing);
|
||||
window->total_rect = rect;
|
||||
window->document_rect = window->total_rect;
|
||||
window->z = 1;
|
||||
float ScrollBarSize = (10.f * DPIScale);
|
||||
Rect2I screen_rect = GetScreenRectI();
|
||||
float line_numbers_size = (float)FontCharSpacing * 10;
|
||||
float sizex = (float)GetSize(screen_rect).x;
|
||||
Window *search_window = GetWindow(SearchWindowID);
|
||||
if (search_window->visible) {
|
||||
Rect2I rect = CutBottom(&screen_rect, FontLineSpacing);
|
||||
search_window->total_rect = rect;
|
||||
search_window->document_rect = search_window->total_rect;
|
||||
}
|
||||
|
||||
{
|
||||
int i = 0;
|
||||
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)sizex * 0.5));
|
||||
Window *title_bar_window = GetWindow(Windows[i].title_bar_window);
|
||||
title_bar_window->total_rect = CutBottom(&Windows[i].total_rect, GetTitleBarSize(title_bar_window));
|
||||
Windows[i].document_rect = Windows[i].total_rect;
|
||||
title_bar_window->document_rect = title_bar_window->total_rect;
|
||||
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, (Int)ScrollBarSize);
|
||||
if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size);
|
||||
Scratch scratch;
|
||||
Array<VisualColumn> columns = GetVisualColumns(scratch);
|
||||
|
||||
float delta_column = 1.0f / (float)columns.len;
|
||||
ForItem(col, columns) {
|
||||
Rect2I rect = CutLeft(&screen_rect, (Int)(delta_column * sizex));
|
||||
|
||||
float sizey = (float)GetSize(rect).y;
|
||||
float delta_row = 1.0f / (float)col.rows.len;
|
||||
ForItem(row, col.rows) {
|
||||
row->total_rect = CutTop(&rect, (Int)(delta_row * sizey));
|
||||
}
|
||||
}
|
||||
{
|
||||
int i = 2;
|
||||
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)sizex));
|
||||
Window *title_bar_window = GetWindow(Windows[i].title_bar_window);
|
||||
title_bar_window->total_rect = CutBottom(&Windows[i].total_rect, GetTitleBarSize(title_bar_window));
|
||||
|
||||
For(Windows) {
|
||||
Window *window = ⁢
|
||||
if (!window->visible || window->absolute_position || window->is_title_bar) continue;
|
||||
|
||||
Window *title_bar_window = GetWindow(window->title_bar_window);
|
||||
title_bar_window->total_rect = CutBottom(&window->total_rect, GetTitleBarSize(title_bar_window));
|
||||
title_bar_window->document_rect = title_bar_window->total_rect;
|
||||
Windows[i].document_rect = Windows[i].total_rect;
|
||||
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, (Int)ScrollBarSize);
|
||||
if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size);
|
||||
|
||||
window->document_rect = window->total_rect;
|
||||
if (window->draw_scrollbar) window->scrollbar_rect = CutRight(&window->document_rect, (Int)ScrollBarSize);
|
||||
if (window->draw_line_numbers) window->line_numbers_rect = CutLeft(&window->document_rect, (Int)line_numbers_size);
|
||||
}
|
||||
|
||||
{
|
||||
Window *window = GetWindow(DebugWindowID);
|
||||
Rect2 screen_rect = GetScreenRectF();
|
||||
|
||||
Reference in New Issue
Block a user