[glom] Print Layout: Make item sizes match the grid size by default.



commit 10d20ddf4460f701b617453058d3df5ca894106e
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Aug 27 16:34:56 2011 +0200

    Print Layout: Make item sizes match the grid size by default.
    
    * glom/mode_design/print_layouts/window_print_layout_edit.cc:
    create_empty_item(): Base the default item sizes on the grid gap,
    so they are more useful.

 ChangeLog                                          |    8 ++++++++
 .../print_layouts/window_print_layout_edit.cc      |   20 +++++++++++++-------
 2 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b341176..0d9f485 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-08-27  Murray Cumming  <murrayc murrayc com>
+
+	Print Layout: Make item sizes match the grid size by default.
+
+	* glom/mode_design/print_layouts/window_print_layout_edit.cc:
+	create_empty_item(): Base the default item sizes on the grid gap,
+	so they are more useful.
+
 2011-08-26  Murray Cumming  <murrayc murrayc com>
 
 	Allow deletion of multiple selected items via the context menu.
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 79341a5..4bf7003 100644
--- a/glom/mode_design/print_layouts/window_print_layout_edit.cc
+++ b/glom/mode_design/print_layouts/window_print_layout_edit.cc
@@ -35,6 +35,12 @@
 namespace Glom
 {
 
+const double GRID_GAP = 5.0f;
+
+//Base the default item sizes on the grid gap, instead of being arbitrary:
+const double ITEM_HEIGHT = GRID_GAP;
+const double ITEM_WIDTH_WIDE = GRID_GAP * 10;
+
 const char* Window_PrintLayout_Edit::glade_id("window_print_layout_edit");
 const bool Window_PrintLayout_Edit::glade_developer(true);
 
@@ -395,7 +401,7 @@ sharedptr<LayoutItem> Window_PrintLayout_Edit::create_empty_item(PrintLayoutTool
   if(item_type == PrintLayoutToolbarButton::ITEM_FIELD)
   {
     layout_item = sharedptr<LayoutItem_Field>::create();
-    layout_item->set_print_layout_position(0, 0, 50, 10);
+    layout_item->set_print_layout_position(0, 0, ITEM_WIDTH_WIDE, ITEM_HEIGHT);
   }
   else if(item_type == PrintLayoutToolbarButton::ITEM_TEXT)
   {
@@ -404,23 +410,23 @@ sharedptr<LayoutItem> Window_PrintLayout_Edit::create_empty_item(PrintLayoutTool
     // Note to translators: This is the default contents of a text item on a print layout: 
     layout_item_derived->set_text(_("text")); //TODO: Choose some other longer default because this is hidden under the drag icon?
     layout_item = layout_item_derived;
-    layout_item->set_print_layout_position(0, 0, 50, 10);
+    layout_item->set_print_layout_position(0, 0, ITEM_WIDTH_WIDE, ITEM_HEIGHT);
   }
   else if(item_type == PrintLayoutToolbarButton::ITEM_IMAGE)
   {
     layout_item = sharedptr<LayoutItem_Image>::create();
-    layout_item->set_print_layout_position(0, 0, 50, 50);
+    layout_item->set_print_layout_position(0, 0, ITEM_WIDTH_WIDE, ITEM_WIDTH_WIDE);
   }
   else if(item_type == PrintLayoutToolbarButton::ITEM_LINE_HORIZONTAL)
   {
     sharedptr<LayoutItem_Line> layout_item_derived = sharedptr<LayoutItem_Line>::create();
-    layout_item_derived->set_coordinates(0, 0, 100, 0);
+    layout_item_derived->set_coordinates(0, 0, ITEM_WIDTH_WIDE * 2, 0);
     layout_item = layout_item_derived;
   }
   else if(item_type == PrintLayoutToolbarButton::ITEM_LINE_VERTICAL)
   {
     sharedptr<LayoutItem_Line> layout_item_derived = sharedptr<LayoutItem_Line>::create();
-    layout_item_derived->set_coordinates(0, 0, 0, 100);
+    layout_item_derived->set_coordinates(0, 0, 0, ITEM_WIDTH_WIDE * 2);
     layout_item = layout_item_derived;
   }
   else if(item_type == PrintLayoutToolbarButton::ITEM_PORTAL)
@@ -428,7 +434,7 @@ sharedptr<LayoutItem> Window_PrintLayout_Edit::create_empty_item(PrintLayoutTool
     sharedptr<LayoutItem_Portal> portal = sharedptr<LayoutItem_Portal>::create();
     portal->set_print_layout_row_height(10); //Otherwise it will be 0, which is useless.
     layout_item = portal;
-    layout_item->set_print_layout_position(0, 0, 100, 50);
+    layout_item->set_print_layout_position(0, 0, ITEM_WIDTH_WIDE * 2, ITEM_WIDTH_WIDE);
   }
   else
   {
@@ -861,7 +867,7 @@ void Window_PrintLayout_Edit::on_menu_view_show_grid()
 {
   if(m_action_showgrid->get_active())
   {
-    m_canvas.set_grid_gap(5.0f);
+    m_canvas.set_grid_gap(GRID_GAP);
   }
   else
   {



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