mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 14:06:02 +01:00
c9eef95492
Instead of guesstimating the values of the scrollbars adjustments after a change in zoom level, connect callbacks to the "changed" GtkAdjustment event (which is emitted when the bounds or page_size of the adjustment change, e.g. when the zoom level changes), and compute the new values from there. The previous adjustment values are tracked in zathura->ui.hadjustment and zathura->ui.vadjustment (and updated by signal handlers as well), so that the view's position can be maintained while zooming. cb_view_hadjustment_changed() centers the page horizontally if a "best-fit" or "width" zoom is being performed, or if "zoom-center" is true; otherwise, it keeps the view horizontally centered around the same area of the page. cb_view_vadjustment_changed() always keeps the view vertically centered around the same area of the page. Many thanks to Marwan Tanager for thoroughly reviewing the various stages of this patch, and actually coming up with a working solution. Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
49 lines
1.4 KiB
C
49 lines
1.4 KiB
C
/* See LICENSE file for license and copyright information */
|
|
|
|
#ifndef ZATHURA_ADJUSTMENT_H
|
|
#define ZATHURA_ADJUSTMENT_H
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
/* Clone a GtkAdjustment
|
|
*
|
|
* Creates a new adjustment with the same value, lower and upper bounds, step
|
|
* and page increments and page_size as the original adjustment.
|
|
*
|
|
* @param adjustment Adjustment instance to be cloned
|
|
* @return Pointer to the new adjustment
|
|
*/
|
|
GtkAdjustment* zathura_adjustment_clone(GtkAdjustment* adjustment);
|
|
|
|
/**
|
|
* Set the adjustment value while enforcing its limits
|
|
*
|
|
* @param adjustment Adjustment instance
|
|
* @param value Adjustment value
|
|
*/
|
|
void zathura_adjustment_set_value(GtkAdjustment* adjustment, gdouble value);
|
|
|
|
/**
|
|
* Compute the adjustment ratio
|
|
*
|
|
* That is, the ratio between the length from the lower bound to the middle of
|
|
* the slider, and the total length of the scrollbar.
|
|
*
|
|
* @param adjustment Scrollbar adjustment
|
|
* @return Adjustment ratio
|
|
*/
|
|
gdouble zathura_adjustment_get_ratio(GtkAdjustment* adjustment);
|
|
|
|
/**
|
|
* Set the adjustment value from ratio
|
|
*
|
|
* The ratio is usually obtained from a previous call to
|
|
* zathura_adjustment_get_ratio().
|
|
*
|
|
* @param adjustment Adjustment instance
|
|
* @param ratio Ratio from which the adjustment value will be set
|
|
*/
|
|
void zathura_adjustment_set_value_from_ratio(GtkAdjustment* adjustment,
|
|
gdouble ratio);
|
|
|
|
#endif /* ZATHURA_ADJUSTMENT_H */
|