# HG changeset patch # User Shai Ayal # Date 1254165885 14400 # Node ID 6291b69cf2d2e3d5c44026183373733f3d95ae74 # Parent 641a788c82a4abd65f6c2ca03c3e45d2a1718736 imported patch fltk_overlay diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2009-09-28 Shai Ayal + + * DLD-FUNCTIONS/fltk_backend.cc (plot_window::handle): Redraw the + overlay when zoom box changes size. + * DLD-FUNCTIONS/fltk_backend.cc (fltk_mouse_wheel_zoom): New + function to set mouse wheel zoom factor. + 2009-09-27 Jaroslav Hajek * DLD-FUNCTIONS/sub2ind.cc (get_dimensions): Allow singleton array. diff --git a/src/DLD-FUNCTIONS/fltk_backend.cc b/src/DLD-FUNCTIONS/fltk_backend.cc --- a/src/DLD-FUNCTIONS/fltk_backend.cc +++ b/src/DLD-FUNCTIONS/fltk_backend.cc @@ -185,6 +185,9 @@ } }; +// Parameter controlling how fast we zoom when using the scrool wheel +static double wheel_zoom_speed = 0.05; + class plot_window : public Fl_Window { public: @@ -482,23 +485,20 @@ } else if (Fl::event_button () == 3) { - canvas->zoom (true); Matrix zoom_box (1,4,0); zoom_box (0) = px0; zoom_box (1) = py0; zoom_box (2) = Fl::event_x (); zoom_box (3) = Fl::event_y (); canvas->set_zoom_box (zoom_box); + canvas->zoom (true); + canvas->redraw_overlay (); } break; case FL_MOUSEWHEEL: { - // Parameter controlling how fast we zoom. FIXME: Should - // this be user tweakable? - const double zoom_speed = 0.05; - graphics_object ax = gh_manager::get_object (pixel2axes_or_ca (Fl::event_x (), Fl::event_y ())); @@ -509,7 +509,7 @@ // Determine if we're zooming in or out const double factor = - (Fl::event_dy () > 0) ? 1.0 + zoom_speed : 1.0 - zoom_speed; + (Fl::event_dy () > 0) ? 1.0 + wheel_zoom_speed : 1.0 - wheel_zoom_speed; // Get the point we're zooming about double x1, y1; @@ -964,6 +964,27 @@ return retval; } +DEFUN_DLD (fltk_mouse_wheel_zoom, args, , +"-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} fltk_mouse_wheel_zoom ([@var{speed}])\n\ +Returns the current mouse wheel zoom factor in the fltk backend. If\n\ +the @var{speed} argument is given, set the mouse zoom factor to this\n\ +value.\n\ +@end deftypefn") +{ + octave_value retval = wheel_zoom_speed; + + if (args.length () == 1) + { + if (args(0).is_real_scalar ()) + wheel_zoom_speed = args(0).double_value (); + else + error ("argument must be a real scalar"); + } + + return retval; +} + #endif /*