Skip to content

Commit

Permalink
Add a lighten_colors_when_embedding_annotations config (addresses #1259)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrm committed Dec 19, 2024
1 parent fd06141 commit bab683c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pdf_viewer/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ bool USE_LEGACY_KEYBINDS = false;
bool MULTILINE_MENUS = true;
bool START_WITH_HELPER_WINDOW = false;
std::map<std::wstring, std::wstring> ADDITIONAL_COMMANDS;
bool LIGHTEN_COLORS_WHEN_EMBEDDING_ANNOTATIONS = true;


std::map<std::wstring, JsCommandInfo> ADDITIONAL_JAVASCRIPT_COMMANDS;
Expand Down Expand Up @@ -987,6 +988,7 @@ ConfigManager::ConfigManager(const Path& default_path, const Path& auto_path, co
add_bool(L"use_legacy_keybinds", &USE_LEGACY_KEYBINDS);
add_bool(L"multiline_menus", &MULTILINE_MENUS);
add_bool(L"start_with_helper_window", &START_WITH_HELPER_WINDOW);
add_bool(L"lighten_colors_when_embedding_annotations", &LIGHTEN_COLORS_WHEN_EMBEDDING_ANNOTATIONS);
add_bool(L"prerender_next_page_presentation", &PRERENDER_NEXT_PAGE);
add_bool(L"highlight_middle_click", &HIGHLIGHT_MIDDLE_CLICK);
add_bool(L"auto_rename_downloaded_papers", &AUTO_RENAME_DOWNLOADED_PAPERS);
Expand Down
14 changes: 11 additions & 3 deletions pdf_viewer/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ extern std::wstring SHARED_DATABASE_PATH;
extern bool DEBUG;
extern bool EXACT_HIGHLIGHT_SELECT;
extern std::wstring ANNOTATIONS_DIR_PATH;
extern bool LIGHTEN_COLORS_WHEN_EMBEDDING_ANNOTATIONS;

int Document::get_mark_index(char symbol) {
for (size_t i = 0; i < marks.size(); i++) {
Expand Down Expand Up @@ -2253,9 +2254,16 @@ void Document::embed_annotations(std::wstring new_file_path) {
}
float* color_ = get_highlight_type_color(highlight.type);
float color[3];
// lighten highlight colors before embedding (because we use alpha to make it lighter but
// the color doesn't take it into accout). Also see: https://github.com/ahrm/sioyek/issues/667
lighten_color(color_, color);
if (LIGHTEN_COLORS_WHEN_EMBEDDING_ANNOTATIONS) {
// lighten highlight colors before embedding (because we use alpha to make it lighter but
// the color doesn't take it into accout). Also see: https://github.com/ahrm/sioyek/issues/667
lighten_color(color_, color);
}
else {
color[0] = color_[0];
color[1] = color_[1];
color[2] = color_[2];
}

pdf_set_annot_color(context, highlight_annot, 3, color);
if (highlight.text_annot.size() > 0) {
Expand Down

0 comments on commit bab683c

Please sign in to comment.