← Back to team overview

kicad-developers team mailing list archive

[PATCH] Fix minor annoyance in BOM editor

 

​Currently in the BOM editor​ (also called "Edit Symbol Fields" or "Symbol
Table"), when you first open it, the columns are auto-sized.  With multiple
references, this means that initially the reference column takes up the
whole window.

I realized that I had just fallen into the habit of unchecking and
immediately checking the "Show" checkbox for all my columns so that I could
see them.  This resets the column width to 150 (hard-coded), which seems
sensible on my monitor.

The attached patch moves the column width at the outset to the default
value, preventing massive strings from taking over the column.  It also
abstracts the default width to a getter method with the intention of having
the variable be configurable come v6.

If someone with a hi-dpi monitor could check whether the hard coded value
is wonky for them, I'd greatly appreciate it!

-S
From 814ec9885a1a07a882b598d4c77f5cccf57c3242 Mon Sep 17 00:00:00 2001
From: Seth Hillbrand <hillbrand@xxxxxxxxxxx>
Date: Wed, 14 Feb 2018 13:37:43 -0800
Subject: [PATCH] Eeschema: Set initial default widths in BOM editor

---
 eeschema/dialogs/dialog_fields_editor_global.cpp |  2 +-
 eeschema/fields_editor_table_model.cpp           | 10 ++++++++--
 eeschema/fields_editor_table_model.h             |  3 +++
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/eeschema/dialogs/dialog_fields_editor_global.cpp b/eeschema/dialogs/dialog_fields_editor_global.cpp
index a5b679eae..a25f91c02 100644
--- a/eeschema/dialogs/dialog_fields_editor_global.cpp
+++ b/eeschema/dialogs/dialog_fields_editor_global.cpp
@@ -92,7 +92,7 @@ DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent
         if( !col )
             continue;
 
-        col->SetWidth( wxCOL_WIDTH_AUTOSIZE );
+        col->SetWidth( m_bom->GetDefaultRowWidth() );
         col->SetResizeable( true );
     }
 
diff --git a/eeschema/fields_editor_table_model.cpp b/eeschema/fields_editor_table_model.cpp
index 262ad49f9..83366e3fd 100644
--- a/eeschema/fields_editor_table_model.cpp
+++ b/eeschema/fields_editor_table_model.cpp
@@ -29,7 +29,7 @@
 
 static const wxColor ROW_COLOUR_ITEM_CHANGED( 200, 0, 0 );
 static const wxColor ROW_COLOUR_MULTIPLE_ITEMS( 60, 90, 200 );
-
+static const int default_row_width = 100;
 
 /**
  * Convert FIELDS_EDITOR_TABLE_ROW -> wxDataViewItem
@@ -805,6 +805,12 @@ FIELDS_EDITOR_TABLE_MODEL::~FIELDS_EDITOR_TABLE_MODEL()
 }
 
 
+int FIELDS_EDITOR_TABLE_MODEL::GetDefaultRowWidth()
+{
+    return default_row_width;
+}
+
+
 wxDataViewColumn* FIELDS_EDITOR_TABLE_MODEL::AddColumn( FIELDS_EDITOR_COLUMN* aColumn, int aPosition )
 {
     static const unsigned int flags = wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE;
@@ -819,7 +825,7 @@ wxDataViewColumn* FIELDS_EDITOR_TABLE_MODEL::AddColumn( FIELDS_EDITOR_COLUMN* aC
     auto column = new wxDataViewColumn( aColumn->Title(),
                                         renderer,
                                         aColumn->Id(),
-                                        150, //TODO - variable default width?
+                                        GetDefaultRowWidth(), //TODO - variable default width?
                                         wxAlignment( wxALIGN_LEFT ),
                                         flags );
 
diff --git a/eeschema/fields_editor_table_model.h b/eeschema/fields_editor_table_model.h
index b5aeb98f4..4eede5695 100644
--- a/eeschema/fields_editor_table_model.h
+++ b/eeschema/fields_editor_table_model.h
@@ -317,6 +317,9 @@ public:
 
     void AttachTo( wxDataViewCtrl* aView );
 
+    // Returns the current default row width for new rows
+    int GetDefaultRowWidth();
+
     wxDataViewColumn* AddColumn( FIELDS_EDITOR_COLUMN* aColumn, int aPosition = -1 );
     bool RemoveColumn( FIELDS_EDITOR_COLUMN* aColumn );
 
-- 
2.11.0


Follow ups