Fix a few (minor) issues:
- Make DIALOG_SHIM::SetPosition working) - rename PCB_BASE_FRAME::SelectLayer() to PCB_BASE_FRAME::SelectOneLayer() - PCB_BASE_FRAME::SelectOneLayer(): make dismiss dialog by escape key working. Fixes #7578 https://gitlab.com/kicad/code/kicad/issues/7578
This commit is contained in:
parent
34c2028e7b
commit
5d2dc0b50e
|
@ -183,6 +183,36 @@ int DIALOG_SHIM::vertPixelsFromDU( int y ) const
|
||||||
|
|
||||||
static RECT_MAP class_map;
|
static RECT_MAP class_map;
|
||||||
|
|
||||||
|
|
||||||
|
void DIALOG_SHIM::SetPosition( const wxPoint& aNewPosition )
|
||||||
|
{
|
||||||
|
wxDialog::SetPosition( aNewPosition );
|
||||||
|
|
||||||
|
// Now update the stored position:
|
||||||
|
const char* hash_key;
|
||||||
|
|
||||||
|
if( m_hash_key.size() )
|
||||||
|
{
|
||||||
|
// a special case like EDA_LIST_DIALOG, which has multiple uses.
|
||||||
|
hash_key = m_hash_key.c_str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hash_key = typeid(*this).name();
|
||||||
|
}
|
||||||
|
|
||||||
|
RECT_MAP::iterator it = class_map.find( hash_key );
|
||||||
|
|
||||||
|
if( it == class_map.end() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
EDA_RECT rect = it->second;
|
||||||
|
rect.SetOrigin( aNewPosition );
|
||||||
|
|
||||||
|
class_map[ hash_key ] = rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DIALOG_SHIM::Show( bool show )
|
bool DIALOG_SHIM::Show( bool show )
|
||||||
{
|
{
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
|
@ -112,6 +112,11 @@ public:
|
||||||
|
|
||||||
void OnPaint( wxPaintEvent &event );
|
void OnPaint( wxPaintEvent &event );
|
||||||
|
|
||||||
|
/** Force the position of the dialog to a new position
|
||||||
|
* @param aNewPosition is the new forced position
|
||||||
|
*/
|
||||||
|
void SetPosition( const wxPoint& aNewPosition );
|
||||||
|
|
||||||
EDA_UNITS GetUserUnits() const
|
EDA_UNITS GetUserUnits() const
|
||||||
{
|
{
|
||||||
return m_units;
|
return m_units;
|
||||||
|
|
|
@ -328,16 +328,16 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the dialog box for layer selection.
|
* Show the dialog box for a layer selection.
|
||||||
*
|
*
|
||||||
* @param aDefaultLayer is the default layer to select. Use #NB_PCB_LAYERS if no selection
|
* @param aDefaultLayer is the default layer to select. Use UNDEFINED_LAYER if no selection
|
||||||
* is desired.
|
* is desired.
|
||||||
* @param aNotAllowedLayersMask is a layer mask for not allowed layers. Use 0 to show all
|
* @param aNotAllowedLayersMask is a layer mask for not allowed layers. Use 0 to show all
|
||||||
* layers in use.
|
* layers in use.
|
||||||
* @param aDlgPosition is the position of dialog (default is centered).
|
* @param aDlgPosition is the position of dialog (default is centered).
|
||||||
* @return the selected layer id.
|
* @return the selected layer id.
|
||||||
*/
|
*/
|
||||||
PCB_LAYER_ID SelectLayer( PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask = LSET(),
|
PCB_LAYER_ID SelectOneLayer( PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask = LSET(),
|
||||||
wxPoint aDlgPosition = wxDefaultPosition );
|
wxPoint aDlgPosition = wxDefaultPosition );
|
||||||
|
|
||||||
virtual void SwitchLayer( wxDC* DC, PCB_LAYER_ID layer );
|
virtual void SwitchLayer( wxDC* DC, PCB_LAYER_ID layer );
|
||||||
|
|
|
@ -753,10 +753,8 @@ int ROUTER_TOOL::handleLayerSwitch( const TOOL_EVENT& aEvent, bool aForceVia )
|
||||||
wxPoint endPoint = (wxPoint) view()->ToScreen( m_endSnapPoint );
|
wxPoint endPoint = (wxPoint) view()->ToScreen( m_endSnapPoint );
|
||||||
endPoint = frame()->GetCanvas()->ClientToScreen( endPoint );
|
endPoint = frame()->GetCanvas()->ClientToScreen( endPoint );
|
||||||
|
|
||||||
controls()->WarpCursor( endPoint );
|
targetLayer = frame()->SelectOneLayer( static_cast<PCB_LAYER_ID>( currentLayer ),
|
||||||
|
LSET::AllNonCuMask(), endPoint );
|
||||||
targetLayer = frame()->SelectLayer( static_cast<PCB_LAYER_ID>( currentLayer ),
|
|
||||||
LSET::AllNonCuMask(), endPoint );
|
|
||||||
|
|
||||||
// Reset the cursor to the end of the track
|
// Reset the cursor to the end of the track
|
||||||
controls()->SetCursorPosition( m_endSnapPoint );
|
controls()->SetCursorPosition( m_endSnapPoint );
|
||||||
|
|
|
@ -89,6 +89,7 @@ class PCB_ONE_LAYER_SELECTOR : public PCB_LAYER_SELECTOR,
|
||||||
public:
|
public:
|
||||||
PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD * aBrd, PCB_LAYER_ID aDefaultLayer,
|
PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD * aBrd, PCB_LAYER_ID aDefaultLayer,
|
||||||
LSET aNotAllowedLayersMask );
|
LSET aNotAllowedLayersMask );
|
||||||
|
~PCB_ONE_LAYER_SELECTOR();
|
||||||
|
|
||||||
LAYER_NUM GetLayerSelection() { return m_layerSelected; }
|
LAYER_NUM GetLayerSelection() { return m_layerSelected; }
|
||||||
|
|
||||||
|
@ -97,6 +98,9 @@ private:
|
||||||
void OnLeftGridCellClick( wxGridEvent& event ) override;
|
void OnLeftGridCellClick( wxGridEvent& event ) override;
|
||||||
void OnRightGridCellClick( wxGridEvent& event ) override;
|
void OnRightGridCellClick( wxGridEvent& event ) override;
|
||||||
|
|
||||||
|
// Will close the dialog on ESC key
|
||||||
|
void onCharHook( wxKeyEvent& event );
|
||||||
|
|
||||||
void buildList();
|
void buildList();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,12 +123,27 @@ PCB_ONE_LAYER_SELECTOR::PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD*
|
||||||
m_rightGridLayers->SetColFormatBool( SELECT_COLNUM );
|
m_rightGridLayers->SetColFormatBool( SELECT_COLNUM );
|
||||||
buildList();
|
buildList();
|
||||||
|
|
||||||
|
Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
GetSizer()->SetSizeHints( this );
|
GetSizer()->SetSizeHints( this );
|
||||||
SetFocus();
|
SetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCB_ONE_LAYER_SELECTOR::~PCB_ONE_LAYER_SELECTOR()
|
||||||
|
{
|
||||||
|
Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_ONE_LAYER_SELECTOR::onCharHook( wxKeyEvent& event )
|
||||||
|
{
|
||||||
|
if( event.GetKeyCode() == WXK_ESCAPE )
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_ONE_LAYER_SELECTOR::buildList()
|
void PCB_ONE_LAYER_SELECTOR::buildList()
|
||||||
{
|
{
|
||||||
wxColour bg = getLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
|
wxColour bg = getLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
|
||||||
|
@ -203,8 +222,9 @@ void PCB_ONE_LAYER_SELECTOR::OnRightGridCellClick( wxGridEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PCB_LAYER_ID PCB_BASE_FRAME::SelectLayer( PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask,
|
PCB_LAYER_ID PCB_BASE_FRAME::SelectOneLayer( PCB_LAYER_ID aDefaultLayer,
|
||||||
wxPoint aDlgPosition )
|
LSET aNotAllowedLayersMask,
|
||||||
|
wxPoint aDlgPosition )
|
||||||
{
|
{
|
||||||
PCB_ONE_LAYER_SELECTOR dlg( this, GetBoard(), aDefaultLayer, aNotAllowedLayersMask );
|
PCB_ONE_LAYER_SELECTOR dlg( this, GetBoard(), aDefaultLayer, aNotAllowedLayersMask );
|
||||||
|
|
||||||
|
|
|
@ -537,7 +537,7 @@ int CONVERT_TOOL::PolyToLines( const TOOL_EVENT& aEvent )
|
||||||
BOARD_ITEM_CONTAINER* parent = frame->GetModel();
|
BOARD_ITEM_CONTAINER* parent = frame->GetModel();
|
||||||
|
|
||||||
if( !IsCopperLayer( layer ) )
|
if( !IsCopperLayer( layer ) )
|
||||||
layer = frame->SelectLayer( F_Cu, LSET::AllNonCuMask() );
|
layer = frame->SelectOneLayer( F_Cu, LSET::AllNonCuMask() );
|
||||||
|
|
||||||
// I am really unsure converting a polygon to "tracks" (i.e. segments on
|
// I am really unsure converting a polygon to "tracks" (i.e. segments on
|
||||||
// copper layers) make sense for footprints, but anyway this code exists
|
// copper layers) make sense for footprints, but anyway this code exists
|
||||||
|
|
Loading…
Reference in New Issue