[glom/maemo5] Maemo: Details: More correct padding, maybe.



commit 50560d2126562f076aff883372e3bb483c9e64a2
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Oct 12 10:24:35 2009 +0200

    Maemo: Details: More correct padding, maybe.
    
    * glom/utility_widgets/flowtable.[h|cc]: Change set_padding() to
    set_column_padding() and set_row_padding(), allowing different padding
    between rows and between columns, as per Maemo's UI specifications.

 ChangeLog                              |    8 +++++
 glom/mode_data/box_data_details.cc     |    9 +++++-
 glom/mode_data/flowtablewithfields.cc  |   24 ++++++++------
 glom/utility_widgets/flowtable.cc      |   53 ++++++++++++++++++++------------
 glom/utility_widgets/flowtable.h       |   22 ++++++++++---
 glom/utility_widgets/test_flowtable.cc |    6 +--
 6 files changed, 81 insertions(+), 41 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c3b7b0a..fc2ce3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-10-12  Murray Cumming  <murrayc murrayc com>
+
+  Maemo: Details: More correct padding, maybe.
+  
+	* glom/utility_widgets/flowtable.[h|cc]: Change set_padding() to 
+	set_column_padding() and set_row_padding(), allowing different padding 
+	between rows and between columns, as per Maemo's UI specifications.
+
 2009-10-11  Murray Cumming  <murrayc murrayc com>
 
   Maemo: Use Hildon buttons for Open, Find and ... buttons.
diff --git a/glom/mode_data/box_data_details.cc b/glom/mode_data/box_data_details.cc
index 9a357fb..0f1bda2 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -58,8 +58,15 @@ Box_Data_Details::Box_Data_Details(bool bWithNavButtons /* = true */)
   add_view(&m_FlowTable); //Allow this to access the document too.
 
   m_FlowTable.set_columns_count(1); //Sub-groups will have multiple columns (by default, there is one sub-group, with 2 columns).
-  m_FlowTable.set_padding(Utils::DEFAULT_SPACING_SMALL);
 
+  #ifndef GLOM_ENABLE_MAEMO
+  m_FlowTable.set_column_padding(Utils::DEFAULT_SPACING_SMALL); //The default anyway.
+  m_FlowTable.set_row_padding(Utils::DEFAULT_SPACING_SMALL); //The default anyway.
+  #else
+  m_FlowTable.set_row_padding(0); //The hildon buttons and entries have their own default padding.
+  m_FlowTable.set_column_padding(HILDON_MARGIN_DOUBLE); //As per the UI specs.
+  #endif
+  
   //m_strHint = _("When you change the data in a field the database is updated immediately.\n Click [New] to add a new record.\n Leave automatic ID fields empty - they will be filled for you.");
 
 
diff --git a/glom/mode_data/flowtablewithfields.cc b/glom/mode_data/flowtablewithfields.cc
index 2062e4e..b9fb52a 100644
--- a/glom/mode_data/flowtablewithfields.cc
+++ b/glom/mode_data/flowtablewithfields.cc
@@ -194,7 +194,12 @@ void FlowTableWithFields::add_layout_group_at_position(const sharedptr<LayoutGro
     Gtk::Alignment* alignment = Gtk::manage( new Gtk::Alignment ); //TODO_leak: This is possibly leaked, according to valgrind.
 
     if(!group->get_title().empty()) //Don't indent if it has no title, to allow use of groups just for positioning.
+    {
       alignment->set_padding(Glom::Utils::DEFAULT_SPACING_SMALL, 0, 6, 0); //Use left-padding of 6 even on Maemo because indentation is important.
+      #ifdef GLOM_ENABLE_MAEMO
+      std::cerr << "DEBUG: Unexpected group with title causing extra spacing on Maemo." << std::endl;
+      #endif
+    }
 
     alignment->show();
     frame->add(*alignment);
@@ -204,11 +209,10 @@ void FlowTableWithFields::add_layout_group_at_position(const sharedptr<LayoutGro
     flow_table->set_table(m_table_name);
 
     flow_table->set_columns_count(group->get_columns_count());
-    #ifndef GLOM_ENABLE_MAEMO
-    flow_table->set_padding(Utils::DEFAULT_SPACING_SMALL);
-    #else
-    flow_table->set_padding(0);HILDON_MARGIN_HALF);
-    #endif
+    
+    //Use the parent table's padding:
+    flow_table->set_column_padding(get_column_padding());
+    flow_table->set_row_padding(get_row_padding());
     flow_table->show();
     
     Gtk::EventBox* event_box = Gtk::manage( new Gtk::EventBox() ); //TODO_Leak: Valgrind says this is possibly leaked.
@@ -393,11 +397,8 @@ void FlowTableWithFields::add_layout_notebook_at_position(const sharedptr<Layout
         flow_table->set_table(m_table_name);
 
         flow_table->set_columns_count(group->get_columns_count());
-        #ifndef GLOM_ENABLE_MAEMO
-        flow_table->set_padding(Utils::DEFAULT_SPACING_SMALL);
-        #else
-        flow_table->set_padding(HILDON_MARGIN_HALF);
-        #endif
+        flow_table->set_column_padding(get_column_padding());
+        flow_table->set_row_padding(get_row_padding());
         flow_table->show();
         
         // Put the new flowtable in an event box to catch events
@@ -485,7 +486,8 @@ void FlowTableWithFields::add_group(const Glib::ustring& group_name, const Glib:
     FlowTableWithFields* flow_table = Gtk::manage( new FlowTableWithFields() );
 
     flow_table->set_columns_count(1);
-    flow_table->set_padding(Utils::DEFAULT_SPACING_SMALL);
+    flow_table->set_column_padding(get_column_padding());
+    flow_table->set_row_padding(get_row_padding());
     flow_table->show();
     alignment->add(*flow_table);
 
diff --git a/glom/utility_widgets/flowtable.cc b/glom/utility_widgets/flowtable.cc
index 6b94ee1..9724ed1 100644
--- a/glom/utility_widgets/flowtable.cc
+++ b/glom/utility_widgets/flowtable.cc
@@ -24,6 +24,7 @@
 #include <gdk/gdktypes.h>
 #include <iostream>
 #include <gdkmm/window.h>
+#include <glom/utils_ui.h>
 #include <gtk/gtk.h>
 
 
@@ -201,7 +202,8 @@ FlowTable::FlowTable()
   Glib::ObjectBase("Glom_FlowTable"),
 #endif // ! !defined(GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED)
   m_columns_count(1),
-  m_padding(0),
+  m_column_padding(Utils::DEFAULT_SPACING_SMALL), //A sane default.
+  m_row_padding(Utils::DEFAULT_SPACING_SMALL), //A sane default.
   m_design_mode(false)
 {
 #if !defined(GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED)
@@ -452,8 +454,7 @@ int FlowTable::get_column_height(guint start_widget, guint widget_count, int& to
     //Add the padding if it's not the first widget, and if one is visible:
     if( (i != start_widget) && item_height)
     {
-      std::cout << "debug: row padding=" << m_padding << std::endl;
-      column_height += m_padding;
+      column_height += m_row_padding;
     }
 
     if(item_height) //If one was visible.
@@ -479,7 +480,7 @@ int FlowTable::get_column_height(guint start_widget, guint widget_count, int& to
    total_width = MAX(total_width, column_width_singles);
 
    if( (column_width_first > 0) && (column_width_second > 0) ) //Add padding if necessary.
-     total_width += m_padding;
+     total_width += m_column_padding;
 
   return column_height;
 }  
@@ -522,7 +523,7 @@ int FlowTable::get_minimum_column_height(guint start_widget, guint columns_count
       if( others_column_start_widget  < m_children.size())
       {
         minimum_column_height_nextcolumns = get_minimum_column_height(others_column_start_widget, columns_count - 1, others_column_width);
-        others_column_width += m_padding; //Add the padding between the previous column and this one.
+        others_column_width += m_column_padding; //Add the padding between the previous column and this one.
 
         minimum_column_height_sofar = MAX(first_column_height, minimum_column_height_nextcolumns);
       }
@@ -626,7 +627,7 @@ void FlowTable::get_item_max_width_requested(guint start, guint height, guint& f
     guint padding_above = 0;
     //Add padding above the item, if it is after another one.
     if( first_item_added && (child_is_visible(first) || child_is_visible(second)) )
-       padding_above += m_padding;
+       padding_above += m_row_padding;
 
     guint item_first_width = 0;
     guint singles_width = 0;
@@ -709,10 +710,10 @@ void FlowTable::on_size_allocate(Gtk::Allocation& allocation)
 
   int column_x_start_second = column_x_start + first_max_width;
   if(first_max_width > 0) //Add padding between first and second sub sets of items, if there is a first set.
-    column_x_start_second += m_padding;
+    column_x_start_second += m_column_padding;
 
   //Used for drawing horizontal lines:
-  guint column_max_width = MAX(first_max_width + m_padding + second_max_width, singles_max_width);
+  guint column_max_width = MAX(first_max_width + m_column_padding + second_max_width, singles_max_width);
   //Use the whole remaining width if there is no column after this:
   if(is_last_column)
   {
@@ -737,10 +738,10 @@ void FlowTable::on_size_allocate(Gtk::Allocation& allocation)
       int column_x_start_plus_singles = column_x_start + singles_max_width;
       column_x_start = column_x_start_second + second_max_width;
       column_x_start = MAX(column_x_start, column_x_start_plus_singles); //Maybe the single items take up even more width.
-      column_x_start += m_padding;
+      column_x_start += m_column_padding;
 
       //Draw vertical line to separate the columns, in the middle of the padding:
-      const int line_x = column_x_start - (m_padding / 2);
+      const int line_x = column_x_start - (m_column_padding / 2);
       const int line_height = allocation.get_height();
       m_lines_vertical.push_back( type_line( Gdk::Point(line_x, allocation.get_y()), Gdk::Point(line_x, allocation.get_y() + line_height) ) );
 
@@ -755,10 +756,10 @@ void FlowTable::on_size_allocate(Gtk::Allocation& allocation)
 
         column_x_start_second = column_x_start + first_max_width;
         if(first_max_width > 0) //Add padding between first and second sub sets of items, if there is a first set.
-          column_x_start_second += m_padding;
+          column_x_start_second += m_column_padding;
 
         //Used for drawing horizontal lines:
-        column_max_width = MAX(first_max_width + m_padding + second_max_width, singles_max_width);
+        column_max_width = MAX(first_max_width + m_column_padding + second_max_width, singles_max_width);
 
         //Use the whole remaining width if there is no column after this:
         if(is_last_column)
@@ -795,7 +796,7 @@ void FlowTable::on_size_allocate(Gtk::Allocation& allocation)
           item.m_second_allocation = assign_child(second, column_x_start_second, column_child_y_start);
         else
         {
-          const int second_width_available = column_max_width - first_max_width - m_padding;
+          const int second_width_available = column_max_width - first_max_width - m_column_padding;
           item.m_second_allocation = assign_child(second, column_x_start_second, column_child_y_start, second_width_available, item_height);
         }
 
@@ -821,10 +822,10 @@ void FlowTable::on_size_allocate(Gtk::Allocation& allocation)
     {
       //Start the next child below this child, plus the padding
       column_child_y_start += item_height;
-      column_child_y_start += m_padding; //Ignored if this is the last item - we will just start a new column when we find that column_child_y_start is too much.
+      column_child_y_start += m_row_padding; //Ignored if this is the last item - we will just start a new column when we find that column_child_y_start is too much.
 
       //Add horizontal line in the middle of the padding:
-      const guint line_y = column_child_y_start - (m_padding / 2);
+      const guint line_y = column_child_y_start - (m_row_padding / 2);
       const guint line_width = column_max_width;
       m_lines_horizontal.push_back( type_line( Gdk::Point(column_x_start, line_y), Gdk::Point(column_x_start + line_width, line_y) ) );
     }
@@ -913,11 +914,24 @@ void FlowTable::forall(const ForallSlot& slot)
   gtk_container_forall(gobj(), &container_forall_callback, &slot_copy);
 }
 
-/** Sets the padding to put between the child widgets.
- */
-void FlowTable::set_padding(guint padding)
+void FlowTable::set_column_padding(guint padding)
+{
+  m_column_padding = padding; 
+}
+
+guint FlowTable::get_column_padding() const
 {
-  m_padding = padding; 
+  return m_column_padding;
+}
+
+void FlowTable::set_row_padding(guint padding)
+{
+  m_row_padding = padding; 
+}
+
+guint FlowTable::get_row_padding() const
+{
+  return m_row_padding;
 }
 
 bool FlowTable::child_is_visible(const Gtk::Widget* widget) const
@@ -1041,4 +1055,3 @@ bool FlowTable::on_expose_event(GdkEventExpose* event)
 
 } //namespace Glom
 
-
diff --git a/glom/utility_widgets/flowtable.h b/glom/utility_widgets/flowtable.h
index db57674..c568e6a 100644
--- a/glom/utility_widgets/flowtable.h
+++ b/glom/utility_widgets/flowtable.h
@@ -44,9 +44,21 @@ public:
 
   void set_columns_count(guint value);
 
-  /** Sets the padding to put between the child widgets.
+  /** Sets the padding to put between the columns of widgets.
    */
-  virtual void set_padding(guint padding);
+  void set_column_padding(guint padding);
+  
+  /** Gets the padding between the columns of widgets.
+   */
+  guint get_column_padding() const;
+  
+  /** Sets the padding to put between the rows of widgets.
+   */
+  void set_row_padding(guint padding);
+  
+  /** Gets the padding between the rows of widgets.
+   */
+  guint get_row_padding() const;
 
   /** Show extra UI that is useful in RAD tools:
    */
@@ -60,7 +72,7 @@ public:
 
 protected:
 
-#ifndef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
+  #ifndef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
   // These are the hand-coded C default signal handlers in case the
   // corresponding glibmm API has been disabled
   static void glom_size_request_impl(GtkWidget* widget, GtkRequisition* requisition);
@@ -71,7 +83,7 @@ protected:
   static void glom_realize_impl(GtkWidget* widget);
   static void glom_unrealize_impl(GtkWidget* widget);
   static gboolean glom_expose_event_impl(GtkWidget* widget, GdkEventExpose* event);
-#endif
+  #endif
   //Overrides:
 
   //Handle child widgets:
@@ -129,7 +141,7 @@ protected:
 
   type_vecChildren m_children;
   guint m_columns_count;
-  guint m_padding;
+  guint m_column_padding, m_row_padding;
   bool m_design_mode;
 
   //Lines to draw in on_expose_event:
diff --git a/glom/utility_widgets/test_flowtable.cc b/glom/utility_widgets/test_flowtable.cc
index afd203a..78f7dba 100644
--- a/glom/utility_widgets/test_flowtable.cc
+++ b/glom/utility_widgets/test_flowtable.cc
@@ -45,7 +45,8 @@ main(int argc, char* argv[])
   //Gtk::VBox flowtable;
   Glom::FlowTable flowtable;
   flowtable.set_columns_count(3);
-  flowtable.set_padding(5);
+  flowtable.set_column_padding(100);
+  flowtable.set_row_padding(0);
 
   Gtk::Entry button7; button7.set_text("seven");
   button7.show();
@@ -73,9 +74,6 @@ main(int argc, char* argv[])
   flowtable.set_design_mode();
   flowtable.show();
 
-
-  flowtable.set_padding(20);
-
 //  Glom::DragWindow drag_window;
 //  drag_window.show();
   



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