Fix python console toggle to work across pcbnew/eeschema
This commit is contained in:
parent
5e30be66aa
commit
a5308e5f5c
|
@ -234,7 +234,13 @@ void EDA_DRAW_FRAME::ScriptingConsoleEnableDisable()
|
|||
}
|
||||
|
||||
frame->Show( !frame->IsVisible() );
|
||||
}
|
||||
|
||||
|
||||
bool EDA_DRAW_FRAME::IsScriptingConsoleVisible()
|
||||
{
|
||||
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PYTHON, false );
|
||||
return frame && frame->IsVisible();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -104,6 +104,16 @@ SELECTION_CONDITION EDITOR_CONDITIONS::FullscreenCursor()
|
|||
}
|
||||
|
||||
|
||||
SELECTION_CONDITION EDITOR_CONDITIONS::ScriptingConsoleVisible()
|
||||
{
|
||||
EDA_DRAW_FRAME* drwFrame = dynamic_cast<EDA_DRAW_FRAME*>( m_frame );
|
||||
|
||||
wxASSERT( drwFrame );
|
||||
|
||||
return std::bind( &EDITOR_CONDITIONS::consoleVisibleFunc, _1, drwFrame );
|
||||
}
|
||||
|
||||
|
||||
bool EDITOR_CONDITIONS::contentModifiedFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame )
|
||||
{
|
||||
return aFrame->IsContentModified();
|
||||
|
@ -159,3 +169,8 @@ bool EDITOR_CONDITIONS::cursorFunc( const SELECTION& aSelection, EDA_DRAW_FRAME*
|
|||
return aFrame->GetGalDisplayOptions().m_fullscreenCursor;
|
||||
}
|
||||
|
||||
|
||||
bool EDITOR_CONDITIONS::consoleVisibleFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame )
|
||||
{
|
||||
return aFrame->IsScriptingConsoleVisible();
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <project.h>
|
||||
#include <project/project_file.h>
|
||||
#include <project/net_settings.h>
|
||||
#include <python_scripting.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <sch_painter.h>
|
||||
#include <sch_sheet.h>
|
||||
|
@ -412,6 +413,9 @@ void SCH_EDIT_FRAME::setupUIConditions()
|
|||
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
|
||||
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
|
||||
|
||||
if( SCRIPTING::IsWxAvailable() )
|
||||
mgr->SetConditions( EE_ACTIONS::showPythonConsole, CHECK( cond.ScriptingConsoleVisible() ) );
|
||||
|
||||
auto showHiddenPinsCond =
|
||||
[this] ( const SELECTION& )
|
||||
{
|
||||
|
|
|
@ -97,6 +97,11 @@ public:
|
|||
*/
|
||||
void ScriptingConsoleEnableDisable();
|
||||
|
||||
/**
|
||||
* Gets the current visibility of the scripting console window
|
||||
*/
|
||||
bool IsScriptingConsoleVisible();
|
||||
|
||||
wxFindReplaceData& GetFindReplaceData() { return *m_findReplaceData; }
|
||||
wxArrayString& GetFindHistoryList() { return m_findStringHistoryList; }
|
||||
|
||||
|
|
|
@ -118,6 +118,15 @@ public:
|
|||
*/
|
||||
SELECTION_CONDITION FullscreenCursor();
|
||||
|
||||
/**
|
||||
* Create a functor testing if the python scripting console window is visible.
|
||||
*
|
||||
* @note This requires the frame passed into the constructor be be derived from EDA_DRAW_FRAME.
|
||||
*
|
||||
* @return Functor testing if the python scripting console window is visible
|
||||
*/
|
||||
SELECTION_CONDITION ScriptingConsoleVisible();
|
||||
|
||||
protected:
|
||||
///< Helper function used by ContentModified().
|
||||
static bool contentModifiedFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame );
|
||||
|
@ -147,9 +156,8 @@ protected:
|
|||
///< Helper function used by FullscreenCursor().
|
||||
static bool cursorFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame );
|
||||
|
||||
///< Helper function used by CanvasType().
|
||||
static bool canvasTypeFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame,
|
||||
EDA_DRAW_PANEL_GAL::GAL_TYPE aType );
|
||||
///< Helper function used by ScriptingConsoleVisible().
|
||||
static bool consoleVisibleFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame );
|
||||
|
||||
///< The frame to apply the conditions to.
|
||||
EDA_BASE_FRAME* m_frame;
|
||||
|
|
|
@ -551,20 +551,9 @@ void PCB_EDIT_FRAME::setupUIConditions()
|
|||
mgr->SetConditions( PCB_ACTIONS::viaDisplayMode, CHECK( !cond.ViaFillDisplay() ) );
|
||||
mgr->SetConditions( PCB_ACTIONS::trackDisplayMode, CHECK( !cond.TrackFillDisplay() ) );
|
||||
|
||||
auto pythonConsoleCond =
|
||||
[] ( const SELECTION& )
|
||||
{
|
||||
if( SCRIPTING::IsWxAvailable() )
|
||||
{
|
||||
wxWindow* console = PCB_EDIT_FRAME::findPythonConsole();
|
||||
return console && console->IsShown();
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
mgr->SetConditions( PCB_ACTIONS::showPythonConsole, CHECK( pythonConsoleCond ) );
|
||||
|
||||
if( SCRIPTING::IsWxAvailable() )
|
||||
mgr->SetConditions( PCB_ACTIONS::showPythonConsole, CHECK( cond.ScriptingConsoleVisible() ) );
|
||||
|
||||
auto enableZoneControlConition =
|
||||
[this] ( const SELECTION& )
|
||||
{
|
||||
|
|
|
@ -707,25 +707,6 @@ protected:
|
|||
*/
|
||||
void OnActionPluginButton( wxCommandEvent& aEvent );
|
||||
|
||||
|
||||
/**
|
||||
* Has meaning only if KICAD_SCRIPTING_WXPYTHON option is not defined.
|
||||
*
|
||||
* @return the frame name identifier for the python console frame.
|
||||
*/
|
||||
static const wxChar * pythonConsoleNameId()
|
||||
{
|
||||
return wxT( "PythonConsole" );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a pointer to the python console frame, or NULL if not exist
|
||||
*/
|
||||
static wxWindow * findPythonConsole()
|
||||
{
|
||||
return FindWindowByName( pythonConsoleNameId() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the state of the GUI after a new board is loaded or created.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue