diff --git a/kicad/CMakeLists.txt b/kicad/CMakeLists.txt index 201932dd1c..e3263ce4b8 100644 --- a/kicad/CMakeLists.txt +++ b/kicad/CMakeLists.txt @@ -17,6 +17,8 @@ include_directories( set( KICAD_SRCS dialogs/dialog_template_selector_base.cpp dialogs/dialog_template_selector.cpp + dialogs/panel_kicad_launcher_base.cpp + dialogs/panel_kicad_launcher.cpp files-io.cpp import_project.cpp kicad.cpp diff --git a/kicad/dialogs/panel_kicad_launcher.cpp b/kicad/dialogs/panel_kicad_launcher.cpp new file mode 100644 index 0000000000..b432d05c62 --- /dev/null +++ b/kicad/dialogs/panel_kicad_launcher.cpp @@ -0,0 +1,116 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include +#include +#include +#include +#include + +#include "panel_kicad_launcher.h" + + +PANEL_KICAD_LAUNCHER::PANEL_KICAD_LAUNCHER( wxWindow* aParent ) : + PANEL_KICAD_LAUNCHER_BASE( aParent ) +{ + m_toolManager = static_cast( aParent )->GetToolManager(); + CreateLaunchers(); +} + + +void PANEL_KICAD_LAUNCHER::CreateLaunchers() +{ + if( m_toolsSizer->GetRows() > 0 ) + { + m_toolsSizer->Clear( true ); + m_toolsSizer->SetRows( 0 ); + } + + auto addLauncher = + [&]( const TOOL_ACTION& aAction, const wxBitmap& aBitmap, + const wxString& aHelpText = wxEmptyString ) + { + BITMAP_BUTTON* btn = new BITMAP_BUTTON( this, wxID_ANY ); + btn->SetBitmap( aBitmap ); + btn->SetPadding( 5 ); + btn->SetToolTip( aAction.GetDescription() ); + + auto handler = + [&]( wxEvent& aEvent ) + { + OPT_TOOL_EVENT evt = aAction.MakeEvent(); + evt->SetHasPosition( false ); + m_toolManager->ProcessEvent( *evt ); + }; + + bool createHelp = !aHelpText.IsEmpty(); + + wxStaticText* label = new wxStaticText( this, wxID_ANY, aAction.GetLabel() ); + wxStaticText* help; + + label->SetToolTip( aAction.GetDescription() ); + + if( createHelp ) + { + help = new wxStaticText( this, wxID_ANY, aHelpText ); + help->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) ); + } + + btn->Bind( wxEVT_BUTTON, handler ); + label->Bind( wxEVT_LEFT_UP, handler ); + + int row = m_toolsSizer->GetRows(); + int rowSpan = createHelp ? 2 : 1; + int flags = createHelp ? wxALIGN_BOTTOM : wxALIGN_CENTER_VERTICAL; + + m_toolsSizer->Add( btn, wxGBPosition( row, 0 ), wxGBSpan( rowSpan, 1 ), 0, 0 ); + m_toolsSizer->Add( label, wxGBPosition( row, 1 ), wxGBSpan( 1, 1 ), flags, 0 ); + + if( createHelp ) + { + m_toolsSizer->Add( help, wxGBPosition( row + 1, 1 ), wxGBSpan( 1, 1 ), + wxALIGN_TOP, 0 ); + } + }; + + addLauncher( KICAD_MANAGER_ACTIONS::editSchematic, KiScaledBitmap( icon_eeschema_xpm, this ) ); + + addLauncher( KICAD_MANAGER_ACTIONS::editSymbols, KiScaledBitmap( icon_libedit_xpm, this ) ); + + addLauncher( KICAD_MANAGER_ACTIONS::editPCB, KiScaledBitmap( icon_pcbnew_xpm, this ) ); + + addLauncher( KICAD_MANAGER_ACTIONS::editFootprints, KiScaledBitmap( icon_modedit_xpm, this ) ); + + addLauncher( KICAD_MANAGER_ACTIONS::viewGerbers, KiScaledBitmap( icon_gerbview_xpm, this ) ); + + addLauncher( KICAD_MANAGER_ACTIONS::convertImage, + KiScaledBitmap( icon_bitmap2component_xpm, this ) ); + + addLauncher( KICAD_MANAGER_ACTIONS::showCalculator, + KiScaledBitmap( icon_pcbcalculator_xpm, this ) ); + + addLauncher( KICAD_MANAGER_ACTIONS::editWorksheet, + KiScaledBitmap( icon_pagelayout_editor_xpm, this ) ); + + if( m_toolsSizer->IsColGrowable( 1 ) ) + m_toolsSizer->RemoveGrowableCol( 1 ); + + m_toolsSizer->AddGrowableCol( 1 ); + Layout(); +} diff --git a/kicad/dialogs/panel_kicad_launcher.h b/kicad/dialogs/panel_kicad_launcher.h new file mode 100644 index 0000000000..5e42d6d012 --- /dev/null +++ b/kicad/dialogs/panel_kicad_launcher.h @@ -0,0 +1,45 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef KICAD_PANEL_KICAD_LAUNCHER_H +#define KICAD_PANEL_KICAD_LAUNCHER_H + +#include "panel_kicad_launcher_base.h" + +class TOOL_MANAGER; + +class PANEL_KICAD_LAUNCHER : public PANEL_KICAD_LAUNCHER_BASE +{ +public: + PANEL_KICAD_LAUNCHER( wxWindow* aParent ); + + virtual ~PANEL_KICAD_LAUNCHER() = default; + + void CreateLaunchers(); + + wxTextCtrl* GetMessagesBox() const { return m_messagesBox; } + +private: + + TOOL_MANAGER* m_toolManager; + +}; + + +#endif // KICAD_PANEL_KICAD_LAUNCHER_H diff --git a/kicad/dialogs/panel_kicad_launcher_base.cpp b/kicad/dialogs/panel_kicad_launcher_base.cpp new file mode 100644 index 0000000000..4de218e3cf --- /dev/null +++ b/kicad/dialogs/panel_kicad_launcher_base.cpp @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "panel_kicad_launcher_base.h" + +/////////////////////////////////////////////////////////////////////////// + +PANEL_KICAD_LAUNCHER_BASE::PANEL_KICAD_LAUNCHER_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +{ + m_mainSizer = new wxBoxSizer( wxVERTICAL ); + + m_toolsSizer = new wxGridBagSizer( 5, 20 ); + m_toolsSizer->SetFlexibleDirection( wxBOTH ); + m_toolsSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_NONE ); + + + m_mainSizer->Add( m_toolsSizer, 0, wxALL|wxEXPAND, 5 ); + + + m_mainSizer->Add( 0, 20, 0, wxEXPAND, 5 ); + + wxStaticBoxSizer* sbSizerMessages; + sbSizerMessages = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Messages") ), wxVERTICAL ); + + m_messagesBox = new wxTextCtrl( sbSizerMessages->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); + m_messagesBox->SetMinSize( wxSize( -1,60 ) ); + + sbSizerMessages->Add( m_messagesBox, 1, wxALL|wxEXPAND, 5 ); + + + m_mainSizer->Add( sbSizerMessages, 1, wxEXPAND|wxLEFT|wxRIGHT, 5 ); + + + this->SetSizer( m_mainSizer ); + this->Layout(); + m_mainSizer->Fit( this ); +} + +PANEL_KICAD_LAUNCHER_BASE::~PANEL_KICAD_LAUNCHER_BASE() +{ +} diff --git a/kicad/dialogs/panel_kicad_launcher_base.fbp b/kicad/dialogs/panel_kicad_launcher_base.fbp new file mode 100644 index 0000000000..34b2d843be --- /dev/null +++ b/kicad/dialogs/panel_kicad_launcher_base.fbp @@ -0,0 +1,165 @@ + + + + + ; + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + panel_kicad_launcher_base + 1000 + none + + 1 + panel_kicad_launcher_base + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + + + PANEL_KICAD_LAUNCHER_BASE + + -1,-1 + ; ; forward_declare + + + + wxTAB_TRAVERSAL + + + m_mainSizer + wxVERTICAL + protected + + 5 + wxALL|wxEXPAND + 0 + + + wxBOTH + + + 20 + + m_toolsSizer + wxFLEX_GROWMODE_NONE + protected + 5 + + + + 5 + wxEXPAND + 0 + + 20 + protected + 0 + + + + 5 + wxEXPAND|wxLEFT|wxRIGHT + 1 + + wxID_ANY + Messages + + sbSizerMessages + wxVERTICAL + 1 + none + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + -1,60 + 1 + m_messagesBox + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_MULTILINE|wxTE_READONLY + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + diff --git a/kicad/dialogs/panel_kicad_launcher_base.h b/kicad/dialogs/panel_kicad_launcher_base.h new file mode 100644 index 0000000000..4aed681e84 --- /dev/null +++ b/kicad/dialogs/panel_kicad_launcher_base.h @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class PANEL_KICAD_LAUNCHER_BASE +/////////////////////////////////////////////////////////////////////////////// +class PANEL_KICAD_LAUNCHER_BASE : public wxPanel +{ + private: + + protected: + wxBoxSizer* m_mainSizer; + wxGridBagSizer* m_toolsSizer; + wxTextCtrl* m_messagesBox; + + public: + + PANEL_KICAD_LAUNCHER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + ~PANEL_KICAD_LAUNCHER_BASE(); + +}; + diff --git a/kicad/files-io.cpp b/kicad/files-io.cpp index 2d947c3fef..adb92e401a 100644 --- a/kicad/files-io.cpp +++ b/kicad/files-io.cpp @@ -27,6 +27,7 @@ */ #include +#include #include #include #include @@ -84,7 +85,7 @@ void KICAD_MANAGER_FRAME::OnUnarchiveFiles( wxCommandEvent& event ) return; } - WX_TEXT_CTRL_REPORTER reporter( m_messagesBox ); + WX_TEXT_CTRL_REPORTER reporter( m_launcher->GetMessagesBox() ); PROJECT_ARCHIVER archiver; @@ -125,7 +126,7 @@ void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event ) if( !dir.IsOpened() ) // wxWidgets display a error message on issue. return; - WX_TEXT_CTRL_REPORTER reporter( m_messagesBox ); + WX_TEXT_CTRL_REPORTER reporter( m_launcher->GetMessagesBox() ); PROJECT_ARCHIVER archiver; diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index 423e57d7d7..8c2193ccba 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -28,18 +28,17 @@ #include "project_tree_pane.h" #include #include +#include #include #include #include #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -100,7 +99,6 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl KICAD_DEFAULT_DRAWFRAME_STYLE, KICAD_MANAGER_FRAME_NAME, &::Kiway ), m_leftWin( nullptr ), m_launcher( nullptr ), - m_messagesBox( nullptr ), m_mainToolBar( nullptr ) { m_active_project = false; @@ -132,16 +130,12 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl // Left window: is the box which display tree project m_leftWin = new PROJECT_TREE_PANE( this ); - // Add the wxTextCtrl showing all messages from KiCad: - m_messagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, - wxTE_MULTILINE | wxTE_READONLY | wxBORDER_NONE ); - setupTools(); setupUIConditions(); + m_launcher = new PANEL_KICAD_LAUNCHER( this ); + RecreateBaseHToolbar(); - RecreateLauncher(); ReCreateMenuBar(); m_auimgr.SetManagedWindow( this ); @@ -157,9 +151,8 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl .CaptionVisible( false ).PaneBorder( false ) .MinSize( m_leftWinWidth, -1 ).BestSize( m_leftWinWidth, -1 ) ); - m_auimgr.AddPane( m_launcher, EDA_PANE().HToolbar().Name( "Launcher" ).Top().Layer(1) ); - - m_auimgr.AddPane( m_messagesBox, EDA_PANE().Messages().Name( "MsgPanel" ).Center() ); + m_auimgr.AddPane( m_launcher, + EDA_PANE().Canvas().PaneBorder( false ).Name( "Launcher" ).Center() ); m_auimgr.Update(); @@ -320,7 +313,7 @@ wxString KICAD_MANAGER_FRAME::help_name() void KICAD_MANAGER_FRAME::PrintMsg( const wxString& aText ) { - m_messagesBox->AppendText( aText ); + m_launcher->GetMessagesBox()->AppendText( aText ); } @@ -590,7 +583,7 @@ void KICAD_MANAGER_FRAME::ShowChangedLanguage() // tooltips in toolbars RecreateBaseHToolbar(); - RecreateLauncher(); + m_launcher->CreateLaunchers(); PrintPrjInfo(); } @@ -628,7 +621,7 @@ void KICAD_MANAGER_FRAME::ProjectChanged() void KICAD_MANAGER_FRAME::ClearMsg() { - m_messagesBox->Clear(); + m_launcher->GetMessagesBox()->Clear(); } diff --git a/kicad/kicad_manager_frame.h b/kicad/kicad_manager_frame.h index 31c68390ef..c234205227 100644 --- a/kicad/kicad_manager_frame.h +++ b/kicad/kicad_manager_frame.h @@ -34,6 +34,7 @@ class PROJECT_TREE_PANE; class ACTION_TOOLBAR; class KICAD_SETTINGS; class EDA_BASE_FRAME; +class PANEL_KICAD_LAUNCHER; /** * The main KiCad project manager frame. It is not a KIWAY_PLAYER. @@ -64,7 +65,6 @@ public: void ReCreateMenuBar() override; void RecreateBaseHToolbar(); - void RecreateLauncher(); wxString GetCurrentFileName() const override { @@ -185,10 +185,9 @@ private: bool m_openSavedWindows; private: - PROJECT_TREE_PANE* m_leftWin; - ACTION_TOOLBAR* m_launcher; - wxTextCtrl* m_messagesBox; - ACTION_TOOLBAR* m_mainToolBar; + PROJECT_TREE_PANE* m_leftWin; + PANEL_KICAD_LAUNCHER* m_launcher; + ACTION_TOOLBAR* m_mainToolBar; int m_leftWinWidth; bool m_active_project; diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index 33ab9e1c0c..cbb269251f 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -229,54 +229,3 @@ void KICAD_MANAGER_FRAME::RecreateBaseHToolbar() // Create m_mainToolBar m_mainToolBar->Realize(); } - - -void KICAD_MANAGER_FRAME::RecreateLauncher() -{ - if( m_launcher ) - { - m_launcher->Clear(); - } - else - { - m_launcher = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize, - KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT ); - m_launcher->SetAuiManager( &m_auimgr ); - } - - // Add tools. Note these KICAD_MANAGER_ACTIONS are defined with a bitmap - // suitable for menus. The icans will be changed later. - m_launcher->Add( KICAD_MANAGER_ACTIONS::editSchematic ); - m_launcher->Add( KICAD_MANAGER_ACTIONS::editSymbols ); - - m_launcher->AddScaledSeparator( this ); - m_launcher->Add( KICAD_MANAGER_ACTIONS::editPCB ); - m_launcher->Add( KICAD_MANAGER_ACTIONS::editFootprints ); - - m_launcher->AddScaledSeparator( this ); - m_launcher->Add( KICAD_MANAGER_ACTIONS::viewGerbers ); - m_launcher->Add( KICAD_MANAGER_ACTIONS::convertImage ); - m_launcher->Add( KICAD_MANAGER_ACTIONS::showCalculator ); - m_launcher->Add( KICAD_MANAGER_ACTIONS::editWorksheet ); - - // Now set big icons for these tools: - m_launcher->SetToolBitmap( KICAD_MANAGER_ACTIONS::editSchematic, - KiScaledBitmap( icon_eeschema_xpm, this ) ); - m_launcher->SetToolBitmap( KICAD_MANAGER_ACTIONS::editSymbols, - KiScaledBitmap( icon_libedit_xpm, this ) ); - m_launcher->SetToolBitmap( KICAD_MANAGER_ACTIONS::editPCB, - KiScaledBitmap( icon_pcbnew_xpm, this ) ); - m_launcher->SetToolBitmap( KICAD_MANAGER_ACTIONS::editFootprints, - KiScaledBitmap( icon_modedit_xpm, this ) ); - m_launcher->SetToolBitmap( KICAD_MANAGER_ACTIONS::viewGerbers, - KiScaledBitmap( icon_gerbview_xpm, this ) ); - m_launcher->SetToolBitmap( KICAD_MANAGER_ACTIONS::convertImage, - KiScaledBitmap( icon_bitmap2component_xpm, this ) ); - m_launcher->SetToolBitmap( KICAD_MANAGER_ACTIONS::showCalculator, - KiScaledBitmap( icon_pcbcalculator_xpm, this ) ); - m_launcher->SetToolBitmap( KICAD_MANAGER_ACTIONS::editWorksheet, - KiScaledBitmap( icon_pagelayout_editor_xpm, this ) ); - - // Create mlauncher - m_launcher->Realize(); -} diff --git a/kicad/tools/kicad_manager_actions.cpp b/kicad/tools/kicad_manager_actions.cpp index cdcd527194..67b5d3aead 100644 --- a/kicad/tools/kicad_manager_actions.cpp +++ b/kicad/tools/kicad_manager_actions.cpp @@ -102,7 +102,7 @@ TOOL_ACTION KICAD_MANAGER_ACTIONS::showCalculator( "kicad.Control.showCalculator TOOL_ACTION KICAD_MANAGER_ACTIONS::editWorksheet( "kicad.Control.editWorksheet", AS_GLOBAL, MD_CTRL + 'Y', LEGACY_HK_NAME( "Run PlEditor" ), - _( "Edit Worksheet" ), _( "Edit worksheet graphics and text" ), + _( "Edit Worksheets" ), _( "Edit worksheet graphics and text" ), icon_pagelayout_editor_24_xpm ); TOOL_ACTION KICAD_MANAGER_ACTIONS::openTextEditor( "kicad.Control.openTextEditor",