← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Moveable toolbars

 

Without commenting on the purpose, may I comment on the style?



> === 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:

Two space in front of EDA here is wrong, should be 4.

> +  EDA_PANEINFO& init_horizontal_toolbar(){

Squiggly on next line.

> +    ToolbarPane();
> +    CloseButton( false );
> +    LeftDockable( false );
> +    RightDockable( false );
> +    return *this;
> +  }

Put at least one blank lines between function implementations in header files. 
In *.cpp files, I instead put 2 blank lines.

+ 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;

Two spaces in front of bracket is wrong, should be 4.

> +  }
> +
> +};
>  
>  #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

Why are we so tough on these style issues?  Because we have spent a lot of time
fixing them. 

The concept of factoring code and establishing consistency by way of a shared
base class is sound, in general.  Specifics on the actual accomplishments of
this class I leave to others to comment on.

Dick





References