From a4d7a407c33a37e17a742dc31195f1fc24de5926 Mon Sep 17 00:00:00 2001 From: Jonas Wischeropp Date: Thu, 18 Jul 2024 11:52:10 +0200 Subject: [PATCH] added config for page separator color in dark mode --- pdf_viewer/config.cpp | 2 ++ pdf_viewer/main.cpp | 1 + pdf_viewer/pdf_view_opengl_widget.cpp | 4 +++- pdf_viewer/prefs.config | 1 + resources/sioyek.1 | 5 +++++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pdf_viewer/config.cpp b/pdf_viewer/config.cpp index 9c7ef4854..cd2d87cb3 100644 --- a/pdf_viewer/config.cpp +++ b/pdf_viewer/config.cpp @@ -62,6 +62,7 @@ extern float TOUCHPAD_SENSITIVITY; extern float SCROLL_VIEW_SENSITIVITY; extern float PAGE_SEPARATOR_WIDTH; extern float PAGE_SEPARATOR_COLOR[3]; +extern float DARK_MODE_PAGE_SEPARATOR_COLOR[3]; extern int SINGLE_MAIN_WINDOW_SIZE[2]; extern int SINGLE_MAIN_WINDOW_MOVE[2]; extern float FIT_TO_PAGE_WIDTH_RATIO; @@ -377,6 +378,7 @@ ConfigManager::ConfigManager(const Path& default_path, const Path& auto_path ,co configs.push_back({ L"scrollview_sensitivity", &SCROLL_VIEW_SENSITIVITY, float_serializer, float_deserializer, nullptr }); configs.push_back({ L"page_separator_width", &PAGE_SEPARATOR_WIDTH, float_serializer, float_deserializer, nullptr }); configs.push_back({ L"page_separator_color", PAGE_SEPARATOR_COLOR, vec3_serializer, color3_deserializer, color_3_validator }); + configs.push_back({ L"dark_mode_page_separator_color", DARK_MODE_PAGE_SEPARATOR_COLOR, vec3_serializer, color3_deserializer, color_3_validator }); configs.push_back({ L"single_main_window_size", &SINGLE_MAIN_WINDOW_SIZE, ivec2_serializer, ivec2_deserializer, nullptr }); configs.push_back({ L"single_main_window_move", &SINGLE_MAIN_WINDOW_MOVE, ivec2_serializer, ivec2_deserializer, nullptr }); configs.push_back({ L"fit_to_page_width_ratio", &FIT_TO_PAGE_WIDTH_RATIO, float_serializer, float_deserializer, nullptr }); diff --git a/pdf_viewer/main.cpp b/pdf_viewer/main.cpp index 61c4f4592..3e5e3a5ed 100644 --- a/pdf_viewer/main.cpp +++ b/pdf_viewer/main.cpp @@ -218,6 +218,7 @@ int PRERENDERED_PAGE_COUNT = 0; float PAGE_SEPARATOR_WIDTH = 0.0f; float PAGE_SEPARATOR_COLOR[3] = {0.9f, 0.9f, 0.9f}; +float DARK_MODE_PAGE_SEPARATOR_COLOR[3] = {0.0f, 0.0f, 0.0f}; bool IGNORE_STATUSBAR_IN_PRESENTATION_MODE = false; bool SUPER_FAST_SEARCH = false; bool SHOW_CLOSEST_BOOKMARK_IN_STATUSBAR = false; diff --git a/pdf_viewer/pdf_view_opengl_widget.cpp b/pdf_viewer/pdf_view_opengl_widget.cpp index 0a4e1d4af..1e48e7b30 100644 --- a/pdf_viewer/pdf_view_opengl_widget.cpp +++ b/pdf_viewer/pdf_view_opengl_widget.cpp @@ -19,6 +19,7 @@ extern bool RERENDER_OVERVIEW; extern bool RULER_MODE; extern float PAGE_SEPARATOR_WIDTH; extern float PAGE_SEPARATOR_COLOR[3]; +extern float DARK_MODE_PAGE_SEPARATOR_COLOR[3]; extern float RULER_PADDING; extern float OVERVIEW_SIZE[2]; extern float OVERVIEW_OFFSET[2]; @@ -724,7 +725,8 @@ void PdfViewOpenGLWidget::render_page(int page_number) { fz_rect separator_window_rect = document_view->document_to_window_rect(page_number, separator_rect); rect_to_quad(separator_window_rect, page_vertices); - glUniform3fv(shared_gl_objects.separator_background_color_uniform_location, 1, PAGE_SEPARATOR_COLOR); + auto &separator_color = color_mode == ColorPalette::Dark ? DARK_MODE_PAGE_SEPARATOR_COLOR : PAGE_SEPARATOR_COLOR; + glUniform3fv(shared_gl_objects.separator_background_color_uniform_location, 1, separator_color); glBindBuffer(GL_ARRAY_BUFFER, shared_gl_objects.vertex_buffer_object); glBufferData(GL_ARRAY_BUFFER, sizeof(page_vertices), page_vertices, GL_DYNAMIC_DRAW); diff --git a/pdf_viewer/prefs.config b/pdf_viewer/prefs.config index 4bbfc0be3..9b20c3eea 100644 --- a/pdf_viewer/prefs.config +++ b/pdf_viewer/prefs.config @@ -146,6 +146,7 @@ wheel_zoom_on_cursor 0 ## Configure the appearance of page separator #page_separator_width 2 #page_separator_color 0.9 0.9 0.9 +#dark_mode_page_separator_color 0.0 0.0 0.0 # Ratio of page width to use for `fit_to_page_width_ratio` command fit_to_page_width_ratio 0.75 diff --git a/resources/sioyek.1 b/resources/sioyek.1 index 1ad3a2d1e..eebfac5f4 100644 --- a/resources/sioyek.1 +++ b/resources/sioyek.1 @@ -1134,6 +1134,11 @@ Width of the page separator. Color of the page separator. .HP +.B dark_mode_page_separator_color +.I color_3 + +Color of the page separator in dark mode. +.HP .B single_main_window_size .I ivec[2]