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"
// 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 ) :
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:
CreateCommandToolbar();
@ -48,67 +48,76 @@ LAUNCHER_PANEL::LAUNCHER_PANEL( wxWindow* parent ) :
int LAUNCHER_PANEL::GetPanelHeight() const
{
int height = m_buttonsListPosition.y + m_bitmapButtons_maxHeight
+ m_buttonSeparation;
return height;
return m_height + 2 * BUTTON_SEPARATION;
}
/**
* Function CreateCommandToolbar
* create the buttons to call Eeschema CvPcb, Pcbnew and GerbView
* Add application launcher buttons
* e.g. Eeschema, CvPcb, Pcbnew, GerbView
*/
void LAUNCHER_PANEL::CreateCommandToolbar()
{
wxBitmapButton* btn;
m_buttonSizer = new wxBoxSizer( wxHORIZONTAL );
btn = AddBitmapButton( ID_TO_SCH, KiBitmap( icon_eeschema_xpm ) );
btn->SetToolTip( _( "Eeschema - Electronic schematic editor" ) );
AddButton( ID_TO_SCH,
KiBitmap( icon_eeschema_xpm ),
_( "Schematic layout editor" ) );
btn = AddBitmapButton( ID_TO_SCH_LIB_EDITOR, KiBitmap( icon_libedit_xpm ) );
btn->SetToolTip( _( "Schematic library editor" ) );
AddButton( ID_TO_SCH_LIB_EDITOR,
KiBitmap( icon_libedit_xpm ),
_( "Schematic library editor" ) );
btn = AddBitmapButton( ID_TO_PCB, KiBitmap( icon_pcbnew_xpm ) );
btn->SetToolTip( _( "Pcbnew - Printed circuit board editor" ) );
AddButton( ID_TO_PCB,
KiBitmap( icon_pcbnew_xpm ),
_( "PCB layout editor" ) );
btn = AddBitmapButton( ID_TO_PCB_FP_EDITOR, KiBitmap( icon_modedit_xpm ) );
btn->SetToolTip( _( "PCB footprint editor" ) );
AddButton( ID_TO_PCB_FP_EDITOR,
KiBitmap( icon_modedit_xpm ),
_( "PCB library editor" ) );
btn = AddBitmapButton( ID_TO_GERBVIEW, KiBitmap( icon_gerbview_xpm ) );
btn->SetToolTip( _( "GerbView - Gerber viewer" ) );
AddButton( ID_TO_GERBVIEW,
KiBitmap( icon_gerbview_xpm ),
_( "Gerber viewer" ) );
btn = AddBitmapButton( ID_TO_BITMAP_CONVERTER, KiBitmap( icon_bitmap2component_xpm ) );
btn->SetToolTip( _(
"Bitmap2Component - Convert bitmap images to Eeschema\n"
"or Pcbnew elements" ) );
AddButton( ID_TO_BITMAP_CONVERTER,
KiBitmap( icon_bitmap2component_xpm ),
_( "Import bitmap\n"
"Convert bitmap images to schematic or PCB elements" ) );
btn = AddBitmapButton( ID_TO_PCB_CALCULATOR, KiBitmap( icon_pcbcalculator_xpm ) );
btn->SetToolTip( _( "Pcb calculator - Calculator for components, track width, etc." ) );
AddButton( ID_TO_PCB_CALCULATOR,
KiBitmap( icon_pcbcalculator_xpm ),
_( "Calculator tools" ) );
btn = AddBitmapButton( ID_TO_PL_EDITOR, KiBitmap( icon_pagelayout_editor_xpm ) );
btn->SetToolTip( _( "Pl editor - Worksheet layout editor" ) );
AddButton( ID_TO_PL_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 Bitmap Button (fast launch button) to the buttons panel
* @param aId = the button id
* @param aBitmap = the wxBitmap used to create the button
* Add a single button to the toolbar
* @param aId is the ID of the button
* @param aBitmap is the image to be used
* @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;
int btn_margin = 10; // extra margin around the bitmap.
wxSize buttSize( aBitmap.GetWidth() + BUTTON_EXPANSION,
aBitmap.GetHeight() + BUTTON_EXPANSION );
buttSize.x = aBitmap.GetWidth() + btn_margin;
buttSize.y = aBitmap.GetHeight() + btn_margin;
if( m_height < buttSize.y )
m_height = buttSize.y;
if( m_bitmapButtons_maxHeight < buttSize.y )
m_bitmapButtons_maxHeight = buttSize.y;
auto btn = new wxBitmapButton( this, aId, aBitmap, wxDefaultPosition, buttSize );
wxBitmapButton* btn = new wxBitmapButton( this, aId, aBitmap, buttPos, buttSize );
m_buttonLastPosition.x += buttSize.x + m_buttonSeparation;
btn->SetToolTip( aToolTip );
return btn;
m_buttonSizer->Add( btn,
0,
wxALL | wxEXPAND,
BUTTON_SEPARATION );
}

View File

@ -310,13 +310,9 @@ private:
class LAUNCHER_PANEL : public wxPanel
{
private:
int m_buttonSeparation; // button distance in pixels
wxPoint m_buttonsListPosition; /* position of the left bottom corner
* of the first bitmap button
*/
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.
wxBoxSizer* m_buttonSizer;
int m_height = 0;
public: LAUNCHER_PANEL( wxWindow* parent );
~LAUNCHER_PANEL() { };
@ -331,7 +327,7 @@ private:
*/
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.

View File

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