diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 0353f40836..d9ce08e820 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -238,6 +238,7 @@ set( COMMON_WIDGET_SRCS widgets/widget_save_restore.cpp widgets/widget_hotkey_list.cpp widgets/wx_aui_art_providers.cpp + widgets/wx_aui_utils.cpp widgets/wx_busy_indicator.cpp widgets/wx_ellipsized_static_text.cpp widgets/wx_grid.cpp diff --git a/common/widgets/wx_aui_utils.cpp b/common/widgets/wx_aui_utils.cpp new file mode 100644 index 0000000000..b9656f8b02 --- /dev/null +++ b/common/widgets/wx_aui_utils.cpp @@ -0,0 +1,38 @@ +/* + * 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 + + +void SetAuiPaneSize( wxAuiManager& aManager, wxAuiPaneInfo& aPane, int aWidth, int aHeight ) +{ + wxSize minSize = aPane.min_size; + + // wxAUI hack: force width by setting MinSize() and then Fixed() + // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180 + aPane.MinSize( aWidth, aHeight ); + aPane.Fixed(); + aManager.Update(); + + // now make it resizable again + aPane.MinSize( minSize.x, minSize.y ); + aPane.Resizable(); + aManager.Update(); +} diff --git a/include/widgets/wx_aui_utils.h b/include/widgets/wx_aui_utils.h new file mode 100644 index 0000000000..d56abb9e39 --- /dev/null +++ b/include/widgets/wx_aui_utils.h @@ -0,0 +1,36 @@ +/* + * 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_WX_AUI_UTILS_H +#define KICAD_WX_AUI_UTILS_H + +class wxAuiMangager; +class wxAuiPaneInfo; + +/** + * Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180 + * @param aManager is an AUI manager + * @param aPane is a wxAuiPaneInfo containing pane info managed by aManager + * @param aWidth is the width to set (-1 for automatic) + * @param aHeight is the height to set (-1 for automatic) + */ +void SetAuiPaneSize( wxAuiManager& aManager, wxAuiPaneInfo& aPane, int aWidth, int aHeight ); + +#endif // KICAD_WX_AUI_UTILS_H diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 65fcee1292..8e7f30b0bb 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -99,6 +99,7 @@ #include #include #include +#include #include #include @@ -292,17 +293,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : if( settings->m_AuiPanels.right_panel_width > 0 ) { wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" ); - - // wxAUI hack: force width by setting MinSize() and then Fixed() - // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180 - layersManager.MinSize( settings->m_AuiPanels.right_panel_width, -1 ); - layersManager.Fixed(); - m_auimgr.Update(); - - // now make it resizable again - layersManager.MinSize( 180, -1 ); - layersManager.Resizable(); - m_auimgr.Update(); + SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 ); } m_appearancePanel->SetTabIndex( settings->m_AuiPanels.appearance_panel_tab ); diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index de4a19d1c6..d6f75dfebb 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -46,6 +46,8 @@ #include #include #include +#include +#include #include #include #include @@ -751,11 +753,23 @@ void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar ) void PCB_EDIT_FRAME::ToggleLayersManager() { + PCBNEW_SETTINGS* settings = GetPcbNewSettings(); + wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" ); + // show auxiliary Vertical layers and visibility manager toolbar m_show_layer_manager_tools = !m_show_layer_manager_tools; - m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools ); + layersManager.Show( m_show_layer_manager_tools ); m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools ); - m_auimgr.Update(); + + if( m_show_layer_manager_tools ) + { + SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 ); + } + else + { + settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x; + m_auimgr.Update(); + } }