Add title bar windows
This commit is contained in:
@@ -362,19 +362,20 @@ void GenerateConfig() {
|
|||||||
colors.add({"Text" , "GruvboxDark0Hard"});
|
colors.add({"Text" , "GruvboxDark0Hard"});
|
||||||
colors.add({"Background" , "GruvboxLight0Hard"});
|
colors.add({"Background" , "GruvboxLight0Hard"});
|
||||||
colors.add({"InactiveWindow" , "0x0000000F"});
|
colors.add({"InactiveWindow" , "0x0000000F"});
|
||||||
// colors.add({"TabText" , "GruvboxDark0Hard"});
|
|
||||||
// colors.add({"TabBackground" , "GruvboxLight0Hard"});
|
|
||||||
// colors.add({"TabBackgroundInactive" , "GruvboxLight2"});
|
|
||||||
// colors.add({"TabSeparator" , "GruvboxLight2"});
|
|
||||||
colors.add({"TextLineNumbers" , "GruvboxDark4"});
|
colors.add({"TextLineNumbers" , "GruvboxDark4"});
|
||||||
colors.add({"ScrollbarBackground" , "GruvboxLight2"});
|
|
||||||
colors.add({"ScrollbarScroller" , "GruvboxLight1"});
|
|
||||||
colors.add({"ScrollbarScrollerSelected", "GruvboxLight0Hard"});
|
|
||||||
colors.add({"LineHighlight" , "GruvboxLight0Soft"});
|
colors.add({"LineHighlight" , "GruvboxLight0Soft"});
|
||||||
colors.add({"MainCaret" , "GruvboxDark0Hard"});
|
colors.add({"MainCaret" , "GruvboxDark0Hard"});
|
||||||
colors.add({"SubCaret" , "GruvboxGray245"});
|
colors.add({"SubCaret" , "GruvboxGray245"});
|
||||||
colors.add({"Selection" , "GruvboxLight1"});
|
colors.add({"Selection" , "GruvboxLight1"});
|
||||||
colors.add({"WhitespaceDuringSelection", "GruvboxLight4"});
|
colors.add({"WhitespaceDuringSelection", "GruvboxLight4"});
|
||||||
|
|
||||||
|
colors.add({"ScrollbarBackground" , "GruvboxLight2"});
|
||||||
|
colors.add({"ScrollbarScroller" , "GruvboxLight1"});
|
||||||
|
colors.add({"ScrollbarScrollerSelected", "GruvboxLight0Hard"});
|
||||||
|
|
||||||
|
colors.add({"TitleBarText" , "GruvboxDark0Hard"});
|
||||||
|
colors.add({"TitleBarBackground" , "GruvboxLight2"});
|
||||||
|
colors.add({"TitleBarSelection" , "GruvboxLight1"});
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ void ReplaceDebugData() {
|
|||||||
Append(buffer, ToString16(scratch, window_list));
|
Append(buffer, ToString16(scratch, window_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyInfobarChanges(Window *window, View *view, Buffer *buffer) {
|
void ApplyTitleBarChangesToWindow(Window *window, View *view, Buffer *buffer) {
|
||||||
String16 buffer_string = GetString(*buffer);
|
String16 buffer_string = GetString(*buffer);
|
||||||
Range replace_range = {0, buffer->len};
|
Range replace_range = {0, buffer->len};
|
||||||
if (Seek(buffer_string, L" |", &replace_range.max)) {
|
if (Seek(buffer_string, L" |", &replace_range.max)) {
|
||||||
@@ -300,7 +300,7 @@ void ApplyInfobarChanges(Window *window, View *view, Buffer *buffer) {
|
|||||||
}
|
}
|
||||||
buffer_string = Chop(buffer_string, line.len + 1);
|
buffer_string = Chop(buffer_string, line.len + 1);
|
||||||
|
|
||||||
Window *last_window = GetWindow(GetLastActiveWindow());
|
Window *last_window = GetWindow(window->title_bar_window);
|
||||||
View *last_view = GetActiveView(last_window);
|
View *last_view = GetActiveView(last_window);
|
||||||
Buffer *last_buffer = GetBuffer(last_view->active_buffer);
|
Buffer *last_buffer = GetBuffer(last_view->active_buffer);
|
||||||
|
|
||||||
@@ -324,18 +324,17 @@ void ApplyInfobarChanges(Window *window, View *view, Buffer *buffer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplaceInfobarData() {
|
void ReplaceTitleBarData(Window *window) {
|
||||||
Window *window = GetWindow(InfoBarWindowID);
|
|
||||||
View *view = GetView(window->active_view);
|
View *view = GetView(window->active_view);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
if (IsActive(window)) {
|
if (IsActive(window)) {
|
||||||
if (buffer->change_frame_id == FrameID) {
|
if (buffer->change_frame_id == FrameID) {
|
||||||
ApplyInfobarChanges(window, view, buffer);
|
ApplyTitleBarChangesToWindow(window, view, buffer);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window *last_window = GetWindow(GetLastActiveWindow());
|
Window *last_window = GetWindow(window->title_bar_window);
|
||||||
View *last_view = GetActiveView(last_window);
|
View *last_view = GetActiveView(last_window);
|
||||||
Buffer *last_buffer = GetBuffer(last_view->active_buffer);
|
Buffer *last_buffer = GetBuffer(last_view->active_buffer);
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
|
|||||||
@@ -39,14 +39,17 @@ Color ColorText = GruvboxDark0Hard;
|
|||||||
Color ColorBackground = GruvboxLight0Hard;
|
Color ColorBackground = GruvboxLight0Hard;
|
||||||
Color ColorInactiveWindow = {0x00, 0x00, 0x00, 0x0F};
|
Color ColorInactiveWindow = {0x00, 0x00, 0x00, 0x0F};
|
||||||
Color ColorTextLineNumbers = GruvboxDark4;
|
Color ColorTextLineNumbers = GruvboxDark4;
|
||||||
Color ColorScrollbarBackground = GruvboxLight2;
|
|
||||||
Color ColorScrollbarScroller = GruvboxLight1;
|
|
||||||
Color ColorScrollbarScrollerSelected = GruvboxLight0Hard;
|
|
||||||
Color ColorLineHighlight = GruvboxLight0Soft;
|
Color ColorLineHighlight = GruvboxLight0Soft;
|
||||||
Color ColorMainCaret = GruvboxDark0Hard;
|
Color ColorMainCaret = GruvboxDark0Hard;
|
||||||
Color ColorSubCaret = GruvboxGray245;
|
Color ColorSubCaret = GruvboxGray245;
|
||||||
Color ColorSelection = GruvboxLight1;
|
Color ColorSelection = GruvboxLight1;
|
||||||
Color ColorWhitespaceDuringSelection = GruvboxLight4;
|
Color ColorWhitespaceDuringSelection = GruvboxLight4;
|
||||||
|
Color ColorScrollbarBackground = GruvboxLight2;
|
||||||
|
Color ColorScrollbarScroller = GruvboxLight1;
|
||||||
|
Color ColorScrollbarScrollerSelected = GruvboxLight0Hard;
|
||||||
|
Color ColorTitleBarText = GruvboxDark0Hard;
|
||||||
|
Color ColorTitleBarBackground = GruvboxLight2;
|
||||||
|
Color ColorTitleBarSelection = GruvboxLight1;
|
||||||
String BaseLuaConfig = R"==(
|
String BaseLuaConfig = R"==(
|
||||||
local GruvboxDark0Hard = 0x1d2021ff
|
local GruvboxDark0Hard = 0x1d2021ff
|
||||||
local GruvboxDark0 = 0x282828ff
|
local GruvboxDark0 = 0x282828ff
|
||||||
@@ -90,14 +93,17 @@ Color.Text = GruvboxDark0Hard
|
|||||||
Color.Background = GruvboxLight0Hard
|
Color.Background = GruvboxLight0Hard
|
||||||
Color.InactiveWindow = 0x0000000F
|
Color.InactiveWindow = 0x0000000F
|
||||||
Color.TextLineNumbers = GruvboxDark4
|
Color.TextLineNumbers = GruvboxDark4
|
||||||
Color.ScrollbarBackground = GruvboxLight2
|
|
||||||
Color.ScrollbarScroller = GruvboxLight1
|
|
||||||
Color.ScrollbarScrollerSelected = GruvboxLight0Hard
|
|
||||||
Color.LineHighlight = GruvboxLight0Soft
|
Color.LineHighlight = GruvboxLight0Soft
|
||||||
Color.MainCaret = GruvboxDark0Hard
|
Color.MainCaret = GruvboxDark0Hard
|
||||||
Color.SubCaret = GruvboxGray245
|
Color.SubCaret = GruvboxGray245
|
||||||
Color.Selection = GruvboxLight1
|
Color.Selection = GruvboxLight1
|
||||||
Color.WhitespaceDuringSelection = GruvboxLight4
|
Color.WhitespaceDuringSelection = GruvboxLight4
|
||||||
|
Color.ScrollbarBackground = GruvboxLight2
|
||||||
|
Color.ScrollbarScroller = GruvboxLight1
|
||||||
|
Color.ScrollbarScrollerSelected = GruvboxLight0Hard
|
||||||
|
Color.TitleBarText = GruvboxDark0Hard
|
||||||
|
Color.TitleBarBackground = GruvboxLight2
|
||||||
|
Color.TitleBarSelection = GruvboxLight1
|
||||||
|
|
||||||
-- @todo: should we rewrite linux paths to windows on windows and vice-versa?
|
-- @todo: should we rewrite linux paths to windows on windows and vice-versa?
|
||||||
|
|
||||||
@@ -226,12 +232,15 @@ void ReloadColors() {
|
|||||||
ColorBackground = GetColor("Background", ColorBackground);
|
ColorBackground = GetColor("Background", ColorBackground);
|
||||||
ColorInactiveWindow = GetColor("InactiveWindow", ColorInactiveWindow);
|
ColorInactiveWindow = GetColor("InactiveWindow", ColorInactiveWindow);
|
||||||
ColorTextLineNumbers = GetColor("TextLineNumbers", ColorTextLineNumbers);
|
ColorTextLineNumbers = GetColor("TextLineNumbers", ColorTextLineNumbers);
|
||||||
ColorScrollbarBackground = GetColor("ScrollbarBackground", ColorScrollbarBackground);
|
|
||||||
ColorScrollbarScroller = GetColor("ScrollbarScroller", ColorScrollbarScroller);
|
|
||||||
ColorScrollbarScrollerSelected = GetColor("ScrollbarScrollerSelected", ColorScrollbarScrollerSelected);
|
|
||||||
ColorLineHighlight = GetColor("LineHighlight", ColorLineHighlight);
|
ColorLineHighlight = GetColor("LineHighlight", ColorLineHighlight);
|
||||||
ColorMainCaret = GetColor("MainCaret", ColorMainCaret);
|
ColorMainCaret = GetColor("MainCaret", ColorMainCaret);
|
||||||
ColorSubCaret = GetColor("SubCaret", ColorSubCaret);
|
ColorSubCaret = GetColor("SubCaret", ColorSubCaret);
|
||||||
ColorSelection = GetColor("Selection", ColorSelection);
|
ColorSelection = GetColor("Selection", ColorSelection);
|
||||||
ColorWhitespaceDuringSelection = GetColor("WhitespaceDuringSelection", ColorWhitespaceDuringSelection);
|
ColorWhitespaceDuringSelection = GetColor("WhitespaceDuringSelection", ColorWhitespaceDuringSelection);
|
||||||
|
ColorScrollbarBackground = GetColor("ScrollbarBackground", ColorScrollbarBackground);
|
||||||
|
ColorScrollbarScroller = GetColor("ScrollbarScroller", ColorScrollbarScroller);
|
||||||
|
ColorScrollbarScrollerSelected = GetColor("ScrollbarScrollerSelected", ColorScrollbarScrollerSelected);
|
||||||
|
ColorTitleBarText = GetColor("TitleBarText", ColorTitleBarText);
|
||||||
|
ColorTitleBarBackground = GetColor("TitleBarBackground", ColorTitleBarBackground);
|
||||||
|
ColorTitleBarSelection = GetColor("TitleBarSelection", ColorTitleBarSelection);
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,10 @@ int main()
|
|||||||
Format(scratch, "%.*s%s", buffer->name, dirty);
|
Format(scratch, "%.*s%s", buffer->name, dirty);
|
||||||
SDL_SetWindowTitle(SDLWindow, buffer->name.data);
|
SDL_SetWindowTitle(SDLWindow, buffer->name.data);
|
||||||
}
|
}
|
||||||
ReplaceInfobarData();
|
|
||||||
|
For(Windows) {
|
||||||
|
if (it.is_title_bar) ReplaceTitleBarData(&it);
|
||||||
|
}
|
||||||
ReplaceDebugData();
|
ReplaceDebugData();
|
||||||
|
|
||||||
if (lua_buffer->dirty == false && lua_buffer->change_id != lua_buffer_change_id) {
|
if (lua_buffer->dirty == false && lua_buffer->change_id != lua_buffer_change_id) {
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ struct Window {
|
|||||||
ViewID active_view;
|
ViewID active_view;
|
||||||
CircularArray<ViewID> view_history;
|
CircularArray<ViewID> view_history;
|
||||||
|
|
||||||
|
WindowID title_bar_window;
|
||||||
|
|
||||||
Rect2I total_rect;
|
Rect2I total_rect;
|
||||||
Rect2I scrollbar_rect;
|
Rect2I scrollbar_rect;
|
||||||
Rect2I line_numbers_rect;
|
Rect2I line_numbers_rect;
|
||||||
@@ -80,6 +82,7 @@ struct Window {
|
|||||||
bool invisible_when_inactive : 1;
|
bool invisible_when_inactive : 1;
|
||||||
bool dont_save_in_active_window_history : 1;
|
bool dont_save_in_active_window_history : 1;
|
||||||
bool deactivate_on_escape : 1;
|
bool deactivate_on_escape : 1;
|
||||||
|
bool is_title_bar : 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,29 +6,56 @@ Array<Int> GetWindowZOrder(Allocator allocator) {
|
|||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Window *CreateInfobar(Window *parent_window) {
|
||||||
|
Window *window = CreateWindow();
|
||||||
|
window->draw_scrollbar = false;
|
||||||
|
window->draw_line_numbers = false;
|
||||||
|
window->dont_save_in_active_window_history = true;
|
||||||
|
window->deactivate_on_escape = true;
|
||||||
|
window->is_title_bar = true;
|
||||||
|
|
||||||
|
static int InfobarCount;
|
||||||
|
Allocator sys_allocator = GetSystemAllocator();
|
||||||
|
String name = Format(sys_allocator, "*infobar%d", ++InfobarCount);
|
||||||
|
|
||||||
|
Buffer *b = CreateBuffer(sys_allocator, name);
|
||||||
|
b->no_history = true;
|
||||||
|
View *v = CreateView(b->id);
|
||||||
|
window->active_view = v->id;
|
||||||
|
SetActiveView(window, v->id);
|
||||||
|
|
||||||
|
parent_window->title_bar_window = window->id;
|
||||||
|
window->title_bar_window = parent_window->id;
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
void InitWindows(View *null_view) {
|
void InitWindows(View *null_view) {
|
||||||
Allocator sys_allocator = GetSystemAllocator();
|
Allocator sys_allocator = GetSystemAllocator();
|
||||||
|
|
||||||
{
|
{
|
||||||
Window *w = CreateWindow();
|
Window *window = CreateWindow();
|
||||||
Buffer *b = CreateBuffer(sys_allocator, "*load_text_a*");
|
window->draw_line_numbers = false;
|
||||||
View *v = CreateView(b->id);
|
Buffer *buffer = CreateBuffer(sys_allocator, "*load_text_a*");
|
||||||
LoadTextA(b);
|
View *view = CreateView(buffer->id);
|
||||||
LoadUnicode(b);
|
LoadTextA(buffer);
|
||||||
w->active_view = v->id;
|
LoadUnicode(buffer);
|
||||||
SetActiveView(w, v->id);
|
window->active_view = view->id;
|
||||||
}
|
SetActiveView(window, view->id);
|
||||||
|
CreateInfobar(window);
|
||||||
{
|
|
||||||
Window *w = CreateWindow();
|
|
||||||
Buffer *b = CreateBuffer(sys_allocator, "*console*");
|
|
||||||
b->no_history = true;
|
|
||||||
View *v = CreateView(b->id);
|
|
||||||
SetActiveView(w, v->id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Window *window = CreateWindow();
|
Window *window = CreateWindow();
|
||||||
|
Buffer *buffer = CreateBuffer(sys_allocator, "*console*");
|
||||||
|
View *view = CreateView(buffer->id);
|
||||||
|
SetActiveView(window, view->id);
|
||||||
|
CreateInfobar(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Window *window = CreateWindow();
|
||||||
|
window->draw_line_numbers = false;
|
||||||
Buffer *buffer = CreateBuffer(sys_allocator, "*debug*");
|
Buffer *buffer = CreateBuffer(sys_allocator, "*debug*");
|
||||||
window->draw_line_numbers = false;
|
window->draw_line_numbers = false;
|
||||||
window->draw_scrollbar = false;
|
window->draw_scrollbar = false;
|
||||||
@@ -41,20 +68,6 @@ void InitWindows(View *null_view) {
|
|||||||
DebugWindowID = window->id;
|
DebugWindowID = window->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
Window *w = CreateWindow();
|
|
||||||
w->draw_scrollbar = false;
|
|
||||||
w->draw_line_numbers = false;
|
|
||||||
w->dont_save_in_active_window_history = true;
|
|
||||||
w->deactivate_on_escape = true;
|
|
||||||
Buffer *b = CreateBuffer(sys_allocator, "*infobar*");
|
|
||||||
b->no_history = true;
|
|
||||||
View *v = CreateView(b->id);
|
|
||||||
w->active_view = v->id;
|
|
||||||
SetActiveView(w, v->id);
|
|
||||||
InfoBarWindowID = w->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Window *w = CreateWindow();
|
Window *w = CreateWindow();
|
||||||
w->draw_scrollbar = false;
|
w->draw_scrollbar = false;
|
||||||
@@ -110,7 +123,6 @@ void InitWindows(View *null_view) {
|
|||||||
void LayoutWindows() {
|
void LayoutWindows() {
|
||||||
float ScrollBarSize = (10.f * DPIScale);
|
float ScrollBarSize = (10.f * DPIScale);
|
||||||
Rect2I screen_rect = GetScreenRectI();
|
Rect2I screen_rect = GetScreenRectI();
|
||||||
Rect2I infobar_rect = CutBottom(&screen_rect, (Int)FontLineSpacing);
|
|
||||||
float line_numbers_size = (float)FontCharSpacing * 10;
|
float line_numbers_size = (float)FontCharSpacing * 10;
|
||||||
double sizex = (double)GetSize(screen_rect).x;
|
double sizex = (double)GetSize(screen_rect).x;
|
||||||
{
|
{
|
||||||
@@ -125,13 +137,19 @@ void LayoutWindows() {
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)sizex * 0.5));
|
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 = CutTop(&Windows[i].total_rect, FontLineSpacing);
|
||||||
Windows[i].document_rect = Windows[i].total_rect;
|
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_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);
|
if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 2;
|
||||||
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)sizex));
|
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 = CutTop(&Windows[i].total_rect, FontLineSpacing);
|
||||||
|
title_bar_window->document_rect = title_bar_window->total_rect;
|
||||||
Windows[i].document_rect = Windows[i].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_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);
|
if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size);
|
||||||
@@ -150,11 +168,6 @@ void LayoutWindows() {
|
|||||||
window->document_rect = window->total_rect;
|
window->document_rect = window->total_rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
Window *window = GetWindow(InfoBarWindowID);
|
|
||||||
window->total_rect = infobar_rect;
|
|
||||||
window->document_rect = window->total_rect;
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
Window *window = GetWindow(CommandWindowID);
|
Window *window = GetWindow(CommandWindowID);
|
||||||
Rect2 screen_rect = GetScreenRectF();
|
Rect2 screen_rect = GetScreenRectF();
|
||||||
|
|||||||
@@ -38,9 +38,8 @@ Scroller ComputeScrollerRect(Window *window) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawVisibleText(Window *window) {
|
void DrawVisibleText(Window *window, Color tint) {
|
||||||
ProfileFunction();
|
ProfileFunction();
|
||||||
Color tint = ColorText;
|
|
||||||
View *view = GetActiveView(window);
|
View *view = GetActiveView(window);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
|
|
||||||
@@ -96,7 +95,22 @@ void DrawWindow(Window *window) {
|
|||||||
SetScissor(GetScreenRectF());
|
SetScissor(GetScreenRectF());
|
||||||
bool is_active = IsActive(window) || window->id.id == GetLastActiveWindow().id;
|
bool is_active = IsActive(window) || window->id.id == GetLastActiveWindow().id;
|
||||||
|
|
||||||
DrawRect(window->total_rect, ColorBackground);
|
Color color_whitespace_during_selection = ColorWhitespaceDuringSelection;
|
||||||
|
Color color_background = ColorBackground;
|
||||||
|
Color color_line_highlight = ColorLineHighlight;
|
||||||
|
Color color_selection = ColorSelection;
|
||||||
|
Color color_main_caret = ColorMainCaret;
|
||||||
|
Color color_sub_caret = ColorSubCaret;
|
||||||
|
Color color_text_line_numbers = ColorTextLineNumbers;
|
||||||
|
Color color_text = ColorText;
|
||||||
|
if (window->is_title_bar) {
|
||||||
|
color_background = ColorTitleBarBackground;
|
||||||
|
color_selection = ColorTitleBarSelection;
|
||||||
|
color_text = ColorTitleBarText;
|
||||||
|
color_line_highlight = ColorTitleBarBackground;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawRect(window->total_rect, color_background);
|
||||||
|
|
||||||
Rect2I combined_document_line_number = window->document_rect;
|
Rect2I combined_document_line_number = window->document_rect;
|
||||||
if (window->draw_line_numbers) combined_document_line_number.min.x = window->line_numbers_rect.min.x;
|
if (window->draw_line_numbers) combined_document_line_number.min.x = window->line_numbers_rect.min.x;
|
||||||
@@ -126,14 +140,14 @@ void DrawWindow(Window *window) {
|
|||||||
pos -= view->scroll;
|
pos -= view->scroll;
|
||||||
pos += window->document_rect.min;
|
pos += window->document_rect.min;
|
||||||
Rect2 rect = Rect2FromSize({(float)pos.x, (float)pos.y}, {(float)FontCharSpacing, (float)FontLineSpacing});
|
Rect2 rect = Rect2FromSize({(float)pos.x, (float)pos.y}, {(float)FontCharSpacing, (float)FontLineSpacing});
|
||||||
DrawRect(rect, ColorSelection);
|
DrawRect(rect, color_selection);
|
||||||
|
|
||||||
if (line_string[col] == ' ' || line_string[col] == '\t') {
|
if (line_string[col] == ' ' || line_string[col] == '\t') {
|
||||||
DrawCircle({pos.x + (float)FontCharSpacing / 2.f, (float)pos.y + MainFont.ascent - MainFont.descent}, MainFont.size / 8.f, ColorWhitespaceDuringSelection);
|
DrawCircle({pos.x + (float)FontCharSpacing / 2.f, (float)pos.y + MainFont.ascent - MainFont.descent}, MainFont.size / 8.f, color_whitespace_during_selection);
|
||||||
} else if (line_string[col] == '\n') {
|
} else if (line_string[col] == '\n') {
|
||||||
DrawCircle({pos.x + (float)FontCharSpacing / 2.f, pos.y + MainFont.ascent - MainFont.descent}, MainFont.size / 8.f, ColorWhitespaceDuringSelection);
|
DrawCircle({pos.x + (float)FontCharSpacing / 2.f, pos.y + MainFont.ascent - MainFont.descent}, MainFont.size / 8.f, color_whitespace_during_selection);
|
||||||
} else if (line_string[col] == '\r') {
|
} else if (line_string[col] == '\r') {
|
||||||
DrawCircle({pos.x + (float)FontCharSpacing / 2.f, pos.y + MainFont.ascent - MainFont.descent}, MainFont.size / 8.f, ColorWhitespaceDuringSelection);
|
DrawCircle({pos.x + (float)FontCharSpacing / 2.f, pos.y + MainFont.ascent - MainFont.descent}, MainFont.size / 8.f, color_whitespace_during_selection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,11 +163,11 @@ void DrawWindow(Window *window) {
|
|||||||
{ 0.f, (float)w.y},
|
{ 0.f, (float)w.y},
|
||||||
{WindowSize.x, (float)w.y + (float)FontLineSpacing}
|
{WindowSize.x, (float)w.y + (float)FontLineSpacing}
|
||||||
};
|
};
|
||||||
DrawRect(rect, ColorLineHighlight);
|
DrawRect(rect, color_line_highlight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndProfileScope();
|
EndProfileScope();
|
||||||
DrawVisibleText(window);
|
DrawVisibleText(window, color_text);
|
||||||
|
|
||||||
BeginProfileScope(draw_carets);
|
BeginProfileScope(draw_carets);
|
||||||
if (is_active) {
|
if (is_active) {
|
||||||
@@ -162,7 +176,7 @@ void DrawWindow(Window *window) {
|
|||||||
XY fxy = PosToXY(*buffer, front);
|
XY fxy = PosToXY(*buffer, front);
|
||||||
if (fxy.col >= visible.min.x && fxy.col < visible.max.x && fxy.line >= visible.min.y && fxy.line <= visible.max.y) {
|
if (fxy.col >= visible.min.x && fxy.col < visible.max.x && fxy.line >= visible.min.y && fxy.line <= visible.max.y) {
|
||||||
bool main_caret = &it == &view->carets.data[0];
|
bool main_caret = &it == &view->carets.data[0];
|
||||||
DrawCaret(window, fxy, 0.3f, main_caret ? ColorMainCaret : ColorSubCaret);
|
DrawCaret(window, fxy, 0.3f, main_caret ? color_main_caret : color_sub_caret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,7 +199,7 @@ void DrawWindow(Window *window) {
|
|||||||
float rectx = (float)GetSize(window->line_numbers_rect).x;
|
float rectx = (float)GetSize(window->line_numbers_rect).x;
|
||||||
p.x += (rectx - x) / 2.f;
|
p.x += (rectx - x) / 2.f;
|
||||||
if (x > rectx) p.x = (float)window->line_numbers_rect.min.x;
|
if (x > rectx) p.x = (float)window->line_numbers_rect.min.x;
|
||||||
DrawString(&MainFont, string, p, ColorTextLineNumbers);
|
DrawString(&MainFont, string, p, color_text_line_numbers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user