Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#4034 closed defect (fixed)

ImageViewer: zoom gesture center

Reported by: godiard Owned by: humitos
Priority: Unspecified by Maintainer Milestone:
Component: Imageviewer Version: Unspecified
Severity: Unspecified Keywords:
Cc: aguz, dsd Distribution/OS: Unspecified
Bug Status: Unconfirmed

Description

when using a gesture to zoom in / out, the image center is displaced

Attachments (3)

0001-Scale-the-image-through-its-center.patch (2.9 KB) - added by humitos 9 years ago.
This patch just zooms the image always from its centre
0001-gestures-Fix-silly-typo-on-get_center-implementation.patch (988 bytes) - added by humitos 9 years ago.
Patch for sugar-toolkit-gtk3
0001-Zoom-Gesture-zooms-through-the-gesture-s-center.patch (5.0 KB) - added by humitos 8 years ago.
An intersting approach to the "zoom to fixed point" feature

Download all attachments as: .zip

Change History (12)

comment:1 Changed 9 years ago by humitos

From Carlos Garnacho's email:

there is a get_center() method at the SugarTouchController class level,
both the rotate and zoom controllers inherit from that class.

Changed 9 years ago by humitos

This patch just zooms the image always from its centre

comment:2 Changed 9 years ago by humitos

Changed 9 years ago by humitos

Patch for sugar-toolkit-gtk3

comment:3 Changed 9 years ago by humitos

Taking a look at the eog (Eye Of GNOME - the application to see images on GNOME) I found that it uses: g_signal_handlers_block_matched before setting the adjustment value. I understand that this is to avoid the vibration that my patch added.

http://git.gnome.org/browse/eog/tree/src/eog-scroll-view.c#n311

I tried to use that function but I'm not being able to pass None as the fifth argument and trying with another thing I'm getting a segmentation fault.

Here are a code example:

from gi.repository import Gtk
from gi.repository import GObject


def my_func(*args, **kargs):
    print 'my_func was called.'


adj = Gtk.Adjustment()
sw = Gtk.ScrolledWindow()
GObject.signal_handlers_block_matched(
    adj, GObject.SignalMatchType.DATA, 0, 0, None, my_func, sw)

comment:4 Changed 9 years ago by humitos

Changed 8 years ago by humitos

An intersting approach to the "zoom to fixed point" feature

comment:5 Changed 8 years ago by humitos

  • Cc aguz added

The patch attached implements the "Zoom to fixed point" feature, but it does not work when the image is rotated.

This patch works better in conjunction with this patch on XO-4:

comment:6 follow-up: Changed 8 years ago by dsd

  • Cc dsd added

There are alternatives to GObject.signal_handlers_block_matched which might work better, e.g. signal_handlers_block_by_func. Or you can store the signal ID when you connect it in some "global" variable and block it using that (g_signal_handler_block).

comment:7 in reply to: ↑ 6 Changed 8 years ago by humitos

Replying to dsd:

Or you can store the signal ID when you connect it in some "global" variable and block it using that (g_signal_handler_block).

Yes, but the thing here is that I wanted to disconnect some default behaviour: I didn't connect the adjustment to anything and it was moved by default when the widget changes it size. So, when I change the widget's size and the adjustment value, the adjustment was moved to 0,0 in the middle of my actions and a flickering was noticed.

I have to check this again after applying this patch: http://bugs.sugarlabs.org/attachment/ticket/4060/0001-scrolledwindow-Stop-scrolling-when-a-second-touch-po.patch

comment:8 Changed 8 years ago by humitos

  • Resolution set to fixed
  • Status changed from new to closed

This is already pushed here:

http://git.sugarlabs.org/imageviewer/mainline/commit/290189d892861a30fb97cefe9197cd2194e89594

Comment: this patch does not work when the image is rotated at 90º or 270º. In that case the patch does not do anything. It works as it was working before: zooming from the left-top corner

comment:9 Changed 8 years ago by dnarvaez

  • Milestone 0.98 deleted

Milestone 0.98 deleted

Note: See TracTickets for help on using tickets.