Split out footprint editor color settings
Migrate COLOR_SETTINGS 0->1 to remove fpedit section Migrate FOOTPRINT_EDITOR_SETTINGS 0->1 to use new theme if created Remove COLOR_CONTEXT that is no longer needed
This commit is contained in:
parent
66eb84097a
commit
9916f24fab
|
@ -19,18 +19,21 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <layers_id_colors_and_visibility.h>
|
#include <layers_id_colors_and_visibility.h>
|
||||||
|
#include <pgm_base.h>
|
||||||
#include <settings/color_settings.h>
|
#include <settings/color_settings.h>
|
||||||
#include <settings/parameters.h>
|
#include <settings/parameters.h>
|
||||||
|
#include <settings/settings_manager.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern const char* traceSettings;
|
||||||
|
|
||||||
///! Update the schema version whenever a migration is required
|
///! Update the schema version whenever a migration is required
|
||||||
const int colorsSchemaVersion = 0;
|
const int colorsSchemaVersion = 1;
|
||||||
|
|
||||||
|
|
||||||
COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) :
|
COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) :
|
||||||
JSON_SETTINGS( std::move( aFilename ), SETTINGS_LOC::COLORS, colorsSchemaVersion ),
|
JSON_SETTINGS( std::move( aFilename ), SETTINGS_LOC::COLORS, colorsSchemaVersion ),
|
||||||
m_overrideSchItemColors( false ),
|
m_overrideSchItemColors( false )
|
||||||
m_color_context( COLOR_CONTEXT::PCB )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<wxString>( "meta.name", &m_displayName, "KiCad Default" ) );
|
m_params.emplace_back( new PARAM<wxString>( "meta.name", &m_displayName, "KiCad Default" ) );
|
||||||
|
@ -196,97 +199,6 @@ COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) :
|
||||||
CLR( "board.b_fab", B_Fab, COLOR4D( BLUE ) );
|
CLR( "board.b_fab", B_Fab, COLOR4D( BLUE ) );
|
||||||
CLR( "board.f_fab", F_Fab, COLOR4D( DARKGRAY ) );
|
CLR( "board.f_fab", F_Fab, COLOR4D( DARKGRAY ) );
|
||||||
|
|
||||||
// TODO(JE) Storing fpedit colors here is a temporary hack to preserve user settings.
|
|
||||||
// Ultimately, if a user wants to have different colors for pcbnew and the footprint editor,
|
|
||||||
// they should simply choose a different named color theme for each.
|
|
||||||
// While we only have a single color theme, we need to store two mappings of all the
|
|
||||||
// pcb-related colors, one for pcbnew and one for footprint editor.
|
|
||||||
// Once color themes are supported, we should bump the schema version of COLOR_SETTINGS
|
|
||||||
// and in the migration split out the "User" theme to "User.FpEdit" or something, then set
|
|
||||||
// the User.FpEdit scheme as active for the footprint editor.
|
|
||||||
|
|
||||||
#define FL FPEDIT_LAYER_ID_START
|
|
||||||
|
|
||||||
CLR( "fpedit.anchor", FL + LAYER_ANCHOR, COLOR4D( BLUE ) );
|
|
||||||
CLR( "fpedit.aux_items", FL + LAYER_AUX_ITEMS, COLOR4D( WHITE ) );
|
|
||||||
CLR( "fpedit.background", FL + LAYER_PCB_BACKGROUND, COLOR4D( BLACK ) );
|
|
||||||
CLR( "fpedit.cursor", FL + LAYER_CURSOR, COLOR4D( WHITE ) );
|
|
||||||
CLR( "fpedit.drc_error", FL + LAYER_DRC_ERROR, COLOR4D( PURERED ) );
|
|
||||||
CLR( "fpedit.drc_warning", FL + LAYER_DRC_WARNING, COLOR4D( PUREYELLOW ) );
|
|
||||||
CLR( "fpedit.footprint_text_back", FL + LAYER_MOD_TEXT_BK, COLOR4D( BLUE ) );
|
|
||||||
CLR( "fpedit.footprint_text_front", FL + LAYER_MOD_TEXT_FR, COLOR4D( LIGHTGRAY ) );
|
|
||||||
CLR( "fpedit.footprint_text_invisible", FL + LAYER_MOD_TEXT_INVISIBLE, COLOR4D( LIGHTGRAY ) );
|
|
||||||
CLR( "fpedit.grid", FL + LAYER_GRID, COLOR4D( DARKGRAY ) );
|
|
||||||
CLR( "fpedit.grid_axes", FL + LAYER_GRID_AXES, COLOR4D( LIGHTGRAY ) );
|
|
||||||
CLR( "fpedit.microvia", FL + LAYER_VIA_MICROVIA, COLOR4D( LIGHTGRAY ) );
|
|
||||||
CLR( "fpedit.no_connect", FL + LAYER_NO_CONNECTS, COLOR4D( BLUE ) );
|
|
||||||
CLR( "fpedit.pad_back", FL + LAYER_PAD_BK, COLOR4D( GREEN ) );
|
|
||||||
CLR( "fpedit.pad_front", FL + LAYER_PAD_FR, COLOR4D( RED ) );
|
|
||||||
CLR( "fpedit.pad_plated_hole", FL + LAYER_PADS_PLATEDHOLES, COLOR4D( YELLOW ) );
|
|
||||||
CLR( "fpedit.pad_through_hole", FL + LAYER_PADS_TH, COLOR4D( YELLOW ) );
|
|
||||||
CLR( "fpedit.plated_hole", FL + LAYER_NON_PLATEDHOLES, COLOR4D( YELLOW ) );
|
|
||||||
CLR( "fpedit.ratsnest", FL + LAYER_RATSNEST, COLOR4D( WHITE ) );
|
|
||||||
CLR( "fpedit.select_overlay", FL + LAYER_SELECT_OVERLAY, COLOR4D( DARKRED ) );
|
|
||||||
CLR( "fpedit.through_via", FL + LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) );
|
|
||||||
CLR( "fpedit.via", FL + LAYER_VIAS, COLOR4D( BLACK ) );
|
|
||||||
CLR( "fpedit.via_blind_buried", FL + LAYER_VIA_BBLIND, COLOR4D( BROWN ) );
|
|
||||||
CLR( "fpedit.via_hole", FL + LAYER_VIAS_HOLES, COLOR4D( WHITE ) );
|
|
||||||
CLR( "fpedit.via_micro", FL + LAYER_VIA_MICROVIA, COLOR4D( CYAN ) );
|
|
||||||
CLR( "fpedit.via_through", FL + LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) );
|
|
||||||
CLR( "fpedit.worksheet", FL + LAYER_WORKSHEET, COLOR4D( DARKRED ) );
|
|
||||||
|
|
||||||
CLR( "fpedit.copper.f", FL + F_Cu, COLOR4D( RED ) );
|
|
||||||
CLR( "fpedit.copper.in1", FL + In1_Cu, COLOR4D( YELLOW ) );
|
|
||||||
CLR( "fpedit.copper.in2", FL + In2_Cu, COLOR4D( LIGHTMAGENTA ) );
|
|
||||||
CLR( "fpedit.copper.in3", FL + In3_Cu, COLOR4D( LIGHTRED ) );
|
|
||||||
CLR( "fpedit.copper.in4", FL + In4_Cu, COLOR4D( CYAN ) );
|
|
||||||
CLR( "fpedit.copper.in5", FL + In5_Cu, COLOR4D( GREEN ) );
|
|
||||||
CLR( "fpedit.copper.in6", FL + In6_Cu, COLOR4D( BLUE ) );
|
|
||||||
CLR( "fpedit.copper.in7", FL + In7_Cu, COLOR4D( DARKGRAY ) );
|
|
||||||
CLR( "fpedit.copper.in8", FL + In8_Cu, COLOR4D( MAGENTA ) );
|
|
||||||
CLR( "fpedit.copper.in9", FL + In9_Cu, COLOR4D( LIGHTGRAY ) );
|
|
||||||
CLR( "fpedit.copper.in10", FL + In10_Cu, COLOR4D( MAGENTA ) );
|
|
||||||
CLR( "fpedit.copper.in11", FL + In11_Cu, COLOR4D( RED ) );
|
|
||||||
CLR( "fpedit.copper.in12", FL + In12_Cu, COLOR4D( BROWN ) );
|
|
||||||
CLR( "fpedit.copper.in13", FL + In13_Cu, COLOR4D( LIGHTGRAY ) );
|
|
||||||
CLR( "fpedit.copper.in14", FL + In14_Cu, COLOR4D( BLUE ) );
|
|
||||||
CLR( "fpedit.copper.in15", FL + In15_Cu, COLOR4D( GREEN ) );
|
|
||||||
CLR( "fpedit.copper.in16", FL + In16_Cu, COLOR4D( RED ) );
|
|
||||||
CLR( "fpedit.copper.in17", FL + In17_Cu, COLOR4D( YELLOW ) );
|
|
||||||
CLR( "fpedit.copper.in18", FL + In18_Cu, COLOR4D( LIGHTMAGENTA ) );
|
|
||||||
CLR( "fpedit.copper.in19", FL + In19_Cu, COLOR4D( LIGHTRED ) );
|
|
||||||
CLR( "fpedit.copper.in20", FL + In20_Cu, COLOR4D( CYAN ) );
|
|
||||||
CLR( "fpedit.copper.in21", FL + In21_Cu, COLOR4D( GREEN ) );
|
|
||||||
CLR( "fpedit.copper.in22", FL + In22_Cu, COLOR4D( BLUE ) );
|
|
||||||
CLR( "fpedit.copper.in23", FL + In23_Cu, COLOR4D( DARKGRAY ) );
|
|
||||||
CLR( "fpedit.copper.in24", FL + In24_Cu, COLOR4D( MAGENTA ) );
|
|
||||||
CLR( "fpedit.copper.in25", FL + In25_Cu, COLOR4D( LIGHTGRAY ) );
|
|
||||||
CLR( "fpedit.copper.in26", FL + In26_Cu, COLOR4D( MAGENTA ) );
|
|
||||||
CLR( "fpedit.copper.in27", FL + In27_Cu, COLOR4D( RED ) );
|
|
||||||
CLR( "fpedit.copper.in28", FL + In28_Cu, COLOR4D( BROWN ) );
|
|
||||||
CLR( "fpedit.copper.in29", FL + In29_Cu, COLOR4D( LIGHTGRAY ) );
|
|
||||||
CLR( "fpedit.copper.in30", FL + In30_Cu, COLOR4D( BLUE ) );
|
|
||||||
CLR( "fpedit.copper.b", FL + B_Cu, COLOR4D( GREEN ) );
|
|
||||||
|
|
||||||
CLR( "fpedit.b_adhes", FL + B_Adhes, COLOR4D( BLUE ) );
|
|
||||||
CLR( "fpedit.f_adhes", FL + F_Adhes, COLOR4D( MAGENTA ) );
|
|
||||||
CLR( "fpedit.b_paste", FL + B_Paste, COLOR4D( LIGHTCYAN ) );
|
|
||||||
CLR( "fpedit.f_paste", FL + F_Paste, COLOR4D( RED ) );
|
|
||||||
CLR( "fpedit.b_silks", FL + B_SilkS, COLOR4D( MAGENTA ) );
|
|
||||||
CLR( "fpedit.f_silks", FL + F_SilkS, COLOR4D( CYAN ) );
|
|
||||||
CLR( "fpedit.b_mask", FL + B_Mask, COLOR4D( BROWN ) );
|
|
||||||
CLR( "fpedit.f_mask", FL + F_Mask, COLOR4D( MAGENTA ) );
|
|
||||||
CLR( "fpedit.dwgs_user", FL + Dwgs_User, COLOR4D( LIGHTGRAY ) );
|
|
||||||
CLR( "fpedit.cmts_user", FL + Cmts_User, COLOR4D( BLUE ) );
|
|
||||||
CLR( "fpedit.eco1_user", FL + Eco1_User, COLOR4D( GREEN ) );
|
|
||||||
CLR( "fpedit.eco2_user", FL + Eco2_User, COLOR4D( YELLOW ) );
|
|
||||||
CLR( "fpedit.edge_cuts", FL + Edge_Cuts, COLOR4D( YELLOW ) );
|
|
||||||
CLR( "fpedit.margin", FL + Margin, COLOR4D( LIGHTMAGENTA ) );
|
|
||||||
CLR( "fpedit.b_crtyd", FL + B_CrtYd, COLOR4D( DARKGRAY ) );
|
|
||||||
CLR( "fpedit.f_crtyd", FL + F_CrtYd, COLOR4D( LIGHTGRAY ) );
|
|
||||||
CLR( "fpedit.b_fab", FL + B_Fab, COLOR4D( BLUE ) );
|
|
||||||
CLR( "fpedit.f_fab", FL + F_Fab, COLOR4D( DARKGRAY ) );
|
|
||||||
|
|
||||||
// Colors for 3D viewer, which are used as defaults unless overridden by the board
|
// Colors for 3D viewer, which are used as defaults unless overridden by the board
|
||||||
CLR( "3d_viewer.background_bottom", LAYER_3D_BACKGROUND_BOTTOM, COLOR4D( 0.4, 0.4, 0.5, 1.0 ) );
|
CLR( "3d_viewer.background_bottom", LAYER_3D_BACKGROUND_BOTTOM, COLOR4D( 0.4, 0.4, 0.5, 1.0 ) );
|
||||||
CLR( "3d_viewer.background_top", LAYER_3D_BACKGROUND_TOP, COLOR4D( 0.8, 0.8, 0.9, 1.0 ) );
|
CLR( "3d_viewer.background_top", LAYER_3D_BACKGROUND_TOP, COLOR4D( 0.8, 0.8, 0.9, 1.0 ) );
|
||||||
|
@ -305,14 +217,75 @@ bool COLOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
COLOR4D COLOR_SETTINGS::GetColor( int aLayer ) const
|
bool COLOR_SETTINGS::Migrate()
|
||||||
{
|
{
|
||||||
if( m_color_context == COLOR_CONTEXT::FOOTPRINT && aLayer >= PCBNEW_LAYER_ID_START
|
bool ret = true;
|
||||||
&& aLayer <= GAL_LAYER_ID_END )
|
int filever = at( PointerFromString( "meta.version" ) ).get<int>();
|
||||||
|
|
||||||
|
if( filever == 0 )
|
||||||
{
|
{
|
||||||
aLayer += FPEDIT_LAYER_ID_START;
|
ret &= migrateSchema0to1();
|
||||||
|
|
||||||
|
if( ret )
|
||||||
|
{
|
||||||
|
( *this )[PointerFromString( "meta.version" )] = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool COLOR_SETTINGS::migrateSchema0to1()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Schema version 0 to 1:
|
||||||
|
*
|
||||||
|
* - Footprint editor settings are split out into a new file called "ThemeName (Footprints)"
|
||||||
|
* - fpedit namespace is removed from the schema
|
||||||
|
*/
|
||||||
|
|
||||||
|
if( !m_manager )
|
||||||
|
{
|
||||||
|
wxLogTrace( traceSettings, "Error: COLOR_SETTINGS migration cannot run unmanaged!" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
nlohmann::json::json_pointer board( "/board" );
|
||||||
|
nlohmann::json::json_pointer fpedit( "/fpedit" );
|
||||||
|
|
||||||
|
if( !contains( fpedit ) )
|
||||||
|
{
|
||||||
|
wxLogTrace( traceSettings, "migrateSchema0to1: %s doesn't have fpedit settings; skipping.",
|
||||||
|
m_filename );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString filename = m_filename + wxT( "_footprints" );
|
||||||
|
|
||||||
|
COLOR_SETTINGS* fpsettings = m_manager->AddNewColorSettings( filename );
|
||||||
|
|
||||||
|
// Start out with a clone
|
||||||
|
nlohmann::json::json_pointer root( "" );
|
||||||
|
( *fpsettings )[root] = at( root );
|
||||||
|
|
||||||
|
// Footprint editor now just looks at the "board" namespace
|
||||||
|
( *fpsettings )[board] = fpsettings->at( fpedit );
|
||||||
|
|
||||||
|
fpsettings->erase( "fpedit" );
|
||||||
|
fpsettings->Load();
|
||||||
|
fpsettings->SetName( fpsettings->GetName() + _( " (Footprints)" ) );
|
||||||
|
m_manager->Save( fpsettings );
|
||||||
|
|
||||||
|
// Now we can get rid of our own copy
|
||||||
|
erase( "fpedit" );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
COLOR4D COLOR_SETTINGS::GetColor( int aLayer ) const
|
||||||
|
{
|
||||||
if( m_colors.count( aLayer ) )
|
if( m_colors.count( aLayer ) )
|
||||||
return m_colors.at( aLayer );
|
return m_colors.at( aLayer );
|
||||||
|
|
||||||
|
@ -324,12 +297,6 @@ COLOR4D COLOR_SETTINGS::GetDefaultColor( int aLayer )
|
||||||
{
|
{
|
||||||
if( !m_defaultColors.count( aLayer ) )
|
if( !m_defaultColors.count( aLayer ) )
|
||||||
{
|
{
|
||||||
if( m_color_context == COLOR_CONTEXT::FOOTPRINT && aLayer >= PCBNEW_LAYER_ID_START
|
|
||||||
&& aLayer <= GAL_LAYER_ID_END )
|
|
||||||
{
|
|
||||||
aLayer += FPEDIT_LAYER_ID_START;
|
|
||||||
}
|
|
||||||
|
|
||||||
COLOR_MAP_PARAM* p = nullptr;
|
COLOR_MAP_PARAM* p = nullptr;
|
||||||
|
|
||||||
for( auto param : m_params )
|
for( auto param : m_params )
|
||||||
|
@ -347,8 +314,5 @@ COLOR4D COLOR_SETTINGS::GetDefaultColor( int aLayer )
|
||||||
|
|
||||||
void COLOR_SETTINGS::SetColor( int aLayer, COLOR4D aColor )
|
void COLOR_SETTINGS::SetColor( int aLayer, COLOR4D aColor )
|
||||||
{
|
{
|
||||||
if( m_color_context == COLOR_CONTEXT::FOOTPRINT )
|
|
||||||
aLayer += FPEDIT_LAYER_ID_START;
|
|
||||||
|
|
||||||
m_colors[ aLayer ] = aColor;
|
m_colors[ aLayer ] = aColor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,25 +312,11 @@ enum GERBVIEW_LAYER_ID: int
|
||||||
|
|
||||||
#define GERBER_DRAW_LAYER_INDEX( x ) ( x - GERBVIEW_LAYER_ID_START )
|
#define GERBER_DRAW_LAYER_INDEX( x ) ( x - GERBVIEW_LAYER_ID_START )
|
||||||
|
|
||||||
// TODO(JE) Remove after we have color themes
|
|
||||||
// Temporary virtual layers to store color themes for footprint editor
|
|
||||||
enum FPEDIT_LAYER_ID : int
|
|
||||||
{
|
|
||||||
FPEDIT_LAYER_ID_START = GERBVIEW_LAYER_ID_END,
|
|
||||||
|
|
||||||
// Reserve a copy of the board and netname layers...
|
|
||||||
FPEDIT_LAYER_ID_RESERVED = FPEDIT_LAYER_ID_START + ( 2 * PCB_LAYER_ID_COUNT ),
|
|
||||||
|
|
||||||
// And a copy of the GAL layers
|
|
||||||
FPEDIT_GAL_RESERVED = FPEDIT_LAYER_ID_RESERVED + ( GAL_LAYER_ID_END - GAL_LAYER_ID_START ),
|
|
||||||
|
|
||||||
FPEDIT_LAYER_ID_END
|
|
||||||
};
|
|
||||||
|
|
||||||
/// 3D Viewer virtual layers for color settings
|
/// 3D Viewer virtual layers for color settings
|
||||||
enum LAYER_3D_ID : int
|
enum LAYER_3D_ID : int
|
||||||
{
|
{
|
||||||
LAYER_3D_START = FPEDIT_LAYER_ID_END,
|
LAYER_3D_START = GERBVIEW_LAYER_ID_END,
|
||||||
|
|
||||||
LAYER_3D_BACKGROUND_BOTTOM,
|
LAYER_3D_BACKGROUND_BOTTOM,
|
||||||
LAYER_3D_BACKGROUND_TOP,
|
LAYER_3D_BACKGROUND_TOP,
|
||||||
|
@ -345,7 +331,7 @@ enum LAYER_3D_ID : int
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Must update this if you add any enums after GerbView!
|
/// Must update this if you add any enums after GerbView!
|
||||||
#define LAYER_ID_COUNT FPEDIT_LAYER_ID_END
|
#define LAYER_ID_COUNT LAYER_3D_END
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -168,7 +168,11 @@ public:
|
||||||
* Helper to retrieve the current color settings
|
* Helper to retrieve the current color settings
|
||||||
* @return a pointer to the active COLOR_SETTINGS
|
* @return a pointer to the active COLOR_SETTINGS
|
||||||
*/
|
*/
|
||||||
COLOR_SETTINGS* ColorSettings();
|
virtual COLOR_SETTINGS* ColorSettings()
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( "Color settings requested for a frame that does not define them!" );
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
PCBNEW_SETTINGS& Settings() { return *m_Settings; }
|
PCBNEW_SETTINGS& Settings() { return *m_Settings; }
|
||||||
|
|
||||||
|
|
|
@ -49,15 +49,6 @@ using KIGFX::COLOR4D;
|
||||||
#include <settings/json_settings.h>
|
#include <settings/json_settings.h>
|
||||||
#include <settings/parameters.h>
|
#include <settings/parameters.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* For specifying whether to retrieve colors from the "pcbnew" or "fpedit" set.
|
|
||||||
* Can be removed once color themes exist.
|
|
||||||
*/
|
|
||||||
enum class COLOR_CONTEXT
|
|
||||||
{
|
|
||||||
PCB,
|
|
||||||
FOOTPRINT
|
|
||||||
};
|
|
||||||
|
|
||||||
class COLOR_SETTINGS : public JSON_SETTINGS
|
class COLOR_SETTINGS : public JSON_SETTINGS
|
||||||
{
|
{
|
||||||
|
@ -75,18 +66,14 @@ public:
|
||||||
|
|
||||||
bool MigrateFromLegacy( wxConfigBase* aCfg ) override;
|
bool MigrateFromLegacy( wxConfigBase* aCfg ) override;
|
||||||
|
|
||||||
|
bool Migrate() override;
|
||||||
|
|
||||||
COLOR4D GetColor( int aLayer ) const;
|
COLOR4D GetColor( int aLayer ) const;
|
||||||
|
|
||||||
COLOR4D GetDefaultColor( int aLayer );
|
COLOR4D GetDefaultColor( int aLayer );
|
||||||
|
|
||||||
void SetColor( int aLayer, COLOR4D aColor );
|
void SetColor( int aLayer, COLOR4D aColor );
|
||||||
|
|
||||||
// TODO(JE) remove once color themes exist
|
|
||||||
void SetColorContext( COLOR_CONTEXT aContext = COLOR_CONTEXT::PCB )
|
|
||||||
{
|
|
||||||
m_color_context = aContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
const wxString& GetName() const { return m_displayName; }
|
const wxString& GetName() const { return m_displayName; }
|
||||||
void SetName( const wxString& aName ) { m_displayName = aName; }
|
void SetName( const wxString& aName ) { m_displayName = aName; }
|
||||||
|
|
||||||
|
@ -94,7 +81,10 @@ public:
|
||||||
void SetOverrideSchItemColors( bool aFlag ) { m_overrideSchItemColors = aFlag; }
|
void SetOverrideSchItemColors( bool aFlag ) { m_overrideSchItemColors = aFlag; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool migrateSchema0to1();
|
||||||
|
|
||||||
wxString m_displayName;
|
wxString m_displayName;
|
||||||
|
|
||||||
bool m_overrideSchItemColors;
|
bool m_overrideSchItemColors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,9 +94,6 @@ private:
|
||||||
std::unordered_map<int, COLOR4D> m_colors;
|
std::unordered_map<int, COLOR4D> m_colors;
|
||||||
|
|
||||||
std::unordered_map<int, COLOR4D> m_defaultColors;
|
std::unordered_map<int, COLOR4D> m_defaultColors;
|
||||||
|
|
||||||
// TODO(JE) remove once color themes exist
|
|
||||||
COLOR_CONTEXT m_color_context;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class COLOR_MAP_PARAM : public PARAM_BASE
|
class COLOR_MAP_PARAM : public PARAM_BASE
|
||||||
|
|
|
@ -146,6 +146,7 @@ set( PCBNEW_DIALOGS
|
||||||
dialogs/dialog_update_pcb_base.cpp
|
dialogs/dialog_update_pcb_base.cpp
|
||||||
dialogs/panel_fp_lib_table.cpp
|
dialogs/panel_fp_lib_table.cpp
|
||||||
dialogs/panel_fp_lib_table_base.cpp
|
dialogs/panel_fp_lib_table_base.cpp
|
||||||
|
dialogs/panel_modedit_color_settings.cpp
|
||||||
dialogs/panel_modedit_defaults.cpp
|
dialogs/panel_modedit_defaults.cpp
|
||||||
dialogs/panel_modedit_defaults_base.cpp
|
dialogs/panel_modedit_defaults_base.cpp
|
||||||
dialogs/panel_modedit_display_options.cpp
|
dialogs/panel_modedit_display_options.cpp
|
||||||
|
|
|
@ -0,0 +1,145 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
|
||||||
|
* Copyright (C) 2020 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
|
||||||
|
* Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
|
#include <class_board.h>
|
||||||
|
#include <footprint_edit_frame.h>
|
||||||
|
#include <footprint_editor_settings.h>
|
||||||
|
#include <gal/gal_display_options.h>
|
||||||
|
#include <layers_id_colors_and_visibility.h>
|
||||||
|
#include <panel_modedit_color_settings.h>
|
||||||
|
#include <pgm_base.h>
|
||||||
|
#include <settings/settings_manager.h>
|
||||||
|
|
||||||
|
|
||||||
|
PANEL_MODEDIT_COLOR_SETTINGS::PANEL_MODEDIT_COLOR_SETTINGS( FOOTPRINT_EDIT_FRAME* aFrame,
|
||||||
|
wxWindow* aParent )
|
||||||
|
: PANEL_COLOR_SETTINGS( aParent ),
|
||||||
|
m_frame( aFrame ),
|
||||||
|
m_page( nullptr ),
|
||||||
|
m_titleBlock( nullptr ),
|
||||||
|
m_ws( nullptr )
|
||||||
|
{
|
||||||
|
// Currently this only applies to eeschema
|
||||||
|
m_optOverrideColors->Hide();
|
||||||
|
|
||||||
|
m_colorNamespace = "board";
|
||||||
|
|
||||||
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||||
|
|
||||||
|
FOOTPRINT_EDITOR_SETTINGS* settings = mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
|
||||||
|
COLOR_SETTINGS* current = mgr.GetColorSettings( settings->m_ColorTheme );
|
||||||
|
|
||||||
|
// Store the current settings before reloading below
|
||||||
|
current->Store();
|
||||||
|
mgr.SaveColorSettings( current, "board" );
|
||||||
|
|
||||||
|
m_optOverrideColors->SetValue( current->GetOverrideSchItemColors() );
|
||||||
|
|
||||||
|
m_currentSettings = new COLOR_SETTINGS( *current );
|
||||||
|
|
||||||
|
mgr.ReloadColorSettings();
|
||||||
|
createThemeList( settings->m_ColorTheme );
|
||||||
|
|
||||||
|
for( int id = F_Cu; id < PCB_LAYER_ID_COUNT; id++ )
|
||||||
|
m_validLayers.push_back( id );
|
||||||
|
|
||||||
|
for( int id = GAL_LAYER_ID_START; id < GAL_LAYER_ID_END; id++ )
|
||||||
|
{
|
||||||
|
if( id == LAYER_VIAS || id == LAYER_GRID_AXES || id == LAYER_PADS_PLATEDHOLES
|
||||||
|
|| id == LAYER_VIAS_HOLES )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_validLayers.push_back( id );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_colorsMainSizer->Insert( 0, 10, 0, 0, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
createButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PANEL_MODEDIT_COLOR_SETTINGS::~PANEL_MODEDIT_COLOR_SETTINGS()
|
||||||
|
{
|
||||||
|
delete m_page;
|
||||||
|
delete m_titleBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PANEL_MODEDIT_COLOR_SETTINGS::TransferDataFromWindow()
|
||||||
|
{
|
||||||
|
m_currentSettings->SetOverrideSchItemColors( m_optOverrideColors->GetValue() );
|
||||||
|
|
||||||
|
if( !saveCurrentTheme( true ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings()->LoadColors( m_currentSettings );
|
||||||
|
|
||||||
|
SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
|
||||||
|
FOOTPRINT_EDITOR_SETTINGS* settings = settingsMgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
|
||||||
|
settings->m_ColorTheme = m_currentSettings->GetFilename();
|
||||||
|
|
||||||
|
m_frame->UpdateUserInterface();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PANEL_MODEDIT_COLOR_SETTINGS::TransferDataToWindow()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PANEL_MODEDIT_COLOR_SETTINGS::createButtons()
|
||||||
|
{
|
||||||
|
std::vector<int> layers;
|
||||||
|
|
||||||
|
for( GAL_LAYER_ID i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; ++i )
|
||||||
|
{
|
||||||
|
if( m_currentSettings->GetColor( i ) != COLOR4D::UNSPECIFIED )
|
||||||
|
layers.push_back( i );
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort( layers.begin(), layers.end(),
|
||||||
|
[]( int a, int b )
|
||||||
|
{
|
||||||
|
return LayerName( a ) < LayerName( b );
|
||||||
|
} );
|
||||||
|
|
||||||
|
// Don't sort board layers by name
|
||||||
|
for( int i = PCBNEW_LAYER_ID_START; i < PCB_LAYER_ID_COUNT; ++i )
|
||||||
|
layers.insert( layers.begin() + i, i );
|
||||||
|
|
||||||
|
BOARD* board = m_frame->GetBoard();
|
||||||
|
|
||||||
|
for( int layer : layers )
|
||||||
|
{
|
||||||
|
wxString name = LayerName( layer );
|
||||||
|
|
||||||
|
if( board && layer >= PCBNEW_LAYER_ID_START && layer < PCB_LAYER_ID_COUNT )
|
||||||
|
name = board->GetLayerName( static_cast<PCB_LAYER_ID>( layer ) );
|
||||||
|
|
||||||
|
createButton( layer, m_currentSettings->GetColor( layer ), name );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
|
||||||
|
* Copyright (C) 2020 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
|
||||||
|
* Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PANEL_MODEDIT_COLOR_SETTINGS_H_
|
||||||
|
#define PANEL_MODEDIT_COLOR_SETTINGS_H_
|
||||||
|
|
||||||
|
#include <gal/color4d.h>
|
||||||
|
#include <layers_id_colors_and_visibility.h>
|
||||||
|
#include <panel_color_settings.h>
|
||||||
|
|
||||||
|
class COLOR_SETTINGS;
|
||||||
|
class PAGE_INFO;
|
||||||
|
class FOOTPRINT_EDIT_FRAME;
|
||||||
|
class TITLE_BLOCK;
|
||||||
|
|
||||||
|
namespace KIGFX
|
||||||
|
{
|
||||||
|
class WS_PROXY_VIEW_ITEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
class PANEL_MODEDIT_COLOR_SETTINGS : public PANEL_COLOR_SETTINGS
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PANEL_MODEDIT_COLOR_SETTINGS( FOOTPRINT_EDIT_FRAME* aFrame, wxWindow* aParent );
|
||||||
|
|
||||||
|
~PANEL_MODEDIT_COLOR_SETTINGS() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool TransferDataFromWindow() override;
|
||||||
|
|
||||||
|
bool TransferDataToWindow() override;
|
||||||
|
|
||||||
|
enum COLOR_CONTEXT_ID
|
||||||
|
{
|
||||||
|
ID_COPY = wxID_HIGHEST + 1,
|
||||||
|
ID_PASTE,
|
||||||
|
ID_REVERT
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
FOOTPRINT_EDIT_FRAME* m_frame;
|
||||||
|
|
||||||
|
PAGE_INFO* m_page;
|
||||||
|
|
||||||
|
TITLE_BLOCK* m_titleBlock;
|
||||||
|
|
||||||
|
KIGFX::WS_PROXY_VIEW_ITEM* m_ws;
|
||||||
|
|
||||||
|
void createButtons();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -49,7 +49,6 @@ PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS( PCB_EDIT_FRAME* aFrame
|
||||||
COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme );
|
COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme );
|
||||||
|
|
||||||
// Store the current settings before reloading below
|
// Store the current settings before reloading below
|
||||||
current->SetColorContext( COLOR_CONTEXT::PCB );
|
|
||||||
current->Store();
|
current->Store();
|
||||||
mgr.SaveColorSettings( current, "board" );
|
mgr.SaveColorSettings( current, "board" );
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <class_module.h>
|
#include <class_module.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
|
#include <dialogs/panel_modedit_color_settings.h>
|
||||||
#include <dialogs/panel_modedit_defaults.h>
|
#include <dialogs/panel_modedit_defaults.h>
|
||||||
#include <dialogs/panel_modedit_display_options.h>
|
#include <dialogs/panel_modedit_display_options.h>
|
||||||
#include <dialogs/panel_modedit_settings.h>
|
#include <dialogs/panel_modedit_settings.h>
|
||||||
|
@ -440,11 +441,6 @@ void FOOTPRINT_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
|
|
||||||
EDA_DRAW_FRAME::LoadSettings( cfg );
|
EDA_DRAW_FRAME::LoadSettings( cfg );
|
||||||
|
|
||||||
// TODO(JE) remove once color themes exist
|
|
||||||
COLOR_SETTINGS* cs = ColorSettings();
|
|
||||||
cs->SetColorContext( COLOR_CONTEXT::FOOTPRINT );
|
|
||||||
cs->Load();
|
|
||||||
|
|
||||||
// Ensure some params are valid
|
// Ensure some params are valid
|
||||||
BOARD_DESIGN_SETTINGS& settings = GetDesignSettings();
|
BOARD_DESIGN_SETTINGS& settings = GetDesignSettings();
|
||||||
|
|
||||||
|
@ -473,12 +469,13 @@ void FOOTPRINT_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
cfg->m_DesignSettings = GetDesignSettings();
|
cfg->m_DesignSettings = GetDesignSettings();
|
||||||
cfg->m_Display = m_DisplayOptions;
|
cfg->m_Display = m_DisplayOptions;
|
||||||
cfg->m_LibWidth = m_treePane->GetSize().x;
|
cfg->m_LibWidth = m_treePane->GetSize().x;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(JE) remove once color themes exist
|
|
||||||
// Ensure footprint editor color settings get flushed to disk before context is changed
|
COLOR_SETTINGS* FOOTPRINT_EDIT_FRAME::ColorSettings()
|
||||||
COLOR_SETTINGS* cs = ColorSettings();
|
{
|
||||||
cs->SetColorContext( COLOR_CONTEXT::FOOTPRINT );
|
return Pgm().GetSettingsManager().GetColorSettings(
|
||||||
Pgm().GetSettingsManager().SaveColorSettings( cs, "fpedit" );
|
GetFootprintEditorSettings()->m_ColorTheme );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -817,6 +814,7 @@ void FOOTPRINT_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent,
|
||||||
|
|
||||||
book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) );
|
book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) );
|
||||||
book->AddSubPage( new PANEL_MODEDIT_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
|
book->AddSubPage( new PANEL_MODEDIT_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
|
||||||
|
book->AddSubPage( new PANEL_MODEDIT_COLOR_SETTINGS( this, book ), _( "Colors" ) );
|
||||||
book->AddSubPage( new PANEL_MODEDIT_SETTINGS( this, aParent ), _( "Editing Options" ) );
|
book->AddSubPage( new PANEL_MODEDIT_SETTINGS( this, aParent ), _( "Editing Options" ) );
|
||||||
book->AddSubPage( new PANEL_MODEDIT_DEFAULTS( this, aParent ), _( "Default Values" ) );
|
book->AddSubPage( new PANEL_MODEDIT_DEFAULTS( this, aParent ), _( "Default Values" ) );
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,8 @@ public:
|
||||||
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
|
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
|
||||||
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
|
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
|
||||||
|
|
||||||
|
COLOR_SETTINGS* ColorSettings() override;
|
||||||
|
|
||||||
const BOX2I GetDocumentExtents() const override;
|
const BOX2I GetDocumentExtents() const override;
|
||||||
|
|
||||||
void OnCloseWindow( wxCloseEvent& Event ) override;
|
void OnCloseWindow( wxCloseEvent& Event ) override;
|
||||||
|
|
|
@ -28,8 +28,11 @@
|
||||||
#include <wx/config.h>
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern const char* traceSettings;
|
||||||
|
|
||||||
|
|
||||||
///! Update the schema version whenever a migration is required
|
///! Update the schema version whenever a migration is required
|
||||||
const int fpEditSchemaVersion = 0;
|
const int fpEditSchemaVersion = 1;
|
||||||
|
|
||||||
|
|
||||||
FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS() :
|
FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS() :
|
||||||
|
@ -239,15 +242,14 @@ bool FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
||||||
const std::string f = "ModEdit";
|
const std::string f = "ModEdit";
|
||||||
|
|
||||||
// Migrate color settings that were stored in the pcbnew config file
|
// Migrate color settings that were stored in the pcbnew config file
|
||||||
|
// We create a copy of the user scheme for the footprint editor context
|
||||||
|
|
||||||
SETTINGS_MANAGER& manager = Pgm().GetSettingsManager();
|
SETTINGS_MANAGER& manager = Pgm().GetSettingsManager();
|
||||||
COLOR_SETTINGS* cs = manager.GetColorSettings();
|
COLOR_SETTINGS* cs = manager.AddNewColorSettings( "user_footprints" );
|
||||||
|
|
||||||
// Flush here just in case we somehow have dirty pcbnew colors
|
cs->SetName( wxT( "KiCad Default (Footprints)" ) );
|
||||||
manager.Save( cs );
|
manager.Save( cs );
|
||||||
|
|
||||||
cs->SetColorContext( COLOR_CONTEXT::FOOTPRINT );
|
|
||||||
|
|
||||||
auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId ) {
|
auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId ) {
|
||||||
wxString str;
|
wxString str;
|
||||||
|
|
||||||
|
@ -280,7 +282,64 @@ bool FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
||||||
migrateLegacyColor( f + "Color4DViaThruEx", LAYER_VIA_THROUGH );
|
migrateLegacyColor( f + "Color4DViaThruEx", LAYER_VIA_THROUGH );
|
||||||
migrateLegacyColor( f + "Color4DWorksheet", LAYER_WORKSHEET );
|
migrateLegacyColor( f + "Color4DWorksheet", LAYER_WORKSHEET );
|
||||||
|
|
||||||
manager.SaveColorSettings( cs, "fpedit" );
|
manager.SaveColorSettings( cs, "board" );
|
||||||
|
|
||||||
|
( *this )[PointerFromString( "appearance.color_theme" )] = "user_footprints";
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FOOTPRINT_EDITOR_SETTINGS::Migrate()
|
||||||
|
{
|
||||||
|
bool ret = true;
|
||||||
|
int filever = at( PointerFromString( "meta.version" ) ).get<int>();
|
||||||
|
|
||||||
|
if( filever == 0 )
|
||||||
|
{
|
||||||
|
ret &= migrateSchema0to1();
|
||||||
|
|
||||||
|
if( ret )
|
||||||
|
{
|
||||||
|
( *this )[PointerFromString( "meta.version" )] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FOOTPRINT_EDITOR_SETTINGS::migrateSchema0to1()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Schema version 0 to 1:
|
||||||
|
*
|
||||||
|
* - Check to see if a footprints version of the currently selected theme exists.
|
||||||
|
* - If so, select it
|
||||||
|
*/
|
||||||
|
|
||||||
|
if( !m_manager )
|
||||||
|
{
|
||||||
|
wxLogTrace(
|
||||||
|
traceSettings, "Error: FOOTPRINT_EDITOR_SETTINGS migration cannot run unmanaged!" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
nlohmann::json::json_pointer theme_ptr( "/appearance/color_theme" );
|
||||||
|
|
||||||
|
wxString selected = at( theme_ptr ).get<wxString>();
|
||||||
|
wxString search = selected + wxT( "_footprints" );
|
||||||
|
|
||||||
|
for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() )
|
||||||
|
{
|
||||||
|
if( settings->GetFilename() == search )
|
||||||
|
{
|
||||||
|
wxLogTrace( traceSettings, "Updating footprint editor theme from %s to %s",
|
||||||
|
selected, search );
|
||||||
|
( *this )[theme_ptr] = search;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -42,6 +42,8 @@ public:
|
||||||
|
|
||||||
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
|
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
|
||||||
|
|
||||||
|
bool Migrate() override;
|
||||||
|
|
||||||
BOARD_DESIGN_SETTINGS m_DesignSettings;
|
BOARD_DESIGN_SETTINGS m_DesignSettings;
|
||||||
|
|
||||||
MAGNETIC_OPTIONS m_MagneticPads;
|
MAGNETIC_OPTIONS m_MagneticPads;
|
||||||
|
@ -64,6 +66,10 @@ public:
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual std::string getLegacyFrameName() const override { return "ModEditFrame"; }
|
virtual std::string getLegacyFrameName() const override { return "ModEditFrame"; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool migrateSchema0to1();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -423,9 +423,7 @@ FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow*
|
||||||
panel->GetGAL()->SetGridVisibility( pcbnew->IsGridVisible() );
|
panel->GetGAL()->SetGridVisibility( pcbnew->IsGridVisible() );
|
||||||
panel->GetGAL()->SetGridSize( VECTOR2D( pcbnew->GetScreen()->GetGridSize() ) );
|
panel->GetGAL()->SetGridSize( VECTOR2D( pcbnew->GetScreen()->GetGridSize() ) );
|
||||||
|
|
||||||
// Grid color (among other things):
|
panel->GetView()->GetPainter()->GetSettings()->LoadColors( pcbnew->GetColorSettings() );
|
||||||
KIGFX::PAINTER* pcbnew_painter = pcbnew->GetCanvas()->GetView()->GetPainter();
|
|
||||||
panel->GetView()->GetPainter()->ApplySettings( pcbnew_painter->GetSettings() );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -435,6 +433,8 @@ FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow*
|
||||||
std::unique_ptr<PCB_SCREEN> temp_screen = std::make_unique<PCB_SCREEN>( wxSize() );
|
std::unique_ptr<PCB_SCREEN> temp_screen = std::make_unique<PCB_SCREEN>( wxSize() );
|
||||||
temp_screen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + cfg->m_Window.grid.last_size );
|
temp_screen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + cfg->m_Window.grid.last_size );
|
||||||
panel->GetGAL()->SetGridSize( VECTOR2D( temp_screen->GetGridSize() ) );
|
panel->GetGAL()->SetGridSize( VECTOR2D( temp_screen->GetGridSize() ) );
|
||||||
|
|
||||||
|
panel->UpdateColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
return panel;
|
return panel;
|
||||||
|
|
|
@ -743,6 +743,17 @@ WINDOW_SETTINGS* FOOTPRINT_VIEWER_FRAME::GetWindowSettings( APP_SETTINGS_BASE* a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
COLOR_SETTINGS* FOOTPRINT_VIEWER_FRAME::ColorSettings()
|
||||||
|
{
|
||||||
|
auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
|
||||||
|
|
||||||
|
if( settings )
|
||||||
|
return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
|
||||||
|
else
|
||||||
|
return Pgm().GetSettingsManager().GetColorSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
|
void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
|
||||||
{
|
{
|
||||||
PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged );
|
PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged );
|
||||||
|
|
|
@ -80,6 +80,8 @@ public:
|
||||||
*/
|
*/
|
||||||
bool ShowModal( wxString* aFootprint, wxWindow* aParent ) override;
|
bool ShowModal( wxString* aFootprint, wxWindow* aParent ) override;
|
||||||
|
|
||||||
|
COLOR_SETTINGS* ColorSettings() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxTextCtrl* m_libFilter;
|
wxTextCtrl* m_libFilter;
|
||||||
wxListBox* m_libList; // The list of libs names
|
wxListBox* m_libList; // The list of libs names
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <grid_tricks.h>
|
#include <grid_tricks.h>
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <footprint_edit_frame.h>
|
#include <footprint_edit_frame.h>
|
||||||
|
#include <footprint_editor_settings.h>
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
#include <pcbnew_settings.h>
|
#include <pcbnew_settings.h>
|
||||||
#include "footprint_wizard_frame.h"
|
#include "footprint_wizard_frame.h"
|
||||||
|
@ -42,6 +43,9 @@
|
||||||
#include <wx/numformatter.h>
|
#include <wx/numformatter.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
#include <base_units.h>
|
#include <base_units.h>
|
||||||
|
#include <pgm_base.h>
|
||||||
|
#include <settings/color_settings.h>
|
||||||
|
#include <settings/settings_manager.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tool/tool_dispatcher.h>
|
#include <tool/tool_dispatcher.h>
|
||||||
#include <tool/action_toolbar.h>
|
#include <tool/action_toolbar.h>
|
||||||
|
@ -290,6 +294,13 @@ void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
COLOR_SETTINGS* FOOTPRINT_WIZARD_FRAME::ColorSettings()
|
||||||
|
{
|
||||||
|
return Pgm().GetSettingsManager().GetColorSettings(
|
||||||
|
GetFootprintEditorSettings()->m_ColorTheme );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT_WIZARD_FRAME::updateView()
|
void FOOTPRINT_WIZARD_FRAME::updateView()
|
||||||
{
|
{
|
||||||
GetCanvas()->UpdateColors();
|
GetCanvas()->UpdateColors();
|
||||||
|
|
|
@ -85,6 +85,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void PythonPluginsReload();
|
void PythonPluginsReload();
|
||||||
|
|
||||||
|
COLOR_SETTINGS* ColorSettings() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void OnSize( wxSizeEvent& event ) override;
|
void OnSize( wxSizeEvent& event ) override;
|
||||||
|
|
|
@ -26,12 +26,15 @@
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <pcb_draw_panel_gal.h>
|
#include <pcb_draw_panel_gal.h>
|
||||||
#include <pcb_layer_widget.h>
|
#include <pcb_layer_widget.h>
|
||||||
|
#include <pcbnew_settings.h>
|
||||||
|
#include <pgm_base.h>
|
||||||
#include <gal/graphics_abstraction_layer.h>
|
#include <gal/graphics_abstraction_layer.h>
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <view/view.h>
|
#include <view/view.h>
|
||||||
#include "footprint_info_impl.h"
|
#include "footprint_info_impl.h"
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
#include <settings/color_settings.h>
|
#include <settings/color_settings.h>
|
||||||
|
#include <settings/settings_manager.h>
|
||||||
#include <tools/pcb_actions.h>
|
#include <tools/pcb_actions.h>
|
||||||
|
|
||||||
PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
||||||
|
@ -131,3 +134,9 @@ void PCB_BASE_EDIT_FRAME::SetGridVisibility( bool aVisible )
|
||||||
// TODO (ISM): Remove this by changing toolbars to use the EVT_UPDATE_UI to get the state
|
// TODO (ISM): Remove this by changing toolbars to use the EVT_UPDATE_UI to get the state
|
||||||
SyncToolbars();
|
SyncToolbars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
COLOR_SETTINGS* PCB_BASE_EDIT_FRAME::ColorSettings()
|
||||||
|
{
|
||||||
|
return Pgm().GetSettingsManager().GetColorSettings( GetPcbNewSettings()->m_ColorTheme );
|
||||||
|
}
|
||||||
|
|
|
@ -190,6 +190,8 @@ public:
|
||||||
|
|
||||||
void OnGridSettings( wxCommandEvent& aEvent ) override;
|
void OnGridSettings( wxCommandEvent& aEvent ) override;
|
||||||
|
|
||||||
|
COLOR_SETTINGS* ColorSettings() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// User defined rotation angle (in tenths of a degree).
|
/// User defined rotation angle (in tenths of a degree).
|
||||||
int m_rotationAngle;
|
int m_rotationAngle;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <3d_viewer/eda_3d_viewer.h> // To include VIEWER3D_FRAMENAME
|
#include <3d_viewer/eda_3d_viewer.h> // To include VIEWER3D_FRAMENAME
|
||||||
#include <pcbnew.h>
|
#include <pcbnew.h>
|
||||||
|
#include <footprint_editor_settings.h>
|
||||||
#include <fp_lib_table.h>
|
#include <fp_lib_table.h>
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
|
@ -320,12 +321,6 @@ void PCB_BASE_FRAME::SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
COLOR_SETTINGS* PCB_BASE_FRAME::ColorSettings()
|
|
||||||
{
|
|
||||||
return Pgm().GetSettingsManager().GetColorSettings( GetSettings()->m_ColorTheme );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PCB_BASE_FRAME::SetDrawBgColor( COLOR4D aColor )
|
void PCB_BASE_FRAME::SetDrawBgColor( COLOR4D aColor )
|
||||||
{
|
{
|
||||||
m_drawBgColor= aColor;
|
m_drawBgColor= aColor;
|
||||||
|
|
|
@ -210,17 +210,21 @@ void PCB_DRAW_PANEL_GAL::UpdateColors()
|
||||||
auto frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
|
auto frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
|
||||||
|
|
||||||
if( frame )
|
if( frame )
|
||||||
|
{
|
||||||
cs = frame->ColorSettings();
|
cs = frame->ColorSettings();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PCBNEW_SETTINGS* app = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
|
||||||
|
|
||||||
|
if( app )
|
||||||
|
cs = Pgm().GetSettingsManager().GetColorSettings( app->m_ColorTheme );
|
||||||
else
|
else
|
||||||
cs = Pgm().GetSettingsManager().GetColorSettings();
|
cs = Pgm().GetSettingsManager().GetColorSettings();
|
||||||
|
}
|
||||||
|
|
||||||
wxCHECK_RET( cs, "null COLOR_SETTINGS" );
|
wxCHECK_RET( cs, "null COLOR_SETTINGS" );
|
||||||
|
|
||||||
if( frame && frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
|
|
||||||
cs->SetColorContext( COLOR_CONTEXT::FOOTPRINT );
|
|
||||||
else
|
|
||||||
cs->SetColorContext( COLOR_CONTEXT::PCB );
|
|
||||||
|
|
||||||
auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() );
|
auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() );
|
||||||
rs->LoadColors( cs );
|
rs->LoadColors( cs );
|
||||||
|
|
||||||
|
|
|
@ -596,7 +596,6 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
||||||
void PCB_EDIT_FRAME::ActivateGalCanvas()
|
void PCB_EDIT_FRAME::ActivateGalCanvas()
|
||||||
{
|
{
|
||||||
PCB_BASE_EDIT_FRAME::ActivateGalCanvas();
|
PCB_BASE_EDIT_FRAME::ActivateGalCanvas();
|
||||||
ColorSettings()->SetColorContext( COLOR_CONTEXT::PCB );
|
|
||||||
GetCanvas()->UpdateColors();
|
GetCanvas()->UpdateColors();
|
||||||
GetCanvas()->Refresh();
|
GetCanvas()->Refresh();
|
||||||
}
|
}
|
||||||
|
@ -636,11 +635,6 @@ void PCB_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
{
|
{
|
||||||
PCB_BASE_FRAME::LoadSettings( aCfg );
|
PCB_BASE_FRAME::LoadSettings( aCfg );
|
||||||
|
|
||||||
// TODO(JE) remove once color themes exist
|
|
||||||
COLOR_SETTINGS* cs = ColorSettings();
|
|
||||||
cs->SetColorContext( COLOR_CONTEXT::PCB );
|
|
||||||
cs->Load();
|
|
||||||
|
|
||||||
PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
|
PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
|
||||||
wxASSERT( cfg );
|
wxASSERT( cfg );
|
||||||
|
|
||||||
|
@ -659,13 +653,6 @@ void PCB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
{
|
{
|
||||||
PCB_BASE_FRAME::SaveSettings( aCfg );
|
PCB_BASE_FRAME::SaveSettings( aCfg );
|
||||||
|
|
||||||
COLOR_SETTINGS* cs = ColorSettings();
|
|
||||||
cs->SetColorContext( COLOR_CONTEXT::PCB );
|
|
||||||
cs->Store();
|
|
||||||
|
|
||||||
// Ensure pcbnew color settings get flushed to disk before context is changed
|
|
||||||
Pgm().GetSettingsManager().SaveColorSettings( cs, "board" );
|
|
||||||
|
|
||||||
auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
|
auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
|
||||||
wxASSERT( cfg );
|
wxASSERT( cfg );
|
||||||
|
|
||||||
|
|
|
@ -122,8 +122,6 @@ PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwn
|
||||||
|
|
||||||
COLOR4D PCB_LAYER_WIDGET::getBackgroundLayerColor()
|
COLOR4D PCB_LAYER_WIDGET::getBackgroundLayerColor()
|
||||||
{
|
{
|
||||||
myframe->ColorSettings()->SetColorContext( m_fp_editor_mode ?
|
|
||||||
COLOR_CONTEXT::FOOTPRINT : COLOR_CONTEXT::PCB );
|
|
||||||
return myframe->ColorSettings()->GetColor( LAYER_PCB_BACKGROUND );
|
return myframe->ColorSettings()->GetColor( LAYER_PCB_BACKGROUND );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,9 +313,6 @@ void PCB_LAYER_WIDGET::ReFillRender()
|
||||||
BOARD* board = myframe->GetBoard();
|
BOARD* board = myframe->GetBoard();
|
||||||
auto settings = board->GetDesignSettings();
|
auto settings = board->GetDesignSettings();
|
||||||
|
|
||||||
myframe->ColorSettings()->SetColorContext( m_fp_editor_mode ?
|
|
||||||
COLOR_CONTEXT::FOOTPRINT : COLOR_CONTEXT::PCB );
|
|
||||||
|
|
||||||
ClearRenderRows();
|
ClearRenderRows();
|
||||||
|
|
||||||
// Add "Items" tab rows to LAYER_WIDGET, after setting color and checkbox state.
|
// Add "Items" tab rows to LAYER_WIDGET, after setting color and checkbox state.
|
||||||
|
@ -428,9 +423,6 @@ void PCB_LAYER_WIDGET::ReFill()
|
||||||
BOARD* brd = myframe->GetBoard();
|
BOARD* brd = myframe->GetBoard();
|
||||||
LSET enabled = brd->GetEnabledLayers();
|
LSET enabled = brd->GetEnabledLayers();
|
||||||
|
|
||||||
myframe->ColorSettings()->SetColorContext( m_fp_editor_mode ?
|
|
||||||
COLOR_CONTEXT::FOOTPRINT : COLOR_CONTEXT::PCB );
|
|
||||||
|
|
||||||
ClearLayerRows();
|
ClearLayerRows();
|
||||||
|
|
||||||
wxString dsc;
|
wxString dsc;
|
||||||
|
@ -522,7 +514,6 @@ void PCB_LAYER_WIDGET::ReFill()
|
||||||
void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor )
|
void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor )
|
||||||
{
|
{
|
||||||
COLOR_SETTINGS* cs = myframe->ColorSettings();
|
COLOR_SETTINGS* cs = myframe->ColorSettings();
|
||||||
cs->SetColorContext( m_fp_editor_mode ? COLOR_CONTEXT::FOOTPRINT : COLOR_CONTEXT::PCB );
|
|
||||||
cs->SetColor( aLayer, aColor );
|
cs->SetColor( aLayer, aColor );
|
||||||
|
|
||||||
myframe->GetCanvas()->UpdateColors();
|
myframe->GetCanvas()->UpdateColors();
|
||||||
|
@ -610,8 +601,6 @@ 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 );
|
||||||
|
|
||||||
myframe->ColorSettings()->SetColorContext( m_fp_editor_mode ?
|
|
||||||
COLOR_CONTEXT::FOOTPRINT : COLOR_CONTEXT::PCB );
|
|
||||||
myframe->ColorSettings()->SetColor( aId, aColor );
|
myframe->ColorSettings()->SetColor( aId, aColor );
|
||||||
myframe->GetCanvas()->UpdateColors();
|
myframe->GetCanvas()->UpdateColors();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue