Color of title bar when active and window size

This commit is contained in:
Krzosa Karol
2025-05-03 21:16:16 +02:00
parent 7a5d949a12
commit dec70c10e7
6 changed files with 21 additions and 5 deletions

View File

@@ -55,6 +55,7 @@ Color.ScrollbarScroller = GruvboxLight1
Color.ScrollbarScrollerSelected = GruvboxLight0Hard
Color.TitleBarText = GruvboxDark2
Color.TitleBarBackground = GruvboxLight1
Color.TitleBarActiveBackground = 0xfefefefe
Color.TitleBarSelection = GruvboxLight3
Style = {}
Style.ConsoleSizeSmall = 10
@@ -347,6 +348,7 @@ void ReloadStyle() {
ColorScrollbarScrollerSelected = GetColor("ScrollbarScrollerSelected", ColorScrollbarScrollerSelected);
ColorTitleBarText = GetColor("TitleBarText", ColorTitleBarText);
ColorTitleBarBackground = GetColor("TitleBarBackground", ColorTitleBarBackground);
ColorTitleBarActiveBackground = GetColor("TitleBarActiveBackground", ColorTitleBarActiveBackground);
ColorTitleBarSelection = GetColor("TitleBarSelection", ColorTitleBarSelection);
StyleConsoleSizeSmall = GetStyleInt("ConsoleSizeSmall", StyleConsoleSizeSmall);
StyleConsoleSizeBig = GetStyleInt("ConsoleSizeBig", StyleConsoleSizeBig);

View File

@@ -53,6 +53,7 @@ Color ColorScrollbarScroller = GruvboxLight1;
Color ColorScrollbarScrollerSelected = GruvboxLight0Hard;
Color ColorTitleBarText = GruvboxDark2;
Color ColorTitleBarBackground = GruvboxLight1;
Color ColorTitleBarActiveBackground = {0xfe, 0xfe, 0xfe, 0xfe};
Color ColorTitleBarSelection = GruvboxLight3;
Int StyleConsoleSizeSmall = 10;
Int StyleConsoleSizeBig = 30;

View File

@@ -352,7 +352,8 @@ Buffer *BufferOpenFile(String path) {
if (!FileExists(path)) {
buffer = CreateBuffer(sys_allocator, path);
} else if (IsDir(path)) {
Assert(!"Invalid codepath");
ReportWarningf("failed to open, it's a directory: %.*s", FmtString(path));
return GetBuffer(NullBufferID);
} else {
String string = ReadFile(scratch, path);
buffer = CreateBuffer(sys_allocator, path, string.len * 4 + 4096);

View File

@@ -295,8 +295,11 @@ int main(int argc, char **argv)
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
SDL_DisplayID primary_display_id = SDL_GetPrimaryDisplay();
const SDL_DisplayMode *display_mode = SDL_GetCurrentDisplayMode(primary_display_id);
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
SDLWindow = SDL_CreateWindow("Text editor", 1280, 720, window_flags);
SDLWindow = SDL_CreateWindow("Text editor", (int)(display_mode->w * 0.8), (int)(display_mode->h * 0.8), window_flags);
if (SDLWindow == NULL) {
ReportErrorf("Couldn't create window! %s", SDL_GetError());
return 1;

View File

@@ -123,7 +123,11 @@ void DrawWindow(Window *window, Event &event) {
Color color_text_line_numbers = ColorTextLineNumbers;
Color color_text = ColorText;
if (window->is_title_bar) {
color_background = ColorTitleBarBackground;
if (is_active) {
color_background = ColorTitleBarActiveBackground;
} else {
color_background = ColorTitleBarBackground;
}
color_selection = ColorTitleBarSelection;
color_text = ColorTitleBarText;
color_line_highlight = ColorTitleBarBackground;
@@ -170,7 +174,7 @@ void DrawWindow(Window *window, Event &event) {
}
}
}
} else {
} else if (!window->is_title_bar) {
//
// Draw highlight
Int front = GetFront(it);
@@ -267,6 +271,10 @@ void DrawWindow(Window *window, Event &event) {
if (!is_active) {
SetScissor(screen_rect);
DrawRect(window->total_rect, ColorInactiveWindow);
if (window->is_title_bar) {
} else {
DrawRect(window->total_rect, ColorInactiveWindow);
}
}
}