Merge highlight-transparency into other settings

This commit is contained in:
Sebastian Ramacher 2024-03-02 18:24:59 +01:00
parent 60afd2a9ed
commit fb2b5da84b
4 changed files with 28 additions and 48 deletions

View File

@ -41,7 +41,7 @@ General settings
(e.g.: show search results)
:type: String
:default: #9FBC00
:default: rgba(159,251,0,0.5)
.. describe:: highlight-fg
@ -49,7 +49,7 @@ General settings
(e.g.: numbers for links)
:type: String
:default: #FFFFFF
:default: rgba(0,0,0,0.5)
.. describe:: highlight-active-color
@ -57,14 +57,7 @@ General settings
element (e.g: current search result)
:type: String
:default: #00BC00
.. describe:: highlight-transparency
Defines the opacity of a highlighted element
:type: Float
:default: 0.5
:default: rgba(0,188,0,0.5)
.. describe:: page-padding

View File

@ -659,27 +659,21 @@ zathura
(e.g: current search result)
* Value type: String
* Default value: #00BC00
* Default value: rgba(0,188,0,0.5)
*highlight-color*
Defines the color that is used for highlighting parts of the document (e.g.:
show search results)
* Value type: String
* Default value: #9FBC00
* Default value: rgba(159,251,0,0.5)
*highlight-fg*
Defines the color that is used for text when highlighting parts of the
document (e.g.: number for links).
* Value type: String
* Default value: #9FBC00
*highlight-transparency*
Defines the opacity of a highlighted element
* Value type: Float
* Default value: 0.5
* Default value: rgba(0,0,0,0.5)
*highlighter-modifier*
Defines the modifier that needs to be pressed together with the left mouse button

View File

@ -243,6 +243,7 @@ void config_load_default(zathura_t* zathura) {
/* Set default mode */
girara_mode_set(gsession, zathura->modes.normal);
/* clang-format off */
/* zathura settings */
girara_setting_add(gsession, "database", "plain", STRING, true, _("Database backend"), NULL, NULL);
girara_setting_add(gsession, "filemonitor", "glib", STRING, true, _("File monitor backend"), NULL, NULL);
@ -276,11 +277,11 @@ void config_load_default(zathura_t* zathura) {
girara_setting_add(gsession, "recolor-darkcolor", "#FFFFFF", STRING, false, _("Recoloring (dark color)"), cb_color_change, NULL);
girara_setting_add(gsession, "recolor-lightcolor", "#000000", STRING, false, _("Recoloring (light color)"), cb_color_change, NULL);
girara_setting_add(gsession, "highlight-color", NULL, STRING, false, _("Color for highlighting"), cb_color_change, NULL);
girara_setting_set(gsession, "highlight-color", "#9FBC00");
girara_setting_set(gsession, "highlight-color", "rgba(159,251,0,0.5)");
girara_setting_add(gsession, "highlight-fg", NULL, STRING, false, _("Foreground color for highlighting"), cb_color_change, NULL);
girara_setting_set(gsession, "highlight-fg", "#000000");
girara_setting_set(gsession, "highlight-fg", "rgba(0,0,0,0.5)");
girara_setting_add(gsession, "highlight-active-color", NULL, STRING, false, _("Color for highlighting (active)"), cb_color_change, NULL);
girara_setting_set(gsession, "highlight-active-color", "#00BC00");
girara_setting_set(gsession, "highlight-active-color", "rgba(0,188,0,0.5)");
girara_setting_add(gsession, "render-loading-bg", NULL, STRING, false, _("'Loading ...' background color"), cb_color_change, NULL);
girara_setting_set(gsession, "render-loading-bg", "#FFFFFF");
girara_setting_add(gsession, "render-loading-fg", NULL, STRING, false, _("'Loading ...' foreground color"), cb_color_change, NULL);
@ -322,8 +323,6 @@ void config_load_default(zathura_t* zathura) {
girara_setting_add(gsession, "link-zoom", &bool_value, BOOLEAN, false, _("Let zoom be changed when following links"), NULL, NULL);
bool_value = true;
girara_setting_add(gsession, "search-hadjust", &bool_value, BOOLEAN, false, _("Center result horizontally"), NULL, NULL);
float_value = 0.5;
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, _("Transparency for highlighting"), NULL, NULL);
bool_value = true;
girara_setting_add(gsession, "render-loading", &bool_value, BOOLEAN, false, _("Render 'Loading ...'"), NULL, NULL);
bool_value = true;
@ -670,6 +669,7 @@ void config_load_default(zathura_t* zathura) {
girara_argument_mapping_add(gsession, "width", ZATHURA_ADJUST_WIDTH);
girara_argument_mapping_add(gsession, "rotate-cw", ROTATE_CW);
girara_argument_mapping_add(gsession, "rotate-ccw", ROTATE_CCW);
/* clang-format on */
}
void

View File

@ -641,9 +641,6 @@ static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) {
/* draw links */
set_font_from_property(cairo, zathura, CAIRO_FONT_WEIGHT_BOLD);
float transparency = 0.5;
girara_setting_get(zathura->ui.session, "highlight-transparency", &transparency);
if (priv->links.draw == true && priv->links.n != 0) {
unsigned int link_counter = 0;
for (size_t idx = 0; idx != girara_list_size(priv->links.list); ++idx) {
@ -653,14 +650,14 @@ static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) {
/* draw position */
const GdkRGBA color = zathura->ui.colors.highlight_color;
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, color.alpha);
cairo_rectangle(cairo, rectangle.x1, rectangle.y1, (rectangle.x2 - rectangle.x1),
(rectangle.y2 - rectangle.y1));
cairo_fill(cairo);
/* draw text */
const GdkRGBA color_fg = zathura->ui.colors.highlight_color_fg;
cairo_set_source_rgba(cairo, color_fg.red, color_fg.green, color_fg.blue, transparency);
cairo_set_source_rgba(cairo, color_fg.red, color_fg.green, color_fg.blue, color.alpha);
cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y2 - 1);
char* link_number = g_strdup_printf("%i", priv->links.offset + ++link_counter);
cairo_show_text(cairo, link_number);
@ -721,7 +718,7 @@ static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) {
/* draw text */
const GdkRGBA color_fg = zathura->ui.colors.highlight_color_fg;
cairo_set_source_rgba(cairo, color_fg.red, color_fg.green, color_fg.blue, transparency);
cairo_set_source_rgba(cairo, color_fg.red, color_fg.green, color_fg.blue, color.alpha);
cairo_text_extents_t extents;
cairo_text_extents(cairo, text, &extents);
@ -743,10 +740,10 @@ static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) {
/* draw position */
if (idx == priv->search.current) {
const GdkRGBA color = zathura->ui.colors.highlight_color_active;
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, color.alpha);
} else {
const GdkRGBA color = zathura->ui.colors.highlight_color;
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, color.alpha);
}
cairo_rectangle(cairo, rectangle.x1, rectangle.y1, (rectangle.x2 - rectangle.x1),
(rectangle.y2 - rectangle.y1));
@ -756,28 +753,24 @@ static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) {
}
if (priv->selection.list != NULL && priv->selection.draw == true) {
const GdkRGBA color = priv->zathura->ui.colors.highlight_color;
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
GIRARA_LIST_FOREACH_BODY(priv->selection.list, zathura_rectangle_t*, rect,
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
rectangle.x2 - rectangle.x1, rectangle.y2 - rectangle.y1);
cairo_fill(cairo);
);
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, color.alpha);
GIRARA_LIST_FOREACH_BODY(
priv->selection.list, zathura_rectangle_t*, rect,
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
cairo_rectangle(cairo, rectangle.x1, rectangle.y1, rectangle.x2 - rectangle.x1, rectangle.y2 - rectangle.y1);
cairo_fill(cairo););
}
if (priv->highlighter.bounds.x1 != -1
&& priv->highlighter.bounds.y1 != -1
&& priv->highlighter.draw == true) {
if (priv->highlighter.bounds.x1 != -1 && priv->highlighter.bounds.y1 != -1 && priv->highlighter.draw == true) {
const GdkRGBA color = priv->zathura->ui.colors.highlight_color;
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, color.alpha);
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, priv->highlighter.bounds);
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
rectangle.x2 - rectangle.x1, rectangle.y2 - rectangle.y1);
cairo_rectangle(cairo, rectangle.x1, rectangle.y1, rectangle.x2 - rectangle.x1, rectangle.y2 - rectangle.y1);
cairo_fill(cairo);
}
} else {
if (smooth_reload) {
girara_debug("rendering loading screen, flicker might be happening");
}
if (smooth_reload) {
girara_debug("rendering loading screen, flicker might be happening");
}
/* set background color */
if (zathura_renderer_recolor_enabled(priv->zathura->sync.render_thread) == true) {