Move footprint properties dialogs to symbol properties grid resizing strategy.

Fixes https://gitlab.com/kicad/code/kicad/issues/9883
This commit is contained in:
Jeff Young 2022-10-12 00:38:01 +01:00
parent 971cbfa2ed
commit bd1114d94d
7 changed files with 71 additions and 29 deletions

View File

@ -36,7 +36,6 @@
#include <kiplatform/ui.h>
#include <widgets/grid_icon_text_helpers.h>
#include <widgets/grid_combobox.h>
#include <widgets/wx_grid.h>
#include <settings/settings_manager.h>
#include <ee_collectors.h>
#include <symbol_library.h>
@ -299,6 +298,9 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent,
DIALOG_SYMBOL_PROPERTIES_BASE( aParent ),
m_symbol( nullptr ),
m_part( nullptr ),
m_fieldsSize( 0, 0 ),
m_lastRequestedSize( 0, 0 ),
m_editorShown( false ),
m_fields( nullptr ),
m_dataModel( nullptr )
{
@ -312,9 +314,6 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent,
m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( this, aParent, m_fieldsGrid, m_symbol );
m_editorShown = false;
m_lastRequestedSize = wxSize( 0, 0 );
#ifndef KICAD_SPICE
m_spiceFieldsButton->Hide();
#endif /* not KICAD_SPICE */

View File

@ -39,7 +39,6 @@
#include <kiplatform/ui.h>
#include <widgets/grid_text_button_helpers.h>
#include <widgets/text_ctrl_eval.h>
#include <widgets/wx_grid.h>
#include <settings/settings_manager.h>
#include <panel_fp_properties_3d_model.h>
@ -69,7 +68,9 @@ DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES( PCB_EDIT_FRAME* aParen
m_solderPasteRatio( aParent, m_PasteMarginRatioLabel, m_PasteMarginRatioCtrl,
m_PasteMarginRatioUnits ),
m_returnValue( FP_PROPS_CANCEL ),
m_initialized( false )
m_initialized( false ),
m_gridSize( 0, 0 ),
m_lastRequestedSize( 0, 0 )
{
// Create the 3D models page
m_3dPanel = new PANEL_FP_PROPERTIES_3D_MODEL( m_frame, m_footprint, this, m_NoteBook );
@ -678,9 +679,6 @@ void DIALOG_FOOTPRINT_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& )
if( !m_initialized )
return;
if( !m_itemsGrid->IsCellEditControlShown() )
adjustGridColumns();
// Handle a grid error. This is delayed to OnUpdateUI so that we can change focus
// even when the original validation was triggered from a killFocus event, and so
// that the corresponding notebook page can be shown in the background when triggered
@ -733,20 +731,35 @@ void DIALOG_FOOTPRINT_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& )
void DIALOG_FOOTPRINT_PROPERTIES::OnGridSize( wxSizeEvent& aEvent )
{
// A trick to fix a cosmetic issue: when, in m_itemsGrid, a layer selector widget
// has the focus (is activated in column 6) when resizing the grid, the widget
// is not moved. So just change the widget having the focus in this case
if( m_NoteBook->GetSelection() == 0 && !m_itemsGrid->HasFocus() )
{
int col = m_itemsGrid->GetGridCursorCol();
wxSize new_size = aEvent.GetSize();
if( col == 6 ) // a layer selector widget can be activated
m_itemsGrid->SetFocus();
if( ( !m_itemsGrid->IsCellEditControlShown() || m_lastRequestedSize != new_size )
&& m_gridSize != new_size )
{
m_gridSize = new_size;
// A trick to fix a cosmetic issue: when, in m_itemsGrid, a layer selector widget has
// the focus (is activated in column 6) when resizing the grid, the widget is not moved.
// So just change the widget having the focus in this case
if( m_NoteBook->GetSelection() == 0 && !m_itemsGrid->HasFocus() )
{
int col = m_itemsGrid->GetGridCursorCol();
if( col == 6 ) // a layer selector widget can be activated
m_itemsGrid->SetFocus();
}
adjustGridColumns();
}
adjustGridColumns();
// We store this value to check whether the dialog is changing size. This might indicate
// that the user is scaling the dialog with an editor shown. Some editors do not close
// (at least on GTK) when the user drags a dialog corner
m_lastRequestedSize = new_size;
// Always propagate for a grid repaint (needed if the height changes, as well as width)
aEvent.Skip();
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010-2015 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 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
@ -103,6 +103,9 @@ private:
PANEL_FP_PROPERTIES_3D_MODEL* m_3dPanel;
bool m_initialized;
wxSize m_gridSize;
wxSize m_lastRequestedSize;
};

View File

@ -48,7 +48,7 @@ DIALOG_FOOTPRINT_PROPERTIES_BASE::DIALOG_FOOTPRINT_PROPERTIES_BASE( wxWindow* pa
m_itemsGrid->SetColSize( 9, 110 );
m_itemsGrid->SetColSize( 10, 110 );
m_itemsGrid->EnableDragColMove( false );
m_itemsGrid->EnableDragColSize( false );
m_itemsGrid->EnableDragColSize( true );
m_itemsGrid->SetColLabelValue( 0, _("Text Items") );
m_itemsGrid->SetColLabelValue( 1, _("Show") );
m_itemsGrid->SetColLabelValue( 2, _("Width") );

View File

@ -232,7 +232,7 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_col_move">0</property>
<property name="drag_col_size">0</property>
<property name="drag_col_size">1</property>
<property name="drag_grid_size">0</property>
<property name="drag_row_size">0</property>
<property name="editing">1</property>

View File

@ -133,7 +133,9 @@ DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(
m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl,
m_SolderPasteMarginUnits ),
m_solderPasteRatio( aParent, m_PasteMarginRatioLabel, m_PasteMarginRatioCtrl,
m_PasteMarginRatioUnits )
m_PasteMarginRatioUnits ),
m_gridSize( 0, 0 ),
m_lastRequestedSize( 0, 0 )
{
// Create the 3D models page
m_3dPanel = new PANEL_FP_PROPERTIES_3D_MODEL( m_frame, m_footprint, this, m_NoteBook );
@ -812,9 +814,6 @@ void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::adjustGridColumns()
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnUpdateUI( wxUpdateUIEvent& event )
{
if( !m_itemsGrid->IsCellEditControlShown() )
adjustGridColumns();
// Handle a delayed focus. The delay allows us to:
// a) change focus when the error was triggered from within a killFocus handler
// b) show the correct notebook page in the background before the error dialog comes up
@ -864,9 +863,34 @@ void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnUpdateUI( wxUpdateUIEvent& event )
}
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnGridSize( wxSizeEvent& event )
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnGridSize( wxSizeEvent& aEvent )
{
adjustGridColumns();
wxSize new_size = aEvent.GetSize();
event.Skip();
if( ( !m_itemsGrid->IsCellEditControlShown() || m_lastRequestedSize != new_size )
&& m_gridSize != new_size )
{
m_gridSize = new_size;
// A trick to fix a cosmetic issue: when, in m_itemsGrid, a layer selector widget has
// the focus (is activated in column 6) when resizing the grid, the widget is not moved.
// So just change the widget having the focus in this case
if( m_NoteBook->GetSelection() == 0 && !m_itemsGrid->HasFocus() )
{
int col = m_itemsGrid->GetGridCursorCol();
if( col == 6 ) // a layer selector widget can be activated
m_itemsGrid->SetFocus();
}
adjustGridColumns();
}
// We store this value to check whether the dialog is changing size. This might indicate
// that the user is scaling the dialog with an editor shown. Some editors do not close
// (at least on GTK) when the user drags a dialog corner
m_lastRequestedSize = new_size;
// Always propagate for a grid repaint (needed if the height changes, as well as width)
aEvent.Skip();
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010-2015 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 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
@ -119,6 +119,9 @@ private:
wxString m_delayedErrorMessage;
PANEL_FP_PROPERTIES_3D_MODEL* m_3dPanel;
wxSize m_gridSize;
wxSize m_lastRequestedSize;
};