Fix the font selector "Leave Unchanged" option in global edit dialogs
Fixes https://gitlab.com/kicad/code/kicad/-/issues/23190
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <kiplatform/ui.h>
|
||||
#include <font/fontconfig.h>
|
||||
#include <pgm_base.h>
|
||||
#include <widgets/ui_common.h>
|
||||
|
||||
#include <wx/dc.h>
|
||||
#include <wx/event.h>
|
||||
@@ -181,6 +182,7 @@ FONT_CHOICE::FONT_CHOICE( wxWindow* aParent, int aId, wxPoint aPosition, wxSize
|
||||
{
|
||||
m_systemFontCount = nChoices;
|
||||
m_notFound = wxS( " " ) + _( "<not found>" );
|
||||
m_hasIndeterminateChoice = false;
|
||||
m_isFiltered = false;
|
||||
m_lastText = wxEmptyString;
|
||||
m_originalSelection = wxEmptyString;
|
||||
@@ -231,6 +233,9 @@ void FONT_CHOICE::RefreshFonts()
|
||||
// Store the full font list for filtering
|
||||
m_fullFontList.Clear();
|
||||
|
||||
if( m_hasIndeterminateChoice )
|
||||
m_fullFontList.Add( INDETERMINATE_ACTION );
|
||||
|
||||
if( m_systemFontCount > 1 )
|
||||
m_fullFontList.Add( _( "Default Font" ) );
|
||||
|
||||
@@ -242,6 +247,9 @@ void FONT_CHOICE::RefreshFonts()
|
||||
Freeze();
|
||||
clearList();
|
||||
|
||||
if( m_hasIndeterminateChoice )
|
||||
Append( INDETERMINATE_ACTION );
|
||||
|
||||
if( m_systemFontCount > 1 )
|
||||
Append( _( "Default Font" ) );
|
||||
|
||||
@@ -297,6 +305,10 @@ KIFONT::FONT* FONT_CHOICE::GetFontSelection( bool aBold, bool aItalic, bool aFor
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
else if( GetValue() == INDETERMINATE_ACTION )
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
else if( GetSelection() == 1 && m_systemFontCount == 2 )
|
||||
{
|
||||
return KIFONT::FONT::GetFont( KICAD_FONT_NAME, aBold, aItalic );
|
||||
|
||||
@@ -95,6 +95,10 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( SCH_
|
||||
|
||||
m_lineStyle->Append( INDETERMINATE_ACTION );
|
||||
|
||||
// Allow indeterminate state in font control and rebuild list
|
||||
m_fontCtrl->SetHasIndeterminateChoice();
|
||||
m_fontCtrl->RefreshFonts();
|
||||
|
||||
m_textColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
|
||||
m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
|
||||
m_colorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
|
||||
@@ -139,7 +143,6 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow()
|
||||
if( g_netFilter.IsEmpty() && !m_parent->GetHighlightedConnection().IsEmpty() )
|
||||
m_netFilter->SetValue( m_parent->GetHighlightedConnection() );
|
||||
|
||||
m_fontCtrl->Append( INDETERMINATE_ACTION );
|
||||
m_fontCtrl->SetStringSelection( INDETERMINATE_ACTION );
|
||||
|
||||
m_textSize.SetValue( INDETERMINATE_ACTION );
|
||||
|
||||
@@ -35,6 +35,12 @@ public:
|
||||
|
||||
void RefreshFonts();
|
||||
|
||||
/**
|
||||
* Set if the choice selection should show the INDETERMINATE_ACTION option at the top
|
||||
* of the font selection list.
|
||||
*/
|
||||
void SetHasIndeterminateChoice( bool aHasChoice = true ) { m_hasIndeterminateChoice = aHasChoice; }
|
||||
|
||||
/**
|
||||
* Set the selection in wxChoice widget
|
||||
* @param aFont is the fotn to select
|
||||
@@ -75,6 +81,7 @@ private:
|
||||
int m_systemFontCount;
|
||||
wxString m_notFound;
|
||||
wxArrayString m_fullFontList;
|
||||
bool m_hasIndeterminateChoice;
|
||||
bool m_isFiltered;
|
||||
wxString m_lastText;
|
||||
wxString m_originalSelection; // Store original selection when popup opens
|
||||
|
||||
@@ -140,6 +140,10 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( PCB_
|
||||
m_footprintFilter->Show( false );
|
||||
}
|
||||
|
||||
// Allow indeterminate state in font control and rebuild list
|
||||
m_fontCtrl->SetHasIndeterminateChoice();
|
||||
m_fontCtrl->RefreshFonts();
|
||||
|
||||
m_layerFilter->SetBoardFrame( m_parent );
|
||||
m_layerFilter->SetLayersHotkeys( false );
|
||||
m_layerFilter->Resync();
|
||||
@@ -184,7 +188,6 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow()
|
||||
|
||||
m_lineWidth.SetValue( INDETERMINATE_ACTION );
|
||||
|
||||
m_fontCtrl->Append( INDETERMINATE_ACTION );
|
||||
m_fontCtrl->SetStringSelection( INDETERMINATE_ACTION );
|
||||
|
||||
m_textWidth.SetValue( INDETERMINATE_ACTION );
|
||||
|
||||
Reference in New Issue
Block a user