[glom] Print Layout: Related Records: Move others down when expanding.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Print Layout: Related Records: Move others down when expanding.
- Date: Tue, 11 Oct 2011 23:58:19 +0000 (UTC)
commit 7b269362fedfb2c86656dd146b5c229c957f05a4
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Oct 12 01:58:12 2011 +0200
Print Layout: Related Records: Move others down when expanding.
* glom/print_layout/canvas_layout_item.[h|cc]: Added
move_items_below_item().
* glom/print_layout/canvas_print_layout.[h|cc]: fill_with_data_portal():
move other items lower when changing the size of the portal's table.
ChangeLog | 9 +++++
glom/print_layout/canvas_layout_item.cc | 2 -
glom/print_layout/canvas_print_layout.cc | 53 +++++++++++++++++++++++++++++-
glom/print_layout/canvas_print_layout.h | 7 ++++
4 files changed, 68 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cce74dd..98880db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2011-10-12 Murray Cumming <murrayc murrayc com>
+ Print Layout: Related Records: Move others down when expanding.
+
+ * glom/print_layout/canvas_layout_item.[h|cc]: Added
+ move_items_below_item().
+ * glom/print_layout/canvas_print_layout.[h|cc]: fill_with_data_portal():
+ move other items lower when changing the size of the portal's table.
+
+2011-10-12 Murray Cumming <murrayc murrayc com>
+
Print Layout: Related Records: Expand according to min/max rows count.
* glom/print_layout/canvas_layout_item.[h|cc]:
diff --git a/glom/print_layout/canvas_layout_item.cc b/glom/print_layout/canvas_layout_item.cc
index e5ce553..8ca1a63 100644
--- a/glom/print_layout/canvas_layout_item.cc
+++ b/glom/print_layout/canvas_layout_item.cc
@@ -394,8 +394,6 @@ void CanvasLayoutItem::add_portal_rows_if_necessary(const Glib::RefPtr<CanvasTab
if(cell && cell_as_item)
{
- std::cout << " creating child" << std::endl;
-
const guint width = layout_item->get_display_width();
bool expand = (width == 0);
diff --git a/glom/print_layout/canvas_print_layout.cc b/glom/print_layout/canvas_print_layout.cc
index fe3a43e..b448d31 100644
--- a/glom/print_layout/canvas_print_layout.cc
+++ b/glom/print_layout/canvas_print_layout.cc
@@ -919,7 +919,14 @@ void Canvas_PrintLayout::fill_with_data_portal(const Glib::RefPtr<CanvasLayoutIt
double old_height = 0;
canvas_item->get_width_height(old_width, old_height);
canvas_item->set_width_height(old_width, portal_height);
- std::cout << G_STRFUNC << ": portal_height = " << portal_height << ", for rows_count=" << rows_count << std::endl;
+
+ //Move other items down if the portal table became bigger:
+ double x = 0;
+ double y = 0;
+ canvas_item->get_xy(x, y);
+ const double offset = portal_height - old_height;
+ move_items_below_item(canvas_item, y + old_height, offset);
+
canvas_item->add_portal_rows_if_necessary(rows_count);
//TODO: Move everything else down.
@@ -1175,5 +1182,49 @@ Goocanvas::Bounds Canvas_PrintLayout::get_page_bounds(guint page_num) const
return bounds;
}
+void Canvas_PrintLayout::move_items_below_item(const Glib::RefPtr<CanvasLayoutItem>& canvas_item, double y_start, double offset)
+{
+ Glib::RefPtr<Goocanvas::Item> root = m_items_group;
+ if(!root)
+ return;
+
+ double item_x = 0;
+ double item_y = 0;
+ canvas_item->get_xy(item_x, item_y);
+ double item_width = 0;
+ double item_height = 0;
+ canvas_item->get_width_height(item_width, item_height);
+
+ const int count = root->get_n_children();
+ for(int i = 0; i < count; ++i)
+ {
+ Glib::RefPtr<Goocanvas::Item> child = root->get_child(i);
+ Glib::RefPtr<CanvasLayoutItem> derived =
+ Glib::RefPtr<CanvasLayoutItem>::cast_dynamic(child);
+ if(!derived)
+ continue;
+
+ //Ignore items above y_start:
+ double x = 0;
+ double y = 0;
+ derived->get_xy(x, y);
+ if(y < y_start)
+ continue;
+
+ //Ignore items that would not overlap even if the had the same y:
+ double width = 0;
+ double height = 0;
+ derived->get_width_height(width, height);
+ if( (x + width) < item_x)
+ continue;
+
+ if( x > (item_x + item_width))
+ continue;
+
+ y += offset;
+ derived->set_xy(x, y);
+ }
+}
+
} //namespace Glom
diff --git a/glom/print_layout/canvas_print_layout.h b/glom/print_layout/canvas_print_layout.h
index 50c1f84..3bdd7f5 100644
--- a/glom/print_layout/canvas_print_layout.h
+++ b/glom/print_layout/canvas_print_layout.h
@@ -88,6 +88,13 @@ public:
Goocanvas::Bounds get_page_bounds(guint page_num) const;
+
+ /** Look for any items that overlap the @a canvas_item and move them down so that the no longer overlap.
+ * @param canvas_item The item that should push items out of the way.
+ * @param y_start Ignore any items whose y position is less than this.
+ * @param offset Move items down by this amount:
+ */
+ void move_items_below_item(const Glib::RefPtr<CanvasLayoutItem>& canvas_item, double y_start, double offset);
private:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]