Divorce UNIT_BINDER from wxFrame.

This allows us to supply Pcbnew or Eeschema as the unitsProvider when
called from the main frame.

Fixes https://gitlab.com/kicad/code/kicad/issues/13066
This commit is contained in:
Jeff Young 2022-12-03 19:31:41 +00:00
parent f9b3f14dfa
commit f805fd267f
13 changed files with 151 additions and 152 deletions

View File

@ -51,7 +51,7 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
m_boardAdapter(),
m_currentCamera( m_trackBallCamera ),
m_trackBallCamera( 2 * RANGE_SCALE_3D ),
m_boardThickness( aFrame, aFrame->GetIuScale(), nullptr, m_boardThicknessCtrl, m_boardThicknessUnits )
m_boardThickness( aFrame, nullptr, m_boardThicknessCtrl, m_boardThicknessUnits )
{
m_userUnits = aFrame->GetUserUnits();

View File

@ -26,8 +26,6 @@
#include <wx/clipbrd.h>
#include <wx/stattext.h>
#include <wx/textentry.h>
#include <limits>
#include <base_units.h>
#include <eda_units.h>
#include <eda_draw_frame.h>
#include <confirm.h>
@ -40,30 +38,30 @@ wxDEFINE_EVENT( DELAY_FOCUS, wxCommandEvent );
UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, wxStaticText* aLabel, wxWindow* aValueCtrl,
wxStaticText* aUnitLabel, bool allowEval, bool aBindFrameEvents ) :
UNIT_BINDER( aParent, aParent->GetIuScale(), aLabel, aValueCtrl, aUnitLabel, allowEval,
aBindFrameEvents )
UNIT_BINDER( aParent, aParent, aLabel, aValueCtrl, aUnitLabel, allowEval, aBindFrameEvents )
{
}
UNIT_BINDER::UNIT_BINDER( EDA_BASE_FRAME* aParent, const EDA_IU_SCALE& aIUScale,
wxStaticText* aLabel, wxWindow* aValueCtrl,
wxStaticText* aUnitLabel, bool allowEval, bool aBindFocusEvent ) :
m_frame( aParent ),
UNIT_BINDER::UNIT_BINDER( UNITS_PROVIDER* aUnitsProvider, wxWindow* aEventSource,
wxStaticText* aLabel, wxWindow* aValueCtrl, wxStaticText* aUnitLabel,
bool aAllowEval, bool aBindFocusEvent ) :
m_unitsProvider( aUnitsProvider ),
m_eventSource( aEventSource ),
m_bindFocusEvent( aBindFocusEvent ),
m_label( aLabel ),
m_valueCtrl( aValueCtrl ),
m_unitLabel( aUnitLabel ),
m_iuScale( aIUScale ),
m_iuScale( m_unitsProvider->GetIuScale() ),
m_negativeZero( false ),
m_dataType( EDA_DATA_TYPE::DISTANCE ),
m_precision( 0 ),
m_eval( aParent->GetUserUnits() ),
m_eval( m_unitsProvider->GetUserUnits() ),
m_unitsInValue( false ),
m_originTransforms( aParent->GetOriginTransforms() ),
m_originTransforms( aUnitsProvider->GetOriginTransforms() ),
m_coordType( ORIGIN_TRANSFORMS::NOT_A_COORD )
{
init();
m_allowEval = allowEval && ( !m_valueCtrl || dynamic_cast<wxTextEntry*>( m_valueCtrl ) );
m_allowEval = aAllowEval && ( !m_valueCtrl || dynamic_cast<wxTextEntry*>( m_valueCtrl ) );
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_valueCtrl );
if( textEntry )
@ -84,8 +82,8 @@ UNIT_BINDER::UNIT_BINDER( EDA_BASE_FRAME* aParent, const EDA_IU_SCALE& aIUScale,
nullptr, this );
m_valueCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ),
nullptr, this );
m_valueCtrl->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( UNIT_BINDER::onClick ), nullptr,
this );
m_valueCtrl->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( UNIT_BINDER::onClick ),
nullptr, this );
}
if( m_bindFocusEvent )
@ -94,21 +92,33 @@ UNIT_BINDER::UNIT_BINDER( EDA_BASE_FRAME* aParent, const EDA_IU_SCALE& aIUScale,
this );
}
m_frame->Connect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ),
nullptr, this );
if( m_eventSource )
{
m_eventSource->Connect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ),
nullptr, this );
}
}
UNIT_BINDER::~UNIT_BINDER()
{
m_frame->Disconnect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ),
nullptr, this );
if( m_bindFocusEvent )
{
Disconnect( DELAY_FOCUS, wxCommandEventHandler( UNIT_BINDER::delayedFocusHandler ), nullptr,
this );
}
if( m_eventSource )
{
m_eventSource->Disconnect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ),
nullptr, this );
}
}
void UNIT_BINDER::init()
{
m_units = m_frame->GetUserUnits();
m_units = m_unitsProvider->GetUserUnits();
m_needsEval = false;
m_selStart = 0;
m_selEnd = 0;
@ -149,7 +159,7 @@ void UNIT_BINDER::onUnitsChanged( wxCommandEvent& aEvent )
{
int temp = (int) GetValue();
SetUnits( m_frame->GetUserUnits() );
SetUnits( m_unitsProvider->GetUserUnits() );
SetValue( temp );
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2020 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
@ -30,10 +30,11 @@
PANEL_EESCHEMA_EDITING_OPTIONS::PANEL_EESCHEMA_EDITING_OPTIONS( wxWindow* aWindow,
EDA_BASE_FRAME* aUnitsProvider ) :
UNITS_PROVIDER* aUnitsProvider,
wxWindow* aEventSource ) :
PANEL_EESCHEMA_EDITING_OPTIONS_BASE( aWindow ),
m_hPitch( aUnitsProvider, schIUScale, m_hPitchLabel, m_hPitchCtrl, m_hPitchUnits ),
m_vPitch( aUnitsProvider, schIUScale, m_vPitchLabel, m_vPitchCtrl, m_vPitchUnits )
m_hPitch( aUnitsProvider, aEventSource, m_hPitchLabel, m_hPitchCtrl, m_hPitchUnits ),
m_vPitch( aUnitsProvider, aEventSource, m_vPitchLabel, m_vPitchCtrl, m_vPitchUnits )
{
// Make the color swatch show "Clear Color" instead
m_borderColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017-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 as published by the
@ -29,7 +29,8 @@ class EDA_DRAW_FRAME;
class PANEL_EESCHEMA_EDITING_OPTIONS : public PANEL_EESCHEMA_EDITING_OPTIONS_BASE
{
public:
PANEL_EESCHEMA_EDITING_OPTIONS( wxWindow* aWindow, EDA_BASE_FRAME* aUnitsProvider );
PANEL_EESCHEMA_EDITING_OPTIONS( wxWindow* aWindow, UNITS_PROVIDER* aUnitsProvider,
wxWindow* aEventSource );
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;

View File

@ -30,13 +30,14 @@
PANEL_SYM_EDITING_OPTIONS::PANEL_SYM_EDITING_OPTIONS( wxWindow* aWindow,
EDA_BASE_FRAME* aUnitsProvider ) :
UNITS_PROVIDER* aUnitsProvider,
wxWindow* aEventSource ) :
PANEL_SYM_EDITING_OPTIONS_BASE( aWindow ),
m_lineWidth( aUnitsProvider, schIUScale, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ),
m_textSize( aUnitsProvider, schIUScale, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits ),
m_pinLength( aUnitsProvider, schIUScale, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits ),
m_pinNameSize( aUnitsProvider, schIUScale ,m_pinNameSizeLabel, m_pinNameSizeCtrl, m_pinNameSizeUnits ),
m_pinNumberSize( aUnitsProvider, schIUScale, m_pinNumSizeLabel, m_pinNumSizeCtrl, m_pinNumSizeUnits )
m_lineWidth( aUnitsProvider, aEventSource, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ),
m_textSize( aUnitsProvider, aEventSource, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits ),
m_pinLength( aUnitsProvider, aEventSource, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits ),
m_pinNameSize( aUnitsProvider, aEventSource ,m_pinNameSizeLabel, m_pinNameSizeCtrl, m_pinNameSizeUnits ),
m_pinNumberSize( aUnitsProvider, aEventSource, m_pinNumSizeLabel, m_pinNumSizeCtrl, m_pinNumSizeUnits )
{
m_widthHelpText->SetFont( KIUI::GetInfoFont( this ).Italic() );
}

View File

@ -29,7 +29,8 @@ class EDA_DRAW_FRAME;
class PANEL_SYM_EDITING_OPTIONS : public PANEL_SYM_EDITING_OPTIONS_BASE
{
public:
PANEL_SYM_EDITING_OPTIONS( wxWindow* aWindow, EDA_BASE_FRAME* aUnitsProvider );
PANEL_SYM_EDITING_OPTIONS( wxWindow* aWindow, UNITS_PROVIDER* aUnitsProvider,
wxWindow* aEventSource );
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;

View File

@ -123,12 +123,13 @@ bool generateSchematicNetlist( const wxString& aFilename, wxString& aNetlist )
}
static struct IFACE : public KIFACE_BASE
static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
{
// Of course all are virtual overloads, implementations of the KIFACE.
IFACE( const char* aName, KIWAY::FACE_T aType ) :
KIFACE_BASE( aName, aType )
KIFACE_BASE( aName, aType ),
UNITS_PROVIDER( schIUScale, EDA_UNITS::MILLIMETRES )
{}
bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
@ -191,29 +192,18 @@ static struct IFACE : public KIFACE_BASE
case PANEL_SYM_EDIT_OPTIONS:
{
EDA_BASE_FRAME* unitsProvider = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
if( !unitsProvider )
unitsProvider = aKiway->Player( FRAME_SCH_VIEWER, false );
if( !frame )
frame = aKiway->Player( FRAME_SCH_VIEWER, false );
if( !unitsProvider )
unitsProvider = aKiway->Player( FRAME_SCH, false );
if( !frame )
frame = aKiway->Player( FRAME_SCH, false );
if( !unitsProvider )
{
// If we can't find an eeschema unitsProvider we'll have to make do with the units
// defined in whatever FRAME we _can_ find.
for( unsigned i = 0; !unitsProvider && i < KIWAY_PLAYER_COUNT; ++i )
unitsProvider = aKiway->Player( (FRAME_T) i, false );
}
if( !unitsProvider )
{
wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME );
unitsProvider = static_cast<EDA_BASE_FRAME*>( manager );
}
return new PANEL_SYM_EDITING_OPTIONS( aParent, unitsProvider );
if( frame )
return new PANEL_SYM_EDITING_OPTIONS( aParent, frame, frame );
else
return new PANEL_SYM_EDITING_OPTIONS( aParent, this, nullptr );
}
case PANEL_SYM_COLORS:
@ -229,29 +219,18 @@ static struct IFACE : public KIFACE_BASE
case PANEL_SCH_EDIT_OPTIONS:
{
EDA_BASE_FRAME* unitsProvider = aKiway->Player( FRAME_SCH, false );
EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
if( !unitsProvider )
unitsProvider = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
if( !frame )
frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
if( !unitsProvider )
unitsProvider = aKiway->Player( FRAME_SCH_VIEWER, false );
if( !frame )
frame = aKiway->Player( FRAME_SCH_VIEWER, false );
if( !unitsProvider )
{
// If we can't find an eeschema frame we'll have to make do with the units
// defined in whatever FRAME we _can_ find.
for( unsigned i = 0; !unitsProvider && i < KIWAY_PLAYER_COUNT; ++i )
unitsProvider = aKiway->Player( (FRAME_T) i, false );
}
if( !unitsProvider )
{
wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME );
unitsProvider = static_cast<EDA_BASE_FRAME*>( manager );
}
return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, unitsProvider );
if( frame )
return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, frame, frame );
else
return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, this, nullptr );
}
case PANEL_SCH_ANNO_OPTIONS:

View File

@ -127,7 +127,10 @@ public:
/**
* Return a reference to the default ORIGIN_TRANSFORMS object
*/
virtual ORIGIN_TRANSFORMS& GetOriginTransforms() { return m_originTransforms; }
ORIGIN_TRANSFORMS& GetOriginTransforms() override
{
return m_originTransforms;
}
SETTINGS_MANAGER* GetSettingsManager() const { return m_settingsManager; }

View File

@ -25,6 +25,8 @@
#define UNITS_PROVIDER_H
#include <eda_units.h>
#include <origin_transforms.h>
class UNITS_PROVIDER
{
@ -40,6 +42,13 @@ public:
const EDA_IU_SCALE& GetIuScale() const { return m_iuScale; }
// No SetIuScale(); scale is invariant
virtual ORIGIN_TRANSFORMS& GetOriginTransforms()
{
static ORIGIN_TRANSFORMS identityTransform;
return identityTransform;
}
/**
* Converts \a aValue in internal units into a united string.
*

View File

@ -27,7 +27,7 @@
#define __UNIT_BINDER_H_
#include <base_units.h>
#include <origin_transforms.h>
#include <units_provider.h>
#include <libeval/numeric_evaluator.h>
#include <wx/event.h>
@ -47,18 +47,19 @@ public:
* @param aLabel is the static text used to label the text input widget (note: the label
* text, trimmed of its colon, will also be used in error messages)
* @param aValueCtrl is the control used to edit or display the given value (wxTextCtrl,
* wxComboBox, wxStaticText, etc.).
* @param aUnitLabel is the units label displayed after the text input widget
* Can be nullptr.
* wxComboBox, wxStaticText, etc.).
* @param aUnitLabel (optional) is the units label displayed after the text input widget
* @param aAllowEval indicates \a aTextInput's content should be eval'ed before storing
* @param aBindFocusEvent indicates the control should respond to DELAY_FOCUS from the
* parent frame
*/
UNIT_BINDER( EDA_DRAW_FRAME* aParent,
wxStaticText* aLabel, wxWindow* aValueCtrl, wxStaticText* aUnitLabel,
bool aAllowEval = true, bool aBindFocusEvent = true );
UNIT_BINDER( EDA_BASE_FRAME* aParent, const EDA_IU_SCALE& aIUScale, wxStaticText* aLabel,
wxWindow* aValueCtrl, wxStaticText* aUnitLabel, bool aAllowEval = true,
bool aBindFocusEvent = true );
UNIT_BINDER( UNITS_PROVIDER* aUnitsProvider, wxWindow* aEventSource,
wxStaticText* aLabel, wxWindow* aValueCtrl, wxStaticText* aUnitLabel,
bool aAllowEval = true, bool aBindFocusEvent = true );
virtual ~UNIT_BINDER() override;
@ -220,34 +221,36 @@ protected:
*/
double setPrecision( double aValue, bool aValueUsesUserUnits );
EDA_BASE_FRAME* m_frame;
bool m_bindFocusEvent;
protected:
UNITS_PROVIDER* m_unitsProvider;
wxWindow* m_eventSource;
bool m_bindFocusEvent;
///< The bound widgets
wxStaticText* m_label;
wxWindow* m_valueCtrl;
wxStaticText* m_unitLabel; ///< Can be nullptr
wxStaticText* m_label;
wxWindow* m_valueCtrl;
wxStaticText* m_unitLabel; ///< Can be nullptr
///< Currently used units.
const EDA_IU_SCALE& m_iuScale;
EDA_UNITS m_units;
bool m_negativeZero; ///< Indicates "-0" should be displayed for 0.
EDA_DATA_TYPE m_dataType;
int m_precision; ///< 0 to 6
EDA_UNITS m_units;
bool m_negativeZero; ///< Indicates "-0" should be displayed for 0.
EDA_DATA_TYPE m_dataType;
int m_precision; ///< 0 to 6
wxString m_errorMessage;
wxString m_errorMessage;
NUMERIC_EVALUATOR m_eval;
bool m_allowEval;
bool m_needsEval;
NUMERIC_EVALUATOR m_eval;
bool m_allowEval;
bool m_needsEval;
long m_selStart; ///< Selection start and end of the original text
long m_selEnd;
long m_selStart; ///< Selection start and end of the original text
long m_selEnd;
bool m_unitsInValue; ///< Units label should be included in value text
bool m_unitsInValue; ///< Units label should be included in value text
/// A reference to an ORIGIN_TRANSFORMS object
ORIGIN_TRANSFORMS& m_originTransforms;
ORIGIN_TRANSFORMS& m_originTransforms;
/// Type of coordinate for display origin transforms
ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* 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
@ -30,11 +30,11 @@
#include <panel_edit_options.h>
PANEL_EDIT_OPTIONS::PANEL_EDIT_OPTIONS( wxWindow* aParent, EDA_BASE_FRAME* aUnitsProvider,
bool isFootprintEditor ) :
PANEL_EDIT_OPTIONS::PANEL_EDIT_OPTIONS( wxWindow* aParent, UNITS_PROVIDER* aUnitsProvider,
wxWindow* aEventSource, bool isFootprintEditor ) :
PANEL_EDIT_OPTIONS_BASE( aParent ),
m_isFootprintEditor( isFootprintEditor ),
m_rotationAngle( aUnitsProvider, pcbIUScale, m_rotationAngleLabel, m_rotationAngleCtrl,
m_rotationAngle( aUnitsProvider, aEventSource, m_rotationAngleLabel, m_rotationAngleCtrl,
m_rotationAngleUnits )
{
m_magneticPads->Show( m_isFootprintEditor );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010-2014 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
@ -37,7 +37,8 @@ class EDA_BASE_FRAME;
class PANEL_EDIT_OPTIONS : public PANEL_EDIT_OPTIONS_BASE
{
public:
PANEL_EDIT_OPTIONS( wxWindow* aParent, EDA_BASE_FRAME* aUnitsProvider, bool isFootprintEditor );
PANEL_EDIT_OPTIONS( wxWindow* aParent, UNITS_PROVIDER* aUnitsProvider, wxWindow* aEventSource,
bool isFootprintEditor );
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;

View File

@ -69,12 +69,13 @@ extern "C" PyObject* PyInit__pcbnew( void );
namespace PCB {
static struct IFACE : public KIFACE_BASE
static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
{
// Of course all are virtual overloads, implementations of the KIFACE.
IFACE( const char* aName, KIWAY::FACE_T aType ) :
KIFACE_BASE( aName, aType )
KIFACE_BASE( aName, aType ),
UNITS_PROVIDER( pcbIUScale, EDA_UNITS::MILLIMETRES )
{}
bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
@ -146,35 +147,35 @@ static struct IFACE : public KIFACE_BASE
}
case PANEL_FP_EDIT_OPTIONS:
{
EDA_BASE_FRAME* frame = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
if( !frame )
frame = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
if( !frame )
frame = aKiway->Player( FRAME_PCB_EDITOR, false );
if( frame )
return new PANEL_EDIT_OPTIONS( aParent, frame, frame, true );
else
return new PANEL_EDIT_OPTIONS( aParent, this, nullptr, true );
}
case PANEL_FP_DEFAULT_VALUES:
{
EDA_BASE_FRAME* unitsProvider = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
EDA_BASE_FRAME* frame = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
if( !unitsProvider )
unitsProvider = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
if( !frame )
frame = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
if( !unitsProvider )
unitsProvider = aKiway->Player( FRAME_PCB_EDITOR, false );
if( !frame )
frame = aKiway->Player( FRAME_PCB_EDITOR, false );
if( !unitsProvider )
{
// If we can't find a pcb-type frame we'll have to make do with whatever FRAME
// we _can_ find.
for( unsigned i = 0; !unitsProvider && i < KIWAY_PLAYER_COUNT; ++i )
unitsProvider = aKiway->Player( (FRAME_T) i, false );
}
if( !unitsProvider )
{
wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME );
unitsProvider = static_cast<EDA_BASE_FRAME*>( manager );
wxASSERT( unitsProvider );
}
if( aClassId == PANEL_FP_EDIT_OPTIONS )
return new PANEL_EDIT_OPTIONS( aParent, unitsProvider, true );
if( frame )
return new PANEL_FP_EDITOR_DEFAULTS( aParent, frame );
else
return new PANEL_FP_EDITOR_DEFAULTS( aParent, unitsProvider );
return new PANEL_FP_EDITOR_DEFAULTS( aParent, this );
}
case PANEL_FP_COLORS:
@ -190,29 +191,18 @@ static struct IFACE : public KIFACE_BASE
case PANEL_PCB_EDIT_OPTIONS:
{
EDA_BASE_FRAME* unitsProvider = aKiway->Player( FRAME_PCB_EDITOR, false );
EDA_BASE_FRAME* frame = aKiway->Player( FRAME_PCB_EDITOR, false );
if( !unitsProvider )
unitsProvider = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
if( !frame )
frame = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
if( !unitsProvider )
unitsProvider = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
if( !frame )
frame = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
if( !unitsProvider )
{
// If we can't find an eeschema frame we'll have to make do with the units
// defined in whatever FRAME we _can_ find.
for( unsigned i = 0; !unitsProvider && i < KIWAY_PLAYER_COUNT; ++i )
unitsProvider = aKiway->Player( (FRAME_T) i, false );
}
if( !unitsProvider )
{
wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME );
unitsProvider = static_cast<EDA_BASE_FRAME*>( manager );
}
return new PANEL_EDIT_OPTIONS( aParent, unitsProvider, false );
if( frame )
return new PANEL_EDIT_OPTIONS( aParent, frame, frame, false );
else
return new PANEL_EDIT_OPTIONS( aParent, this, nullptr, false );
}
case PANEL_PCB_COLORS: