Improved button layout on splash screen

- Simplified code
- Button bar expands to fill entire screen width
This commit is contained in:
Oliver Walters 2017-05-24 23:51:02 +10:00 committed by Wayne Stambaugh
parent b8183a1aa5
commit e6baaa6164
3 changed files with 61 additions and 55 deletions

View File

@ -32,15 +32,15 @@
#include "kicad.h" #include "kicad.h"
// Amount of clearance between tool buttons
const int BUTTON_SEPARATION = 5;
// Buttons are larger than images by this amount
const int BUTTON_EXPANSION = 5;
LAUNCHER_PANEL::LAUNCHER_PANEL( wxWindow* parent ) : LAUNCHER_PANEL::LAUNCHER_PANEL( wxWindow* parent ) :
wxPanel( parent, wxID_ANY ) wxPanel( parent, wxID_ANY )
{ {
m_bitmapButtons_maxHeight = 0;
m_buttonSeparation = 10; // control of command buttons position
m_buttonsListPosition.x = m_buttonSeparation;
m_buttonsListPosition.y = m_buttonSeparation;
m_buttonLastPosition = m_buttonsListPosition;
// Add bitmap buttons to launch KiCad utilities: // Add bitmap buttons to launch KiCad utilities:
CreateCommandToolbar(); CreateCommandToolbar();
@ -48,67 +48,76 @@ LAUNCHER_PANEL::LAUNCHER_PANEL( wxWindow* parent ) :
int LAUNCHER_PANEL::GetPanelHeight() const int LAUNCHER_PANEL::GetPanelHeight() const
{ {
int height = m_buttonsListPosition.y + m_bitmapButtons_maxHeight return m_height + 2 * BUTTON_SEPARATION;
+ m_buttonSeparation;
return height;
} }
/** /**
* Function CreateCommandToolbar * Add application launcher buttons
* create the buttons to call Eeschema CvPcb, Pcbnew and GerbView * e.g. Eeschema, CvPcb, Pcbnew, GerbView
*/ */
void LAUNCHER_PANEL::CreateCommandToolbar() void LAUNCHER_PANEL::CreateCommandToolbar()
{ {
wxBitmapButton* btn; m_buttonSizer = new wxBoxSizer( wxHORIZONTAL );
btn = AddBitmapButton( ID_TO_SCH, KiBitmap( icon_eeschema_xpm ) ); AddButton( ID_TO_SCH,
btn->SetToolTip( _( "Eeschema - Electronic schematic editor" ) ); KiBitmap( icon_eeschema_xpm ),
_( "Schematic layout editor" ) );
btn = AddBitmapButton( ID_TO_SCH_LIB_EDITOR, KiBitmap( icon_libedit_xpm ) ); AddButton( ID_TO_SCH_LIB_EDITOR,
btn->SetToolTip( _( "Schematic library editor" ) ); KiBitmap( icon_libedit_xpm ),
_( "Schematic library editor" ) );
btn = AddBitmapButton( ID_TO_PCB, KiBitmap( icon_pcbnew_xpm ) ); AddButton( ID_TO_PCB,
btn->SetToolTip( _( "Pcbnew - Printed circuit board editor" ) ); KiBitmap( icon_pcbnew_xpm ),
_( "PCB layout editor" ) );
btn = AddBitmapButton( ID_TO_PCB_FP_EDITOR, KiBitmap( icon_modedit_xpm ) ); AddButton( ID_TO_PCB_FP_EDITOR,
btn->SetToolTip( _( "PCB footprint editor" ) ); KiBitmap( icon_modedit_xpm ),
_( "PCB library editor" ) );
btn = AddBitmapButton( ID_TO_GERBVIEW, KiBitmap( icon_gerbview_xpm ) ); AddButton( ID_TO_GERBVIEW,
btn->SetToolTip( _( "GerbView - Gerber viewer" ) ); KiBitmap( icon_gerbview_xpm ),
_( "Gerber viewer" ) );
btn = AddBitmapButton( ID_TO_BITMAP_CONVERTER, KiBitmap( icon_bitmap2component_xpm ) ); AddButton( ID_TO_BITMAP_CONVERTER,
btn->SetToolTip( _( KiBitmap( icon_bitmap2component_xpm ),
"Bitmap2Component - Convert bitmap images to Eeschema\n" _( "Import bitmap\n"
"or Pcbnew elements" ) ); "Convert bitmap images to schematic or PCB elements" ) );
btn = AddBitmapButton( ID_TO_PCB_CALCULATOR, KiBitmap( icon_pcbcalculator_xpm ) ); AddButton( ID_TO_PCB_CALCULATOR,
btn->SetToolTip( _( "Pcb calculator - Calculator for components, track width, etc." ) ); KiBitmap( icon_pcbcalculator_xpm ),
_( "Calculator tools" ) );
btn = AddBitmapButton( ID_TO_PL_EDITOR, KiBitmap( icon_pagelayout_editor_xpm ) ); AddButton( ID_TO_PL_EDITOR,
btn->SetToolTip( _( "Pl editor - Worksheet layout editor" ) ); KiBitmap( icon_pagelayout_editor_xpm ),
_( "Worksheet layout editor" ) );
// Add a stretchy spacer to make button bar fill the entire screen
m_buttonSizer->AddStretchSpacer();
SetSizer( m_buttonSizer );
} }
/** /**
* Function AddBitmapButton * Add a single button to the toolbar
* add a Bitmap Button (fast launch button) to the buttons panel * @param aId is the ID of the button
* @param aId = the button id * @param aBitmap is the image to be used
* @param aBitmap = the wxBitmap used to create the button * @param aToolTip is the button mouse-over tool tip
*/ */
wxBitmapButton* LAUNCHER_PANEL::AddBitmapButton( wxWindowID aId, const wxBitmap& aBitmap ) void LAUNCHER_PANEL::AddButton( wxWindowID aId, const wxBitmap& aBitmap, wxString aToolTip )
{ {
wxPoint buttPos = m_buttonLastPosition; wxSize buttSize( aBitmap.GetWidth() + BUTTON_EXPANSION,
wxSize buttSize; aBitmap.GetHeight() + BUTTON_EXPANSION );
int btn_margin = 10; // extra margin around the bitmap.
buttSize.x = aBitmap.GetWidth() + btn_margin; if( m_height < buttSize.y )
buttSize.y = aBitmap.GetHeight() + btn_margin; m_height = buttSize.y;
if( m_bitmapButtons_maxHeight < buttSize.y ) auto btn = new wxBitmapButton( this, aId, aBitmap, wxDefaultPosition, buttSize );
m_bitmapButtons_maxHeight = buttSize.y;
wxBitmapButton* btn = new wxBitmapButton( this, aId, aBitmap, buttPos, buttSize ); btn->SetToolTip( aToolTip );
m_buttonLastPosition.x += buttSize.x + m_buttonSeparation;
return btn; m_buttonSizer->Add( btn,
0,
wxALL | wxEXPAND,
BUTTON_SEPARATION );
} }

View File

@ -310,13 +310,9 @@ private:
class LAUNCHER_PANEL : public wxPanel class LAUNCHER_PANEL : public wxPanel
{ {
private: private:
int m_buttonSeparation; // button distance in pixels wxBoxSizer* m_buttonSizer;
wxPoint m_buttonsListPosition; /* position of the left bottom corner
* of the first bitmap button int m_height = 0;
*/
wxPoint m_buttonLastPosition; // position of the last button in the window
int m_bitmapButtons_maxHeight; // height of bigger bitmap buttons
// Used to calculate the height of the panel.
public: LAUNCHER_PANEL( wxWindow* parent ); public: LAUNCHER_PANEL( wxWindow* parent );
~LAUNCHER_PANEL() { }; ~LAUNCHER_PANEL() { };
@ -331,7 +327,7 @@ private:
*/ */
void CreateCommandToolbar( void ); void CreateCommandToolbar( void );
wxBitmapButton* AddBitmapButton( wxWindowID aId, const wxBitmap& aBitmap ); void AddButton( wxWindowID aId, const wxBitmap& aBitmap, wxString aToolTip );
}; };
// The C++ project manager includes a single PROJECT in its link image. // The C++ project manager includes a single PROJECT in its link image.

View File

@ -101,8 +101,9 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent,
Layer( 1 ) ); Layer( 1 ) );
m_auimgr.AddPane( m_Launcher, wxTOP ); m_auimgr.AddPane( m_Launcher, wxTOP );
m_auimgr.GetPane( m_Launcher).CaptionVisible( false ).Row(1) m_auimgr.GetPane( m_Launcher).CaptionVisible( false ).PaneBorder(false)
.BestSize( -1, m_Launcher->GetPanelHeight() ).PaneBorder( false ).Resizable( false ); .MinSize( wxSize( 100, m_Launcher->GetPanelHeight() ) )
.Resizable( false );
m_auimgr.AddPane( m_MessagesBox, m_auimgr.AddPane( m_MessagesBox,
wxAuiPaneInfo().Name( wxT( "m_MessagesBox" ) ).CentrePane().Layer( 2 ) ); wxAuiPaneInfo().Name( wxT( "m_MessagesBox" ) ).CentrePane().Layer( 2 ) );