From 6417c9888f5dc52d0f41b4d094ca0ef81d2ba713 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 10 Nov 2023 11:15:42 +0000 Subject: [PATCH] Update EDA_REORDERABLE_LIST_DIALOG to current GUI style. Note: while we try to omit sizing info from FBP files, the list controls assume way too wide a minimum width if they're not set. Furthermore, sizing the dialog ends up leaving them a certain size and clipping other elements is the dialog itself doesn't have limits set. Sigh. --- .../dialogs/eda_reorderable_list_dialog.cpp | 30 +- .../eda_reorderable_list_dialog_base.cpp | 71 +-- .../eda_reorderable_list_dialog_base.fbp | 516 +++++++++--------- .../eda_reorderable_list_dialog_base.h | 14 +- common/tool/actions.cpp | 2 +- include/dialogs/eda_reorderable_list_dialog.h | 2 - 6 files changed, 332 insertions(+), 303 deletions(-) diff --git a/common/dialogs/eda_reorderable_list_dialog.cpp b/common/dialogs/eda_reorderable_list_dialog.cpp index 02cda55a77..73924ef607 100644 --- a/common/dialogs/eda_reorderable_list_dialog.cpp +++ b/common/dialogs/eda_reorderable_list_dialog.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2022-2023 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 @@ -21,6 +21,7 @@ #include #include #include +#include static int DEFAULT_SINGLE_COL_WIDTH = 260; @@ -122,7 +123,10 @@ void EDA_REORDERABLE_LIST_DIALOG::onAddItem( wxCommandEvent& aEvent ) wxListItem info; if( !getSelectedItem( m_availableListBox, info ) ) + { + wxBell(); return; + } m_availableItems.erase( m_availableItems.begin() + info.m_itemId ); m_availableListBox->DeleteItem( m_selectedAvailable ); @@ -134,8 +138,6 @@ void EDA_REORDERABLE_LIST_DIALOG::onAddItem( wxCommandEvent& aEvent ) m_enabledItems.insert( m_enabledItems.begin() + pos, info.m_text ); m_enabledListBox->InsertItem( info ); - - updateButtons(); } @@ -144,7 +146,10 @@ void EDA_REORDERABLE_LIST_DIALOG::onRemoveItem( wxCommandEvent& aEvent ) wxListItem info; if( !getSelectedItem( m_enabledListBox, info ) || info.m_itemId == 0 ) + { + wxBell(); return; + } m_enabledItems.erase( m_enabledItems.begin() + info.m_itemId ); m_enabledListBox->DeleteItem( m_selectedEnabled ); @@ -160,8 +165,6 @@ void EDA_REORDERABLE_LIST_DIALOG::onRemoveItem( wxCommandEvent& aEvent ) m_availableItems.insert( m_availableItems.begin() + pos, info.m_text ); m_availableListBox->InsertItem( info ); - - updateButtons(); } @@ -170,7 +173,10 @@ void EDA_REORDERABLE_LIST_DIALOG::onMoveUp( wxCommandEvent& aEvent ) wxListItem info; if( !getSelectedItem( m_enabledListBox, info ) || info.m_itemId == 0 ) + { + wxBell(); return; + } auto current = m_enabledItems.begin() + info.m_itemId; auto prev = m_enabledItems.begin() + info.m_itemId - 1; @@ -179,7 +185,6 @@ void EDA_REORDERABLE_LIST_DIALOG::onMoveUp( wxCommandEvent& aEvent ) m_selectedEnabled--; - updateButtons(); updateItems(); } @@ -191,6 +196,7 @@ void EDA_REORDERABLE_LIST_DIALOG::onMoveDown( wxCommandEvent& aEvent ) if( !getSelectedItem( m_enabledListBox, info ) || info.m_itemId == static_cast( m_enabledItems.size() ) - 1 ) { + wxBell(); return; } @@ -201,7 +207,6 @@ void EDA_REORDERABLE_LIST_DIALOG::onMoveDown( wxCommandEvent& aEvent ) m_selectedEnabled++; - updateButtons(); updateItems(); } @@ -235,7 +240,6 @@ void EDA_REORDERABLE_LIST_DIALOG::onEnabledListItemSelected( wxListEvent& event } m_selectedEnabled = info.m_itemId; - updateButtons(); } @@ -250,15 +254,5 @@ void EDA_REORDERABLE_LIST_DIALOG::onAvailableListItemSelected( wxListEvent& even } m_selectedAvailable = info.m_itemId; - updateButtons(); } - -void EDA_REORDERABLE_LIST_DIALOG::updateButtons() -{ - m_btnUp->Enable( !m_enabledItems.empty() && m_selectedEnabled > 0 ); - m_btnDown->Enable( !m_enabledItems.empty() && m_selectedEnabled > 0 && - m_selectedEnabled < static_cast( m_enabledItems.size() ) - 1 ); - m_btnAdd->Enable( !m_availableItems.empty() && m_selectedAvailable >= 0 ); - m_btnRemove->Enable( !m_enabledItems.empty() && m_selectedEnabled > 0 ); -} diff --git a/common/dialogs/eda_reorderable_list_dialog_base.cpp b/common/dialogs/eda_reorderable_list_dialog_base.cpp index 6552cc4c50..a0c69b2d03 100644 --- a/common/dialogs/eda_reorderable_list_dialog_base.cpp +++ b/common/dialogs/eda_reorderable_list_dialog_base.cpp @@ -1,17 +1,19 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "widgets/std_bitmap_button.h" + #include "eda_reorderable_list_dialog_base.h" /////////////////////////////////////////////////////////////////////////// EDA_REORDERABLE_LIST_DIALOG_BASE::EDA_REORDERABLE_LIST_DIALOG_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( wxDefaultSize, wxDefaultSize ); + this->SetSizeHints( wxSize( 320,220 ), wxDefaultSize ); wxBoxSizer* bSizerMain; bSizerMain = new wxBoxSizer( wxVERTICAL ); @@ -19,63 +21,71 @@ EDA_REORDERABLE_LIST_DIALOG_BASE::EDA_REORDERABLE_LIST_DIALOG_BASE( wxWindow* pa wxBoxSizer* bTop; bTop = new wxBoxSizer( wxHORIZONTAL ); - wxBoxSizer* bLeftSide; - bLeftSide = new wxBoxSizer( wxVERTICAL ); + wxFlexGridSizer* fgSizer1; + fgSizer1 = new wxFlexGridSizer( 0, 3, 3, 0 ); + fgSizer1->AddGrowableCol( 0 ); + fgSizer1->AddGrowableCol( 2 ); + fgSizer1->AddGrowableRow( 1 ); + fgSizer1->SetFlexibleDirection( wxBOTH ); + fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_availableListLabel = new wxStaticText( this, wxID_ANY, _("Available:"), wxDefaultPosition, wxDefaultSize, 0 ); m_availableListLabel->Wrap( -1 ); - bLeftSide->Add( m_availableListLabel, 0, wxALL, 5 ); - - m_availableListBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES|wxBORDER_SIMPLE|wxVSCROLL ); - m_availableListBox->SetMinSize( wxSize( 280,150 ) ); - - bLeftSide->Add( m_availableListBox, 0, wxALL, 5 ); + fgSizer1->Add( m_availableListLabel, 0, 0, 5 ); - bTop->Add( bLeftSide, 1, wxEXPAND, 5 ); + fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_enabledListLabel = new wxStaticText( this, wxID_ANY, _("Enabled:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_enabledListLabel->Wrap( -1 ); + fgSizer1->Add( m_enabledListLabel, 0, 0, 5 ); + + m_availableListBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL|wxBORDER_SIMPLE|wxVSCROLL ); + m_availableListBox->SetMinSize( wxSize( 140,20 ) ); + + fgSizer1->Add( m_availableListBox, 1, wxEXPAND, 5 ); wxBoxSizer* bMiddleButtons; bMiddleButtons = new wxBoxSizer( wxVERTICAL ); - m_btnAdd = new wxButton( this, wxID_ANY, _(">>"), wxDefaultPosition, wxSize( 48,-1 ), 0 ); - bMiddleButtons->Add( m_btnAdd, 0, wxALL, 5 ); + m_btnAdd = new wxButton( this, wxID_ANY, _(">"), wxDefaultPosition, wxSize( 24,24 ), 0 ); + bMiddleButtons->Add( m_btnAdd, 0, wxBOTTOM, 10 ); - m_btnRemove = new wxButton( this, wxID_ANY, _("<<"), wxDefaultPosition, wxSize( 48,-1 ), 0 ); - bMiddleButtons->Add( m_btnRemove, 0, wxALL, 5 ); + m_btnRemove = new wxButton( this, wxID_ANY, _("<"), wxDefaultPosition, wxSize( 24,24 ), 0 ); + bMiddleButtons->Add( m_btnRemove, 0, wxBOTTOM|wxALIGN_CENTER_HORIZONTAL, 20 ); - bTop->Add( bMiddleButtons, 0, wxALIGN_CENTER_VERTICAL, 5 ); + fgSizer1->Add( bMiddleButtons, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 10 ); - wxBoxSizer* bRightSide; - bRightSide = new wxBoxSizer( wxVERTICAL ); + m_enabledListBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL|wxBORDER_SIMPLE|wxVSCROLL ); + m_enabledListBox->SetMinSize( wxSize( 140,20 ) ); - m_enabledListLabel = new wxStaticText( this, wxID_ANY, _("Enabled:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_enabledListLabel->Wrap( -1 ); - bRightSide->Add( m_enabledListLabel, 0, wxALL, 5 ); + fgSizer1->Add( m_enabledListBox, 3, wxEXPAND, 5 ); - m_enabledListBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES|wxBORDER_SIMPLE|wxVSCROLL ); - m_enabledListBox->SetMinSize( wxSize( 280,150 ) ); - bRightSide->Add( m_enabledListBox, 3, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); + + + fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); wxBoxSizer* bSizer4; bSizer4 = new wxBoxSizer( wxHORIZONTAL ); - m_btnUp = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_btnUp = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_btnUp->SetToolTip( _("Move up") ); - bSizer4->Add( m_btnUp, 0, wxALL, 5 ); + bSizer4->Add( m_btnUp, 0, 0, 5 ); - m_btnDown = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_btnDown = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_btnDown->SetToolTip( _("Move down") ); - bSizer4->Add( m_btnDown, 0, wxALL, 5 ); + bSizer4->Add( m_btnDown, 0, wxLEFT, 5 ); - bRightSide->Add( bSizer4, 1, wxEXPAND, 5 ); + fgSizer1->Add( bSizer4, 0, wxEXPAND, 5 ); - bTop->Add( bRightSide, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + bTop->Add( fgSizer1, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); bSizerMain->Add( bTop, 1, wxEXPAND, 5 ); @@ -97,7 +107,6 @@ EDA_REORDERABLE_LIST_DIALOG_BASE::EDA_REORDERABLE_LIST_DIALOG_BASE( wxWindow* pa this->SetSizer( bSizerMain ); this->Layout(); - bSizerMain->Fit( this ); this->Centre( wxBOTH ); diff --git a/common/dialogs/eda_reorderable_list_dialog_base.fbp b/common/dialogs/eda_reorderable_list_dialog_base.fbp index 546f5d7a95..a76f09242d 100644 --- a/common/dialogs/eda_reorderable_list_dialog_base.fbp +++ b/common/dialogs/eda_reorderable_list_dialog_base.fbp @@ -44,10 +44,10 @@ 0 wxID_ANY - + 320,220 EDA_REORDERABLE_LIST_DIALOG_BASE - + 580,260 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h @@ -71,17 +71,24 @@ wxHORIZONTAL none - 5 - wxEXPAND + 10 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 1 - - - bLeftSide - wxVERTICAL + + 3 + wxBOTH + 0,2 + 1 + 0 + -1,-1 + fgSizer1 + wxFLEX_GROWMODE_SPECIFIED none + 0 + 3 5 - wxALL + 0 1 @@ -142,240 +149,17 @@ 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - 280,150 - 1 - m_availableListBox - 1 - - + wxEXPAND + 1 + + 0 protected - 1 - - Resizable - 1 - - wxLC_HRULES|wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - wxBORDER_SIMPLE|wxVSCROLL - onAvailableListItemSelected - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - - bMiddleButtons - wxVERTICAL - none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - >> - -1,-1 - 0 - - 0 - - - 0 - - 1 - m_btnAdd - 1 - - - protected - 1 - - - - Resizable - 1 - 48,-1 - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onAddItem + 0 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - << - - 0 - - 0 - - - 0 - - 1 - m_btnRemove - 1 - - - protected - 1 - - - - Resizable - 1 - 48,-1 - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onRemoveItem - - - - - - 5 - wxEXPAND|wxRIGHT|wxLEFT - 1 - - - bRightSide - wxVERTICAL - none - - 5 - wxALL + 0 1 @@ -436,7 +220,229 @@ 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 140,20 + 1 + m_availableListBox + 1 + + + protected + 1 + + Resizable + 1 + + wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + wxBORDER_SIMPLE|wxVSCROLL + onAvailableListItemSelected + + + + 10 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + + bMiddleButtons + wxVERTICAL + none + + 10 + wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + > + -1,-1 + 0 + + 0 + + + 0 + + 1 + m_btnAdd + 1 + + + protected + 1 + + + + Resizable + 1 + 24,24 + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onAddItem + + + + 20 + wxBOTTOM|wxALIGN_CENTER_HORIZONTAL + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + < + + 0 + + 0 + + + 0 + + 1 + m_btnRemove + 1 + + + protected + 1 + + + + Resizable + 1 + 24,24 + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onRemoveItem + + + + + + 5 + wxEXPAND 3 1 @@ -471,7 +477,7 @@ 0 - 280,150 + 140,20 1 m_enabledListBox 1 @@ -483,7 +489,7 @@ Resizable 1 - wxLC_HRULES|wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES + wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL 0 @@ -501,6 +507,26 @@ 5 wxEXPAND 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 0 bSizer4 @@ -508,7 +534,7 @@ none 5 - wxALL + 0 1 @@ -567,7 +593,7 @@ 1 - ; ; forward_declare + STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare 0 Move up @@ -582,7 +608,7 @@ 5 - wxALL + wxLEFT 0 1 @@ -641,7 +667,7 @@ 1 - ; ; forward_declare + STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare 0 Move down diff --git a/common/dialogs/eda_reorderable_list_dialog_base.h b/common/dialogs/eda_reorderable_list_dialog_base.h index 7259d8969f..49fe0afb38 100644 --- a/common/dialogs/eda_reorderable_list_dialog_base.h +++ b/common/dialogs/eda_reorderable_list_dialog_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -10,6 +10,8 @@ #include #include #include +class STD_BITMAP_BUTTON; + #include "dialog_shim.h" #include #include @@ -18,11 +20,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include @@ -38,13 +40,13 @@ class EDA_REORDERABLE_LIST_DIALOG_BASE : public DIALOG_SHIM protected: wxStaticText* m_availableListLabel; + wxStaticText* m_enabledListLabel; wxListCtrl* m_availableListBox; wxButton* m_btnAdd; wxButton* m_btnRemove; - wxStaticText* m_enabledListLabel; wxListCtrl* m_enabledListBox; - wxBitmapButton* m_btnUp; - wxBitmapButton* m_btnDown; + STD_BITMAP_BUTTON* m_btnUp; + STD_BITMAP_BUTTON* m_btnDown; wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel; @@ -61,7 +63,7 @@ class EDA_REORDERABLE_LIST_DIALOG_BASE : public DIALOG_SHIM public: wxBoxSizer* m_ButtonsSizer; - EDA_REORDERABLE_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + EDA_REORDERABLE_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 580,260 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~EDA_REORDERABLE_LIST_DIALOG_BASE(); diff --git a/common/tool/actions.cpp b/common/tool/actions.cpp index c81c0acebf..04464143f1 100644 --- a/common/tool/actions.cpp +++ b/common/tool/actions.cpp @@ -748,7 +748,7 @@ TOOL_ACTION ACTIONS::updatePreferences( TOOL_ACTION_ARGS() TOOL_ACTION ACTIONS::selectColumns( TOOL_ACTION_ARGS() .Name( "common.Control.selectColumns" ) .Scope( AS_GLOBAL ) - .FriendlyName( _( "Select Columns" ) ) ); + .FriendlyName( _( "Select Columns..." ) ) ); TOOL_ACTION ACTIONS::toggleUnits( TOOL_ACTION_ARGS() .Name( "common.Control.toggleUnits" ) diff --git a/include/dialogs/eda_reorderable_list_dialog.h b/include/dialogs/eda_reorderable_list_dialog.h index fa75a66ef6..4c6044e859 100644 --- a/include/dialogs/eda_reorderable_list_dialog.h +++ b/include/dialogs/eda_reorderable_list_dialog.h @@ -55,8 +55,6 @@ private: bool getSelectedItem( wxListCtrl* aList, wxListItem& aInfo ); - void updateButtons(); - std::vector m_availableItems; std::vector m_enabledItems;