Make indeterminate control states clearer for the user.

Fixes https://gitlab.com/kicad/code/kicad/issues/4313
This commit is contained in:
Jeff Young 2020-05-05 16:40:18 +01:00
parent a06fa22b8a
commit 67bccaf465
22 changed files with 266 additions and 161 deletions

View File

@ -154,7 +154,7 @@ void LAYER_BOX_SELECTOR::ResyncBitmapOnly()
for( LAYER_NUM i = 0; i < elements; ++i )
{
wxBitmap layerbmp( 14, 14 );
DrawColorSwatch( layerbmp, GetLayerColor( LAYER_PCB_BACKGROUND ), GetLayerColor( i ) );
DrawColorSwatch( layerbmp, getLayerColor( LAYER_PCB_BACKGROUND ), getLayerColor( i ) );
}
}

View File

@ -110,6 +110,9 @@ public:
wxString GetStringValue() const override
{
if( m_selectedNetcode == -1 )
return m_indeterminateLabel;
NETINFO_ITEM* netInfo = m_netinfoList->GetNetItem( m_selectedNetcode );
if( netInfo && netInfo->GetNet() > 0 )
@ -124,6 +127,12 @@ public:
rebuildList();
}
void SetIndeterminateLabel( const wxString& aIndeterminateLabel )
{
m_indeterminateLabel = aIndeterminateLabel;
rebuildList();
}
void SetBoard( BOARD* aBoard )
{
m_board = aBoard;
@ -186,10 +195,10 @@ public:
if( selection >= 0 )
selectedNetName = m_listBox->GetString( (unsigned) selection );
if( selectedNetName.IsEmpty() )
if( selectedNetName.IsEmpty() || selectedNetName == m_indeterminateLabel )
{
m_selectedNetcode = -1;
GetComboCtrl()->SetValue( INDETERMINATE );
GetComboCtrl()->SetValue( m_indeterminateLabel );
}
else if( selectedNetName == NO_NET )
{
@ -314,6 +323,9 @@ protected:
netNames.insert( netNames.begin(), newnet );
}
if( !m_indeterminateLabel.IsEmpty() )
netNames.push_back( m_indeterminateLabel );
m_listBox->Set( netNames );
}
@ -504,6 +516,7 @@ protected:
int m_maxPopupHeight;
NETINFO_LIST* m_netinfoList;
wxString m_indeterminateLabel;
BOARD* m_board;
int m_selectedNetcode;
@ -574,6 +587,13 @@ void NET_SELECTOR::SetNetInfo( NETINFO_LIST* aNetInfoList )
}
void NET_SELECTOR::SetIndeterminateString( const wxString& aString )
{
m_indeterminateString = aString;
m_netSelectorPopup->SetIndeterminateLabel( aString );
}
void NET_SELECTOR::SetBoard( BOARD* aBoard )
{
m_netSelectorPopup->SetBoard( aBoard );
@ -603,7 +623,7 @@ wxString NET_SELECTOR::GetSelectedNetname()
void NET_SELECTOR::SetIndeterminate()
{
m_netSelectorPopup->SetIndeterminate();
SetValue( INDETERMINATE );
SetValue( m_indeterminateString );
}

View File

@ -51,7 +51,8 @@ UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent,
m_selStart = 0;
m_selEnd = 0;
auto textEntry = dynamic_cast<wxTextEntry*>( m_value );
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_value );
if( textEntry )
{
// Use ChangeValue() instead of SetValue() so we don't generate events.
@ -96,7 +97,7 @@ void UNIT_BINDER::onUnitsChanged( wxCommandEvent& aEvent )
void UNIT_BINDER::onSetFocus( wxFocusEvent& aEvent )
{
auto textEntry = dynamic_cast<wxTextEntry*>( m_value );
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_value );
if( m_allowEval && textEntry )
{
@ -117,7 +118,7 @@ void UNIT_BINDER::onSetFocus( wxFocusEvent& aEvent )
void UNIT_BINDER::onKillFocus( wxFocusEvent& aEvent )
{
auto textEntry = dynamic_cast<wxTextEntry*>( m_value );
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_value );
if( m_allowEval && textEntry )
{
@ -169,10 +170,14 @@ void UNIT_BINDER::delayedFocusHandler( wxCommandEvent& )
bool UNIT_BINDER::Validate( long long int aMin, long long int aMax, bool setFocusOnError )
{
auto textEntry = dynamic_cast<wxTextEntry*>( m_value );
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_value );
if( !textEntry || textEntry->GetValue() == INDETERMINATE )
if( !textEntry
|| textEntry->GetValue() == INDETERMINATE_ACTION
|| textEntry->GetValue() == INDETERMINATE_STATE )
{
return true;
}
if( GetValue() < aMin )
{
@ -224,9 +229,12 @@ void UNIT_BINDER::SetDoubleValue( double aValue )
void UNIT_BINDER::SetValue( wxString aValue )
{
if( auto textEntry = dynamic_cast<wxTextEntry*>( m_value ) )
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_value );
wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_value );
if( textEntry )
textEntry->SetValue( aValue );
else if( auto staticText = dynamic_cast<wxStaticText*>( m_value ) )
else if( staticText )
staticText->SetLabel( aValue );
if( m_allowEval )
@ -242,11 +250,14 @@ void UNIT_BINDER::ChangeValue( int aValue )
}
void UNIT_BINDER::ChangeValue( wxString aValue )
void UNIT_BINDER::ChangeValue( const wxString& aValue )
{
if( auto textEntry = dynamic_cast<wxTextEntry*>( m_value ) )
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_value );
wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_value );
if( textEntry )
textEntry->ChangeValue( aValue );
else if( auto staticText = dynamic_cast<wxStaticText*>( m_value ) )
else if( staticText )
staticText->SetLabel( aValue );
if( m_allowEval )
@ -258,16 +269,18 @@ void UNIT_BINDER::ChangeValue( wxString aValue )
long long int UNIT_BINDER::GetValue()
{
wxString value;
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_value );
wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_value );
wxString value;
if( auto textEntry = dynamic_cast<wxTextEntry*>( m_value ) )
if( textEntry )
{
if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
value = m_eval.Result();
else
value = textEntry->GetValue();
}
else if( auto staticText = dynamic_cast<wxStaticText*>( m_value ) )
else if( staticText )
value = staticText->GetLabel();
else
return 0;
@ -278,16 +291,18 @@ long long int UNIT_BINDER::GetValue()
double UNIT_BINDER::GetDoubleValue()
{
wxString value;
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_value );
wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_value );
wxString value;
if( auto textEntry = dynamic_cast<wxTextEntry*>( m_value ) )
if( textEntry )
{
if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
value = m_eval.Result();
else
value = textEntry->GetValue();
}
else if( auto staticText = dynamic_cast<wxStaticText*>( m_value ) )
else if( staticText )
value = staticText->GetLabel();
else
return 0.0;
@ -298,8 +313,10 @@ double UNIT_BINDER::GetDoubleValue()
bool UNIT_BINDER::IsIndeterminate() const
{
if( auto textEntry = dynamic_cast<wxTextEntry*>( m_value ) )
return textEntry->GetValue() == INDETERMINATE;
wxTextEntry* te = dynamic_cast<wxTextEntry*>( m_value );
if( te )
return te->GetValue() == INDETERMINATE_STATE || te->GetValue() == INDETERMINATE_ACTION;
return false;
}
@ -307,11 +324,14 @@ bool UNIT_BINDER::IsIndeterminate() const
wxString UNIT_BINDER::GetOriginalText() const
{
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_value );
wxStaticText* staticText = dynamic_cast<wxStaticText*>( m_value );
if( m_allowEval )
return m_eval.OriginalText();
else if( auto textEntry = dynamic_cast<wxTextEntry*>( m_value ) )
else if( textEntry )
return textEntry->GetValue();
else if( auto staticText = dynamic_cast<wxStaticText*>( m_value ) )
else if( staticText )
return staticText->GetLabel();
else
return wxEmptyString;

View File

@ -89,7 +89,7 @@ bool DIALOG_EDIT_LINE_STYLE::TransferDataToWindow()
}
else
{
m_width.SetValue( INDETERMINATE );
m_width.SetValue( INDETERMINATE_ACTION );
}
if( std::all_of( m_lines.begin() + 1, m_lines.end(),

View File

@ -273,12 +273,18 @@ public:
if( !m_dataStore.count( compID ) ||
!m_dataStore[ compID ].count( m_fieldNames[ aCol ] ) )
return INDETERMINATE;
{
return INDETERMINATE_STATE;
}
if( &ref == &group.m_Refs.front() )
{
fieldValue = m_dataStore[ compID ][ m_fieldNames[ aCol ] ];
}
else if ( fieldValue != m_dataStore[ compID ][ m_fieldNames[ aCol ] ] )
return INDETERMINATE;
{
return INDETERMINATE_STATE;
}
}
}

View File

@ -181,15 +181,15 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow()
m_netFilterOpt->SetValue( g_filterByNet );
m_textSize.SetValue( INDETERMINATE );
m_orientation->SetStringSelection( INDETERMINATE );
m_hAlign->SetStringSelection( INDETERMINATE );
m_vAlign->SetStringSelection( INDETERMINATE );
m_textSize.SetValue( INDETERMINATE_ACTION );
m_orientation->SetStringSelection( INDETERMINATE_ACTION );
m_hAlign->SetStringSelection( INDETERMINATE_ACTION );
m_vAlign->SetStringSelection( INDETERMINATE_ACTION );
m_Italic->Set3StateValue( wxCHK_UNDETERMINED );
m_Bold->Set3StateValue( wxCHK_UNDETERMINED );
m_Visible->Set3StateValue( wxCHK_UNDETERMINED );
m_lineWidth.SetValue( INDETERMINATE );
m_lineStyle->SetStringSelection( INDETERMINATE );
m_lineWidth.SetValue( INDETERMINATE_ACTION );
m_lineStyle->SetStringSelection( INDETERMINATE_ACTION );
m_setColor->SetValue( false );
m_setBgColor->SetValue( false );
@ -217,13 +217,13 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( const SCH_SHEET_PATH& aS
m_hasChange = true;
}
if( m_hAlign->GetStringSelection() != INDETERMINATE )
if( m_hAlign->GetStringSelection() != INDETERMINATE_ACTION )
{
eda_text->SetHorizJustify( EDA_TEXT::MapHorizJustify( m_hAlign->GetSelection() - 1 ) );
m_hasChange = true;
}
if( m_hAlign->GetStringSelection() != INDETERMINATE )
if( m_hAlign->GetStringSelection() != INDETERMINATE_ACTION )
{
eda_text->SetVertJustify( EDA_TEXT::MapVertJustify( m_vAlign->GetSelection() - 1 ) );
m_hasChange = true;
@ -251,7 +251,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( const SCH_SHEET_PATH& aS
// No else! Labels are both.
if( sch_text )
{
if( m_orientation->GetStringSelection() != INDETERMINATE )
if( m_orientation->GetStringSelection() != INDETERMINATE_ACTION )
{
sch_text->SetLabelSpinStyle( (LABEL_SPIN_STYLE::SPIN) m_orientation->GetSelection() );
m_hasChange = true;
@ -268,7 +268,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( const SCH_SHEET_PATH& aS
if( lineItem->GetLayer() == LAYER_NOTES )
{
if( m_lineStyle->GetStringSelection() != INDETERMINATE )
if( m_lineStyle->GetStringSelection() != INDETERMINATE_ACTION )
{
lineItem->SetLineStyle( m_lineStyle->GetSelection() );
m_hasChange = true;

View File

@ -157,7 +157,7 @@ public:
if( !fieldValue.Length() )
fieldValue = val;
else if( val != fieldValue )
fieldValue = INDETERMINATE;
fieldValue = INDETERMINATE_STATE;
}
}
@ -166,7 +166,7 @@ public:
void SetValue( int aRow, int aCol, const wxString &aValue ) override
{
if( aValue == INDETERMINATE )
if( aValue == INDETERMINATE_STATE )
return;
LIB_PINS pins = m_rows[ aRow ];
@ -389,28 +389,33 @@ public:
DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( LIB_EDIT_FRAME* parent, LIB_PART* aPart ) :
DIALOG_LIB_EDIT_PIN_TABLE_BASE( parent ),
m_editFrame( parent ),
m_part( aPart )
DIALOG_LIB_EDIT_PIN_TABLE_BASE( parent ),
m_editFrame( parent ),
m_part( aPart )
{
if( g_typeNames.empty())
{
for( unsigned i = 0; i < ELECTRICAL_PINTYPES_TOTAL; ++i )
g_typeIcons.push_back( GetBitmap( static_cast<ELECTRICAL_PINTYPE>( i ) ) );
for( unsigned i = 0; i < ELECTRICAL_PINTYPES_TOTAL; ++i )
g_typeNames.push_back( GetText( static_cast<ELECTRICAL_PINTYPE>( i ) ) );
g_typeNames.push_back( INDETERMINATE );
g_typeNames.push_back( INDETERMINATE_STATE );
for( unsigned i = 0; i < GRAPHIC_PINSHAPES_TOTAL; ++i )
g_shapeIcons.push_back( GetBitmap( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
for( unsigned i = 0; i < GRAPHIC_PINSHAPES_TOTAL; ++i )
g_shapeNames.push_back( GetText( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
g_shapeNames.push_back( INDETERMINATE );
g_shapeNames.push_back( INDETERMINATE_STATE );
for( unsigned i = 0; i < LIB_PIN::GetOrientationNames().size(); ++i )
g_orientationIcons.push_back( LIB_PIN::GetOrientationSymbols()[ i ] );
g_orientationNames = LIB_PIN::GetOrientationNames();
g_orientationNames.push_back( INDETERMINATE );
g_orientationNames.push_back( INDETERMINATE_STATE );
}
m_dataModel = new PIN_TABLE_DATA_MODEL( GetUserUnits() );

View File

@ -45,14 +45,14 @@ void GBR_LAYER_BOX_SELECTOR::Resync()
for( unsigned layerid = 0; layerid < images.ImagesMaxCount(); ++layerid )
{
if( !IsLayerEnabled( layerid ) )
if( !isLayerEnabled( layerid ) )
continue;
// Prepare Bitmap
wxBitmap bmp( BM_SIZE, BM_SIZE );
DrawColorSwatch( bmp, GetLayerColor( LAYER_PCB_BACKGROUND ), GetLayerColor( layerid ) );
DrawColorSwatch( bmp, getLayerColor( LAYER_PCB_BACKGROUND ), getLayerColor( layerid ) );
Append( GetLayerName( layerid ), bmp, (void*)(intptr_t) layerid );
Append( getLayerName( layerid ), bmp, (void*)(intptr_t) layerid );
}
// Ensure the width of the widget is enough to show the text and the icon
@ -65,7 +65,7 @@ void GBR_LAYER_BOX_SELECTOR::Resync()
// Returns a color index from the layer id
COLOR4D GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayer ) const
COLOR4D GBR_LAYER_BOX_SELECTOR::getLayerColor( int aLayer ) const
{
GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
@ -74,7 +74,7 @@ COLOR4D GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayer ) const
// Returns the name of the layer id
wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( int aLayer ) const
wxString GBR_LAYER_BOX_SELECTOR::getLayerName( int aLayer ) const
{
GERBER_FILE_IMAGE_LIST& images = GERBER_FILE_IMAGE_LIST::GetImagesList();
wxString name = images.GetDisplayName( aLayer );

View File

@ -46,14 +46,14 @@ public:
// Returns a color index from the layer id
// Virtual function
COLOR4D GetLayerColor( int aLayer ) const override;
COLOR4D getLayerColor( int aLayer ) const override;
// Returns true if the layer id is enabled (i.e. is it should be displayed)
// Virtual function
bool IsLayerEnabled( int aLayer ) const override { return true; }
bool isLayerEnabled( int aLayer ) const override { return true; }
// Returns the name of the layer id
wxString GetLayerName( int aLayer ) const override;
wxString getLayerName( int aLayer ) const override;
};
#endif //GBR_LAYER_BOX_SELECTOR_H

View File

@ -45,7 +45,8 @@
* Used for holding indeterminate values, such as with multiple selections
* holding different values or controls which do not wish to set a value.
*/
#define INDETERMINATE wxString( "..." )
#define INDETERMINATE_STATE _( "-- mixed values --" )
#define INDETERMINATE_ACTION _( "-- leave unchanged --" )
// PCBNew doesn't support a bold style so we want to allow text thicknesses

View File

@ -47,22 +47,20 @@ public:
{
}
// Returns a color index from the layer id
// Virtual function because GerbView uses its own functions in a derived class
virtual COLOR4D GetLayerColor( LAYER_NUM aLayer ) const = 0;
// Returns the name of the layer id
// Virtual pure function because GerbView uses its own functions in a derived class
virtual wxString GetLayerName( LAYER_NUM aLayer ) const = 0;
// Returns true if the layer id is enabled (i.e. is it should be displayed)
// Virtual function pure because GerbView uses its own functions in a derived class
virtual bool IsLayerEnabled( LAYER_NUM aLayer ) const = 0;
bool SetLayersHotkeys( bool value );
// Fills the layer bitmap aLayerbmp with the layer color
// Fills the layer bitmap aLayerbmp with the layer color
static void DrawColorSwatch( wxBitmap& aLayerbmp, COLOR4D aBackground, COLOR4D aColor );
protected:
// Returns a color index from the layer id
virtual COLOR4D getLayerColor( LAYER_NUM aLayer ) const = 0;
// Returns the name of the layer id
virtual wxString getLayerName( LAYER_NUM aLayer ) const = 0;
// Returns true if the layer id is enabled (i.e. is it should be displayed)
virtual bool isLayerEnabled( LAYER_NUM aLayer ) const = 0;
};

View File

@ -49,6 +49,9 @@ public:
void SetNetInfo( NETINFO_LIST* aNetInfoList );
// Set to wxEmptyString to disallow indeterminate settings
void SetIndeterminateString( const wxString& aString );
void SetBoard( BOARD* aBoard );
void SetSelectedNetcode( int aNetcode );
@ -63,6 +66,7 @@ protected:
void onKeyDown( wxKeyEvent& aEvt );
NET_SELECTOR_COMBOPOPUP* m_netSelectorPopup;
wxString m_indeterminateString;
};

View File

@ -89,7 +89,7 @@ public:
*/
virtual void ChangeValue( int aValue );
void ChangeValue( wxString aValue );
void ChangeValue( const wxString& aValue );
/**
* Function GetValue

View File

@ -131,7 +131,7 @@ LSET D_PAD::UnplatedHoleMask()
LSET D_PAD::ApertureMask()
{
static LSET saved = LSET( 1, F_Paste );
static LSET saved( 1, F_Paste );
return saved;
}

View File

@ -127,6 +127,7 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( PCB_
m_LayerCtrl->SetBoardFrame( m_parent );
m_LayerCtrl->SetLayersHotkeys( false );
m_LayerCtrl->SetUndefinedLayerName( INDETERMINATE_ACTION );
m_LayerCtrl->Resync();
m_grid->SetCellHighlightPenWidth( 0 );
@ -176,10 +177,10 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow()
m_footprintFilter->ChangeValue( g_footprintFilter );
m_footprintFilterOpt->SetValue( g_filterByFootprint );
m_lineWidth.SetValue( INDETERMINATE );
m_textWidth.SetValue( INDETERMINATE );
m_textHeight.SetValue( INDETERMINATE );
m_thickness.SetValue( INDETERMINATE );
m_lineWidth.SetValue( INDETERMINATE_ACTION );
m_textWidth.SetValue( INDETERMINATE_ACTION );
m_textHeight.SetValue( INDETERMINATE_ACTION );
m_thickness.SetValue( INDETERMINATE_ACTION );
m_Italic->Set3StateValue( wxCHK_UNDETERMINED );
m_keepUpright->Set3StateValue( wxCHK_UNDETERMINED );
m_Visible->Set3StateValue( wxCHK_UNDETERMINED );

View File

@ -109,6 +109,8 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 0, 5, 2, 0 );
fgSizer1->AddGrowableCol( 1 );
fgSizer1->AddGrowableCol( 4 );
fgSizer1->SetFlexibleDirection( wxBOTH );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@ -123,11 +125,11 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_
fgSizer1->Add( 0, 0, 0, wxEXPAND, 5 );
fgSizer1->Add( 100, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_Visible = new wxCheckBox( m_specifiedValues, wxID_ANY, _("Visible"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
m_Visible->SetValue(true);
fgSizer1->Add( m_Visible, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( m_Visible, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 120 );
m_lineWidthLabel = new wxStaticText( m_specifiedValues, wxID_ANY, _("Line thickness:"), wxDefaultPosition, wxDefaultSize, 0 );
m_lineWidthLabel->Wrap( -1 );
@ -178,7 +180,7 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_
fgSizer1->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 20 );
m_Italic = new wxCheckBox( m_specifiedValues, wxID_ANY, _("Italic"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
fgSizer1->Add( m_Italic, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( m_Italic, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 120 );
m_SizeYlabel = new wxStaticText( m_specifiedValues, wxID_ANY, _("Text height:"), wxDefaultPosition, wxDefaultSize, 0 );
m_SizeYlabel->Wrap( -1 );
@ -196,7 +198,7 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_
m_keepUpright = new wxCheckBox( m_specifiedValues, wxID_ANY, _("Keep upright"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
m_keepUpright->SetValue(true);
fgSizer1->Add( m_keepUpright, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
fgSizer1->Add( m_keepUpright, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 120 );
m_ThicknessLabel = new wxStaticText( m_specifiedValues, wxID_ANY, _("Text thickness:"), wxDefaultPosition, wxDefaultSize, 0 );
m_ThicknessLabel->Wrap( -1 );

View File

@ -1081,7 +1081,7 @@
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">5</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols"></property>
<property name="growablecols">1,4</property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
@ -1233,11 +1233,11 @@
<object class="spacer" expanded="0">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">100</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="border">120</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
@ -1753,7 +1753,7 @@
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="border">120</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
@ -2013,7 +2013,7 @@
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="border">120</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">

View File

@ -118,11 +118,14 @@ DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS( PCB_EDIT
buildFilterLists();
m_parent->UpdateTrackWidthSelectBox( m_trackWidthSelectBox, false );
m_trackWidthSelectBox->Append( INDETERMINATE_ACTION );
m_parent->UpdateViaSizeSelectBox( m_viaSizesSelectBox, false );
m_viaSizesSelectBox->Append( INDETERMINATE_ACTION );
m_layerBox->SetBoardFrame( m_parent );
m_layerBox->SetLayersHotkeys( false );
m_layerBox->SetNotAllowedLayerSet( LSET::AllNonCuMask() );
m_layerBox->SetUndefinedLayerName( INDETERMINATE_ACTION );
m_layerBox->Resync();
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
@ -246,6 +249,10 @@ bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow()
else if( item )
m_layerFilter->SetLayerSelection( item->GetLayer() );
m_trackWidthSelectBox->SetSelection( (int) m_trackWidthSelectBox->GetCount() - 1 );
m_viaSizesSelectBox->SetSelection( (int) m_viaSizesSelectBox->GetCount() - 1 );
m_layerBox->SetStringSelection( INDETERMINATE_ACTION );
return true;
}
@ -266,22 +273,33 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnUpdateUI( wxUpdateUIEvent& )
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoList, TRACK* aItem )
{
BOARD_DESIGN_SETTINGS& brdSettings = m_brd->GetDesignSettings();
bool isTrack = aItem->Type() == PCB_TRACE_T;
bool isVia = aItem->Type() == PCB_VIA_T;
if( m_setToSpecifiedValues->GetValue() )
{
unsigned int prevTrackWidthIndex = brdSettings.GetTrackWidthIndex();
unsigned int prevViaSizeIndex = brdSettings.GetViaSizeIndex();
if( isTrack && m_trackWidthSelectBox->GetStringSelection() != INDETERMINATE_ACTION )
{
unsigned int prevTrackWidthIndex = brdSettings.GetTrackWidthIndex();
brdSettings.SetTrackWidthIndex( (unsigned) m_trackWidthSelectBox->GetSelection() );
if( m_parent->SetTrackSegmentWidth( aItem, aUndoList, false ) == TRACK_ACTION_DRC_ERROR )
m_failedDRC = true;
brdSettings.SetTrackWidthIndex( prevTrackWidthIndex );
}
else if( isVia && m_viaSizesSelectBox->GetStringSelection() != INDETERMINATE_ACTION )
{
unsigned int prevViaSizeIndex = brdSettings.GetViaSizeIndex();
brdSettings.SetViaSizeIndex( (unsigned) m_viaSizesSelectBox->GetSelection() );
if( m_parent->SetTrackSegmentWidth( aItem, aUndoList, false ) == TRACK_ACTION_DRC_ERROR )
m_failedDRC = true;
}
brdSettings.SetTrackWidthIndex( prevTrackWidthIndex );
brdSettings.SetViaSizeIndex( prevViaSizeIndex );
if( m_layerBox->GetLayerSelection() != UNDEFINED_LAYER && aItem->Type() == PCB_TRACE_T )
brdSettings.SetViaSizeIndex( prevViaSizeIndex );
}
if( isTrack && m_layerBox->GetLayerSelection() != UNDEFINED_LAYER )
{
if( aUndoList->FindItem( aItem ) < 0 )
{

View File

@ -56,9 +56,6 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
VIATYPE viaType = VIATYPE::NOT_DEFINED;
m_netSelector->SetBoard( aParent->GetBoard() );
m_netSelector->SetNetInfo( &aParent->GetBoard()->GetNetInfo() );
m_TrackLayerCtrl->SetLayersHotkeys( false );
m_TrackLayerCtrl->SetNotAllowedLayerSet( LSET::AllNonCuMask() );
m_TrackLayerCtrl->SetBoardFrame( aParent );
@ -80,7 +77,7 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
bool hasUnlocked = false;
// Look for values that are common for every item that is selected
for( auto& item : m_items )
for( EDA_ITEM* item : m_items )
{
if( !nets )
{
@ -112,22 +109,26 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
else // check if values are the same for every selected track
{
if( m_trackStartX.GetValue() != t->GetStart().x )
m_trackStartX.SetValue( INDETERMINATE );
m_trackStartX.SetValue( INDETERMINATE_STATE );
if( m_trackStartY.GetValue() != t->GetStart().y )
m_trackStartY.SetValue( INDETERMINATE );
m_trackStartY.SetValue( INDETERMINATE_STATE );
if( m_trackEndX.GetValue() != t->GetEnd().x )
m_trackEndX.SetValue( INDETERMINATE );
m_trackEndX.SetValue( INDETERMINATE_STATE );
if( m_trackEndY.GetValue() != t->GetEnd().y )
m_trackEndY.SetValue( INDETERMINATE );
m_trackEndY.SetValue( INDETERMINATE_STATE );
if( m_trackWidth.GetValue() != t->GetWidth() )
m_trackWidth.SetValue( INDETERMINATE );
m_trackWidth.SetValue( INDETERMINATE_STATE );
if( m_TrackLayerCtrl->GetLayerSelection() != t->GetLayer() )
{
m_TrackLayerCtrl->SetUndefinedLayerName( INDETERMINATE_STATE );
m_TrackLayerCtrl->Resync();
m_TrackLayerCtrl->SetLayerSelection( UNDEFINED_LAYER );
}
}
if( t->IsLocked() )
@ -156,25 +157,33 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
else // check if values are the same for every selected via
{
if( m_viaX.GetValue() != v->GetPosition().x )
m_viaX.SetValue( INDETERMINATE );
m_viaX.SetValue( INDETERMINATE_STATE );
if( m_viaY.GetValue() != v->GetPosition().y )
m_viaY.SetValue( INDETERMINATE );
m_viaY.SetValue( INDETERMINATE_STATE );
if( m_viaDiameter.GetValue() != v->GetWidth() )
m_viaDiameter.SetValue( INDETERMINATE );
m_viaDiameter.SetValue( INDETERMINATE_STATE );
if( m_viaDrill.GetValue() != v->GetDrillValue() )
m_viaDrill.SetValue( INDETERMINATE );
m_viaDrill.SetValue( INDETERMINATE_STATE );
if( viaType != v->GetViaType() )
viaType = VIATYPE::NOT_DEFINED;
if( m_ViaStartLayer->GetLayerSelection() != v->TopLayer() )
{
m_ViaStartLayer->SetUndefinedLayerName( INDETERMINATE_STATE );
m_ViaStartLayer->Resync();
m_ViaStartLayer->SetLayerSelection( UNDEFINED_LAYER );
}
if( m_ViaEndLayer->GetLayerSelection() != v->BottomLayer() )
{
m_ViaEndLayer->SetUndefinedLayerName( INDETERMINATE_STATE );
m_ViaEndLayer->Resync();
m_ViaEndLayer->SetLayerSelection( UNDEFINED_LAYER );
}
}
if( v->IsLocked() )
@ -193,10 +202,18 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
}
}
m_netSelector->SetBoard( aParent->GetBoard() );
m_netSelector->SetNetInfo( &aParent->GetBoard()->GetNetInfo() );
if ( net >= 0 )
{
m_netSelector->SetSelectedNetcode( net );
}
else
{
m_netSelector->SetIndeterminateString( INDETERMINATE_STATE );
m_netSelector->SetIndeterminate();
}
wxASSERT( m_tracks || m_vias );

View File

@ -28,10 +28,7 @@
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <common.h>
#include <pcbnew.h>
#include <pcb_edit_frame.h>
#include <board_design_settings.h>
#include <layers_id_colors_and_visibility.h>
#include <settings/color_settings.h>
@ -45,18 +42,38 @@ static TOOL_ACTION* layer2action( PCB_LAYER_ID aLayer )
switch( aLayer )
{
case F_Cu: return &PCB_ACTIONS::layerTop;
case B_Cu: return &PCB_ACTIONS::layerBottom;
case In1_Cu: return &PCB_ACTIONS::layerInner1;
case In2_Cu: return &PCB_ACTIONS::layerInner2;
case In3_Cu: return &PCB_ACTIONS::layerInner3;
case In4_Cu: return &PCB_ACTIONS::layerInner4;
case In5_Cu: return &PCB_ACTIONS::layerInner5;
case In6_Cu: return &PCB_ACTIONS::layerInner6;
default:
return nullptr;
case In7_Cu: return &PCB_ACTIONS::layerInner7;
case In8_Cu: return &PCB_ACTIONS::layerInner8;
case In9_Cu: return &PCB_ACTIONS::layerInner9;
case In10_Cu: return &PCB_ACTIONS::layerInner10;
case In11_Cu: return &PCB_ACTIONS::layerInner11;
case In12_Cu: return &PCB_ACTIONS::layerInner12;
case In13_Cu: return &PCB_ACTIONS::layerInner13;
case In14_Cu: return &PCB_ACTIONS::layerInner14;
case In15_Cu: return &PCB_ACTIONS::layerInner15;
case In16_Cu: return &PCB_ACTIONS::layerInner16;
case In17_Cu: return &PCB_ACTIONS::layerInner17;
case In18_Cu: return &PCB_ACTIONS::layerInner18;
case In19_Cu: return &PCB_ACTIONS::layerInner19;
case In20_Cu: return &PCB_ACTIONS::layerInner20;
case In21_Cu: return &PCB_ACTIONS::layerInner21;
case In22_Cu: return &PCB_ACTIONS::layerInner22;
case In23_Cu: return &PCB_ACTIONS::layerInner23;
case In24_Cu: return &PCB_ACTIONS::layerInner24;
case In25_Cu: return &PCB_ACTIONS::layerInner25;
case In26_Cu: return &PCB_ACTIONS::layerInner26;
case In27_Cu: return &PCB_ACTIONS::layerInner27;
case In28_Cu: return &PCB_ACTIONS::layerInner28;
case In29_Cu: return &PCB_ACTIONS::layerInner29;
case In30_Cu: return &PCB_ACTIONS::layerInner30;
case B_Cu: return &PCB_ACTIONS::layerBottom;
default: return nullptr;
}
}
@ -91,9 +108,9 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
layerstatus.Empty();
wxBitmap bmp( BM_SIZE, BM_SIZE );
DrawColorSwatch( bmp, GetLayerColor( LAYER_PCB_BACKGROUND ), GetLayerColor( layerid ) );
DrawColorSwatch( bmp, getLayerColor( LAYER_PCB_BACKGROUND ), getLayerColor( layerid ) );
wxString layername = GetLayerName( layerid ) + layerstatus;
wxString layername = getLayerName( layerid ) + layerstatus;
if( m_layerhotkeys )
{
@ -110,6 +127,15 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
minwidth = std::max( minwidth, w );
}
if( !m_undefinedLayerName.IsEmpty() )
{
Append( m_undefinedLayerName, wxNullBitmap, (void*)(intptr_t)UNDEFINED_LAYER );
int w, h;
dc.GetTextExtent ( m_undefinedLayerName, &w, &h );
minwidth = std::max( minwidth, w );
}
// Approximate bitmap size and margins
minwidth += BM_SIZE + 32 + ConvertDialogToPixels( wxSize( 8, 0 ) ).x;
SetMinSize( wxSize( minwidth, -1 ) );
@ -117,11 +143,9 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
// Returns true if the layer id is enabled (i.e. is it should be displayed)
bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled( LAYER_NUM aLayer ) const
bool PCB_LAYER_BOX_SELECTOR::isLayerEnabled( LAYER_NUM aLayer ) const
{
wxASSERT( m_boardFrame != NULL );
BOARD* board = m_boardFrame->GetBoard();
wxASSERT( board != NULL );
return board->IsLayerEnabled( ToLAYER_ID( aLayer ) );
}
@ -129,16 +153,14 @@ bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled( LAYER_NUM aLayer ) const
LSET PCB_LAYER_BOX_SELECTOR::getEnabledLayers() const
{
wxASSERT( m_boardFrame != NULL );
BOARD* board = m_boardFrame->GetBoard();
wxASSERT( board != NULL );
return board->GetEnabledLayers();
}
// Returns a color index from the layer id
COLOR4D PCB_LAYER_BOX_SELECTOR::GetLayerColor( LAYER_NUM aLayer ) const
COLOR4D PCB_LAYER_BOX_SELECTOR::getLayerColor( LAYER_NUM aLayer ) const
{
wxASSERT( m_boardFrame );
@ -147,11 +169,9 @@ COLOR4D PCB_LAYER_BOX_SELECTOR::GetLayerColor( LAYER_NUM aLayer ) const
// Returns the name of the layer id
wxString PCB_LAYER_BOX_SELECTOR::GetLayerName( LAYER_NUM aLayer ) const
wxString PCB_LAYER_BOX_SELECTOR::getLayerName( LAYER_NUM aLayer ) const
{
wxASSERT( m_boardFrame );
BOARD* board = m_boardFrame->GetBoard();
wxASSERT( board );
return board->GetLayerName( ToLAYER_ID( aLayer ) );
}

View File

@ -36,17 +36,17 @@ class PCB_LAYER_BOX_SELECTOR : public LAYER_BOX_SELECTOR
{
PCB_BASE_FRAME* m_boardFrame;
LSET m_layerMaskDisable; // A mask to remove some (not allowed) layers
// from layer list
bool m_showNotEnabledBrdlayers; // true to list all allowed layers
// (with not activated layers flagged)
LSET m_layerMaskDisable; // A mask to remove some (not allowed) layers
// from layer list
bool m_showNotEnabledBrdlayers; // true to list all allowed layers
// (with not activated layers flagged)
wxString m_undefinedLayerName; // if not empty add an item with this name which sets
// the layer to UNDEFINED_LAYER
public:
// If you are thinking the constructor is a bit curious,
// just remember it is used by automatically generated by wxFormBuilder files,
// and it should mimic the wxBitmapComboBox constructor.
// Therefore, value, style are not yet used,
// but they are here for compatibility
// If you are thinking the constructor is a bit curious, just remember it is automatically
// generated when used in wxFormBuilder files, and so must have the same signature as the
// wxBitmapComboBox constructor. In particular, value and style are not used by this class.
PCB_LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
@ -58,41 +58,34 @@ public:
m_showNotEnabledBrdlayers = false;
}
// Accessors
// SetBoardFrame should be called after creating a PCB_LAYER_BOX_SELECTOR
// It is not passed through the constructor because when using wxFormBuilder
// we should use a constructor compatible with a wxBitmapComboBox
// SetBoardFrame should be called after creating a PCB_LAYER_BOX_SELECTOR. It is not passed
// through the constructor because it must have the same signature as wxBitmapComboBox for
// use with wxFormBuilder.
void SetBoardFrame( PCB_BASE_FRAME* aFrame ) { m_boardFrame = aFrame; };
// SetLayerSet allows disableing some layers, which are not
// shown in list
// SetLayerSet allows disableing some layers, which are not shown in list
void SetNotAllowedLayerSet( LSET aMask ) { m_layerMaskDisable = aMask; }
// If the UNDEFINED_LAYER should be selectable, give it a name here. Usually either
// INDETERMINATE_STATE or INDETERMINATE_ACTION.
void SetUndefinedLayerName( const wxString& aName ) { m_undefinedLayerName = aName; }
// Reload the Layers names and bitmaps
// Virtual function
void Resync() override;
// Allow (or not) the layers not activated for the current board to be shown
// in layer selector. Not actavated layers are flagged
// ( "(not activated)" added to the layer name )
void ShowNonActivatedLayers( bool aShow )
{
m_showNotEnabledBrdlayers = aShow;
}
// Allow (or not) the layers not activated for the current board to be shown in layer
// selector. Not actavated layers have their names appended with "(not activated)".
void ShowNonActivatedLayers( bool aShow ) { m_showNotEnabledBrdlayers = aShow; }
private:
// Returns a color index from the layer id
// Virtual function
COLOR4D GetLayerColor( LAYER_NUM aLayer ) const override;
COLOR4D getLayerColor( LAYER_NUM aLayer ) const override;
// Returns true if the layer id is enabled (i.e. is it should be displayed)
// Virtual function
bool IsLayerEnabled( LAYER_NUM aLayer ) const override;
// Returns true if the layer id is enabled (i.e. if it should be displayed)
bool isLayerEnabled( LAYER_NUM aLayer ) const override;
// Returns the name of the layer id
// Virtual function
wxString GetLayerName( LAYER_NUM aLayer ) const override;
wxString getLayerName( LAYER_NUM aLayer ) const override;
LSET getEnabledLayers() const;
};

View File

@ -55,20 +55,20 @@ protected:
PCB_BASE_FRAME* m_frame;
// Returns true if the layer id is enabled (i.e. is it should be displayed)
bool IsLayerEnabled( LAYER_NUM aLayer ) const override
bool isLayerEnabled( LAYER_NUM aLayer ) const override
{
return m_frame->GetBoard()->IsLayerEnabled( PCB_LAYER_ID( aLayer ) );
}
// Returns a color index from the layer id
// Virtual function
COLOR4D GetLayerColor( LAYER_NUM aLayer ) const override
COLOR4D getLayerColor( LAYER_NUM aLayer ) const override
{
return m_frame->ColorSettings()->GetColor( aLayer );
}
// Returns the name of the layer id
wxString GetLayerName( LAYER_NUM aLayer ) const override
wxString getLayerName( LAYER_NUM aLayer ) const override
{
return m_frame->GetBoard()->GetLayerName( ToLAYER_ID( aLayer ) );
}
@ -127,7 +127,7 @@ PCB_ONE_LAYER_SELECTOR::PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD*
void PCB_ONE_LAYER_SELECTOR::buildList()
{
wxColour bg = GetLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
wxColour bg = getLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
int left_row = 0;
int right_row = 0;
wxString layername;
@ -139,12 +139,12 @@ void PCB_ONE_LAYER_SELECTOR::buildList()
if( m_notAllowedLayersMask[layerid] )
continue;
wxColour fg = GetLayerColor( layerid ).ToColour();
wxColour fg = getLayerColor( layerid ).ToColour();
wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
layername = wxT( " " ) + GetLayerName( layerid );
layername = wxT( " " ) + getLayerName( layerid );
if( IsCopperLayer( layerid ) )
{
@ -305,7 +305,7 @@ SELECT_COPPER_LAYERS_PAIR_DIALOG::SELECT_COPPER_LAYERS_PAIR_DIALOG(
void SELECT_COPPER_LAYERS_PAIR_DIALOG::buildList()
{
wxColour bg = GetLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
wxColour bg = getLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
int row = 0;
wxString layername;
@ -316,12 +316,12 @@ void SELECT_COPPER_LAYERS_PAIR_DIALOG::buildList()
if( !IsCopperLayer( layerid ) )
continue;
wxColour fg = GetLayerColor( layerid ).ToColour();
wxColour fg = getLayerColor( layerid ).ToColour();
wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
layername = wxT( " " ) + GetLayerName( layerid );
layername = wxT( " " ) + getLayerName( layerid );
if( row )
m_leftGridLayers->AppendRows( 1 );