A more nuanced method of making Board & Schematic Setup read-only.
This one still allows you to scroll to see all contents. Fixes https://gitlab.com/kicad/code/kicad/issues/9302
This commit is contained in:
parent
935a307674
commit
95f841a037
|
@ -27,6 +27,9 @@
|
||||||
#include <wx/spinctrl.h>
|
#include <wx/spinctrl.h>
|
||||||
#include <wx/srchctrl.h>
|
#include <wx/srchctrl.h>
|
||||||
#include <wx/stc/stc.h>
|
#include <wx/stc/stc.h>
|
||||||
|
#include <wx/scrolbar.h>
|
||||||
|
#include <wx/scrolwin.h>
|
||||||
|
#include <wx/grid.h>
|
||||||
#include <widgets/ui_common.h>
|
#include <widgets/ui_common.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -267,4 +270,39 @@ bool KIUI::IsInputControlEditable( wxWindow* aFocus )
|
||||||
bool KIUI::IsModalDialogFocused()
|
bool KIUI::IsModalDialogFocused()
|
||||||
{
|
{
|
||||||
return Pgm().m_ModalDialogCount > 0;
|
return Pgm().m_ModalDialogCount > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KIUI::Disable( wxWindow* aWindow )
|
||||||
|
{
|
||||||
|
wxScrollBar* scrollBar = dynamic_cast<wxScrollBar*>( aWindow );
|
||||||
|
wxGrid* grid = dynamic_cast<wxGrid*>( aWindow );
|
||||||
|
wxStyledTextCtrl* scintilla = dynamic_cast<wxStyledTextCtrl*>( aWindow );
|
||||||
|
wxControl* control = dynamic_cast<wxControl*>( aWindow );
|
||||||
|
|
||||||
|
if( scrollBar )
|
||||||
|
{
|
||||||
|
// Leave a scroll bar active
|
||||||
|
}
|
||||||
|
else if( grid )
|
||||||
|
{
|
||||||
|
for( int row = 0; row < grid->GetNumberRows(); ++row )
|
||||||
|
{
|
||||||
|
for( int col = 0; col < grid->GetNumberCols(); ++col )
|
||||||
|
grid->SetReadOnly( row, col );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( scintilla )
|
||||||
|
{
|
||||||
|
scintilla->SetReadOnly( true );
|
||||||
|
}
|
||||||
|
else if( control )
|
||||||
|
{
|
||||||
|
control->Disable();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for( wxWindow* child : aWindow->GetChildren() )
|
||||||
|
Disable( child );
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -87,16 +87,8 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
|
||||||
|
|
||||||
if( Prj().IsReadOnly() )
|
if( Prj().IsReadOnly() )
|
||||||
{
|
{
|
||||||
m_infoBar->ShowMessage( _( "Project is missing or read-only. "
|
m_infoBar->ShowMessage( _( "Project is missing or read-only. Settings will not be "
|
||||||
"Settings will not be editable." ),
|
"editable." ), wxICON_WARNING );
|
||||||
wxICON_WARNING );
|
|
||||||
|
|
||||||
m_formatting->Disable();
|
|
||||||
m_fieldNameTemplates->Disable();
|
|
||||||
m_severities->Disable();
|
|
||||||
m_pinMap->Disable();
|
|
||||||
m_netclasses->Disable();
|
|
||||||
m_textVars->Disable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +105,8 @@ void DIALOG_SCHEMATIC_SETUP::OnPageChange( wxBookCtrlEvent& event )
|
||||||
{
|
{
|
||||||
int page = event.GetSelection();
|
int page = event.GetSelection();
|
||||||
|
|
||||||
|
KIUI::Disable( m_treebook->GetPage( page ) );
|
||||||
|
|
||||||
// Enable the reset button only if the page is resettable
|
// Enable the reset button only if the page is resettable
|
||||||
if( m_resetButton )
|
if( m_resetButton )
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,6 +95,12 @@ bool IsInputControlEditable( wxWindow* aControl );
|
||||||
|
|
||||||
bool IsModalDialogFocused();
|
bool IsModalDialogFocused();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a window read-only. Does some extra work over wxWindow::Disable() to make sure you
|
||||||
|
* can still scroll around in sub-windows.
|
||||||
|
*/
|
||||||
|
void Disable( wxWindow* aWindow );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SEVERITY SeverityFromString( const wxString& aSeverity );
|
SEVERITY SeverityFromString( const wxString& aSeverity );
|
||||||
|
|
|
@ -113,25 +113,15 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
|
||||||
|
|
||||||
// Connect Events
|
// Connect Events
|
||||||
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
||||||
wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ),
|
wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ), nullptr,
|
||||||
nullptr, this );
|
this );
|
||||||
|
|
||||||
finishDialogSettings();
|
finishDialogSettings();
|
||||||
|
|
||||||
if( Prj().IsReadOnly() )
|
if( Prj().IsReadOnly() )
|
||||||
{
|
{
|
||||||
m_infoBar->ShowMessage( _( "Project is missing or read-only. "
|
m_infoBar->ShowMessage( _( "Project is missing or read-only. Some settings will not "
|
||||||
"Some settings will not be editable." ),
|
"be editable." ), wxICON_WARNING );
|
||||||
wxICON_WARNING );
|
|
||||||
|
|
||||||
m_boardFinish->Disable();
|
|
||||||
m_maskAndPaste->Disable();
|
|
||||||
m_textAndGraphics->Disable();
|
|
||||||
m_textVars->Disable();
|
|
||||||
m_constraints->Disable();
|
|
||||||
m_tracksAndVias->Disable();
|
|
||||||
m_netclasses->Disable();
|
|
||||||
m_severities->Disable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,23 +129,25 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
|
||||||
DIALOG_BOARD_SETUP::~DIALOG_BOARD_SETUP()
|
DIALOG_BOARD_SETUP::~DIALOG_BOARD_SETUP()
|
||||||
{
|
{
|
||||||
m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
||||||
wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ),
|
wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ), nullptr,
|
||||||
nullptr, this );
|
this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_BOARD_SETUP::OnPageChange( wxBookCtrlEvent& event )
|
void DIALOG_BOARD_SETUP::OnPageChange( wxBookCtrlEvent& event )
|
||||||
{
|
{
|
||||||
if( event.GetSelection() == m_physicalStackupPage )
|
int page = event.GetSelection();
|
||||||
|
|
||||||
|
if( page == m_physicalStackupPage )
|
||||||
m_physicalStackup->OnLayersOptionsChanged( m_layers->GetUILayerMask() );
|
m_physicalStackup->OnLayersOptionsChanged( m_layers->GetUILayerMask() );
|
||||||
else if( event.GetSelection() == m_layerSetupPage )
|
else if( page == m_layerSetupPage )
|
||||||
m_layers->SyncCopperLayers( m_physicalStackup->GetCopperLayerCount() );
|
m_layers->SyncCopperLayers( m_physicalStackup->GetCopperLayerCount() );
|
||||||
|
else
|
||||||
|
KIUI::Disable( m_treebook->GetPage( page ) );
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
// Work around an OSX bug where the wxGrid children don't get placed correctly until
|
// Work around an OSX bug where the wxGrid children don't get placed correctly until
|
||||||
// the first resize event
|
// the first resize event
|
||||||
int page = event.GetSelection();
|
|
||||||
|
|
||||||
if( m_macHack[ page ] )
|
if( m_macHack[ page ] )
|
||||||
{
|
{
|
||||||
wxSize pageSize = m_treebook->GetPage( page )->GetSize();
|
wxSize pageSize = m_treebook->GetPage( page )->GetSize();
|
||||||
|
|
Loading…
Reference in New Issue