Hi,
I am not sure whether non-roadmap items might be of interest. Here is a
(rather crude) implementation of mouse wheel support.
Best,
Yue Shi Lai
Index: synfig-studio/src/gtkmm/workarea.cpp
===================================================================
--- synfig-studio/src/gtkmm/workarea.cpp (revision 229)
+++ synfig-studio/src/gtkmm/workarea.cpp (working copy)
@@ -1242,6 +1242,16 @@
// button_pressed=0;
}
}
+ // GDK mouse scrolling events
+ else if(event->any.type==GDK_SCROLL)
+ {
+ // GDK information needed to properly interprete mouse
+ // scrolling events are: scroll.state, scroll.x/scroll.y, and
+ // scroll.direction. The value of scroll.direction will be
+ // obtained later.
+ modifier=Gdk::ModifierType(event->scroll.state);
+ mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(event->scroll.x,event->scroll.y)));
+ }
// Handle the renderables
@@ -1644,6 +1654,91 @@
return ret;
}
break;
+ case GDK_SCROLL:
+ {
+ // Handle a mouse scrolling event like Xara Xtreme and
+ // Inkscape:
+ //
+ // Scroll up/down: scroll up/down
+ // Shift + scroll up/down: scroll left/right
+ // Control + scroll up/down: zoom in/out
+ if(modifier&GDK_CONTROL_MASK)
+ {
+ // The zoom is performed while preserving the pointer
+ // position as a fixed point (similarly to Xara Xtreme and
+ // Inkscape).
+ //
+ // The strategy used below is to scroll to the updated
+ // position, then zoom. This is easy to implement within
+ // the present architecture, but has the disadvantage of
+ // triggering multiple visible refreshes. Note: 1.25 is
+ // the hard wired ratio in zoom_in()/zoom_out(). The
+ // variable "drift" compensates additional inaccuracies in
+ // the zoom. There is also an additional minus sign for
+ // the inverted y coordinates.
+ const synfig::Point scroll_point(get_scrollx_adjustment()->get_value(),get_scrolly_adjustment()->get_value());
+ // FIXME: One might want to figure out where in the code
+ // this empirical drift is been introduced.
+ const double drift = 0.052;
+
+ switch(event->scroll.direction)
+ {
+ case GDK_SCROLL_UP:
+ get_scrollx_adjustment()->set_value(scroll_point[0]+(mouse_pos[0]-scroll_point[0])*(1.25-(1+drift)));
+ get_scrolly_adjustment()->set_value(scroll_point[1]-(mouse_pos[1]+scroll_point[1])*(1.25-(1+drift)));
+ zoom_in();
+ break;
+ case GDK_SCROLL_DOWN:
+ get_scrollx_adjustment()->set_value(scroll_point[0]+(mouse_pos[0]-scroll_point[0])*(1/1.25-(1+drift)));
+ get_scrolly_adjustment()->set_value(scroll_point[1]-(mouse_pos[1]+scroll_point[1])*(1/1.25-(1+drift)));
+ zoom_out();
+ break;
+ default:
+ break;
+ }
+ }
+ else if(modifier&GDK_SHIFT_MASK)
+ {
+ // Scroll in either direction by 20 pixels. Ideally, the
+ // amount of pixels per scrolling event should be
+ // configurable. Xara Xtreme currently uses an (hard
+ // wired) amount 20 pixel, Inkscape defaults to 40 pixels.
+ const int scroll_pixel = 20;
+
+ switch(event->scroll.direction)
+ {
+ case GDK_SCROLL_UP:
+ get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()-scroll_pixel*pw);
+ break;
+ case GDK_SCROLL_DOWN:
+ get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()+scroll_pixel*pw);
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ // Scroll in either direction by 20 pixels. Ideally, the
+ // amount of pixels per scrolling event should be
+ // configurable. Xara Xtreme currently uses an (hard
+ // wired) amount 20 pixel, Inkscape defaults to 40 pixels.
+ const int scroll_pixel = 20;
+
+ switch(event->scroll.direction)
+ {
+ case GDK_SCROLL_UP:
+ get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()+scroll_pixel*ph);
+ break;
+ case GDK_SCROLL_DOWN:
+ get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()-scroll_pixel*ph);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ break;
default:
break;
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl