diff options
| author | Martin Owens <doctormo@gmail.com> | 2014-03-27 01:33:44 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2014-03-27 01:33:44 +0000 |
| commit | 5a4fb2325f60d292b47330f540b26a3279341c90 (patch) | |
| tree | d2aa7967be25450b83e625025366c618101ae49f /src/ui/widget/rotateable.cpp | |
| parent | The Polar Arrange Tab of the Arrange Dialog now hides the parametric (diff) | |
| parent | Remove Snap menu item and improve grid menu item text (diff) | |
| download | inkscape-5a4fb2325f60d292b47330f540b26a3279341c90.tar.gz inkscape-5a4fb2325f60d292b47330f540b26a3279341c90.zip | |
Commit a merge to trunk, with probabal errors
(bzr r11073.1.36)
Diffstat (limited to 'src/ui/widget/rotateable.cpp')
| -rw-r--r-- | src/ui/widget/rotateable.cpp | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp index c31e6f529..72ec69362 100644 --- a/src/ui/widget/rotateable.cpp +++ b/src/ui/widget/rotateable.cpp @@ -7,11 +7,19 @@ * Released under GNU GPL. Read the file 'COPYING' for more information. */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/eventbox.h> #include <glibmm/i18n.h> #include <2geom/point.h> -#include "event-context.h" +#include "ui/tools/tool-base.h" #include "rotateable.h" namespace Inkscape { @@ -24,25 +32,28 @@ Rotateable::Rotateable(): { dragging = false; working = false; + scrolling = false; modifier = 0; current_axis = axis; signal_button_press_event().connect(sigc::mem_fun(*this, &Rotateable::on_click)); signal_motion_notify_event().connect(sigc::mem_fun(*this, &Rotateable::on_motion)); signal_button_release_event().connect(sigc::mem_fun(*this, &Rotateable::on_release)); + signal_scroll_event().connect(sigc::mem_fun(*this, &Rotateable::on_scroll)); + } bool Rotateable::on_click(GdkEventButton *event) { - if (event->button == 1) { + if (event->button == 1) { drag_started_x = event->x; drag_started_y = event->y; - modifier = get_single_modifier(modifier, event->state); + modifier = get_single_modifier(modifier, event->state); dragging = true; working = false; current_axis = axis; return true; - } - return false; + } + return false; } guint Rotateable::get_single_modifier(guint old, guint state) { @@ -100,7 +111,7 @@ bool Rotateable::on_motion(GdkEventMotion *event) { do_motion(force, modifier); } } - gobble_motion_events(GDK_BUTTON1_MASK); + Inkscape::UI::Tools::gobble_motion_events(GDK_BUTTON1_MASK); return true; } return false; @@ -108,9 +119,9 @@ bool Rotateable::on_motion(GdkEventMotion *event) { bool Rotateable::on_release(GdkEventButton *event) { - if (dragging && working) { + if (dragging && working) { double angle = atan2(event->y - drag_started_y, event->x - drag_started_x); - double force = CLAMP (-(angle - current_axis)/maxdecl, -1, 1); + double force = CLAMP(-(angle - current_axis) / maxdecl, -1, 1); if (fabs(force) < 0.002) force = 0; // snap to zero do_release(force, modifier); @@ -118,12 +129,40 @@ bool Rotateable::on_release(GdkEventButton *event) { dragging = false; working = false; return true; - } + } dragging = false; working = false; - return false; + return false; } +bool Rotateable::on_scroll(GdkEventScroll* event) +{ + double change = 0.0; + + if (event->direction == GDK_SCROLL_UP) { + change = 1.0; + } else if (event->direction == GDK_SCROLL_DOWN) { + change = -1.0; + } else { + return FALSE; + } + + drag_started_x = event->x; + drag_started_y = event->y; + modifier = get_single_modifier(modifier, event->state); + dragging = false; + working = false; + scrolling = true; + current_axis = axis; + + do_scroll(change, modifier); + + dragging = false; + working = false; + scrolling = false; + + return TRUE; +} Rotateable::~Rotateable() { } |
