Right click option to change layer and render color
This commit is contained in:
parent
df472e6426
commit
d7b143f6f0
|
@ -114,8 +114,6 @@ PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwn
|
||||||
Connect( ID_SHOW_ALL_COPPER_LAYERS, ID_LAST_VALUE - 1,
|
Connect( ID_SHOW_ALL_COPPER_LAYERS, ID_LAST_VALUE - 1,
|
||||||
wxEVT_COMMAND_MENU_SELECTED,
|
wxEVT_COMMAND_MENU_SELECTED,
|
||||||
wxCommandEventHandler( PCB_LAYER_WIDGET::onPopupSelection ), NULL, this );
|
wxCommandEventHandler( PCB_LAYER_WIDGET::onPopupSelection ), NULL, this );
|
||||||
// install the right click handler into each control at end of ReFill()
|
|
||||||
// using installRightLayerClickHandler
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,27 +143,8 @@ bool PCB_LAYER_WIDGET::isLayerAllowedInFpMode( PCB_LAYER_ID aLayer )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_LAYER_WIDGET::installRightLayerClickHandler()
|
void PCB_LAYER_WIDGET::AddRightClickMenuItems( wxMenu& menu )
|
||||||
{
|
{
|
||||||
int rowCount = GetLayerRowCount();
|
|
||||||
|
|
||||||
for( int row=0; row < rowCount; ++row )
|
|
||||||
{
|
|
||||||
for( int col=0; col<LYR_COLUMN_COUNT; ++col )
|
|
||||||
{
|
|
||||||
wxWindow* w = getLayerComp( row, col );
|
|
||||||
|
|
||||||
w->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler(
|
|
||||||
PCB_LAYER_WIDGET::onRightDownLayers ), NULL, this );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PCB_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
|
|
||||||
{
|
|
||||||
wxMenu menu;
|
|
||||||
|
|
||||||
// menu text is capitalized:
|
// menu text is capitalized:
|
||||||
// http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization
|
// http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization
|
||||||
AddMenuItem( &menu, ID_SHOW_ALL_COPPER_LAYERS,
|
AddMenuItem( &menu, ID_SHOW_ALL_COPPER_LAYERS,
|
||||||
|
@ -204,7 +183,14 @@ void PCB_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
|
||||||
|
|
||||||
AddMenuItem( &menu, ID_SHOW_ALL_BACK, _( "Show All Back Layers" ),
|
AddMenuItem( &menu, ID_SHOW_ALL_BACK, _( "Show All Back Layers" ),
|
||||||
KiBitmap( show_all_layers_xpm ) );
|
KiBitmap( show_all_layers_xpm ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
|
||||||
|
{
|
||||||
|
wxMenu menu;
|
||||||
|
|
||||||
|
AddRightClickMenuItems( menu );
|
||||||
PopupMenu( &menu );
|
PopupMenu( &menu );
|
||||||
|
|
||||||
passOnFocus();
|
passOnFocus();
|
||||||
|
@ -224,7 +210,6 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
|
||||||
|
|
||||||
switch( menuId )
|
switch( menuId )
|
||||||
{
|
{
|
||||||
|
|
||||||
case ID_SHOW_NO_LAYERS:
|
case ID_SHOW_NO_LAYERS:
|
||||||
case ID_SHOW_ALL_LAYERS:
|
case ID_SHOW_ALL_LAYERS:
|
||||||
{
|
{
|
||||||
|
@ -536,8 +521,6 @@ void PCB_LAYER_WIDGET::ReFill()
|
||||||
COLUMN_COLORBM )->SetToolTip( wxEmptyString );
|
COLUMN_COLORBM )->SetToolTip( wxEmptyString );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
installRightLayerClickHandler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -626,6 +609,12 @@ void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_LAYER_WIDGET::OnLayerRightClick( wxMenu& aMenu )
|
||||||
|
{
|
||||||
|
AddRightClickMenuItems( aMenu );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor )
|
void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor )
|
||||||
{
|
{
|
||||||
wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
|
wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
|
||||||
|
|
|
@ -91,6 +91,7 @@ public:
|
||||||
void OnLayerColorChange( int aLayer, COLOR4D aColor ) override;
|
void OnLayerColorChange( int aLayer, COLOR4D aColor ) override;
|
||||||
bool OnLayerSelect( int aLayer ) override;
|
bool OnLayerSelect( int aLayer ) override;
|
||||||
void OnLayerVisible( int aLayer, bool isVisible, bool isFinal ) override;
|
void OnLayerVisible( int aLayer, bool isVisible, bool isFinal ) override;
|
||||||
|
void OnLayerRightClick( wxMenu& aMenu ) override;
|
||||||
void OnRenderColorChange( int aId, COLOR4D aColor ) override;
|
void OnRenderColorChange( int aId, COLOR4D aColor ) override;
|
||||||
void OnRenderEnable( int aId, bool isEnabled ) override;
|
void OnRenderEnable( int aId, bool isEnabled ) override;
|
||||||
//-----</implement LAYER_WIDGET abstract callback functions>----------
|
//-----</implement LAYER_WIDGET abstract callback functions>----------
|
||||||
|
@ -107,6 +108,13 @@ public:
|
||||||
// ensure active layer visible if
|
// ensure active layer visible if
|
||||||
// m_alwaysShowActiveCopperLayer is true;
|
// m_alwaysShowActiveCopperLayer is true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function addRightClickMenuItems
|
||||||
|
* add menu items to a menu that should be shown when right-clicking
|
||||||
|
* the PCB layer widget.
|
||||||
|
*/
|
||||||
|
void AddRightClickMenuItems( wxMenu& menu );
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -120,7 +128,7 @@ protected:
|
||||||
// popup menu ids.
|
// popup menu ids.
|
||||||
enum POPUP_ID
|
enum POPUP_ID
|
||||||
{
|
{
|
||||||
ID_SHOW_ALL_COPPER_LAYERS = wxID_HIGHEST,
|
ID_SHOW_ALL_COPPER_LAYERS = LAYER_WIDGET::ID_LAST_VALUE,
|
||||||
ID_SHOW_NO_COPPER_LAYERS,
|
ID_SHOW_NO_COPPER_LAYERS,
|
||||||
ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE,
|
ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE,
|
||||||
ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE,
|
ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE,
|
||||||
|
|
|
@ -38,11 +38,12 @@
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
|
||||||
#include <widgets/color_swatch.h>
|
|
||||||
#include <widgets/indicator_icon.h>
|
#include <widgets/indicator_icon.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <menus_helpers.h>
|
||||||
|
|
||||||
|
|
||||||
const wxEventType LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE = wxNewEventType();
|
const wxEventType LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE = wxNewEventType();
|
||||||
|
|
||||||
|
@ -126,6 +127,30 @@ void LAYER_WIDGET::OnLeftDownLayers( wxMouseEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LAYER_WIDGET::OnRightDownLayer( wxMouseEvent& aEvent, COLOR_SWATCH* aColorSwatch, const wxString& aLayerName )
|
||||||
|
{
|
||||||
|
wxMenu menu;
|
||||||
|
|
||||||
|
AddMenuItem( &menu, ID_CHANGE_LAYER_COLOR,
|
||||||
|
_( "Change Layer Color for " ) + aLayerName,
|
||||||
|
KiBitmap( setcolor_copper_xpm ) );
|
||||||
|
menu.AppendSeparator();
|
||||||
|
|
||||||
|
OnLayerRightClick( menu );
|
||||||
|
|
||||||
|
menu.Bind( wxEVT_COMMAND_MENU_SELECTED, [this, aColorSwatch]( wxCommandEvent& event ) {
|
||||||
|
if ( event.GetId() == ID_CHANGE_LAYER_COLOR ) {
|
||||||
|
aColorSwatch->GetNewSwatchColor();
|
||||||
|
} else {
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
PopupMenu( &menu );
|
||||||
|
passOnFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LAYER_WIDGET::OnLayerSwatchChanged( wxCommandEvent& aEvent )
|
void LAYER_WIDGET::OnLayerSwatchChanged( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
auto eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
|
auto eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
|
||||||
|
@ -154,6 +179,27 @@ void LAYER_WIDGET::OnLayerCheckBox( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LAYER_WIDGET::OnRightDownRender( wxMouseEvent& aEvent, COLOR_SWATCH* aColorSwatch, const wxString& aRenderName )
|
||||||
|
{
|
||||||
|
wxMenu menu;
|
||||||
|
|
||||||
|
AddMenuItem( &menu, ID_CHANGE_RENDER_COLOR,
|
||||||
|
_( "Change Render Color for " ) + aRenderName,
|
||||||
|
KiBitmap( setcolor_board_body_xpm ) );
|
||||||
|
|
||||||
|
menu.Bind( wxEVT_COMMAND_MENU_SELECTED, [this, aColorSwatch]( wxCommandEvent& event ) {
|
||||||
|
if ( event.GetId() == ID_CHANGE_RENDER_COLOR ) {
|
||||||
|
aColorSwatch->GetNewSwatchColor();
|
||||||
|
} else {
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
PopupMenu( &menu );
|
||||||
|
passOnFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LAYER_WIDGET::OnRenderSwatchChanged( wxCommandEvent& aEvent )
|
void LAYER_WIDGET::OnRenderSwatchChanged( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
auto eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
|
auto eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
|
||||||
|
@ -288,6 +334,22 @@ void LAYER_WIDGET::insertLayerRow( int aRow, const ROW& aSpec )
|
||||||
st->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
|
st->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
|
||||||
st->SetToolTip( aSpec.tooltip );
|
st->SetToolTip( aSpec.tooltip );
|
||||||
m_LayersFlexGridSizer->wxSizer::Insert( index+col, st, 0, flags );
|
m_LayersFlexGridSizer->wxSizer::Insert( index+col, st, 0, flags );
|
||||||
|
|
||||||
|
// Bind right click eventhandler to all columns
|
||||||
|
wxString layerName( aSpec.rowName );
|
||||||
|
|
||||||
|
sbm->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt ) {
|
||||||
|
OnRightDownLayer( aEvt, bmb, layerName );
|
||||||
|
} );
|
||||||
|
bmb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt ) {
|
||||||
|
OnRightDownLayer( aEvt, bmb, layerName );
|
||||||
|
} );
|
||||||
|
cb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt ) {
|
||||||
|
OnRightDownLayer( aEvt, bmb, layerName );
|
||||||
|
} );
|
||||||
|
st->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt ) {
|
||||||
|
OnRightDownLayer( aEvt, bmb, layerName );
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,24 +361,7 @@ void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
|
||||||
int index = aRow * RND_COLUMN_COUNT;
|
int index = aRow * RND_COLUMN_COUNT;
|
||||||
const int flags = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT;
|
const int flags = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT;
|
||||||
|
|
||||||
// column 0
|
wxString renderName( aSpec.rowName );
|
||||||
col = 0;
|
|
||||||
if( aSpec.color != COLOR4D::UNSPECIFIED )
|
|
||||||
{
|
|
||||||
auto bmb = new COLOR_SWATCH( m_RenderScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
|
|
||||||
AreArbitraryColorsAllowed() );
|
|
||||||
bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnRenderSwatchChanged, this );
|
|
||||||
bmb->SetToolTip( _( "Left double click or middle click for color change" ) );
|
|
||||||
m_RenderFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
|
|
||||||
|
|
||||||
// could add a left click handler on the color button that toggles checkbox.
|
|
||||||
}
|
|
||||||
else // == -1, no color selection wanted
|
|
||||||
{
|
|
||||||
// need a place holder within the sizer to keep grid full.
|
|
||||||
wxPanel* invisible = new wxPanel( m_RenderScrolledWindow, encodeId( col, aSpec.id ) );
|
|
||||||
m_RenderFlexGridSizer->wxSizer::Insert( index+col, invisible, 0, flags );
|
|
||||||
}
|
|
||||||
|
|
||||||
// column 1
|
// column 1
|
||||||
col = 1;
|
col = 1;
|
||||||
|
@ -327,6 +372,35 @@ void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
|
||||||
cb->Enable( aSpec.changeable );
|
cb->Enable( aSpec.changeable );
|
||||||
cb->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LAYER_WIDGET::OnRenderCheckBox, this );
|
cb->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LAYER_WIDGET::OnRenderCheckBox, this );
|
||||||
cb->SetToolTip( aSpec.tooltip );
|
cb->SetToolTip( aSpec.tooltip );
|
||||||
|
|
||||||
|
// column 0
|
||||||
|
col = 0;
|
||||||
|
if( aSpec.color != COLOR4D::UNSPECIFIED )
|
||||||
|
{
|
||||||
|
auto bmb = new COLOR_SWATCH( m_RenderScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
|
||||||
|
AreArbitraryColorsAllowed() );
|
||||||
|
bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnRenderSwatchChanged, this );
|
||||||
|
bmb->SetToolTip( _( "Left double click or middle click for color change" ) );
|
||||||
|
m_RenderFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
|
||||||
|
|
||||||
|
bmb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, renderName] ( wxMouseEvent& aEvt ) {
|
||||||
|
OnRightDownRender( aEvt, bmb, renderName );
|
||||||
|
} );
|
||||||
|
cb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, renderName] ( wxMouseEvent& aEvt ) {
|
||||||
|
OnRightDownRender( aEvt, bmb, renderName );
|
||||||
|
} );
|
||||||
|
|
||||||
|
// could add a left click handler on the color button that toggles checkbox.
|
||||||
|
}
|
||||||
|
else // == -1, no color selection wanted
|
||||||
|
{
|
||||||
|
// need a place holder within the sizer to keep grid full.
|
||||||
|
wxPanel* invisible = new wxPanel( m_RenderScrolledWindow, encodeId( col, aSpec.id ) );
|
||||||
|
m_RenderFlexGridSizer->wxSizer::Insert( index+col, invisible, 0, flags );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Items have to be inserted in order
|
||||||
|
col = 1;
|
||||||
m_RenderFlexGridSizer->wxSizer::Insert( index+col, cb, 0, flags );
|
m_RenderFlexGridSizer->wxSizer::Insert( index+col, cb, 0, flags );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include <wx/icon.h>
|
#include <wx/icon.h>
|
||||||
#include <layers_id_colors_and_visibility.h>
|
#include <layers_id_colors_and_visibility.h>
|
||||||
#include <gal/color4d.h>
|
#include <gal/color4d.h>
|
||||||
|
#include <widgets/color_swatch.h>
|
||||||
|
|
||||||
#define LYR_COLUMN_COUNT 4 ///< Layer tab column count
|
#define LYR_COLUMN_COUNT 4 ///< Layer tab column count
|
||||||
#define RND_COLUMN_COUNT 2 ///< Rendering tab column count
|
#define RND_COLUMN_COUNT 2 ///< Rendering tab column count
|
||||||
|
@ -153,6 +154,12 @@ protected:
|
||||||
|
|
||||||
void OnLeftDownLayers( wxMouseEvent& event );
|
void OnLeftDownLayers( wxMouseEvent& event );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function OnRightDownLayer
|
||||||
|
* Called when user right-clicks a layer
|
||||||
|
*/
|
||||||
|
void OnRightDownLayer( wxMouseEvent& event, COLOR_SWATCH* aColorSwatch, const wxString& aLayerName );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function OnSwatchChanged()
|
* Function OnSwatchChanged()
|
||||||
* is called when a user changes a swatch color
|
* is called when a user changes a swatch color
|
||||||
|
@ -166,6 +173,12 @@ protected:
|
||||||
*/
|
*/
|
||||||
void OnLayerCheckBox( wxCommandEvent& event );
|
void OnLayerCheckBox( wxCommandEvent& event );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function OnRightDownRender
|
||||||
|
* Called when user right-clicks a render option
|
||||||
|
*/
|
||||||
|
void OnRightDownRender( wxMouseEvent& aEvent, COLOR_SWATCH* aColorSwatch, const wxString& aRenderName );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function OnRenderSwatchChanged
|
* Function OnRenderSwatchChanged
|
||||||
* Called when user has changed the swatch color of a render entry
|
* Called when user has changed the swatch color of a render entry
|
||||||
|
@ -210,6 +223,14 @@ protected:
|
||||||
*/
|
*/
|
||||||
void passOnFocus();
|
void passOnFocus();
|
||||||
|
|
||||||
|
// popup menu ids.
|
||||||
|
enum POPUP_ID
|
||||||
|
{
|
||||||
|
ID_CHANGE_LAYER_COLOR = wxID_HIGHEST,
|
||||||
|
ID_CHANGE_RENDER_COLOR,
|
||||||
|
ID_LAST_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Constructor
|
/** Constructor
|
||||||
|
@ -416,6 +437,15 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool isFinal = true ) = 0;
|
virtual void OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool isFinal = true ) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function OnLayerRightClick
|
||||||
|
* is called to notify client code about a layer being right-clicked.
|
||||||
|
*
|
||||||
|
* @param aMenu is the right-click menu containing layer-scoped options.
|
||||||
|
* It can be used to add extra, wider scoped menu items.
|
||||||
|
*/
|
||||||
|
virtual void OnLayerRightClick( wxMenu& aMenu ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function OnRenderColorChange
|
* Function OnRenderColorChange
|
||||||
* is called to notify client code whenever the user changes a rendering
|
* is called to notify client code whenever the user changes a rendering
|
||||||
|
|
Loading…
Reference in New Issue