← Back to team overview

kicad-developers team mailing list archive

[PATCH] Moveable toolbars

 

Here's the diff I promised.

The main thing I'm wondering is does the idiom (inheriting the
wxPaneInfo class) suit you guys?

The purpose of this patch (when finished) would be to fix erroneous
usage of the toolbar api and centralize the common portion.

If it looks like it's in the right direction I'll add comments,
propagate it to the other apps and change the defaults from moveable
toolbars to ones that match the present behavior.

I'll wait to work on the moveable aspect until later as the discussion
matures a bit.

-hauptmech
=== modified file 'include/wxstruct.h'
--- include/wxstruct.h	2011-08-18 19:25:12 +0000
+++ include/wxstruct.h	2011-08-29 22:27:03 +0000
@@ -773,5 +773,41 @@
     int GetDimension( );
 };
 
+/* Specialization of the wxAuiPaneInfo class for Kicad elements */
+
+class EDA_PANEINFO : public wxAuiPaneInfo
+{
+  
+public:
+  EDA_PANEINFO& init_horizontal_toolbar(){
+    ToolbarPane();
+    CloseButton( false );
+    LeftDockable( false );
+    RightDockable( false );
+    return *this;
+  }
+  EDA_PANEINFO& init_vertical_toolbar(){
+    ToolbarPane();
+    CloseButton( false );
+    TopDockable( false );
+    BottomDockable( false );
+    return *this;
+  }
+  EDA_PANEINFO& init_message_pane(){
+    Gripper( false );
+    DockFixed( true );
+    Movable( false );
+    Floatable( false );
+    CloseButton( false );
+    CaptionVisible( false );
+    return *this;
+  }
+  EDA_PANEINFO& init_layers_pane(){
+    CloseButton( false );
+    
+    return *this;
+  }
+
+};
 
 #endif  /* WXSTRUCT_H */

=== modified file 'pcbnew/pcbframe.cpp'
--- pcbnew/pcbframe.cpp	2011-08-26 17:01:17 +0000
+++ pcbnew/pcbframe.cpp	2011-08-29 22:27:03 +0000
@@ -328,66 +328,51 @@
 
     m_auimgr.SetManagedWindow( this );
 
-    // Create a wxAuiPaneInfo template for other wxAuiPaneInfo items
-    // Actual wxAuiPaneInfo items will be built from this item.
-    wxAuiPaneInfo horiz;
-    horiz.Gripper( false );
-    horiz.DockFixed( true );
-    horiz.Movable( false );
-    horiz.Floatable( false );
-    horiz.CloseButton( false );
-    horiz.CaptionVisible( false );
-
-    // Create a second template from the first:
-    wxAuiPaneInfo vert( horiz );
-
-    // Set specific options for horizontal and vertical toolbars, using horiz and vert
-    // wxAuiPaneInfo items to manage them.
-    vert.TopDockable( false ).BottomDockable( false );
-    horiz.LeftDockable( false ).RightDockable( false );
-
-    // Create a template from the horiz wxAuiPaneInfo, specific to horizontal toolbars:
-    wxAuiPaneInfo horiz_tb( horiz );
-    horiz_tb.ToolbarPane().Gripper( false );
-
+    EDA_PANEINFO horiz;
+    horiz.init_horizontal_toolbar();
+
+    EDA_PANEINFO vert;
+    vert.init_vertical_toolbar();
+
+    EDA_PANEINFO mesg;
+    mesg.init_message_pane();
+    
     // Create a wxAuiPaneInfo for the Layers Manager, not derived from the template.
     // LAYER_WIDGET is floatable, but initially docked at far right
-    wxAuiPaneInfo   lyrs;
+    EDA_PANEINFO   lyrs;
+    lyrs.init_layers_pane();
     lyrs.MinSize( m_Layers->GetBestSize() );    // updated in ReFillLayerWidget
     lyrs.BestSize( m_Layers->GetBestSize() );
-    lyrs.CloseButton( false );
     lyrs.Caption( _( "Visibles" ) );
-    lyrs.IsFloatable();
 
 
     if( m_HToolBar )    // The main horizontal toolbar
     {
         m_auimgr.AddPane( m_HToolBar,
-                          wxAuiPaneInfo( horiz_tb ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) );
+                          wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) );
     }
 
     if( m_AuxiliaryToolBar )    // the auxiliary horizontal toolbar, that shows track and via sizes, zoom ...)
     {
         m_auimgr.AddPane( m_AuxiliaryToolBar,
-                          wxAuiPaneInfo( horiz_tb ).Name( wxT( "m_AuxiliaryToolBar" ) ).Top().Row( 1 ) );
+                          wxAuiPaneInfo( horiz ).Name( wxT( "m_AuxiliaryToolBar" ) ).Top().Row( 1 ) );
     }
 
     if( m_AuxVToolBar )    // The auxiliary vertical toolbar (currently microwave tools)
         m_auimgr.AddPane( m_AuxVToolBar,
-                          wxAuiPaneInfo( vert ).Name( wxT( "m_AuxVToolBar" ) ).Right().Row( 2 ).Hide() );
+                          wxAuiPaneInfo( vert ).Name( wxT( "m_AuxVToolBar" ) ).Right().Layer( 1 ).Position(1).Hide() );
 
     if( m_VToolBar )    // The main right vertical toolbar
         m_auimgr.AddPane( m_VToolBar,
-                          wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Row( 1 ) );
+                          wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Layer( 1 ) );
 
     // Add the layer manager (right side of pcbframe)
-    m_auimgr.AddPane( m_Layers, lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Row( 0 ) );
+    m_auimgr.AddPane( m_Layers, lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 2 ) );
 
     if( m_OptionsToolBar )    // The left vertical toolbar
     {
         m_auimgr.AddPane( m_OptionsToolBar,
-                          wxAuiPaneInfo( vert ).Name( wxT( "m_OptionsToolBar" ) ).Left()
-                          .ToolbarPane().Gripper( false ) );
+                          wxAuiPaneInfo( vert ).Name( wxT( "m_OptionsToolBar" ) ).Left() );
 
         m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
         m_auimgr.GetPane( wxT( "m_AuxVToolBar" ) ).Show( m_show_microwave_tools );
@@ -399,7 +384,7 @@
 
     if( MsgPanel )
         m_auimgr.AddPane( MsgPanel,
-                          wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
+                          wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom() );
 
     ReFillLayerWidget();        // this is near end because contents establish size
     m_Layers->ReFillRender();   // Update colors in Render after the config is read

Follow ups