mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 21:46:01 +01:00
We added three options
1) zoom-center :: bool zoom-center = false If zoom-center = false nothing changes. If zoom-center = true zooming respects the horizontal center of the pageview. That is, the vertical line dividing the displayed part of the document doesn't move within the document. Reasoning: When viewing a pdf with a margin we usually want to hide the margin at both sides by zooming in. 2) scroll-hstep :: float scroll-hstep = -1 If scroll-hstep < 0 nothing changes. If scroll-hstep >= 0 then scroll-hstep defines the scroll step in the horizontal direction. Reasoning: This allows us to make finer adjustments in the horizontal direction without the mouse and without loosing the ablility to navigate quickly through the document. 3) search-hadjust :: bool search-hadjust = true If search-hadjust = true nothing changes. If search-hadjust = false searching does not adjust the horizontal center of the document when showing search results. Reasoning: When viewing a pdf with a margin we usually want to hide the margin at both sides by zooming in. The horizontal adjustment sometimes hides parts of the document by moving the horizontal center.
This commit is contained in:
parent
efcdfaefbb
commit
30eda65aaa
4 changed files with 53 additions and 5 deletions
6
config.c
6
config.c
|
@ -106,6 +106,8 @@ config_load_default(zathura_t* zathura)
|
|||
girara_setting_add(gsession, "pages-per-row", &int_value, INT, false, _("Number of pages per row"), cb_pages_per_row_value_changed, NULL);
|
||||
float_value = 40;
|
||||
girara_setting_add(gsession, "scroll-step", &float_value, FLOAT, false, _("Scroll step"), NULL, NULL);
|
||||
float_value = -1;
|
||||
girara_setting_add(gsession, "scroll-hstep", &float_value, FLOAT, false, _("Horizontal scroll step"), NULL, NULL);
|
||||
int_value = 10;
|
||||
girara_setting_add(gsession, "zoom-min", &int_value, INT, false, _("Zoom minimum"), NULL, NULL);
|
||||
int_value = 1000;
|
||||
|
@ -129,6 +131,10 @@ config_load_default(zathura_t* zathura)
|
|||
girara_setting_add(gsession, "scroll-wrap", &bool_value, BOOLEAN, false, _("Wrap scrolling"), NULL, NULL);
|
||||
bool_value = false;
|
||||
girara_setting_add(gsession, "advance-pages-per-row", &bool_value, BOOLEAN, false, _("Advance number of pages per row"), NULL, NULL);
|
||||
bool_value = false;
|
||||
girara_setting_add(gsession, "zoom-center", &bool_value, BOOLEAN, false, _("Horizontally centered zoom"), 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;
|
||||
|
|
21
shortcuts.c
21
shortcuts.c
|
@ -548,6 +548,11 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument,
|
|||
|
||||
float scroll_step = 40;
|
||||
girara_setting_get(session, "scroll-step", &scroll_step);
|
||||
float scroll_hstep = -1;
|
||||
girara_setting_get(session, "scroll-hstep", &scroll_hstep);
|
||||
if (scroll_hstep < 0) {
|
||||
scroll_hstep = scroll_step;
|
||||
}
|
||||
int padding = 1;
|
||||
girara_setting_get(session, "page-padding", &padding);
|
||||
|
||||
|
@ -571,10 +576,14 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument,
|
|||
new_value = value + ((view_size + padding) / 2);
|
||||
break;
|
||||
case LEFT:
|
||||
new_value = value - scroll_hstep;
|
||||
break;
|
||||
case UP:
|
||||
new_value = value - scroll_step;
|
||||
break;
|
||||
case RIGHT:
|
||||
new_value = value + scroll_hstep;
|
||||
break;
|
||||
case DOWN:
|
||||
new_value = value + scroll_step;
|
||||
break;
|
||||
|
@ -666,12 +675,16 @@ sc_search(girara_session_t* session, girara_argument_t* argument,
|
|||
page_calculate_offset(zathura, target_page, &offset);
|
||||
|
||||
GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
|
||||
GtkAdjustment* view_hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
|
||||
|
||||
int x = offset.x - gtk_adjustment_get_page_size(view_hadjustment) / 2 + rectangle.x1;
|
||||
int y = offset.y - gtk_adjustment_get_page_size(view_vadjustment) / 2 + rectangle.y1;
|
||||
set_adjustment(view_hadjustment, x);
|
||||
set_adjustment(view_vadjustment, y);
|
||||
|
||||
bool search_hadjust = true;
|
||||
girara_setting_get(session, "search-hadjust", &search_hadjust);
|
||||
if (search_hadjust == true) {
|
||||
GtkAdjustment* view_hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
|
||||
int x = offset.x - gtk_adjustment_get_page_size(view_hadjustment) / 2 + rectangle.x1;
|
||||
set_adjustment(view_hadjustment, x);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
10
utils.c
10
utils.c
|
@ -11,6 +11,7 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <girara/session.h>
|
||||
#include <girara/utils.h>
|
||||
#include <girara/settings.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "links.h"
|
||||
|
@ -312,7 +313,8 @@ zathura_page_get_widget(zathura_t* zathura, zathura_page_t* page)
|
|||
}
|
||||
|
||||
void
|
||||
readjust_view_after_zooming(zathura_t *zathura, float old_zoom, bool delay) {
|
||||
readjust_view_after_zooming(zathura_t *zathura, float old_zoom, bool delay)
|
||||
{
|
||||
if (zathura == NULL || zathura->document == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -325,6 +327,12 @@ readjust_view_after_zooming(zathura_t *zathura, float old_zoom, bool delay) {
|
|||
gdouble valx = gtk_adjustment_get_value(hadjustment) / old_zoom * scale;
|
||||
gdouble valy = gtk_adjustment_get_value(vadjustment) / old_zoom * scale;
|
||||
|
||||
bool zoom_center = false;
|
||||
girara_setting_get(zathura->ui.session, "zoom-center", &zoom_center);
|
||||
if (zoom_center) {
|
||||
valx += gtk_adjustment_get_page_size(hadjustment) * (scale / old_zoom - 1) / 2;
|
||||
}
|
||||
|
||||
if (delay == true) {
|
||||
position_set_delayed(zathura, valx, valy);
|
||||
} else {
|
||||
|
|
|
@ -570,6 +570,13 @@ Defines if the "Loading..." text should be displayed if a page is rendered.
|
|||
* Value type: Boolean
|
||||
* Default value: true
|
||||
|
||||
scroll-hstep
|
||||
^^^^^^^^^^^^
|
||||
Defines the horizontal step size of scrolling by calling the scroll command once
|
||||
|
||||
* Value-type: Float
|
||||
* Default value: -1
|
||||
|
||||
scroll-step
|
||||
^^^^^^^^^^^
|
||||
Defines the step size of scrolling by calling the scroll command once
|
||||
|
@ -584,6 +591,20 @@ Defines if the last/first page should be wrapped
|
|||
* Value type: Boolean
|
||||
* Default value: false
|
||||
|
||||
search-hadjust
|
||||
^^^^^^^^^^^^^^
|
||||
En/Disables horizontally centered search results
|
||||
|
||||
* Value-type: Boolean
|
||||
* Default value: true
|
||||
|
||||
zoom-center
|
||||
^^^^^^^^^^^
|
||||
En/Disables horizontally centered zooming
|
||||
|
||||
* Value-type: Bool
|
||||
* Default value: False
|
||||
|
||||
zoom-max
|
||||
^^^^^^^^
|
||||
Defines the maximum percentage that the zoom level can be
|
||||
|
|
Loading…
Reference in a new issue