Hi all,

This patch rearranges the Render panel to be in a more logical order, and
adds some whitespace.
I divided it into three groupings:
1) footprint related
2) other board objects
3) non-board stuff like grid, ratlines, etc.

I also bumped out the default size so that scrollbars aren't needed by
default on my Linux system.

-Jon
From f7aedd67a9dc51a312106c5232a7803b1cfddd23 Mon Sep 17 00:00:00 2001
From: Jon Evans <j...@craftyjon.com>
Date: Wed, 21 Feb 2018 23:39:14 -0500
Subject: [PATCH] Rearrange Render panel of PcbNew layer widget; add spacers

---
 pcbnew/layer_widget.cpp     | 35 ++++++++++++++++++++++++-----------
 pcbnew/layer_widget.h       |  8 ++++++++
 pcbnew/pcb_layer_widget.cpp | 32 +++++++++++++++++---------------
 3 files changed, 49 insertions(+), 26 deletions(-)

diff --git a/pcbnew/layer_widget.cpp b/pcbnew/layer_widget.cpp
index 87acce504..404b6bf2a 100644
--- a/pcbnew/layer_widget.cpp
+++ b/pcbnew/layer_widget.cpp
@@ -385,16 +385,20 @@ void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
     const int   flags = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT;
 
     wxString renderName( aSpec.rowName );
+    wxCheckBox* cb = nullptr;
 
     // column 1
-    col = 1;
-    wxCheckBox* cb = new wxCheckBox( m_RenderScrolledWindow, encodeId( col, aSpec.id ),
-                        aSpec.rowName, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT );
-    shrinkFont( cb, m_PointSize );
-    cb->SetValue( aSpec.state );
-    cb->Enable( aSpec.changeable );
-    cb->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LAYER_WIDGET::OnRenderCheckBox, this );
-    cb->SetToolTip( aSpec.tooltip );
+    if( !aSpec.spacer )
+    {
+        col = 1;
+        cb = new wxCheckBox( m_RenderScrolledWindow, encodeId( col, aSpec.id ),
+                            aSpec.rowName, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT );
+        shrinkFont( cb, m_PointSize );
+        cb->SetValue( aSpec.state );
+        cb->Enable( aSpec.changeable );
+        cb->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LAYER_WIDGET::OnRenderCheckBox, this );
+        cb->SetToolTip( aSpec.tooltip );
+    }
 
     // column 0
     col = 0;
@@ -424,7 +428,16 @@ void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
 
     // Items have to be inserted in order
     col = 1;
-    m_RenderFlexGridSizer->wxSizer::Insert( index+col, cb, 0, flags );
+
+    if( aSpec.spacer )
+    {
+        wxPanel* invisible = new wxPanel( m_RenderScrolledWindow, wxID_ANY );
+        m_RenderFlexGridSizer->wxSizer::Insert( index+col, invisible, 0, flags );
+    }
+    else
+    {
+        m_RenderFlexGridSizer->wxSizer::Insert( index+col, cb, 0, flags );
+    }
 }
 
 
@@ -539,7 +552,7 @@ wxSize LAYER_WIDGET::GetBestSize() const
     }
 
     // Account for the parent's frame:
-    totWidth += 10;
+    totWidth += 32;
 
 
     /* The minimum height is a small size to properly force computation
@@ -565,7 +578,7 @@ wxSize LAYER_WIDGET::GetBestSize() const
         }
     }
     // account for the parent's frame, this one has void space of 10 PLUS a border:
-    totWidth += 20;
+    totWidth += 32;
 
     // For totHeight re-use the previous small one
     wxSize renderz( totWidth, totHeight );
diff --git a/pcbnew/layer_widget.h b/pcbnew/layer_widget.h
index d1fe0e76b..e76a710b4 100644
--- a/pcbnew/layer_widget.h
+++ b/pcbnew/layer_widget.h
@@ -90,6 +90,7 @@ public:
         bool        state;      ///< initial wxCheckBox state
         wxString    tooltip;    ///< if not empty, use this tooltip on row
         bool        changeable; ///< if true, the state can be changed
+        bool        spacer;     ///< if true, this row is a spacer
 
         ROW( const wxString& aRowName, int aId, COLOR4D aColor = COLOR4D::UNSPECIFIED,
             const wxString& aTooltip = wxEmptyString, bool aState = true, bool aChangeable = true )
@@ -101,6 +102,13 @@ public:
             tooltip = aTooltip;
             changeable = aChangeable;
         }
+
+        ROW()
+        {
+            spacer = true;
+            color = COLOR4D::UNSPECIFIED;
+            id = 0;
+        }
     };
 
     static const wxEventType EVT_LAYER_COLOR_CHANGE;
diff --git a/pcbnew/pcb_layer_widget.cpp b/pcbnew/pcb_layer_widget.cpp
index a2a184b65..3d0f746c5 100644
--- a/pcbnew/pcb_layer_widget.cpp
+++ b/pcbnew/pcb_layer_widget.cpp
@@ -60,31 +60,30 @@ const LAYER_WIDGET::ROW PCB_LAYER_WIDGET::s_render_rows[] = {
 #define NOCOLOR COLOR4D::UNSPECIFIED    // specify rows that do not have a color selector icon
 
          // text                id                      color       tooltip
+    RR( _( "Footprints Front" ),LAYER_MOD_FR,         NOCOLOR,  _( "Show footprints that are on board's front") ),
+    RR( _( "Footprints Back" ), LAYER_MOD_BK,         NOCOLOR,  _( "Show footprints that are on board's back") ),
+    RR( _( "Values" ),          LAYER_MOD_VALUES,     NOCOLOR,  _( "Show footprint values") ),
+    RR( _( "References" ),      LAYER_MOD_REFERENCES, NOCOLOR,  _( "Show footprint references") ),
+    RR( _( "Text Front" ),      LAYER_MOD_TEXT_FR,    NOCOLOR,  _( "Show footprint text on board's front" ) ),
+    RR( _( "Text Back" ),       LAYER_MOD_TEXT_BK,    NOCOLOR,  _( "Show footprint text on board's back" ) ),
+    RR( _( "Hidden Text" ),     LAYER_MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ),
+    RR( _( "Pads Front" ),      LAYER_PAD_FR,         WHITE,    _( "Show footprint pads on board's front" ) ),
+    RR( _( "Pads Back" ),       LAYER_PAD_BK,         WHITE,    _( "Show footprint pads on board's back" ) ),
+    RR( _( "Through Hole Pads" ),LAYER_PADS_TH,       YELLOW,   _( "Show through hole pads in specific color") ),
+    RR(),
     RR( _( "Tracks" ),          LAYER_TRACKS,         NOCOLOR,  _( "Show tracks" ) ),
     RR( _( "Through Via" ),     LAYER_VIA_THROUGH,    WHITE,    _( "Show through vias" ) ),
     RR( _( "Bl/Buried Via" ),   LAYER_VIA_BBLIND,     WHITE,    _( "Show blind or buried vias" )  ),
     RR( _( "Micro Via" ),       LAYER_VIA_MICROVIA,   WHITE,    _( "Show micro vias") ),
     RR( _( "Non Plated Holes" ),LAYER_NON_PLATEDHOLES,WHITE,    _( "Show non plated holes in specific color") ),
+    RR(),
     RR( _( "Ratsnest" ),        LAYER_RATSNEST,       WHITE,    _( "Show unconnected nets as a ratsnest") ),
-
     RR( _( "No-Connects" ),     LAYER_NO_CONNECTS,    BLUE,     _( "Show a marker on pads which have no net connected" ) ),
-    RR( _( "Pads Front" ),      LAYER_PAD_FR,         WHITE,    _( "Show footprint pads on board's front" ) ),
-    RR( _( "Through Hole Pads" ),LAYER_PADS_TH,       YELLOW,   _( "Show through hole pads in specific color") ),
-    RR( _( "Pads Back" ),       LAYER_PAD_BK,         WHITE,    _( "Show footprint pads on board's back" ) ),
-
-    RR( _( "Text Front" ),      LAYER_MOD_TEXT_FR,    NOCOLOR,  _( "Show footprint text on board's front" ) ),
-    RR( _( "Text Back" ),       LAYER_MOD_TEXT_BK,    NOCOLOR,  _( "Show footprint text on board's back" ) ),
-    RR( _( "Hidden Text" ),     LAYER_MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ),
-
     RR( _( "Anchors" ),         LAYER_ANCHOR,         WHITE,    _( "Show footprint and text origins as a cross" ) ),
-    RR( _( "Grid" ),            LAYER_GRID,           WHITE,    _( "Show the (x,y) grid dots" ) ),
-    RR( _( "Footprints Front" ),LAYER_MOD_FR,         NOCOLOR,  _( "Show footprints that are on board's front") ),
-    RR( _( "Footprints Back" ), LAYER_MOD_BK,         NOCOLOR,  _( "Show footprints that are on board's back") ),
-    RR( _( "Values" ),          LAYER_MOD_VALUES,     NOCOLOR,  _( "Show footprint's values") ),
-    RR( _( "References" ),      LAYER_MOD_REFERENCES, NOCOLOR,  _( "Show footprint's references") ),
     RR( _( "Worksheet" ),       LAYER_WORKSHEET,      DARKRED,  _( "Show worksheet") ),
     RR( _( "Cursor" ),          LAYER_CURSOR,         WHITE,    _( "PCB Cursor" ), true, false ),
-    RR( _( "Aux items" ),       LAYER_AUX_ITEMS,      WHITE,    _( "Auxillary items (rulers, assistants, axes, etc.)" ), true, false ),
+    RR( _( "Aux items" ),       LAYER_AUX_ITEMS,      WHITE,    _( "Auxiliary items (rulers, assistants, axes, etc.)" ), true, false ),
+    RR( _( "Grid" ),            LAYER_GRID,           WHITE,    _( "Show the (x,y) grid dots" ) ),
     RR( _( "Background" ),      LAYER_PCB_BACKGROUND, BLACK,    _( "PCB Background" ), true, false )
 };
 
@@ -425,6 +424,9 @@ void PCB_LAYER_WIDGET::SyncRenderStates()
         if( m_fp_editor_mode && !isAllowedInFpMode( rowId ) )
             continue;
 
+        if( s_render_rows[row].spacer )
+            continue;
+
         // this does not fire a UI event
         SetRenderState( rowId, board->IsElementVisible( static_cast<GAL_LAYER_ID>( rowId ) ) );
     }
-- 
2.14.1

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to