Decouple left and right pane minimums for splitter window.
This commit is contained in:
parent
faabcc079a
commit
0b48876ce5
|
@ -243,6 +243,7 @@ set( COMMON_WIDGET_SRCS
|
|||
widgets/wx_ellipsized_static_text.cpp
|
||||
widgets/wx_grid.cpp
|
||||
widgets/wx_progress_reporters.cpp
|
||||
widgets/wx_splitter_window.cpp
|
||||
)
|
||||
|
||||
set( COMMON_DRAWING_SHEET_SRCS
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018-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, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <widgets/wx_splitter_window.h>
|
||||
|
||||
|
||||
bool WX_SPLITTER_WINDOW::OnSashPositionChange( int newSashPosition )
|
||||
{
|
||||
if( newSashPosition < m_minFirstPane )
|
||||
return false;
|
||||
|
||||
int totalSize;
|
||||
|
||||
if( GetSplitMode() == wxSPLIT_HORIZONTAL )
|
||||
totalSize = GetSize().GetHeight();
|
||||
else
|
||||
totalSize = GetSize().GetWidth();
|
||||
|
||||
if( totalSize - newSashPosition < m_minSecondPane )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void WX_SPLITTER_WINDOW::OnSize( wxSizeEvent& aEvent )
|
||||
{
|
||||
wxSplitterWindow::OnSize( aEvent );
|
||||
|
||||
if( GetSashPosition() < m_minFirstPane )
|
||||
SetSashPosition( m_minFirstPane );
|
||||
|
||||
int totalSize;
|
||||
|
||||
if( GetSplitMode() == wxSPLIT_HORIZONTAL )
|
||||
totalSize = GetSize().GetHeight();
|
||||
else
|
||||
totalSize = GetSize().GetWidth();
|
||||
|
||||
if( totalSize - GetSashPosition() < m_minSecondPane )
|
||||
SetSashPosition( totalSize - m_minSecondPane );
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018 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, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef KICAD_WX_SPLITTER_WINDOW_H
|
||||
#define KICAD_WX_SPLITTER_WINDOW_H
|
||||
|
||||
#include <wx/splitter.h>
|
||||
|
||||
class WX_SPLITTER_WINDOW : public wxSplitterWindow
|
||||
{
|
||||
public:
|
||||
WX_SPLITTER_WINDOW( wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
long style = wxSP_3D, const wxString& name = wxT( "splitter" ) ) :
|
||||
wxSplitterWindow( parent, id, pos, size, style, name )
|
||||
{
|
||||
this->Connect( wxEVT_SIZE, wxSizeEventHandler( WX_SPLITTER_WINDOW::OnSize ) );
|
||||
}
|
||||
|
||||
|
||||
~WX_SPLITTER_WINDOW() override
|
||||
{ }
|
||||
|
||||
bool OnSashPositionChange( int newSashPosition ) override;
|
||||
|
||||
void OnSize( wxSizeEvent& aEvent );
|
||||
|
||||
void SetPaneMinimums( int aFirst, int aSecond )
|
||||
{
|
||||
m_minFirstPane = aFirst;
|
||||
m_minSecondPane = aSecond;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_minFirstPane;
|
||||
int m_minSecondPane;
|
||||
};
|
||||
|
||||
#endif //KICAD_WX_SPLITTER_WINDOW_H
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
DIALOG_PCM_BASE::DIALOG_PCM_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxSize( 960,560 ), wxDefaultSize );
|
||||
this->SetSizeHints( wxSize( 900,560 ), wxDefaultSize );
|
||||
|
||||
wxBoxSizer* m_MainSizer;
|
||||
m_MainSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="minimum_size">960,560</property>
|
||||
<property name="minimum_size">900,560</property>
|
||||
<property name="name">DIALOG_PCM_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">960,560</property>
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <kicad_settings.h>
|
||||
#include <pgm_base.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <widgets/wx_splitter_window.h>
|
||||
#include <string_utils.h>
|
||||
#include <html_window.h>
|
||||
|
||||
|
@ -50,6 +51,16 @@ PANEL_PACKAGES_VIEW::PANEL_PACKAGES_VIEW( wxWindow*
|
|||
PANEL_PACKAGES_VIEW_BASE( parent ),
|
||||
m_pcm( aPcm )
|
||||
{
|
||||
// Replace wxFormBuilder's sash initializer with one which will respect m_initialSashPos.
|
||||
m_splitter1->Disconnect( wxEVT_IDLE,
|
||||
wxIdleEventHandler( PANEL_PACKAGES_VIEW_BASE::m_splitter1OnIdle ),
|
||||
NULL, this );
|
||||
m_splitter1->Connect( wxEVT_IDLE, wxIdleEventHandler( PANEL_PACKAGES_VIEW::SetSashOnIdle ),
|
||||
NULL, this );
|
||||
|
||||
m_initSashPos = 380;
|
||||
m_splitter1->SetPaneMinimums( 320, 460 );
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// wxSearchCtrl vertical height is not calculated correctly on some GTK setups
|
||||
// See https://gitlab.com/kicad/code/kicad/-/issues/9019
|
||||
|
@ -598,3 +609,11 @@ void PANEL_PACKAGES_VIEW::OnInfoMouseWheel( wxMouseEvent& event )
|
|||
// Transfer scrolling from the info window to its parent scroll window
|
||||
m_infoScrollWindow->HandleOnMouseWheel( event );
|
||||
}
|
||||
|
||||
|
||||
void PANEL_PACKAGES_VIEW::SetSashOnIdle( wxIdleEvent& aEvent )
|
||||
{
|
||||
m_splitter1->SetSashPosition( m_initSashPos );
|
||||
m_splitter1->Disconnect( wxEVT_IDLE, wxIdleEventHandler( PANEL_PACKAGES_VIEW::SetSashOnIdle ),
|
||||
NULL, this );
|
||||
}
|
||||
|
|
|
@ -77,8 +77,12 @@ public:
|
|||
///< Respond to a URL in the info window
|
||||
void OnURLClicked( wxHtmlLinkEvent& event ) override;
|
||||
|
||||
///< Respond to scrolling over the window
|
||||
void OnInfoMouseWheel( wxMouseEvent& event ) override;
|
||||
|
||||
///< Replacement of wxFormBuilder's ill-advised m_splitter1OnIdle
|
||||
void SetSashOnIdle( wxIdleEvent& );
|
||||
|
||||
private:
|
||||
///< Updates package listing according to search term
|
||||
void updatePackageList();
|
||||
|
@ -99,6 +103,8 @@ private:
|
|||
PANEL_PACKAGE* m_currentSelected;
|
||||
std::shared_ptr<PLUGIN_CONTENT_MANAGER> m_pcm;
|
||||
|
||||
int m_initSashPos;
|
||||
|
||||
enum PACKAGE_VERSIONS_GRID_COLUMNS
|
||||
{
|
||||
COL_VERSION = 0,
|
||||
|
|
|
@ -16,10 +16,9 @@ PANEL_PACKAGES_VIEW_BASE::PANEL_PACKAGES_VIEW_BASE( wxWindow* parent, wxWindowID
|
|||
wxBoxSizer* bSizer1;
|
||||
bSizer1 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_splitter1 = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3DSASH|wxSP_LIVE_UPDATE );
|
||||
m_splitter1->SetSashGravity( 0.5 );
|
||||
m_splitter1 = new WX_SPLITTER_WINDOW( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3DSASH|wxSP_LIVE_UPDATE );
|
||||
m_splitter1->SetSashGravity( 0.2 );
|
||||
m_splitter1->Connect( wxEVT_IDLE, wxIdleEventHandler( PANEL_PACKAGES_VIEW_BASE::m_splitter1OnIdle ), NULL, this );
|
||||
m_splitter1->SetMinimumPaneSize( 420 );
|
||||
|
||||
m_panelList = new wxPanel( m_splitter1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bPanelListSizer;
|
||||
|
@ -53,6 +52,8 @@ PANEL_PACKAGES_VIEW_BASE::PANEL_PACKAGES_VIEW_BASE( wxWindow* parent, wxWindowID
|
|||
|
||||
m_infoScrollWindow = new wxScrolledWindow( m_panelDetails, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL );
|
||||
m_infoScrollWindow->SetScrollRate( 5, 5 );
|
||||
m_infoScrollWindow->SetMinSize( wxSize( 480,-1 ) );
|
||||
|
||||
wxBoxSizer* bSizerScrolledWindow;
|
||||
bSizerScrolledWindow = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
|
@ -93,7 +94,7 @@ PANEL_PACKAGES_VIEW_BASE::PANEL_PACKAGES_VIEW_BASE( wxWindow* parent, wxWindowID
|
|||
|
||||
// Cell Defaults
|
||||
m_gridVersions->SetDefaultCellAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
|
||||
m_sizerVersions->Add( m_gridVersions, 0, wxEXPAND|wxRIGHT, 15 );
|
||||
m_sizerVersions->Add( m_gridVersions, 0, wxEXPAND|wxRIGHT, 5 );
|
||||
|
||||
wxBoxSizer* bSizerVersionButtons;
|
||||
bSizerVersionButtons = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_pane_size">420</property>
|
||||
<property name="min_pane_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
|
@ -102,14 +102,14 @@
|
|||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="sashgravity">0.5</property>
|
||||
<property name="sashgravity">0.2</property>
|
||||
<property name="sashpos">0</property>
|
||||
<property name="sashsize">-1</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="splitmode">wxSPLIT_VERTICAL</property>
|
||||
<property name="style">wxSP_3DSASH|wxSP_LIVE_UPDATE</property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="subclass">WX_SPLITTER_WINDOW; widgets/wx_splitter_window.h; Not forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
|
@ -274,7 +274,7 @@
|
|||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="minimum_size">-1,-1</property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_packageListWindow</property>
|
||||
<property name="pane_border">1</property>
|
||||
|
@ -399,7 +399,7 @@
|
|||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size">-1,-1</property>
|
||||
<property name="minimum_size">480,-1</property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_infoScrollWindow</property>
|
||||
<property name="pane_border">1</property>
|
||||
|
@ -495,7 +495,7 @@
|
|||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">protected</property>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">15</property>
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxRIGHT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxGrid" expanded="0">
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
class HTML_WINDOW;
|
||||
|
||||
#include "widgets/wx_grid.h"
|
||||
#include "widgets/wx_splitter_window.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/srchctrl.h>
|
||||
#include <wx/gdicmn.h>
|
||||
|
@ -42,7 +43,7 @@ class PANEL_PACKAGES_VIEW_BASE : public wxPanel
|
|||
private:
|
||||
|
||||
protected:
|
||||
wxSplitterWindow* m_splitter1;
|
||||
WX_SPLITTER_WINDOW* m_splitter1;
|
||||
wxPanel* m_panelList;
|
||||
wxSearchCtrl* m_searchCtrl;
|
||||
wxScrolledWindow* m_packageListWindow;
|
||||
|
|
Loading…
Reference in New Issue