[gnome-photos/wip/rishi/zoom: 11/12] add zoom_visible
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/zoom: 11/12] add zoom_visible
- Date: Fri, 2 Jun 2017 20:07:06 +0000 (UTC)
commit 8b21ef19482f6424e3f6cdf15285e00e6ab80920
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Jun 2 19:52:59 2017 +0200
add zoom_visible
src/photos-image-view.c | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/src/photos-image-view.c b/src/photos-image-view.c
index 8b99af3..9423559 100644
--- a/src/photos-image-view.c
+++ b/src/photos-image-view.c
@@ -25,9 +25,11 @@
#include <cairo-gobject.h>
#include <glib.h>
+#include "egg-animation.h"
#include "photos-debug.h"
#include "photos-gegl.h"
#include "photos-image-view.h"
+#include "photos-image-view-animator.h"
#include "photos-marshalers.h"
#include "photos-utils.h"
@@ -54,6 +56,8 @@ struct _PhotosImageView
gdouble y_scaled;
gdouble zoom;
gdouble zoom_scaled;
+ gdouble zoom_visible;
+ gdouble zoom_scaled_visible;
};
enum
@@ -275,7 +279,10 @@ photos_image_view_update (PhotosImageView *self)
bbox_zoomed.y = (gint) (zoom_scaled * bbox.y + 0.5);
self->zoom_scaled = zoom_scaled;
+ self->zoom_scaled_visible = self->zoom_scaled;
+
self->zoom = self->zoom_scaled / (gdouble) scale_factor;
+ self->zoom_visible = self->zoom;
self->x_scaled = (bbox_zoomed.width - viewport_width_real) / 2.0;
self->y_scaled = (bbox_zoomed.height - viewport_height_real) / 2.0;
@@ -286,10 +293,10 @@ photos_image_view_update (PhotosImageView *self)
{
gdouble ratio_old;
- bbox_zoomed.width = (gint) (self->zoom_scaled * bbox.width + 0.5);
- bbox_zoomed.height = (gint) (self->zoom_scaled * bbox.height + 0.5);
- bbox_zoomed.x = (gint) (self->zoom_scaled * bbox.x + 0.5);
- bbox_zoomed.y = (gint) (self->zoom_scaled * bbox.y + 0.5);
+ bbox_zoomed.width = (gint) (self->zoom_scaled_visible * bbox.width + 0.5);
+ bbox_zoomed.height = (gint) (self->zoom_scaled_visible * bbox.height + 0.5);
+ bbox_zoomed.x = (gint) (self->zoom_scaled_visible * bbox.x + 0.5);
+ bbox_zoomed.y = (gint) (self->zoom_scaled_visible * bbox.y + 0.5);
if (bbox_zoomed.width > viewport_width_real)
{
@@ -403,8 +410,8 @@ photos_image_view_draw_node (PhotosImageView *self, cairo_t *cr, GdkRectangle *r
gint64 start;
g_return_if_fail (GEGL_IS_BUFFER (self->buffer));
- g_return_if_fail (self->zoom > 0.0);
- g_return_if_fail (self->zoom_scaled > 0.0);
+ g_return_if_fail (self->zoom_visible > 0.0);
+ g_return_if_fail (self->zoom_scaled_visible > 0.0);
scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
@@ -423,7 +430,7 @@ photos_image_view_draw_node (PhotosImageView *self, cairo_t *cr, GdkRectangle *r
stride = bpp * roi.width;
gegl_buffer_get (self->buffer,
&roi,
- self->zoom_scaled,
+ self->zoom_scaled_visible,
format,
buf,
stride,
@@ -907,6 +914,8 @@ photos_image_view_set_best_fit (PhotosImageView *self, gboolean best_fit)
{
self->zoom = 0.0;
self->zoom_scaled = 0.0;
+ self->zoom_visible = 0.0;
+ self->zoom_scaled_visible = 0.0;
gtk_widget_queue_resize (GTK_WIDGET (self));
g_object_notify (G_OBJECT (self), "zoom");
}
@@ -941,6 +950,8 @@ photos_image_view_set_node (PhotosImageView *self, GeglNode *node)
self->y_scaled = 0.0;
self->zoom = 0.0;
self->zoom_scaled = 0.0;
+ self->zoom_visible = 0.0;
+ self->zoom_scaled_visible = 0.0;
g_clear_object (&self->buffer);
g_clear_object (&self->node);
g_clear_pointer (&self->bbox_region, (GDestroyNotify) cairo_region_destroy);
@@ -981,9 +992,11 @@ photos_image_view_set_zoom (PhotosImageView *self, gdouble zoom)
self->best_fit = FALSE;
self->zoom = zoom;
+ self->zoom_visible = self->zoom;
scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
self->zoom_scaled = self->zoom * scale_factor;
+ self->zoom_scaled_visible = self->zoom_scaled;
gtk_widget_queue_resize (GTK_WIDGET (self));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]