[glom] Canvas_PrintLayout: Move all selected items when dragging.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Canvas_PrintLayout: Move all selected items when dragging.
- Date: Sun, 7 Aug 2011 14:21:22 +0000 (UTC)
commit 672701611177ddc787b9e0d46a7af351178d107b
Author: Murray Cumming <murrayc murrayc com>
Date: Sun Aug 7 16:21:16 2011 +0200
Canvas_PrintLayout: Move all selected items when dragging.
* glom/utility_widgets/canvas/canvas_item_movable.[h|cc]:
signal_moved(): Send the item (for convenience, to avoid dodgy use of
sigc::bind() with RefPtr<>s) and the offset of just the current part
of the move.
* glom/utility_widgets/canvas/canvas_group_resizable.[h|cc]:
* glom/mode_design/relationships_overview/dialog_relationships_over
view.[h|cc]: Adapt.
* glom/mode_design/print_layouts/window_print_layout_edit.[h|cc]:
on_selected_item_moved(): Move all the other selected items by the
same amount.
ChangeLog | 17 +++++++++++++++++
.../print_layouts/window_print_layout_edit.cc | 16 +++++++++++++++-
.../print_layouts/window_print_layout_edit.h | 2 +-
.../dialog_relationships_overview.cc | 15 +++++++++------
.../dialog_relationships_overview.h | 2 +-
.../canvas/canvas_group_resizable.cc | 6 +++---
.../canvas/canvas_group_resizable.h | 6 +++---
glom/utility_widgets/canvas/canvas_item_movable.cc | 15 +++++++++++----
glom/utility_widgets/canvas/canvas_item_movable.h | 11 ++++++++++-
9 files changed, 70 insertions(+), 20 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a627597..502cd54 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2011-08-07 Murray Cumming <murrayc murrayc com>
+ Canvas_PrintLayout: Move all selected items when dragging.
+
+ * glom/utility_widgets/canvas/canvas_item_movable.[h|cc]:
+ signal_moved(): Send the item (for convenience, to avoid dodgy use of
+ sigc::bind() with RefPtr<>s) and the offset of just the current part
+ of the move.
+ * glom/utility_widgets/canvas/canvas_group_resizable.[h|cc]:
+ * glom/mode_design/relationships_overview/dialog_relationships_over
+ view.[h|cc]: Adapt.
+ * glom/mode_design/print_layouts/window_print_layout_edit.[h|cc]:
+ on_selected_item_moved(): Move all the other selected items by the
+ same amount.
+
+on_selected_item_moved
+
+2011-08-07 Murray Cumming <murrayc murrayc com>
+
Canvas_PrintLayout: Selecting unselects others. Allow shift-clicking.
* glom/utility_widgets/canvas/canvas_item_movable.[h|cc]:
diff --git a/glom/mode_design/print_layouts/window_print_layout_edit.cc b/glom/mode_design/print_layouts/window_print_layout_edit.cc
index b9984c8..924c722 100644
--- a/glom/mode_design/print_layouts/window_print_layout_edit.cc
+++ b/glom/mode_design/print_layouts/window_print_layout_edit.cc
@@ -1113,8 +1113,22 @@ void Window_PrintLayout_Edit::on_canvas_selection_changed()
m_action_edit_delete->set_sensitive(some_selected);
}
-void Window_PrintLayout_Edit::on_selected_item_moved()
+void Window_PrintLayout_Edit::on_selected_item_moved(const Glib::RefPtr<CanvasItemMovable>& item, double x_offset, double y_offset)
{
+ //Move the other selected items too:
+ for(type_vec_canvas_items::iterator iter = m_layout_items_selected.begin();
+ iter != m_layout_items_selected.end(); ++iter)
+ {
+ Glib::RefPtr<CanvasLayoutItem> selected_item = *iter;
+ if(!selected_item || (item == selected_item))
+ continue;
+
+ double x = 0;
+ double y = 0;
+ selected_item->get_xy(x, y);
+ selected_item->set_xy(x + x_offset, y + y_offset);
+ }
+
//Show the new positions in the spinbuttons:
on_canvas_selection_changed();
}
diff --git a/glom/mode_design/print_layouts/window_print_layout_edit.h b/glom/mode_design/print_layouts/window_print_layout_edit.h
index 71c16dd..e0fe27a 100644
--- a/glom/mode_design/print_layouts/window_print_layout_edit.h
+++ b/glom/mode_design/print_layouts/window_print_layout_edit.h
@@ -96,7 +96,7 @@ private:
void on_canvas_drag_leave(const Glib::RefPtr<Gdk::DragContext>& drag_context, guint timestamp);
void on_canvas_selection_changed();
- void on_selected_item_moved();
+ void on_selected_item_moved(const Glib::RefPtr<CanvasItemMovable>& item, double x_offset, double y_offset);
void on_spinbutton_x();
void on_spinbutton_y();
diff --git a/glom/mode_design/relationships_overview/dialog_relationships_overview.cc b/glom/mode_design/relationships_overview/dialog_relationships_overview.cc
index c1bdc7a..cfc941a 100644
--- a/glom/mode_design/relationships_overview/dialog_relationships_overview.cc
+++ b/glom/mode_design/relationships_overview/dialog_relationships_overview.cc
@@ -206,12 +206,10 @@ void Dialog_RelationshipsOverview::draw_tables()
CanvasGroupDbTable::create(info->get_name(), info->get_title_or_name(), fields, table_x, table_y);
m_group_tables->add_child(table_group);
- sigc::connection the_connection = table_group->signal_moved().connect( sigc::bind(
- sigc::mem_fun(*this, &Dialog_RelationshipsOverview::on_table_moved),
- table_group) );
- m_list_table_connections.push_back(the_connection);
+ table_group->signal_moved().connect(
+ sigc::mem_fun(*this, &Dialog_RelationshipsOverview::on_table_moved));
- the_connection = table_group->signal_show_context().connect( sigc::bind(
+ sigc::connection the_connection = table_group->signal_show_context().connect( sigc::bind(
sigc::mem_fun(*this, &Dialog_RelationshipsOverview::on_table_show_context),
table_group) );
m_list_table_connections.push_back(the_connection);
@@ -434,8 +432,13 @@ Glib::RefPtr<CanvasGroupDbTable> Dialog_RelationshipsOverview::get_table_group(c
return Glib::RefPtr<CanvasGroupDbTable>();
}
-void Dialog_RelationshipsOverview::on_table_moved(Glib::RefPtr<CanvasGroupDbTable> table)
+void Dialog_RelationshipsOverview::on_table_moved(const Glib::RefPtr<CanvasItemMovable>& item, double /* x_offset */, double /* y_offset */)
{
+ Glib::RefPtr<CanvasGroupDbTable> table =
+ Glib::RefPtr<CanvasGroupDbTable>::cast_dynamic(item);
+ if(!table)
+ return;
+
Document* document = dynamic_cast<Document*>(get_document());
if(document && table)
{
diff --git a/glom/mode_design/relationships_overview/dialog_relationships_overview.h b/glom/mode_design/relationships_overview/dialog_relationships_overview.h
index 7713e76..d87ec55 100644
--- a/glom/mode_design/relationships_overview/dialog_relationships_overview.h
+++ b/glom/mode_design/relationships_overview/dialog_relationships_overview.h
@@ -69,7 +69,7 @@ private:
void on_menu_file_save();
void on_menu_view_showgrid();
- void on_table_moved(Glib::RefPtr<CanvasGroupDbTable> table);
+ void on_table_moved(const Glib::RefPtr<CanvasItemMovable>& item, double x_offset, double y_offset);
void on_table_show_context(guint button, guint32 activate_time, Glib::RefPtr<CanvasGroupDbTable> table);
void on_context_menu_edit_fields(Glib::RefPtr<CanvasGroupDbTable> table);
diff --git a/glom/utility_widgets/canvas/canvas_group_resizable.cc b/glom/utility_widgets/canvas/canvas_group_resizable.cc
index c35ccde..22e4297 100644
--- a/glom/utility_widgets/canvas/canvas_group_resizable.cc
+++ b/glom/utility_widgets/canvas/canvas_group_resizable.cc
@@ -410,7 +410,7 @@ Glib::RefPtr<CanvasItemMovable> CanvasGroupResizable::get_manipulator(Manipulato
}
}
-void CanvasGroupResizable::on_manipulator_corner_moved(Manipulators manipulator_id)
+void CanvasGroupResizable::on_manipulator_corner_moved(const Glib::RefPtr<CanvasItemMovable>& /* item */, double /* x_offset */, double /* y_offset */, Manipulators manipulator_id)
{
//Make sure that the manipulator is still visibile.
//(if the user moves too fast then we get a leave-notify-event on the manipulator, rect, or item):
@@ -483,7 +483,7 @@ void CanvasGroupResizable::on_manipulator_corner_moved(Manipulators manipulator_
m_signal_resized.emit();
}
-void CanvasGroupResizable::on_manipulator_line_end_moved(Manipulators manipulator_id)
+void CanvasGroupResizable::on_manipulator_line_end_moved(const Glib::RefPtr<CanvasItemMovable>& /* item */, double /* x_offset */, double /* y_offset */, Manipulators manipulator_id)
{
//Make sure that the manipulator is still visibile.
//(if the user moves too fast then we get a leave-notify-event on the manipulator, rect, or item):
@@ -533,7 +533,7 @@ bool CanvasGroupResizable::on_manipulator_leave_notify_event(const Glib::RefPtr<
return false;
}
-void CanvasGroupResizable::on_manipulator_edge_moved(Manipulators manipulator_id)
+void CanvasGroupResizable::on_manipulator_edge_moved(const Glib::RefPtr<CanvasItemMovable>& /* item */, double /* x_offset */, double /* y_offset */, Manipulators manipulator_id)
{
//Make sure that the manipulator is still visibile.
//(if the user moves too fast then we get a leave-notify-event on the manipulator, rect, or item):
diff --git a/glom/utility_widgets/canvas/canvas_group_resizable.h b/glom/utility_widgets/canvas/canvas_group_resizable.h
index 29c86b2..11d3843 100644
--- a/glom/utility_widgets/canvas/canvas_group_resizable.h
+++ b/glom/utility_widgets/canvas/canvas_group_resizable.h
@@ -127,9 +127,9 @@ private:
void position_line_manipulators();
void set_manipulators_visibility(Goocanvas::ItemVisibility visibility);
- void on_manipulator_corner_moved(Manipulators manipulator_id);
- void on_manipulator_edge_moved(Manipulators manipulator_id);
- void on_manipulator_line_end_moved(Manipulators manipulator_id);
+ void on_manipulator_corner_moved(const Glib::RefPtr<CanvasItemMovable>& item, double x_offset, double y_offset, Manipulators manipulator_id);
+ void on_manipulator_edge_moved(const Glib::RefPtr<CanvasItemMovable>& item, double x_offset, double y_offset, Manipulators manipulator_id);
+ void on_manipulator_line_end_moved(const Glib::RefPtr<CanvasItemMovable>& item, double x_offset, double y_offset, Manipulators manipulator_id);
bool on_manipulator_enter_notify_event(const Glib::RefPtr<Goocanvas::Item>& target, GdkEventCrossing* event);
bool on_manipulator_leave_notify_event(const Glib::RefPtr<Goocanvas::Item>& target, GdkEventCrossing* event);
diff --git a/glom/utility_widgets/canvas/canvas_item_movable.cc b/glom/utility_widgets/canvas/canvas_item_movable.cc
index f8eb588..b090fcb 100644
--- a/glom/utility_widgets/canvas/canvas_item_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_item_movable.cc
@@ -35,12 +35,12 @@
namespace Glom
{
-
CanvasItemMovable::CanvasItemMovable()
: m_dragging(false),
m_dragging_vertical_only(false), m_dragging_horizontal_only(false),
m_drag_start_cursor_x(0.0), m_drag_start_cursor_y(0.0),
m_drag_start_position_x(0.0), m_drag_start_position_y(0.0),
+ m_drag_latest_position_x(0.0), m_drag_latest_position_y(0.0),
m_grid(0),
m_allow_vertical_movement(true), m_allow_horizontal_movement(true),
m_selected(false),
@@ -81,6 +81,8 @@ bool CanvasItemMovable::on_button_press_event(const Glib::RefPtr<Goocanvas::Item
m_drag_start_cursor_y = event->y;
get_xy(m_drag_start_position_x, m_drag_start_position_y);
+ m_drag_latest_position_x = m_drag_start_position_x;
+ m_drag_latest_position_y = m_drag_start_position_y;
Goocanvas::Canvas* canvas = get_parent_canvas_widget();
if(canvas)
@@ -161,6 +163,9 @@ bool CanvasItemMovable::on_motion_notify_event(const Glib::RefPtr<Goocanvas::Ite
set_xy(new_x, new_y);
+ Glib::RefPtr<CanvasItemMovable> refThis(this);
+ refThis->reference();
+
// A click with a move should always select:
// We emit this before signal_moved,
// so that its signal handler can know about the selection.
@@ -168,12 +173,14 @@ bool CanvasItemMovable::on_motion_notify_event(const Glib::RefPtr<Goocanvas::Ite
set_selected(true);
if(!old_selected)
{
- Glib::RefPtr<CanvasItemMovable> refThis(this);
- refThis->reference();
m_signal_selected.emit(refThis, m_shift_click);
}
- m_signal_moved.emit();
+ const double this_move_offset_x = new_x - m_drag_latest_position_x;
+ const double this_move_offset_y = new_y - m_drag_latest_position_y;
+ m_drag_latest_position_x = new_x;
+ m_drag_latest_position_y = new_y;
+ m_signal_moved.emit(refThis, this_move_offset_x, this_move_offset_y);
return true; //We handled this event.
}
diff --git a/glom/utility_widgets/canvas/canvas_item_movable.h b/glom/utility_widgets/canvas/canvas_item_movable.h
index 4e7b168..14440a4 100644
--- a/glom/utility_widgets/canvas/canvas_item_movable.h
+++ b/glom/utility_widgets/canvas/canvas_item_movable.h
@@ -60,7 +60,15 @@ public:
void set_drag_cursor(Gdk::CursorType cursor);
void set_drag_cursor(const Glib::RefPtr<Gdk::Cursor>& cursor);
- typedef sigc::signal<void> type_signal_moved;
+ /** For instance,
+ *
+ * @param item The item (this item) that was moved, for convenience.
+ * @param x_offset How much the item has moved in the x dimension.
+ * @param y_offset How much the item has moved in the y dimension.
+ *
+ * void on_moved(bool group_select, double x_offset, double y_offset);
+ */
+ typedef sigc::signal<void, const Glib::RefPtr<CanvasItemMovable>&, double, double> type_signal_moved;
/// This signal is emitted when the canvas item is moved by the user.
type_signal_moved signal_moved();
@@ -140,6 +148,7 @@ private:
bool m_dragging_vertical_only, m_dragging_horizontal_only; //Set by using Ctrl while dragging.
double m_drag_start_cursor_x, m_drag_start_cursor_y;
double m_drag_start_position_x, m_drag_start_position_y;
+ double m_drag_latest_position_x, m_drag_latest_position_y; //To discover how much the latest motion_event has moved the item.
Glib::RefPtr<Gdk::Cursor> m_drag_cursor;
protected:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]