7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-03-30 06:46:55 +00:00

Common folder housekeeping part 3.

This commit is contained in:
Wayne Stambaugh 2025-01-16 07:37:05 -05:00
parent af38f76f01
commit e09b095533
76 changed files with 621 additions and 379 deletions

View File

@ -150,16 +150,16 @@ bool isCtrlSlash( wxKeyEvent& aEvent )
// OK, now the wxWidgets hacks start.
// (We should abandon these if https://trac.wxwidgets.org/ticket/18911 gets resolved.)
// Many Latin America and European keyboars have have the / over the 7. We know that
// Many Latin America and European keyboards have have the / over the 7. We know that
// wxWidgets messes this up and returns Shift+7 through GetUnicodeKey(). However, other
// keyboards (such as France and Belgium) have 7 in the shifted position, so a Shift+7
// *could* be legitimate.
// However, we *are* checking Ctrl, so to assume any Shift+7 is a Ctrl-/ really only
// disallows Ctrl+Shift+7 from doing something else, which is probably OK. (This routine
// is only used in the Scintilla editor, not in the rest of Kicad.)
// is only used in the Scintilla editor, not in the rest of KiCad.)
// The other main shifted loation of / is over : (France and Belgium), so we'll sacrifice
// The other main shifted location of / is over : (France and Belgium), so we'll sacrifice
// Ctrl+Shift+: too.
if( aEvent.ShiftDown() && ( aEvent.GetUnicodeKey() == '7' || aEvent.GetUnicodeKey() == ':' ) )
@ -576,7 +576,8 @@ void SCINTILLA_TRICKS::DoTextVarAutocomplete(
auto textVarRef =
[&]( int pos )
{
return pos >= 2 && m_te->GetCharAt( pos-2 ) == '$' && m_te->GetCharAt( pos-1 ) == '{';
return pos >= 2 && m_te->GetCharAt( pos-2 ) == '$'
&& m_te->GetCharAt( pos-1 ) == '{';
};
// Check for cross-reference

View File

@ -58,7 +58,8 @@ static wxString base_dir( const wxString& aRelativePath, const wxString& aBaseDi
if( !fn.IsAbsolute() && !!aBaseDir )
{
wxASSERT_MSG( wxFileName( aBaseDir ).IsAbsolute(), wxT( "Must pass absolute path in aBaseDir" ) );
wxASSERT_MSG( wxFileName( aBaseDir ).IsAbsolute(),
wxT( "Must pass absolute path in aBaseDir" ) );
fn.MakeRelativeTo( aBaseDir );
}
@ -82,7 +83,7 @@ wxString SEARCH_STACK::FilenameWithRelativePathInSearchList(
// Search for the shortest subpath within 'this':
if( fn.MakeRelativeTo( base_dir( (*this)[kk], aBaseDir ) ) )
{
if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside kicad libs paths
if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside KiCad libs paths
continue;
if( pathlen > fn.GetPath().Len() ) // A better (shortest) subpath is found
@ -199,14 +200,14 @@ const wxString SEARCH_STACK::LastVisitedPath( const wxString& aSubPathToSearch )
#endif
#if defined(DEBUG)
#if defined( DEBUG )
void SEARCH_STACK::Show( const wxString& aPrefix ) const
{
wxLogTrace( tracePathsAndFiles, "%s SEARCH_STACK:", aPrefix );
for( unsigned i=0; i<GetCount(); ++i )
for( unsigned i = 0; i < GetCount(); ++i )
{
wxLogTrace( tracePathsAndFiles, " [%2u]:%s", i, TO_UTF8( (*this)[i] ) );
wxLogTrace( tracePathsAndFiles, " [%2u]:%s", i, TO_UTF8( ( *this )[i] ) );
}
}
#endif

View File

@ -325,8 +325,10 @@ bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::stri
ret &= fromLegacy<int>( aCfg, aFrame + "Pos_x", aJsonPath + ".pos_x" );
ret &= fromLegacy<int>( aCfg, aFrame + "Pos_y", aJsonPath + ".pos_y" );
ret &= fromLegacy<bool>( aCfg, frameGDO + "ForceDisplayCursor", cursorPath + ".always_show_cursor" );
ret &= fromLegacy<bool>( aCfg, frameGDO + "CursorFullscreen", cursorPath + ".fullscreen_cursor" );
ret &= fromLegacy<bool>( aCfg, frameGDO + "ForceDisplayCursor",
cursorPath + ".always_show_cursor" );
ret &= fromLegacy<bool>( aCfg, frameGDO + "CursorFullscreen",
cursorPath + ".fullscreen_cursor" );
ret &= fromLegacy<int>( aCfg, aFrame + "_LastGridSize", gridPath + ".last_size" );

View File

@ -99,6 +99,7 @@ void from_json( const nlohmann::json& j, BOM_PRESET& f )
j.at( "filter_string" ).get_to( f.filterString );
j.at( "group_symbols" ).get_to( f.groupSymbols );
j.at( "exclude_dnp" ).get_to( f.excludeDNP );
// Was not present in initial BOM settings in 8.0, so default to false if not found
f.includeExcludedFromBOM = j.value( "include_excluded_from_bom", false );
}
@ -162,7 +163,8 @@ BOM_PRESET BOM_PRESET::GroupedByValue()
BOM_PRESET BOM_PRESET::GroupedByValueFootprint()
{
BOM_PRESET p{
_HKI( "Grouped By Value and Footprint" ), true, {}, _( "Reference" ), true, "", true, false, false
_HKI( "Grouped By Value and Footprint" ), true, {}, _( "Reference" ), true, "",
true, false, false
};
p.fieldsOrdered = std::vector<BOM_FIELD>{
@ -198,12 +200,14 @@ BOM_PRESET BOM_PRESET::Attributes()
return p;
}
std::vector<BOM_PRESET> BOM_PRESET::BuiltInPresets()
{
return { BOM_PRESET::DefaultEditing(), BOM_PRESET::GroupedByValue(),
BOM_PRESET::GroupedByValueFootprint(), BOM_PRESET::Attributes() };
}
//Implementations for BOM_FMT_PRESET
bool BOM_FMT_PRESET::operator==( const BOM_FMT_PRESET& rhs ) const
{
@ -256,11 +260,13 @@ BOM_FMT_PRESET BOM_FMT_PRESET::CSV()
return { _HKI( "CSV" ), true, wxS( "," ), wxT( "\"" ), wxT( "," ), wxT( "" ), false, false };
}
BOM_FMT_PRESET BOM_FMT_PRESET::TSV()
{
return { _HKI( "TSV" ), true, wxS( "\t" ), wxT( "" ), wxT( "," ), wxT( "" ), false, false };
}
BOM_FMT_PRESET BOM_FMT_PRESET::Semicolons()
{
return {
@ -268,11 +274,13 @@ BOM_FMT_PRESET BOM_FMT_PRESET::Semicolons()
};
}
std::vector<BOM_FMT_PRESET> BOM_FMT_PRESET::BuiltInPresets()
{
return { BOM_FMT_PRESET::CSV(), BOM_FMT_PRESET::TSV(), BOM_FMT_PRESET::Semicolons() };
}
#if !defined( __MINGW32__ )
template class KICOMMON_API PARAM_LIST<BOM_PRESET>;
template class KICOMMON_API PARAM_LIST<BOM_FMT_PRESET>;

View File

@ -450,24 +450,29 @@ bool COMMON_SETTINGS::migrateSchema0to1()
}
catch( ... )
{
wxLogTrace( traceSettings, wxT( "COMMON_SETTINGS::Migrate 0->1: mousewheel_pan not found" ) );
wxLogTrace( traceSettings,
wxT( "COMMON_SETTINGS::Migrate 0->1: mousewheel_pan not found" ) );
}
if( mwp )
{
( *m_internals )[nlohmann::json::json_pointer( "/input/horizontal_pan" )] = true;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] = WXK_SHIFT;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] =
WXK_SHIFT;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_v" )] = 0;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = WXK_CONTROL;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] =
WXK_CONTROL;
}
else
{
( *m_internals )[nlohmann::json::json_pointer( "/input/horizontal_pan" )] = false;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] = WXK_CONTROL;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_v" )] = WXK_SHIFT;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = 0;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] =
WXK_CONTROL;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_v" )] =
WXK_SHIFT;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = 0;
}
return true;
@ -483,17 +488,21 @@ bool COMMON_SETTINGS::migrateSchema1to2()
try
{
prefer_selection = m_internals->at( v1_pointer );
m_internals->at( nlohmann::json::json_pointer( "/input"_json_pointer ) ).erase( "prefer_select_to_drag" );
m_internals->at( nlohmann::json::json_pointer( "/input"_json_pointer ) )
.erase( "prefer_select_to_drag" );
}
catch( ... )
{
wxLogTrace( traceSettings, wxT( "COMMON_SETTINGS::Migrate 1->2: prefer_select_to_drag not found" ) );
wxLogTrace( traceSettings,
wxT( "COMMON_SETTINGS::Migrate 1->2: prefer_select_to_drag not found" ) );
}
if( prefer_selection )
( *m_internals )[nlohmann::json::json_pointer( "/input/mouse_left" )] = MOUSE_DRAG_ACTION::SELECT;
( *m_internals )[nlohmann::json::json_pointer( "/input/mouse_left" )] =
MOUSE_DRAG_ACTION::SELECT;
else
( *m_internals )[nlohmann::json::json_pointer( "/input/mouse_left" )] = MOUSE_DRAG_ACTION::DRAG_ANY;
( *m_internals )[nlohmann::json::json_pointer( "/input/mouse_left" )] =
MOUSE_DRAG_ACTION::DRAG_ANY;
return true;
}
@ -518,11 +527,12 @@ bool COMMON_SETTINGS::migrateSchema2to3()
wxString key = path.m_Alias;
const wxString& val = path.m_Pathvar;
// The 3d alias config didnt use the same naming restrictions as real env variables
// The 3d alias config didn't use the same naming restrictions as real env variables
// We need to sanitize them
// upper case only
key.MakeUpper();
// logically swap - with _
key.Replace( wxS( "-" ), wxS( "_" ) );
@ -559,7 +569,8 @@ bool COMMON_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
{
wxString key, value;
long index = 0;
nlohmann::json::json_pointer ptr = m_internals->PointerFromString( "environment.vars" );
nlohmann::json::json_pointer ptr =
m_internals->PointerFromString( "environment.vars" );
aCfg->SetPath( "EnvironmentVariables" );
( *m_internals )[ptr] = nlohmann::json( {} );

View File

@ -599,7 +599,8 @@ std::optional<ValueType> JSON_SETTINGS::Get( const std::string& aPath ) const
// Instantiate all required templates here to allow reducing scope of json.hpp
template KICOMMON_API std::optional<bool> JSON_SETTINGS::Get<bool>( const std::string& aPath ) const;
template KICOMMON_API std::optional<bool>
JSON_SETTINGS::Get<bool>( const std::string& aPath ) const;
template KICOMMON_API std::optional<double>
JSON_SETTINGS::Get<double>( const std::string& aPath ) const;
template KICOMMON_API std::optional<float>
@ -621,7 +622,8 @@ template KICOMMON_API std::optional<BOM_PRESET>
JSON_SETTINGS::Get<BOM_PRESET>( const std::string& aPath ) const;
template KICOMMON_API std::optional<BOM_FMT_PRESET>
JSON_SETTINGS::Get<BOM_FMT_PRESET>( const std::string& aPath ) const;
template KICOMMON_API std::optional<GRID> JSON_SETTINGS::Get<GRID>( const std::string& aPath ) const;
template KICOMMON_API std::optional<GRID>
JSON_SETTINGS::Get<GRID>( const std::string& aPath ) const;
template KICOMMON_API std::optional<wxPoint>
JSON_SETTINGS::Get<wxPoint>( const std::string& aPath ) const;
template KICOMMON_API std::optional<wxSize>

View File

@ -60,7 +60,8 @@ KICAD_SETTINGS::KICAD_SETTINGS() :
m_params.emplace_back( new PARAM<wxPoint>( "template.window.pos", &m_TemplateWindowPos,
wxDefaultPosition ) );
m_params.emplace_back( new PARAM<wxSize>( "template.window.size", &m_TemplateWindowSize, wxDefaultSize ) );
m_params.emplace_back( new PARAM<wxSize>( "template.window.size", &m_TemplateWindowSize,
wxDefaultSize ) );
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>(
"pcm.repositories",

View File

@ -83,6 +83,7 @@ SETTINGS_MANAGER::SETTINGS_MANAGER( bool aHeadless ) :
}
}
SETTINGS_MANAGER::~SETTINGS_MANAGER()
{
for( std::unique_ptr<PROJECT>& project : m_projects_list )
@ -120,7 +121,6 @@ void SETTINGS_MANAGER::Load()
{
// TODO(JE) We should check for dirty settings here and write them if so, because
// Load() could be called late in the application lifecycle
std::vector<JSON_SETTINGS*> toLoad;
// Cache a copy of raw pointers; m_settings may be modified during the load loop
@ -192,7 +192,7 @@ void SETTINGS_MANAGER::FlushAndRelease( JSON_SETTINGS* aSettings, bool aSave )
if( aSave )
( *it )->SaveToFile( GetPathForSettingsFile( it->get() ) );
JSON_SETTINGS* tmp = it->get(); // We use a temporary to surpress a Clang warning
JSON_SETTINGS* tmp = it->get(); // We use a temporary to suppress a Clang warning
size_t typeHash = typeid( *tmp ).hash_code();
if( m_app_settings_cache.count( typeHash ) )
@ -903,8 +903,8 @@ bool SETTINGS_MANAGER::LoadProject( const wxString& aFullPath, bool aSetActive )
wxString fullPath = path.GetFullPath();
// If already loaded, we are all set. This might be called more than once over a project's
// lifetime in case the project is first loaded by the KiCad manager and then eeschema or
// pcbnew try to load it again when they are launched.
// lifetime in case the project is first loaded by the KiCad manager and then Eeschema or
// Pcbnew try to load it again when they are launched.
if( m_projects.count( fullPath ) )
return true;
@ -1044,7 +1044,8 @@ bool SETTINGS_MANAGER::IsProjectOpen() const
bool SETTINGS_MANAGER::IsProjectOpenNotDummy() const
{
return m_projects.size() > 1 || ( m_projects.size() == 1 && !m_projects.begin()->second->GetProjectFullName().IsEmpty() );
return m_projects.size() > 1 || ( m_projects.size() == 1
&& !m_projects.begin()->second->GetProjectFullName().IsEmpty() );
}
@ -1119,7 +1120,7 @@ void SETTINGS_MANAGER::SaveProjectAs( const wxString& aFullPath, PROJECT* aProje
PROJECT_FILE* project = m_project_files.at( oldName );
// Ensure read-only flags are copied; this allows doing a "Save As" on a standalong board/sch
// Ensure read-only flags are copied; this allows doing a "Save As" on a standalone board/sch
// without creating project files if the checkbox is turned off
project->SetReadOnly( aProject->IsReadOnly() );
aProject->GetLocalSettings().SetReadOnly( aProject->IsReadOnly() );
@ -1254,7 +1255,8 @@ bool SETTINGS_MANAGER::BackupProject( REPORTER& aReporter, wxFileName& aTarget )
if( !aTarget.IsDirWritable() )
{
wxLogTrace( traceSettings, wxT( "Backup directory %s is not writable" ), aTarget.GetPath() );
wxLogTrace( traceSettings, wxT( "Backup directory %s is not writable" ),
aTarget.GetPath() );
return false;
}

View File

@ -71,8 +71,7 @@ KIWAY Kiway( KFCTL_STANDALONE );
// implement a PGM_BASE and a wxApp side by side:
/**
* Struct PGM_SINGLE_TOP
* implements PGM_BASE with its own OnPgmInit() and OnPgmExit().
* Implement PGM_BASE with its own OnPgmInit() and OnPgmExit().
*/
static struct PGM_SINGLE_TOP : public PGM_BASE
{
@ -124,6 +123,7 @@ static struct PGM_SINGLE_TOP : public PGM_BASE
} program;
// A module to allow Html module initialization/cleanup
// When a wxHtmlWindow is used *only* in a dll/so module, the Html text is displayed
// as plain text.
@ -135,26 +135,29 @@ public:
HtmlModule() { }
virtual bool OnInit() override { AddDependency( CLASSINFO( wxHtmlWinParser ) ); return true; };
virtual void OnExit() override {};
private:
wxDECLARE_DYNAMIC_CLASS( HtmlModule );
};
wxIMPLEMENT_DYNAMIC_CLASS(HtmlModule, wxModule);
#ifdef NDEBUG
// Define a custom assertion handler
void CustomAssertHandler(const wxString& file,
int line,
const wxString& func,
const wxString& cond,
const wxString& msg)
void CustomAssertHandler( const wxString& file,
int line,
const wxString& func,
const wxString& cond,
const wxString& msg )
{
Pgm().HandleAssert( file, line, func, cond, msg );
}
#endif
/**
* Struct APP_SINGLE_TOP
* implements a bare naked wxApp (so that we don't become dependent on
* Implement a bare naked wxApp (so that we don't become dependent on
* functionality in a wxApp derivative that we cannot deliver under wxPython).
*/
struct APP_SINGLE_TOP : public wxApp
@ -162,6 +165,7 @@ struct APP_SINGLE_TOP : public wxApp
APP_SINGLE_TOP() : wxApp()
{
SetPgm( &program );
// Init the environment each platform wants
KIPLATFORM::ENV::Init();
}
@ -254,7 +258,8 @@ struct APP_SINGLE_TOP : public wxApp
if( dlgs.back() == dialog )
dlgs.pop_back();
// If an out-of-order, remove all dialogs added after the closed one
else if( auto it = std::find( dlgs.begin(), dlgs.end(), dialog ) ; it != dlgs.end() )
else if( auto it = std::find( dlgs.begin(), dlgs.end(), dialog );
it != dlgs.end() )
dlgs.erase( it, dlgs.end() );
}
}
@ -289,9 +294,10 @@ struct APP_SINGLE_TOP : public wxApp
#ifdef __WXMAC__
/**
* Function MacOpenFile
* is specific to MacOSX (not used under Linux or Windows).
* Specific to MacOSX (not used under Linux or Windows).
*
* MacOSX requires it for file association.
*
* @see http://wiki.wxwidgets.org/WxMac-specific_topics
*/
void MacOpenFile( const wxString& aFileName ) override
@ -320,11 +326,12 @@ bool PGM_SINGLE_TOP::OnPgmInit()
// Initialize the git library before trying to initialize individual programs
git_libgit2_init();
// Not all kicad applications use the python stuff. skip python init
// Not all KiCad applications use the python stuff. skip python init
// for these apps.
bool skip_python_initialization = false;
#if defined( BITMAP_2_CMP ) || defined( PL_EDITOR ) || defined( GERBVIEW ) ||\
defined( PCB_CALCULATOR_BUILD )
#if defined( BITMAP_2_CMP ) || defined( PL_EDITOR ) || defined( GERBVIEW ) || \
defined( PCB_CALCULATOR_BUILD )
skip_python_initialization = true;
#endif
@ -403,6 +410,7 @@ bool PGM_SINGLE_TOP::OnPgmInit()
wxCmdLineParser parser( App().argc, App().argv );
parser.SetDesc( desc );
parser.Parse( false );
if( parser.GetParamCount() )
{
/*

View File

@ -462,7 +462,7 @@ int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize )
char* limit = aDest + aDestSize - 1;
char cc;
while( (cc = *aSource++) != 0 && aDest < limit )
while( ( cc = *aSource++ ) != 0 && aDest < limit )
{
if( cc == '"' )
{
@ -471,7 +471,6 @@ int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize )
inside = true; // first delimiter found, make note, do not copy
}
else if( inside )
{
if( cc == '\\' )
@ -664,10 +663,6 @@ bool NoPrintableChars( const wxString& aString )
}
/**
* Return the number of printable (ie: non-formatting) chars. Used to approximate rendered
* text size when speed is more important than accuracy.
*/
int PrintableCharCount( const wxString& aString )
{
int char_count = 0;
@ -997,7 +992,7 @@ bool ApplyModifier( double& value, const wxString& aString )
bool convertSeparators( wxString* value )
{
// Note: fetching the decimal separtor from the current locale isn't a silver bullet because
// Note: fetching the decimal separator from the current locale isn't a silver bullet because
// it assumes the current computer's locale is the same as the locale the schematic was
// authored in -- something that isn't true, for instance, when sharing designs through
// DIYAudio.com.
@ -1072,7 +1067,7 @@ bool convertSeparators( wxString* value )
{
// This is the first separator...
// If it's preceeded by a '0' (only), or if it's followed by some number of
// If it's preceded by a '0' (only), or if it's followed by some number of
// digits not equal to 3, then it -must- be a decimal separator.
//
// In all other cases we don't really know what it is yet.
@ -1097,7 +1092,7 @@ bool convertSeparators( wxString* value )
}
}
// If we found nothing difinitive then we have to look at the current locale
// If we found nothing definitive then we have to look at the current locale
if( decimalSeparator == '?' && thousandsSeparator == '?' )
{
const struct lconv* lc = localeconv();
@ -1406,7 +1401,7 @@ std::string UIDouble2Str( double aValue )
{
// For these small values, %f works fine,
// and %g gives an exponent
len = snprintf( buf, sizeof(buf), "%.16f", aValue );
len = snprintf( buf, sizeof( buf ), "%.16f", aValue );
while( --len > 0 && buf[len] == '0' )
buf[len] = '\0';
@ -1420,7 +1415,7 @@ std::string UIDouble2Str( double aValue )
{
// For these values, %g works fine, and sometimes %f
// gives a bad value (try aValue = 1.222222222222, with %.16f format!)
len = snprintf( buf, sizeof(buf), "%.10g", aValue );
len = snprintf( buf, sizeof( buf ), "%.10g", aValue );
}
return std::string( buf, len );

View File

@ -47,7 +47,8 @@ const std::map<LINE_STYLE, struct LINE_STYLE_DESC> lineTypeNames = {
void STROKE_PARAMS::Stroke( const SHAPE* aShape, LINE_STYLE aLineStyle, int aWidth,
const KIGFX::RENDER_SETTINGS* aRenderSettings,
const std::function<void( const VECTOR2I& a, const VECTOR2I& b )>& aStroker )
const std::function<void( const VECTOR2I& a,
const VECTOR2I& b )>& aStroker )
{
double strokes[6] = { aWidth * 1.0, aWidth * 1.0, aWidth * 1.0, aWidth * 1.0, aWidth * 1.0,
aWidth * 1.0 };

View File

@ -196,7 +196,7 @@ void TEMPLATES::parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal )
}
/*
/**
* Flatten project and global templates into a single list. (Project templates take
* precedence.)
*/

View File

@ -27,6 +27,7 @@
#include <title_block.h>
#include <core/kicad_algo.h>
void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter ) const
{
// Don't write the title block information if there is nothing to write.
@ -70,6 +71,7 @@ void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter ) const
}
}
void TITLE_BLOCK::GetContextualTextVars( wxArrayString* aVars )
{
if( !alg::contains( *aVars, wxT( "ISSUE_DATE" ) ) )

View File

@ -33,6 +33,7 @@
#include <hotkeys_basic.h>
#include <cctype>
ACTION_MANAGER::ACTION_MANAGER( TOOL_MANAGER* aToolManager ) :
m_toolMgr( aToolManager )
{
@ -56,7 +57,8 @@ ACTION_MANAGER::ACTION_MANAGER( TOOL_MANAGER* aToolManager ) :
}
wxLogTrace( kicadTraceToolStack,
"ACTION_MANAGER::ACTION_MANAGER: Registering action %s with ID %d, UI ID %d, and group %s(%d)",
"ACTION_MANAGER::ACTION_MANAGER: Registering action %s with ID %d, UI ID %d, "
"and group %s(%d)",
action->m_name, action->m_id, action->GetUIId(), groupName, groupID );
RegisterAction( action );

View File

@ -108,6 +108,7 @@ void ACTION_MENU::DisplayTitle( bool aDisplay )
wxMenuItem* item = FindItemByPosition( 0 );
wxASSERT( item->GetItemLabelText() == GetTitle() );
Destroy( item );
// ..and separator
item = FindItemByPosition( 0 );
wxASSERT( item->IsSeparator() );
@ -168,7 +169,7 @@ wxMenuItem* ACTION_MENU::Add( const wxString& aLabel, const wxString& aTooltip,
wxMenuItem* ACTION_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntry,
const wxString& aOverrideLabel )
{
/// ID numbers for tool actions are assigned above ACTION_BASE_UI_ID inside TOOL_EVENT
// ID numbers for tool actions are assigned above ACTION_BASE_UI_ID inside TOOL_EVENT
BITMAPS icon = aAction.GetIcon();
// Allow the label to be overridden at point of use
@ -190,7 +191,8 @@ wxMenuItem* ACTION_MENU::Add( ACTION_MENU* aMenu )
{
m_submenus.push_back( aMenu );
wxASSERT_MSG( !aMenu->m_title.IsEmpty(), wxS( "Set a title for ACTION_MENU using SetTitle()" ) );
wxASSERT_MSG( !aMenu->m_title.IsEmpty(),
wxS( "Set a title for ACTION_MENU using SetTitle()" ) );
if( !!aMenu->m_icon )
{
@ -653,9 +655,10 @@ wxMenuItem* ACTION_MENU::appendCopy( const wxMenuItem* aSource )
// On Windows, for Checkable Menu items, adding a bitmap adds also
// our predefined checked alternate bitmap
// On other OS, wxITEM_CHECK and wxITEM_RADIO Menu items do not use custom bitmaps.
#if defined( __WXMSW__ )
// On Windows, AddBitmapToMenuItem() uses the unchecked bitmap for wxITEM_CHECK and
// wxITEM_RADIO menuitems and autoamtically adds a checked bitmap.
// wxITEM_RADIO menuitems and automatically adds a checked bitmap.
// For other menuitrms, use the "checked" bitmap.
bool use_checked_bm = ( aSource->GetKind() == wxITEM_CHECK ||
aSource->GetKind() == wxITEM_RADIO ) ? false : true;

View File

@ -241,7 +241,8 @@ ACTION_TOOLBAR::~ACTION_TOOLBAR()
void ACTION_TOOLBAR::Add( const TOOL_ACTION& aAction, bool aIsToggleEntry, bool aIsCancellable )
{
wxASSERT( GetParent() );
wxASSERT_MSG( !( aIsCancellable && !aIsToggleEntry ), wxS( "aIsCancellable requires aIsToggleEntry" ) );
wxASSERT_MSG( !( aIsCancellable && !aIsToggleEntry ),
wxS( "aIsCancellable requires aIsToggleEntry" ) );
int toolId = aAction.GetUIId();
@ -371,7 +372,8 @@ void ACTION_TOOLBAR::UpdateControlWidth( int aID )
// The control on the toolbar is stored inside the window field of the item
wxControl* control = dynamic_cast<wxControl*>( item->GetWindow() );
wxASSERT_MSG( control, wxString::Format( "No control located in toolbar item with ID %d", aID ) );
wxASSERT_MSG( control,
wxString::Format( "No control located in toolbar item with ID %d", aID ) );
// Update the size the item has stored using the best size of the control
control->InvalidateBestSize();
@ -526,6 +528,7 @@ void ACTION_TOOLBAR::onToolRightClick( wxAuiToolBarEvent& aEvent )
SetHoverItem( nullptr );
}
// The time (in milliseconds) between pressing the left mouse button and opening the palette
#define PALETTE_OPEN_DELAY 500

View File

@ -1263,25 +1263,32 @@ TOOL_ACTION ACTIONS::extractFile( TOOL_ACTION_ARGS()
// System-wide selection Events
const TOOL_EVENT EVENTS::PointSelectedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.pointSelected" );
const TOOL_EVENT EVENTS::PointSelectedEvent( TC_MESSAGE, TA_ACTION,
"common.Interactive.pointSelected" );
const TOOL_EVENT EVENTS::SelectedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.selected" );
const TOOL_EVENT EVENTS::UnselectedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.unselected" );
const TOOL_EVENT EVENTS::ClearedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.cleared" );
const TOOL_EVENT EVENTS::ConnectivityChangedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.connectivityChanged" );
const TOOL_EVENT EVENTS::ConnectivityChangedEvent( TC_MESSAGE, TA_ACTION,
"common.Interactive.connectivityChanged" );
const TOOL_EVENT EVENTS::SelectedItemsModified( TC_MESSAGE, TA_ACTION, "common.Interactive.modified" );
const TOOL_EVENT EVENTS::SelectedItemsModified( TC_MESSAGE, TA_ACTION,
"common.Interactive.modified" );
const TOOL_EVENT EVENTS::SelectedItemsMoved( TC_MESSAGE, TA_ACTION, "common.Interactive.moved" );
const TOOL_EVENT EVENTS::InhibitSelectionEditing( TC_MESSAGE, TA_ACTION, "common.Interactive.inhibit" );
const TOOL_EVENT EVENTS::UninhibitSelectionEditing( TC_MESSAGE, TA_ACTION, "common.Interactive.uninhibit" );
const TOOL_EVENT EVENTS::InhibitSelectionEditing( TC_MESSAGE, TA_ACTION,
"common.Interactive.inhibit" );
const TOOL_EVENT EVENTS::UninhibitSelectionEditing( TC_MESSAGE, TA_ACTION,
"common.Interactive.uninhibit" );
const TOOL_EVENT EVENTS::DisambiguatePoint( TC_MESSAGE, TA_ACTION, "common.Interactive.disambiguate" );
const TOOL_EVENT EVENTS::DisambiguatePoint( TC_MESSAGE, TA_ACTION,
"common.Interactive.disambiguate" );
const TOOL_EVENT EVENTS::GridChangedByKeyEvent( TC_MESSAGE, TA_ACTION,
"common.Interactive.gridChangedByKey" );
const TOOL_EVENT EVENTS::ContrastModeChangedByKeyEvent( TC_MESSAGE, TA_ACTION,
"common.Interactive.contrastModeChangedByKeyEvent" );
const TOOL_EVENT
EVENTS::ContrastModeChangedByKeyEvent( TC_MESSAGE, TA_ACTION,
"common.Interactive.contrastModeChangedByKeyEvent" );
// System-wide undo/redo Events

View File

@ -50,7 +50,8 @@
/// URL to launch a new issue with pre-populated description
wxString COMMON_CONTROL::m_bugReportUrl =
wxS( "https://gitlab.com/kicad/code/kicad/-/issues/new?issuable_template=bare&issue[description]=%s" );
wxS( "https://gitlab.com/kicad/code/kicad/-/issues/new?issuable_template=bare&issue"
"[description]=%s" );
/// Issue template to use for reporting bugs (this should not be translated)
@ -136,7 +137,8 @@ int COMMON_CONTROL::ShowLibraryTable( const TOOL_EVENT& aEvent )
try // Kicad frame was not available, try to start it
{
if( KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_SCH ) )
kiface->CreateKiWindow( m_frame, DIALOG_DESIGN_BLOCK_LIBRARY_TABLE, &m_frame->Kiway() );
kiface->CreateKiWindow( m_frame, DIALOG_DESIGN_BLOCK_LIBRARY_TABLE,
&m_frame->Kiway() );
}
catch( ... )
{

View File

@ -55,6 +55,7 @@ COMMON_TOOLS::COMMON_TOOLS() :
{
}
void COMMON_TOOLS::Reset( RESET_REASON aReason )
{
m_frame = getEditFrame<EDA_DRAW_FRAME>();
@ -102,7 +103,6 @@ int COMMON_TOOLS::SelectionTool( const TOOL_EVENT& aEvent )
}
// Cursor control
int COMMON_TOOLS::CursorControl( const TOOL_EVENT& aEvent )
{
ACTIONS::CURSOR_EVENT_TYPE type = aEvent.Parameter<ACTIONS::CURSOR_EVENT_TYPE>();
@ -405,6 +405,7 @@ int COMMON_TOOLS::CenterSelection( const TOOL_EVENT& aEvent )
return doCenter( CENTER_TYPE::CENTER_SELECTION );
}
int COMMON_TOOLS::CenterContents( const TOOL_EVENT& aEvent )
{
return doCenter( CENTER_TYPE::CENTER_CONTENTS );
@ -489,7 +490,6 @@ int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor )
}
// Grid control
int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent )
{
int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;

View File

@ -152,43 +152,43 @@ void CONDITIONAL_MENU::Evaluate( const SELECTION& aSelection )
switch( entry.Type() )
{
case ENTRY::ACTION:
Add( *entry.Action(), entry.IsCheckmarkEntry() );
menu_count++;
break;
case ENTRY::ACTION:
Add( *entry.Action(), entry.IsCheckmarkEntry() );
menu_count++;
break;
case ENTRY::MENU:
entry.Menu()->UpdateTitle();
Add( entry.Menu()->Clone() );
menu_count++;
break;
case ENTRY::MENU:
entry.Menu()->UpdateTitle();
Add( entry.Menu()->Clone() );
menu_count++;
break;
case ENTRY::WXITEM:
menuItem = new wxMenuItem( this,
entry.wxItem()->GetId(),
wxGetTranslation( entry.wxItem()->GetItemLabel() ),
wxGetTranslation( entry.wxItem()->GetHelp() ),
entry.wxItem()->GetKind() );
case ENTRY::WXITEM:
menuItem = new wxMenuItem( this,
entry.wxItem()->GetId(),
wxGetTranslation( entry.wxItem()->GetItemLabel() ),
wxGetTranslation( entry.wxItem()->GetHelp() ),
entry.wxItem()->GetKind() );
if( !!entry.GetIcon() )
KIUI::AddBitmapToMenuItem( menuItem, KiBitmap( entry.GetIcon() ) );
if( !!entry.GetIcon() )
KIUI::AddBitmapToMenuItem( menuItem, KiBitmap( entry.GetIcon() ) );
// the wxMenuItem must be append only after the bitmap is set:
Append( menuItem );
// the wxMenuItem must be append only after the bitmap is set:
Append( menuItem );
menu_count++;
break;
menu_count++;
break;
case ENTRY::SEPARATOR:
if( menu_count )
AppendSeparator();
case ENTRY::SEPARATOR:
if( menu_count )
AppendSeparator();
menu_count = 0;
break;
menu_count = 0;
break;
default:
wxASSERT( false );
break;
default:
wxASSERT( false );
break;
}
}
@ -231,9 +231,11 @@ CONDITIONAL_MENU::ENTRY::ENTRY( const ENTRY& aEntry )
case ACTION:
m_data.action = aEntry.m_data.action;
break;
case MENU:
m_data.menu = aEntry.m_data.menu;
break;
case WXITEM:
// We own the wxItem, so we need to make a new one for the new object
m_data.wxItem = new wxMenuItem( nullptr,
@ -242,14 +244,17 @@ CONDITIONAL_MENU::ENTRY::ENTRY( const ENTRY& aEntry )
aEntry.m_data.wxItem->GetHelp(),
aEntry.m_data.wxItem->GetKind() );
break;
case SEPARATOR:
break; //No data to copy
}
m_condition = aEntry.m_condition;
m_order = aEntry.m_order;
m_isCheckmarkEntry = aEntry.m_isCheckmarkEntry;
}
CONDITIONAL_MENU::ENTRY::~ENTRY()
{
if( WXITEM == m_type )

View File

@ -34,7 +34,7 @@
* A helper class to manage the activation of a "proposal" after a timeout.
*
* When a proposal is made, a timer starts. If no new proposal is made and the proposal
* is not cancelled before the timer expires, the proposal is "accepted" via a callback.
* is not canceled before the timer expires, the proposal is "accepted" via a callback.
*
* Propos
*
@ -102,6 +102,7 @@ public:
while( !m_stop )
{
std::unique_lock<std::mutex> lock( m_mutex );
if( !m_stop && !m_pendingProposalTag.has_value() )
{
// No active proposal - wait for one (unlocks while waiting)
@ -117,6 +118,7 @@ public:
{
// See if the timeout was extended for a new proposal
now = std::chrono::steady_clock::now();
if( now < m_proposalDeadline )
{
// Extended - wait for the new deadline
@ -124,7 +126,7 @@ public:
}
// See if there is still a proposal to accept
// (could have been cancelled in the meantime)
// (could have been canceled in the meantime)
if( m_pendingProposalTag )
{
m_lastAcceptedProposalTag = m_pendingProposalTag;
@ -132,6 +134,7 @@ public:
T proposalToAccept = std::move( m_lastProposal );
lock.unlock();
// Call the callback (outside the lock)
m_callback( std::move( proposalToAccept ) );
}
@ -143,25 +146,26 @@ public:
private:
mutable std::mutex m_mutex;
// Activation timeout in milliseconds
/// Activation timeout in milliseconds.
std::chrono::milliseconds m_timeout;
std::chrono::time_point<std::chrono::steady_clock> m_proposalDeadline;
///< The last proposal tag that was made
/// The last proposal tag that was made.
std::optional<std::size_t> m_pendingProposalTag;
///< The last proposal that was accepted
/// The last proposal that was accepted.
std::optional<std::size_t> m_lastAcceptedProposalTag;
// The most recently-proposed item
/// The most recently-proposed item.
T m_lastProposal;
///< Callback to call when the proposal is accepted
/// Callback to call when the proposal is accepted.
ACTIVATION_CALLBACK m_callback;
std::condition_variable m_cv;
std::atomic<bool> m_stop;
// The thread must be constructed last, as it starts running immediately
/// The thread must be constructed last, as it starts running immediately.
std::thread m_thread;
};
@ -329,6 +333,7 @@ void CONSTRUCTION_MANAGER::acceptConstructionItems( std::unique_ptr<PENDING_BATC
m_viewHandler.updateView();
}
bool CONSTRUCTION_MANAGER::InvolvesAllGivenRealItems( const std::vector<EDA_ITEM*>& aItems ) const
{
for( EDA_ITEM* item : aItems )
@ -343,6 +348,7 @@ bool CONSTRUCTION_MANAGER::InvolvesAllGivenRealItems( const std::vector<EDA_ITEM
return true;
}
void CONSTRUCTION_MANAGER::GetConstructionItems(
std::vector<CONSTRUCTION_ITEM_BATCH>& aToExtend ) const
{
@ -358,17 +364,20 @@ void CONSTRUCTION_MANAGER::GetConstructionItems(
}
}
bool CONSTRUCTION_MANAGER::HasActiveConstruction() const
{
std::lock_guard<std::mutex> lock( m_batchesMutex );
return m_persistentConstructionBatch.has_value() || !m_temporaryConstructionBatches.empty();
}
SNAP_LINE_MANAGER::SNAP_LINE_MANAGER( CONSTRUCTION_VIEW_HANDLER& aViewHandler ) :
m_viewHandler( aViewHandler )
{
}
void SNAP_LINE_MANAGER::SetSnapLineOrigin( const VECTOR2I& aOrigin )
{
// Setting the origin clears the snap line as the end point is no longer valid
@ -376,6 +385,7 @@ void SNAP_LINE_MANAGER::SetSnapLineOrigin( const VECTOR2I& aOrigin )
m_snapLineOrigin = aOrigin;
}
void SNAP_LINE_MANAGER::SetSnapLineEnd( const OPT_VECTOR2I& aSnapEnd )
{
if( m_snapLineOrigin && aSnapEnd != m_snapLineEnd )
@ -391,6 +401,7 @@ void SNAP_LINE_MANAGER::SetSnapLineEnd( const OPT_VECTOR2I& aSnapEnd )
}
}
void SNAP_LINE_MANAGER::ClearSnapLine()
{
m_snapLineOrigin.reset();
@ -399,6 +410,7 @@ void SNAP_LINE_MANAGER::ClearSnapLine()
m_viewHandler.updateView();
}
void SNAP_LINE_MANAGER::SetSnappedAnchor( const VECTOR2I& aAnchorPos )
{
if( m_snapLineOrigin.has_value() )
@ -440,6 +452,7 @@ static bool pointHasEscapedSnapLineX( const VECTOR2I& aCursor, const VECTOR2I& a
return std::abs( angle.Normalize90() ) > aLongRangeEscapeAngle;
}
/**
* As above, but for the Y direction.
*/

View File

@ -56,6 +56,7 @@ void EMBED_TOOL::Reset( RESET_REASON aReason )
m_files = getModel<EDA_ITEM>()->GetEmbeddedFiles();
}
int EMBED_TOOL::AddFile( const TOOL_EVENT& aEvent )
{
wxString name = aEvent.Parameter<wxString>();
@ -64,6 +65,7 @@ int EMBED_TOOL::AddFile( const TOOL_EVENT& aEvent )
return 1;
}
int EMBED_TOOL::RemoveFile( const TOOL_EVENT& aEvent )
{
wxString name = aEvent.Parameter<wxString>();
@ -72,6 +74,7 @@ int EMBED_TOOL::RemoveFile( const TOOL_EVENT& aEvent )
return 1;
}
std::vector<wxString> EMBED_TOOL::GetFileList()
{
std::vector<wxString> list;
@ -84,6 +87,7 @@ std::vector<wxString> EMBED_TOOL::GetFileList()
return list;
}
void EMBED_TOOL::setTransitions()
{
Go( &EMBED_TOOL::AddFile, ACTIONS::embeddedFiles.MakeEvent() );

View File

@ -85,6 +85,7 @@ GRID_HELPER::~GRID_HELPER()
KIGFX::ANCHOR_DEBUG* GRID_HELPER::enableAndGetAnchorDebug()
{
static bool permitted = ADVANCED_CFG::GetCfg().m_EnableSnapAnchorsDebug;
if( permitted && !m_anchorDebug )
{
KIGFX::VIEW& view = *m_toolMgr->GetView();
@ -92,6 +93,7 @@ KIGFX::ANCHOR_DEBUG* GRID_HELPER::enableAndGetAnchorDebug()
view.Add( m_anchorDebug.get() );
view.SetVisible( m_anchorDebug.get(), true );
}
return m_anchorDebug.get();
}

View File

@ -45,14 +45,17 @@ void LIBRARY_EDITOR_CONTROL::AddContextMenuItems( CONDITIONAL_MENU* aMenu )
{
LIB_TREE* libTree = m_frame->GetLibTree();
LIB_TREE_NODE* current = libTree ? libTree->GetCurrentTreeNode() : nullptr;
return current && current->m_Type == LIB_TREE_NODE::TYPE::LIBRARY && current->m_Pinned;
return current && current->m_Type == LIB_TREE_NODE::TYPE::LIBRARY
&& current->m_Pinned;
};
auto unpinnedLibSelectedCondition =
[this](const SELECTION& aSel )
{
LIB_TREE* libTree = m_frame->GetLibTree();
LIB_TREE_NODE* current = libTree ? libTree->GetCurrentTreeNode() : nullptr;
return current && current->m_Type == LIB_TREE_NODE::TYPE::LIBRARY && !current->m_Pinned;
return current && current->m_Type == LIB_TREE_NODE::TYPE::LIBRARY
&& !current->m_Pinned;
};
aMenu->AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition, 1 );
@ -89,11 +92,15 @@ int LIBRARY_EDITOR_CONTROL::PinLibrary( const TOOL_EVENT& aEvent )
m_frame->Prj().PinLibrary( current->m_LibId.GetLibNickname(),
PROJECT::LIB_TYPE_T::SYMBOL_LIB );
break;
case KIWAY::FACE_PCB:
m_frame->Prj().PinLibrary( current->m_LibId.GetLibNickname(),
PROJECT::LIB_TYPE_T::FOOTPRINT_LIB );
break;
default: wxFAIL_MSG( wxT( "Unsupported frame type for library pinning." ) ); break;
default:
wxFAIL_MSG( wxT( "Unsupported frame type for library pinning." ) );
break;
}
current->m_Pinned = true;
@ -117,11 +124,15 @@ int LIBRARY_EDITOR_CONTROL::UnpinLibrary( const TOOL_EVENT& aEvent )
m_frame->Prj().UnpinLibrary( current->m_LibId.GetLibNickname(),
PROJECT::LIB_TYPE_T::SYMBOL_LIB );
break;
case KIWAY::FACE_PCB:
m_frame->Prj().UnpinLibrary( current->m_LibId.GetLibNickname(),
PROJECT::LIB_TYPE_T::FOOTPRINT_LIB );
break;
default: wxFAIL_MSG( wxT( "Unsupported frame type for library pinning." ) ); break;
default:
wxFAIL_MSG( wxT( "Unsupported frame type for library pinning." ) );
break;
}
current->m_Pinned = false;

View File

@ -46,7 +46,7 @@ public:
std::function<bool( const wxString& aNewName )> aValidator );
private:
///< Set up handlers for various events.
/// Set up handlers for various events.
void setTransitions() override;
void regenerateLibraryTree();

Some files were not shown because too many files have changed in this diff Show More