Commit 6c14eee6 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: Redesign layer selection and layer pair selection (give them a look...

Pcbnew: Redesign layer selection and layer pair selection (give them a look near the Layer selector in toolbarr)
parent 51eaeccf
...@@ -11,6 +11,46 @@ ...@@ -11,6 +11,46 @@
#include <class_layer_box_selector.h> #include <class_layer_box_selector.h>
LAYER_SELECTOR::LAYER_SELECTOR()
{
m_layerorder = true;
m_layerhotkeys = true;
m_hotkeys = NULL;
}
bool LAYER_SELECTOR::SetLayersOrdered( bool value )
{
m_layerorder = value;
return m_layerorder;
}
bool LAYER_SELECTOR::SetLayersHotkeys( bool value )
{
m_layerhotkeys = value;
return m_layerhotkeys;
}
void LAYER_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer )
{
wxMemoryDC bmpDC;
wxBrush brush;
// Prepare Bitmap
bmpDC.SelectObject( aLayerbmp );
brush.SetColour( MakeColour( GetLayerColor( aLayer ) ) );
brush.SetStyle( wxSOLID );
bmpDC.SetBrush( brush );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
bmpDC.SetPen( *wxBLACK_PEN );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
}
/* class to display a layer list. /* class to display a layer list.
* *
*/ */
...@@ -18,12 +58,9 @@ ...@@ -18,12 +58,9 @@
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id, LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
int n, const wxString choices[] ) : int n, const wxString choices[] ) :
LAYER_SELECTOR(),
wxBitmapComboBox( parent, id, wxEmptyString, pos, size, n, choices, wxCB_READONLY ) wxBitmapComboBox( parent, id, wxEmptyString, pos, size, n, choices, wxCB_READONLY )
{ {
m_layerorder = true;
m_layerhotkeys = true;
m_hotkeys = NULL;
if( choices != NULL ) if( choices != NULL )
ResyncBitmapOnly(); ResyncBitmapOnly();
} }
...@@ -32,31 +69,14 @@ LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id, ...@@ -32,31 +69,14 @@ LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id, LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
const wxArrayString& choices ) : const wxArrayString& choices ) :
LAYER_SELECTOR(),
wxBitmapComboBox( parent, id, wxEmptyString, pos, size, choices, wxCB_READONLY ) wxBitmapComboBox( parent, id, wxEmptyString, pos, size, choices, wxCB_READONLY )
{ {
m_layerorder = true;
m_layerhotkeys = true;
m_hotkeys = NULL;
if( !choices.IsEmpty() ) if( !choices.IsEmpty() )
ResyncBitmapOnly(); ResyncBitmapOnly();
} }
bool LAYER_BOX_SELECTOR::SetLayersOrdered( bool value )
{
m_layerorder = value;
return m_layerorder;
}
bool LAYER_BOX_SELECTOR::SetLayersHotkeys( bool value )
{
m_layerhotkeys = value;
return m_layerhotkeys;
}
// Get Current Item # // Get Current Item #
int LAYER_BOX_SELECTOR::GetChoice() int LAYER_BOX_SELECTOR::GetChoice()
{ {
...@@ -104,21 +124,3 @@ void LAYER_BOX_SELECTOR::ResyncBitmapOnly() ...@@ -104,21 +124,3 @@ void LAYER_BOX_SELECTOR::ResyncBitmapOnly()
SetBitmapLayer( layerbmp, i ); SetBitmapLayer( layerbmp, i );
} }
} }
void LAYER_BOX_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer )
{
wxMemoryDC bmpDC;
wxBrush brush;
// Prepare Bitmap
bmpDC.SelectObject( aLayerbmp );
brush.SetColour( MakeColour( GetLayerColor( aLayer ) ) );
brush.SetStyle( wxSOLID );
bmpDC.SetBrush( brush );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
bmpDC.SetPen( *wxBLACK_PEN );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
}
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
class wxAuiToolBar; class wxAuiToolBar;
/* class to display a layer list. /* Basic class to build a layer list.
* * this is an basic abstract class to build a layer list selector.
* To display this list, you should therefore derive this class
*/ */
class LAYER_SELECTOR
class LAYER_BOX_SELECTOR : public wxBitmapComboBox
{ {
protected: protected:
bool m_layerhotkeys; bool m_layerhotkeys;
...@@ -24,14 +24,7 @@ public: ...@@ -24,14 +24,7 @@ public:
struct EDA_HOTKEY_CONFIG* m_hotkeys; struct EDA_HOTKEY_CONFIG* m_hotkeys;
public: public:
LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id, LAYER_SELECTOR();
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL );
LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices );
// Returns a color index from the layer id // Returns a color index from the layer id
// Virtual function because GerbView uses its own functions in a derived class // Virtual function because GerbView uses its own functions in a derived class
...@@ -45,7 +38,33 @@ public: ...@@ -45,7 +38,33 @@ public:
// Virtual function pure because GerbView uses its own functions in a derived class // Virtual function pure because GerbView uses its own functions in a derived class
virtual bool IsLayerEnabled( LAYER_NUM aLayer ) const = 0; virtual bool IsLayerEnabled( LAYER_NUM aLayer ) const = 0;
// Get Current Item # bool SetLayersOrdered(bool value);
bool SetLayersHotkeys(bool value);
protected:
// Fills the layer bitmap aLayerbmp with the layer color
void SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer );
};
/* class to display a layer list in a wxBitmapComboBox.
*/
class LAYER_BOX_SELECTOR : public LAYER_SELECTOR, public wxBitmapComboBox
{
public:
// Hotkey Info
struct EDA_HOTKEY_CONFIG* m_hotkeys;
public:
LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL );
LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices );
// Get Current Item #
int GetChoice(); int GetChoice();
// Get Current Layer // Get Current Layer
...@@ -60,13 +79,6 @@ public: ...@@ -60,13 +79,6 @@ public:
// Reload the Layers bitmaps colors // Reload the Layers bitmaps colors
void ResyncBitmapOnly(); void ResyncBitmapOnly();
bool SetLayersOrdered(bool value);
bool SetLayersHotkeys(bool value);
protected:
// Fills the layer bitmap aLayerbmp with the layer color
void SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer );
}; };
#define DECLARE_LAYERS_HOTKEY(list) int list[NB_LAYERS] = \ #define DECLARE_LAYERS_HOTKEY(list) int list[NB_LAYERS] = \
......
...@@ -186,9 +186,14 @@ void PL_EDITOR_FRAME::Files_io( wxCommandEvent& event ) ...@@ -186,9 +186,14 @@ void PL_EDITOR_FRAME::Files_io( wxCommandEvent& event )
filename = openFileDialog.GetPath(); filename = openFileDialog.GetPath();
// Ensure the file has the right extension: // Ensure the file has the right extension:
// because a name like name.subname.subsubname is legal,
// add the right extension without replacing the wxFileName
// extension
wxFileName fn(filename); wxFileName fn(filename);
fn.SetExt( PageLayoutDescrFileExtension );
filename = fn.GetFullPath(); if( fn.GetExt() != PageLayoutDescrFileExtension )
filename << wxT(".") << PageLayoutDescrFileExtension;
if( !SavePageLayoutDescrFile( filename ) ) if( !SavePageLayoutDescrFile( filename ) )
{ {
wxString msg; wxString msg;
......
...@@ -76,6 +76,7 @@ set( PCBNEW_DIALOGS ...@@ -76,6 +76,7 @@ set( PCBNEW_DIALOGS
dialogs/dialog_global_deletion_base.cpp dialogs/dialog_global_deletion_base.cpp
dialogs/dialog_keepout_area_properties.cpp dialogs/dialog_keepout_area_properties.cpp
dialogs/dialog_keepout_area_properties_base.cpp dialogs/dialog_keepout_area_properties_base.cpp
dialogs/dialog_layer_selection_base.cpp
dialogs/dialog_layers_setup.cpp dialogs/dialog_layers_setup.cpp
dialogs/dialog_layers_setup_base.cpp dialogs/dialog_layers_setup_base.cpp
dialogs/dialog_netlist.cpp dialogs/dialog_netlist.cpp
......
...@@ -925,7 +925,15 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -925,7 +925,15 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
itmp = SelectLayer( getActiveLayer(), UNDEFINED_LAYER, UNDEFINED_LAYER ); itmp = SelectLayer( getActiveLayer(), UNDEFINED_LAYER, UNDEFINED_LAYER );
if( itmp >= 0 ) if( itmp >= 0 )
{
// if user changed colors and we are in high contrast mode, then redraw
// because the PAD_SMD pads may change color.
if( DisplayOpt.ContrastModeDisplay && getActiveLayer() != itmp )
{
m_canvas->Refresh();
}
setActiveLayer( itmp ); setActiveLayer( itmp );
}
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
break; break;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment