Move galDisplayOptions access from pcbnew to common.

This commit is contained in:
Jeff Young 2018-08-28 23:32:36 +01:00
parent a03dc577f8
commit da4fb4ae3a
8 changed files with 61 additions and 41 deletions

View File

@ -48,7 +48,8 @@
EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
const wxPoint& aPosition, const wxSize& aSize,
KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) :
wxScrolledCanvas( aParentWindow, aWindowId, aPosition, aSize ), m_options( aOptions )
wxScrolledCanvas( aParentWindow, aWindowId, aPosition, aSize ),
m_options( aOptions )
{
m_parent = aParentWindow;
m_edaFrame = dynamic_cast<EDA_DRAW_FRAME*>( aParentWindow );

View File

@ -87,8 +87,6 @@ static const wxString ShowGridEntryKeyword( wxT( "ShowGrid" ) );
static const wxString GridColorEntryKeyword( wxT( "GridColor" ) );
/// Most recently used grid size (suffix)
static const wxString LastGridSizeIdKeyword( wxT( "_LastGridSize" ) );
/// GAL Display Options
static const wxString GalDisplayOptionsKeyword( wxT( "GalDisplayOptions" ) );
const wxChar EDA_DRAW_FRAME::CANVAS_TYPE_KEY[] = wxT( "canvas_type" );
@ -145,8 +143,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
const wxString& aTitle,
const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString & aFrameName ) :
KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
m_galDisplayOptions( std::make_unique<KIGFX::GAL_DISPLAY_OPTIONS>() )
KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
{
m_useSingleCanvasPane = false;
m_socketServer = nullptr;
@ -293,6 +290,14 @@ void EDA_DRAW_FRAME::CommonSettingsChanged()
{
EDA_BASE_FRAME::CommonSettingsChanged();
int autosaveInterval;
Pgm().CommonSettings()->Read( AUTOSAVE_INTERVAL_KEY, &autosaveInterval );
SetAutoSaveInterval( autosaveInterval );
int historySize;
Pgm().CommonSettings()->Read( FILE_HISTORY_SIZE_KEY, &historySize, DEFAULT_FILE_HISTORY_SIZE );
Kiface().GetFileHistory().SetMaxFiles( (unsigned) std::max( 0, historySize ) );
bool option;
Pgm().CommonSettings()->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option );
m_canvas->SetEnableMousewheelPan( option );
@ -302,6 +307,8 @@ void EDA_DRAW_FRAME::CommonSettingsChanged()
Pgm().CommonSettings()->Read( ENBL_AUTO_PAN_KEY, &option );
m_canvas->SetEnableAutoPan( option );
m_galDisplayOptions.ReadConfig( Pgm().CommonSettings(), GAL_DISPLAY_OPTIONS_KEY );
}
@ -806,8 +813,7 @@ void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
// Read grid color:
COLOR4D wtmp = COLOR4D::UNSPECIFIED;
if( wtmp.SetFromWxString( aCfg->Read(
baseCfgName + GridColorEntryKeyword, wxT( "NONE" ) ) ) )
if( wtmp.SetFromWxString( aCfg->Read( baseCfgName + GridColorEntryKeyword, wxT( "NONE" ) ) ) )
SetGridColor( wtmp );
aCfg->Read( baseCfgName + LastGridSizeIdKeyword, &m_LastGridSizeId, 0L );
@ -821,7 +827,7 @@ void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
aCfg->Read( baseCfgName + FirstRunShownKeyword, &m_firstRunDialogSetting, 0L );
m_galDisplayOptions->ReadConfig( aCfg, baseCfgName + GalDisplayOptionsKeyword );
m_galDisplayOptions.ReadConfig( Pgm().CommonSettings(), GAL_DISPLAY_OPTIONS_KEY );
}
@ -840,8 +846,6 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
if( GetScreen() )
aCfg->Write( baseCfgName + MaxUndoItemsEntry, long( GetScreen()->GetMaxUndoItems() ) );
m_galDisplayOptions->WriteConfig( aCfg, baseCfgName + GalDisplayOptionsKeyword );
}

View File

@ -90,8 +90,6 @@ static const wxString ShowGridEntryKeyword( wxT( "ShowGrid" ) );
static const wxString GridColorEntryKeyword( wxT( "GridColor" ) );
/// Most recently used grid size (suffix)
static const wxString LastGridSizeIdKeyword( wxT( "_LastGridSize" ) );
/// GAL Display Options
static const wxString GalDisplayOptionsKeyword( wxT( "GalDisplayOptions" ) );
const wxChar EDA_DRAW_FRAME::CANVAS_TYPE_KEY[] = wxT( "canvas_type" );
@ -148,8 +146,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
const wxString& aTitle,
const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString & aFrameName ) :
KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
m_galDisplayOptions( std::make_unique<KIGFX::GAL_DISPLAY_OPTIONS>() )
KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
{
m_socketServer = nullptr;
m_drawToolBar = NULL;
@ -310,6 +307,8 @@ void EDA_DRAW_FRAME::CommonSettingsChanged()
Pgm().CommonSettings()->Read( ENBL_AUTO_PAN_KEY, &option );
m_canvas->SetEnableAutoPan( option );
m_galDisplayOptions.ReadConfig( Pgm().CommonSettings(), GAL_DISPLAY_OPTIONS_KEY );
}
@ -829,7 +828,7 @@ void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
aCfg->Read( baseCfgName + FirstRunShownKeyword, &m_firstRunDialogSetting, 0L );
m_galDisplayOptions->ReadConfig( aCfg, baseCfgName + GalDisplayOptionsKeyword );
m_galDisplayOptions.ReadConfig( Pgm().CommonSettings(), GAL_DISPLAY_OPTIONS_KEY );
}
@ -848,8 +847,6 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
if( GetScreen() )
aCfg->Write( baseCfgName + MaxUndoItemsEntry, long( GetScreen()->GetMaxUndoItems() ) );
m_galDisplayOptions->WriteConfig( aCfg, baseCfgName + GalDisplayOptionsKeyword );
}

View File

@ -53,6 +53,7 @@
#include <dialog_configure_paths.h>
#include <lockfile.h>
#include <systemdirsappend.h>
#include <gal/gal_display_options.h>
#define KICAD_COMMON wxT( "kicad_common" )
@ -551,24 +552,41 @@ void PGM_BASE::loadCommonSettings()
if( !m_common_settings->HasEntry( USE_ICONS_IN_MENUS_KEY ) )
m_common_settings->Write( USE_ICONS_IN_MENUS_KEY, defaultUseIconsInMenus );
if( !m_common_settings->HasEntry( ICON_SCALE_KEY ) )
if( !m_common_settings->HasEntry( ICON_SCALE_KEY )
|| !m_common_settings->HasEntry( GAL_DISPLAY_OPTIONS_KEY ) )
{
// 5.0 and earlier saved these for each app; we arbitrarily pick pcbnew to fetch them from
wxConfigBase* cfg = GetNewConfig( wxString::FromUTF8( "pcbnew" ) );
wxString value;
bool option;
// 5.0 and earlier saved common settings in each app, and saved GAL display options
// only in pcbnew (which was the only canvas to support them). Since there's no
// single right answer to where to pull the common settings from, we might as well
// get them along with the GAL display options from pcbnew.
wxConfigBase* pcbnewConfig = GetNewConfig( wxString::FromUTF8( "pcbnew" ) );
cfg->Read( "PcbIconScale", &value );
m_common_settings->Write( ICON_SCALE_KEY, value );
if( !m_common_settings->HasEntry( ICON_SCALE_KEY ) )
{
wxString value;
bool option;
cfg->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
m_common_settings->Write( ENBL_MOUSEWHEEL_PAN_KEY, option );
pcbnewConfig->Read( "PcbIconScale", &value );
m_common_settings->Write( ICON_SCALE_KEY, value );
cfg->Read( ENBL_ZOOM_NO_CENTER_KEY, &option, false );
m_common_settings->Write( ENBL_ZOOM_NO_CENTER_KEY, option );
pcbnewConfig->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
m_common_settings->Write( ENBL_MOUSEWHEEL_PAN_KEY, option );
cfg->Read( ENBL_AUTO_PAN_KEY, &option, true );
m_common_settings->Write( ENBL_AUTO_PAN_KEY, option );
pcbnewConfig->Read( ENBL_ZOOM_NO_CENTER_KEY, &option, false );
m_common_settings->Write( ENBL_ZOOM_NO_CENTER_KEY, option );
pcbnewConfig->Read( ENBL_AUTO_PAN_KEY, &option, true );
m_common_settings->Write( ENBL_AUTO_PAN_KEY, option );
}
if( !m_common_settings->HasEntry( GAL_DISPLAY_OPTIONS_KEY ) )
{
KIGFX::GAL_DISPLAY_OPTIONS temp;
temp.ReadConfig( pcbnewConfig, wxString( "PcbFrame" ) + GAL_DISPLAY_OPTIONS_KEY );
temp.WriteConfig( m_common_settings, GAL_DISPLAY_OPTIONS_KEY );
m_common_settings->Write( GAL_DISPLAY_OPTIONS_KEY, 1 );
}
}
m_editor_name = m_common_settings->Read( wxT( "Editor" ) );

View File

@ -499,11 +499,8 @@ bool SCH_BASE_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& a
void EDA_DRAW_FRAME::createCanvas()
{
KIGFX::GAL_DISPLAY_OPTIONS options;
m_canvas = new SCH_DRAW_PANEL( this, -1, wxPoint( 0,
0 ), m_FrameSize, options, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
m_canvas = new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_FrameSize,
m_galDisplayOptions, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
m_useSingleCanvasPane = true;

View File

@ -36,6 +36,8 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway )
m_status( nullptr ),
m_sizer( nullptr )
{
m_galDisplayOptions.ReadConfig( Pgm().CommonSettings(), GAL_DISPLAY_OPTIONS_KEY );
m_preview = new SCH_PREVIEW_PANEL( aParent, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ),
m_galDisplayOptions, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
m_preview->SetStealsFocus( false );

View File

@ -67,17 +67,17 @@ class EDA_DRAW_FRAME : public KIWAY_PLAYER
friend class EDA_DRAW_PANEL;
///< Id of active button on the vertical toolbar.
int m_toolId;
int m_toolId;
BASE_SCREEN* m_currentScreen; ///< current used SCREEN
BASE_SCREEN* m_currentScreen; ///< current used SCREEN
bool m_snapToGrid; ///< Indicates if cursor should be snapped to grid.
bool m_galCanvasActive; ///< whether to use new GAL engine
bool m_snapToGrid; ///< Indicates if cursor should be snapped to grid.
bool m_galCanvasActive; ///< whether to use new GAL engine
EDA_DRAW_PANEL_GAL* m_galCanvas;
///< GAL display options - this is the frame's interface to setting GAL display options
std::unique_ptr<KIGFX::GAL_DISPLAY_OPTIONS> m_galDisplayOptions;
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions;
bool m_useSingleCanvasPane;
@ -923,7 +923,7 @@ public:
* Function GetGalDisplayOptions
* Returns a reference to the gal rendering options used by GAL for rendering.
*/
KIGFX::GAL_DISPLAY_OPTIONS& GetGalDisplayOptions() { return *m_galDisplayOptions; }
KIGFX::GAL_DISPLAY_OPTIONS& GetGalDisplayOptions() { return m_galDisplayOptions; }
/**
* Function SyncMenusAndToolbars

View File

@ -49,6 +49,7 @@
#define MIDDLE_BUTT_PAN_LIMITED_KEY wxT( "MiddleBtnPANLimited" )
#define ENBL_AUTO_PAN_KEY wxT( "AutoPAN" )
#define FILE_HISTORY_SIZE_KEY wxT( "FileHistorySize" )
#define GAL_DISPLAY_OPTIONS_KEY wxT( "GalDisplayOptions" )
///@}