[goocanvasmm] Fix the drag_to_canvas example.



commit c878ab9d57db4f1ec1e5b72e76e3743c2addbb26
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Jun 13 15:29:26 2011 +0200

    Fix the drag_to_canvas example.
    
    * examples/drag_to_canvas/examplewindow.cc:
    The way it calls drag_dest_set (with Gtk::DEST_DEFAULT_ALL) is explicitly
    mentioned as dramatic in the documentation of gtk_drag_dest_set. After fixing
    that, a trivial relative/absolute coordinates bug came up, and after fixing
    that, it started working.
    Bug #644033

 ChangeLog                                |   11 +++++++++++
 examples/drag_to_canvas/examplewindow.cc |   14 +++++++++++---
 2 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 40790d7..885ce9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-06-13  Baldvin Kovács  <baldvin kovacs gmail com>
+
+	Fix the drag_to_canvas example.
+
+	* examples/drag_to_canvas/examplewindow.cc:
+	The way it calls drag_dest_set (with Gtk::DEST_DEFAULT_ALL) is explicitly
+	mentioned as "dramatic" in the documentation of gtk_drag_dest_set. After fixing
+	that, a trivial relative/absolute coordinates bug came up, and after fixing
+	that, it started working.
+	Bug #644033
+
 2011-06-13  Murray Cumming  <murrayc murrayc com>
 
 	Get the path to the pangomm and atkmm m4 files.
diff --git a/examples/drag_to_canvas/examplewindow.cc b/examples/drag_to_canvas/examplewindow.cc
index 078bd5a..f78d13b 100644
--- a/examples/drag_to_canvas/examplewindow.cc
+++ b/examples/drag_to_canvas/examplewindow.cc
@@ -47,8 +47,13 @@ ExampleWindow::ExampleWindow()
   sw->add(m_canvas);
   m_vbox.pack_start(*sw);
 
-  //Make the canvas a drag-and-drop destination:
-  m_canvas.drag_dest_set(m_drag_targets, Gtk::DEST_DEFAULT_ALL, Gdk::ACTION_COPY);
+  // Make the canvas a drag-and-drop destination. As we are implementing
+  // custom handlers for all (motion, highlight, drop), we set the second
+  // argument of drag_dest_set to 0. See the documentation of
+  // drag_dest_set for details. It would be nice if Gtk::DestDefaults did
+  // contain a GTK_DEST_DEFAULT_NONE, but short of that we can still brute
+  // force it to 0.
+  m_canvas.drag_dest_set(m_drag_targets, (Gtk::DestDefaults)0, Gdk::ACTION_COPY);
   m_canvas.signal_drag_motion().connect(
       sigc::mem_fun(*this, &ExampleWindow::on_canvas_drag_motion) );
   m_canvas.signal_drag_drop().connect(
@@ -126,7 +131,10 @@ bool ExampleWindow::on_canvas_drag_motion(const Glib::RefPtr<Gdk::DragContext>&
   double item_x = x;
   double item_y = y;
   m_canvas.convert_from_pixels(item_x, item_y);
-  m_layout_item_dropping->translate(item_x, item_y);
+
+  gdouble t_x, t_y, t_scale, t_rotation;
+  m_layout_item_dropping->get_simple_transform(t_x, t_y, t_scale, t_rotation);
+  m_layout_item_dropping->set_simple_transform(item_x, item_y, t_scale, t_rotation);
 
   return true; //Allow the drop.
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]