[glom] Print Layout: Only show grid lines on mouseover.



commit cf18783dfa5dfbbbb1d20e72b8ade9cd72278371
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Aug 11 18:55:29 2011 +0200

    Print Layout: Only show grid lines on mouseover.
    
    * glom/utility_widgets/canvas/canvas_table_movable.[h|cc]:
    Add set_lines_visibility().
    * glom/utility_widgets/canvas/canvas_group_resizable.cc:
    position_line_manipulators(): If the child is a table then
    also show the grid lines.

 ChangeLog                                          |   10 +++++++
 glom/print_layout/canvas_layout_item.cc            |   27 --------------------
 .../canvas/canvas_group_resizable.cc               |   14 ++++++++++
 .../utility_widgets/canvas/canvas_table_movable.cc |   16 +++++++++++
 glom/utility_widgets/canvas/canvas_table_movable.h |    4 +++
 5 files changed, 44 insertions(+), 27 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d451e49..2c21a49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2011-08-11  Murray Cumming  <murrayc murrayc com>
 
+	Print Layout: Only show grid lines on mouseover.
+
+	* glom/utility_widgets/canvas/canvas_table_movable.[h|cc]:
+	Add set_lines_visibility().
+	* glom/utility_widgets/canvas/canvas_group_resizable.cc:
+	position_line_manipulators(): If the child is a table then 
+	also show the grid lines.
+
+2011-08-11  Murray Cumming  <murrayc murrayc com>
+
 	Print Layout: Make the manipulators the same width as the outlines.
 
 	* glom/utility_widgets/canvas/canvas_group_resizable.cc: Change 
diff --git a/glom/print_layout/canvas_layout_item.cc b/glom/print_layout/canvas_layout_item.cc
index c3e53e6..2226563 100644
--- a/glom/print_layout/canvas_layout_item.cc
+++ b/glom/print_layout/canvas_layout_item.cc
@@ -345,33 +345,6 @@ Glib::RefPtr<CanvasItemMovable> CanvasLayoutItem::create_canvas_item_for_layout_
   }
 
   return child;
-
-  if(child && child_item)
-  {
-    //child_item->property_pointer_events() =
-    //  (Goocanvas::PointerEvents)(Goocanvas::EVENTS_VISIBLE_FILL & GOO_CANVAS_EVENTS_VISIBLE_STROKE);
-
-    //Set the position and dimensions of this group to match the child:
-    double x = 0;
-    double y = 0;
-    double width = 0;
-    double height = 0;
-    layout_item->get_print_layout_position(x, y, width, height);
-    child->set_width_height(width, height);
-    //std::cout << "debug: " << G_STRFUNC << ": item x=" << x << std::endl;
-  }
-
-  //Scale images.
-  //This can only be done after setting the size:
-  Glib::RefPtr<CanvasImageMovable> canvas_image = Glib::RefPtr<CanvasImageMovable>::cast_dynamic(child);
-  if(canvas_image)
-  {
-    canvas_image->scale_to_size();
-
-    //It will also be rescaled when this canvas item is resized - see on_resized().
-  }
-
-  return child;
 }
 
 void CanvasLayoutItem::set_db_data(const Gnome::Gda::Value& value)
diff --git a/glom/utility_widgets/canvas/canvas_group_resizable.cc b/glom/utility_widgets/canvas/canvas_group_resizable.cc
index 4a9598f..70c7077 100644
--- a/glom/utility_widgets/canvas/canvas_group_resizable.cc
+++ b/glom/utility_widgets/canvas/canvas_group_resizable.cc
@@ -21,6 +21,7 @@
 #include "canvas_group_resizable.h"
 #include "canvas_rect_movable.h"
 #include "canvas_line_movable.h"
+#include <glom/utility_widgets/canvas/canvas_table_movable.h>
 #include <goocanvasmm/canvas.h>
 #include <goocanvasrect.h>
 #include <goocanvasgroup.h>
@@ -764,6 +765,19 @@ void CanvasGroupResizable::set_manipulators_visibility(Goocanvas::ItemVisibility
   //For testing: visibility = Goocanvas::ITEM_VISIBLE;
   m_group_edge_manipulators->property_visibility() = edge_visibility;
   m_group_corner_manipulators->property_visibility() = visibility;
+
+  //Also show grid lines in the portal table,
+  //though these are not actually manipulatable.
+  Glib::RefPtr<CanvasTableMovable> table = 
+    Glib::RefPtr<CanvasTableMovable>::cast_dynamic(get_child());
+  if(table)
+  {
+    if(visibility == Goocanvas::ITEM_VISIBLE)
+      table->set_lines_visibility();
+    else
+      table->set_lines_visibility(false);
+  }
+  
 }
 
 bool CanvasGroupResizable::on_rect_enter_notify_event(const Glib::RefPtr<Goocanvas::Item>& /* target */, GdkEventCrossing* /* event */)
diff --git a/glom/utility_widgets/canvas/canvas_table_movable.cc b/glom/utility_widgets/canvas/canvas_table_movable.cc
index e2b576f..e0c8f97 100644
--- a/glom/utility_widgets/canvas/canvas_table_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_table_movable.cc
@@ -72,6 +72,8 @@ void CanvasTableMovable::get_width_height(double& width, double& height) const
 
 void CanvasTableMovable::set_width_height(double width, double height)
 {
+  std::cout << "debug: " << G_STRFUNC << ": height=" << height << std::endl;
+
   if(width == -1)
   {
     std::cout << "debug: " << G_STRFUNC << ": width is -1" << std::endl;
@@ -180,6 +182,20 @@ Goocanvas::Canvas* CanvasTableMovable::get_parent_canvas_widget()
   return get_canvas();
 }
 
+void CanvasTableMovable::set_lines_visibility(bool show)
+{
+  if(show)
+  {
+    property_vert_grid_line_width() = 0.5f;
+    property_horz_grid_line_width() = 0.5f;
+    property_stroke_color() = "black";
+  }
+  else
+  {
+    property_vert_grid_line_width() = 0.0f;
+    property_horz_grid_line_width() = 0.0f;
+  }
+}
 
 } //namespace Glom
 
diff --git a/glom/utility_widgets/canvas/canvas_table_movable.h b/glom/utility_widgets/canvas/canvas_table_movable.h
index 4373774..3c4188b 100644
--- a/glom/utility_widgets/canvas/canvas_table_movable.h
+++ b/glom/utility_widgets/canvas/canvas_table_movable.h
@@ -44,6 +44,10 @@ public:
   virtual void set_width_height(double width, double height);
   virtual void set_grid(const Glib::RefPtr<const CanvasGroupGrid>& grid);
 
+  /** Show horizontal and vertical grid lines.
+   */
+  void set_lines_visibility(bool show = true);
+
 private:
   virtual Goocanvas::Canvas* get_parent_canvas_widget();
 



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