From 7f64f4124297147059257c3d1abecf5e78aa2c63 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 22 Jul 2018 16:01:24 +0100 Subject: [PATCH] Fix layout issues in Global Label dialog. Fixes: lp:1782904 * https://bugs.launchpad.net/kicad/+bug/1782904 --- eeschema/dialogs/dialog_edit_label.cpp | 46 +- eeschema/dialogs/dialog_edit_label_base.cpp | 52 +- eeschema/dialogs/dialog_edit_label_base.fbp | 739 ++++++++++++-------- eeschema/dialogs/dialog_edit_label_base.h | 6 +- 4 files changed, 497 insertions(+), 346 deletions(-) diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 2f774aeeac..adde7b4602 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -108,33 +108,18 @@ const int maxSize = (int)( 250 * IU_PER_MM ); DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTextItem ) : DIALOG_LABEL_EDITOR_BASE( aParent ), - m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeLabel, false, minSize, maxSize ) + m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false, minSize, maxSize ) { m_Parent = aParent; m_CurrentText = aTextItem; switch( m_CurrentText->Type() ) { - case SCH_GLOBAL_LABEL_T: - SetTitle( _( "Global Label Properties" ) ); - break; - - case SCH_HIERARCHICAL_LABEL_T: - SetTitle( _( "Hierarchical Label Properties" ) ); - break; - - case SCH_LABEL_T: - SetTitle( _( "Label Properties" ) ); - break; - - case SCH_SHEET_PIN_T: - SetTitle( _( "Hierarchical Sheet Pin Properties" ) ); - break; - - default: - m_Label->SetLabel( _( "Text:" ) ); - SetTitle( _( "Text Properties" ) ); - break; + case SCH_GLOBAL_LABEL_T: SetTitle( _( "Global Label Properties" ) ); break; + case SCH_HIERARCHICAL_LABEL_T: SetTitle( _( "Hierarchical Label Properties" ) ); break; + case SCH_LABEL_T: SetTitle( _( "Label Properties" ) ); break; + case SCH_SHEET_PIN_T: SetTitle( _( "Hierarchical Sheet Pin Properties" ) ); break; + default: SetTitle( _( "Text Properties" ) ); break; } if( m_CurrentText->IsMultilineAllowed() ) @@ -142,26 +127,26 @@ DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTe m_activeTextCtrl = m_valueMultiLine; m_activeTextEntry = m_valueMultiLine; - m_textControlSizer->AddGrowableRow( 0 ); + m_labelSingleLine->Show( false ); m_valueSingleLine->Show( false ); + m_labelCombo->Show( false ); m_valueCombo->Show( false ); - m_valueSingleLine->Show( false ); - m_valueCombo->Show( false ); + m_textEntrySizer->AddGrowableRow( 0 ); } else if( m_CurrentText->Type() == SCH_GLOBAL_LABEL_T || m_CurrentText->Type() == SCH_LABEL_T ) { m_activeTextCtrl = m_valueCombo; m_activeTextEntry = m_valueCombo; - m_valueSingleLine->Show( false ); - m_valueMultiLine->Show( false ); + m_labelSingleLine->Show( false ); m_valueSingleLine->Show( false ); + m_labelMultiLine->Show( false ); m_valueMultiLine->Show( false ); } else { m_activeTextCtrl = m_valueSingleLine; m_activeTextEntry = m_valueSingleLine; - m_valueCombo->Show( false ); - m_valueMultiLine->Show( false ); + m_labelCombo->Show( false ); m_valueCombo->Show( false ); + m_labelMultiLine->Show( false ); m_valueMultiLine->Show( false ); } SetInitialFocus( m_activeTextCtrl ); @@ -179,6 +164,11 @@ DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTe // so we have to listen to wxEVT_CHAR_HOOK events instead. m_valueMultiLine->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_LABEL_EDITOR::OnCharHook ), nullptr, this ); + // DIALOG_SHIM needs a unique hash_key because classname is not sufficient because the + // various versions have different controls so we want to store sizes for each version. + m_hash_key = TO_UTF8( GetTitle() ); + + // Now all widgets have the size fixed, call FinishDialogSettings FinishDialogSettings(); } diff --git a/eeschema/dialogs/dialog_edit_label_base.cpp b/eeschema/dialogs/dialog_edit_label_base.cpp index b3f610b0f5..d904b815f2 100644 --- a/eeschema/dialogs/dialog_edit_label_base.cpp +++ b/eeschema/dialogs/dialog_edit_label_base.cpp @@ -16,59 +16,63 @@ DIALOG_LABEL_EDITOR_BASE::DIALOG_LABEL_EDITOR_BASE( wxWindow* parent, wxWindowID wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); - m_textControlSizer = new wxFlexGridSizer( 2, 2, 3, 3 ); - m_textControlSizer->AddGrowableCol( 1 ); - m_textControlSizer->SetFlexibleDirection( wxBOTH ); - m_textControlSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + m_textEntrySizer = new wxFlexGridSizer( 4, 2, 3, 3 ); + m_textEntrySizer->AddGrowableCol( 1 ); + m_textEntrySizer->SetFlexibleDirection( wxBOTH ); + m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_Label = new wxStaticText( this, wxID_ANY, _("Label:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Label->Wrap( -1 ); - m_Label->SetToolTip( _("Enter the text to be used within the schematic") ); + m_labelSingleLine = new wxStaticText( this, wxID_ANY, _("Label:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_labelSingleLine->Wrap( -1 ); + m_labelSingleLine->SetToolTip( _("Enter the text to be used within the schematic") ); - m_textControlSizer->Add( m_Label, 0, wxALIGN_TOP|wxRIGHT|wxTOP, 3 ); - - wxBoxSizer* bSizeText; - bSizeText = new wxBoxSizer( wxVERTICAL ); + m_textEntrySizer->Add( m_labelSingleLine, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 3 ); m_valueSingleLine = new wxTextCtrl( this, wxID_VALUESINGLE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RICH ); m_valueSingleLine->SetMinSize( wxSize( 360,-1 ) ); m_valueSingleLine->SetValidator( wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, &m_labelText ) ); - bSizeText->Add( m_valueSingleLine, 0, wxBOTTOM|wxEXPAND|wxLEFT, 3 ); + m_textEntrySizer->Add( m_valueSingleLine, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 3 ); + + m_labelMultiLine = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_labelMultiLine->Wrap( -1 ); + m_textEntrySizer->Add( m_labelMultiLine, 0, wxRIGHT, 5 ); m_valueMultiLine = new wxTextCtrl( this, wxID_VALUEMULTI, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); m_valueMultiLine->SetMinSize( wxSize( 480,72 ) ); - bSizeText->Add( m_valueMultiLine, 1, wxBOTTOM|wxEXPAND|wxLEFT, 3 ); + m_textEntrySizer->Add( m_valueMultiLine, 1, wxEXPAND|wxBOTTOM|wxLEFT, 3 ); + + m_labelCombo = new wxStaticText( this, wxID_ANY, _("Label:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_labelCombo->Wrap( -1 ); + m_textEntrySizer->Add( m_labelCombo, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_valueCombo = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); + m_valueCombo->SetMinSize( wxSize( 360,-1 ) ); + m_valueCombo->SetValidator( wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, &m_comboText ) ); - bSizeText->Add( m_valueCombo, 0, wxEXPAND|wxBOTTOM|wxLEFT, 5 ); - - - m_textControlSizer->Add( bSizeText, 1, wxEXPAND, 3 ); + m_textEntrySizer->Add( m_valueCombo, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text Size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_textSizeLabel->Wrap( -1 ); - m_textControlSizer->Add( m_textSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 3 ); + m_textEntrySizer->Add( m_textSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 3 ); wxBoxSizer* bSizeCtrlSizer; bSizeCtrlSizer = new wxBoxSizer( wxHORIZONTAL ); m_textSizeCtrl = new wxTextCtrl( this, wxID_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bSizeCtrlSizer->Add( m_textSizeCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxTOP, 3 ); + bSizeCtrlSizer->Add( m_textSizeCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 3 ); m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); m_textSizeUnits->Wrap( -1 ); - bSizeCtrlSizer->Add( m_textSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 2 ); + bSizeCtrlSizer->Add( m_textSizeUnits, 0, wxALIGN_CENTER_VERTICAL, 2 ); - m_textControlSizer->Add( bSizeCtrlSizer, 1, wxEXPAND, 3 ); + m_textEntrySizer->Add( bSizeCtrlSizer, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 3 ); - bMainSizer->Add( m_textControlSizer, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 12 ); + bMainSizer->Add( m_textEntrySizer, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 12 ); wxBoxSizer* m_OptionsSizer; m_OptionsSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -89,10 +93,10 @@ DIALOG_LABEL_EDITOR_BASE::DIALOG_LABEL_EDITOR_BASE( wxWindow* parent, wxWindowID int m_TextShapeNChoices = sizeof( m_TextShapeChoices ) / sizeof( wxString ); m_TextShape = new wxRadioBox( this, wxID_ANY, _("Shape"), wxDefaultPosition, wxDefaultSize, m_TextShapeNChoices, m_TextShapeChoices, 1, wxRA_SPECIFY_COLS ); m_TextShape->SetSelection( 3 ); - m_OptionsSizer->Add( m_TextShape, 1, wxALL|wxLEFT|wxTOP|wxEXPAND, 3 ); + m_OptionsSizer->Add( m_TextShape, 1, wxEXPAND|wxTOP|wxLEFT, 3 ); - bMainSizer->Add( m_OptionsSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 12 ); + bMainSizer->Add( m_OptionsSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 10 ); m_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( this, wxID_OK ); diff --git a/eeschema/dialogs/dialog_edit_label_base.fbp b/eeschema/dialogs/dialog_edit_label_base.fbp index ec8a4777ad..bfb66094c3 100644 --- a/eeschema/dialogs/dialog_edit_label_base.fbp +++ b/eeschema/dialogs/dialog_edit_label_base.fbp @@ -104,14 +104,14 @@ 3 - m_textControlSizer + m_textEntrySizer wxFLEX_GROWMODE_SPECIFIED protected - 2 + 4 3 3 - wxALIGN_TOP|wxRIGHT|wxTOP + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 0 1 @@ -149,7 +149,7 @@ 0 1 - m_Label + m_labelSingleLine 1 @@ -194,293 +194,448 @@ 3 - wxEXPAND - 1 - - -1,-1 - bSizeText - wxVERTICAL - none - - 3 - wxBOTTOM|wxEXPAND|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_VALUESINGLE - - 0 - - - - 0 - 360,-1 - 1 - m_valueSingleLine - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_PROCESS_ENTER|wxTE_RICH - - 0 - - wxString - wxFILTER_EXCLUDE_CHAR_LIST - wxTextValidator - m_labelText - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnEnterKey - - - - - - - 3 - wxBOTTOM|wxEXPAND|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_VALUEMULTI - - 0 - - - - 0 - 480,72 - 1 - m_valueMultiLine - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_MULTILINE - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_valueCombo - 1 - - - protected - 1 - - Resizable - -1 - 1 - - wxTE_PROCESS_ENTER - ; forward_declare - 0 - - wxString - wxFILTER_EXCLUDE_CHAR_LIST - wxTextValidator - m_comboText - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnEnterKey - - - + wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_VALUESINGLE + + 0 + + + + 0 + 360,-1 + 1 + m_valueSingleLine + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_PROCESS_ENTER|wxTE_RICH + + 0 + + wxString + wxFILTER_EXCLUDE_CHAR_LIST + wxTextValidator + m_labelText + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnEnterKey + + + + + + + 5 + wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Text: + + 0 + + + 0 + + 1 + m_labelMultiLine + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + 3 - wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT + wxEXPAND|wxBOTTOM|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_VALUEMULTI + + 0 + + + + 0 + 480,72 + 1 + m_valueMultiLine + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_MULTILINE + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Label: + + 0 + + + 0 + + 1 + m_labelCombo + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 360,-1 + 1 + m_valueCombo + 1 + + + protected + 1 + + Resizable + -1 + 1 + + wxTE_PROCESS_ENTER + ; forward_declare + 0 + + wxString + wxFILTER_EXCLUDE_CHAR_LIST + wxTextValidator + m_comboText + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnEnterKey + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -563,7 +718,7 @@ 3 - wxEXPAND + wxEXPAND|wxALIGN_CENTER_VERTICAL 1 @@ -572,7 +727,7 @@ none 3 - wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxTOP + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 1 @@ -663,7 +818,7 @@ 2 - wxALIGN_CENTER_VERTICAL|wxTOP + wxALIGN_CENTER_VERTICAL 0 1 @@ -749,7 +904,7 @@ - 12 + 10 wxEXPAND|wxLEFT|wxRIGHT|wxTOP 0 @@ -939,7 +1094,7 @@ 3 - wxALL|wxLEFT|wxTOP|wxEXPAND + wxEXPAND|wxTOP|wxLEFT 1 1 diff --git a/eeschema/dialogs/dialog_edit_label_base.h b/eeschema/dialogs/dialog_edit_label_base.h index 878e104e11..93b111fdfe 100644 --- a/eeschema/dialogs/dialog_edit_label_base.h +++ b/eeschema/dialogs/dialog_edit_label_base.h @@ -43,10 +43,12 @@ class DIALOG_LABEL_EDITOR_BASE : public DIALOG_SHIM wxID_SIZE }; - wxFlexGridSizer* m_textControlSizer; - wxStaticText* m_Label; + wxFlexGridSizer* m_textEntrySizer; + wxStaticText* m_labelSingleLine; wxTextCtrl* m_valueSingleLine; + wxStaticText* m_labelMultiLine; wxTextCtrl* m_valueMultiLine; + wxStaticText* m_labelCombo; wxComboBox* m_valueCombo; wxStaticText* m_textSizeLabel; wxTextCtrl* m_textSizeCtrl;