ADDED: Focus follows mouse between SCH and PCB editors (option).

This commit is contained in:
dsa-t 2022-09-30 18:32:06 +00:00 committed by Seth Hillbrand
parent a2a442a9f7
commit 01572c0f7d
9 changed files with 115 additions and 9 deletions

View File

@ -60,7 +60,7 @@ public:
if( m_win )
{
m_win->Enable();
m_win->SetFocus(); // let's focus back on the parent window
m_win->Raise(); // let's focus back on the parent window
}
}
};

View File

@ -292,15 +292,16 @@ bool PANEL_COMMON_SETTINGS::TransferDataFromWindow()
m_highContrastCtrl->GetValue().ToDouble( &dimmingPercent );
commonSettings->m_Appearance.hicontrast_dimming_factor = dimmingPercent / 100.0f;
commonSettings->m_Input.immediate_actions = !m_NonImmediateActions->GetValue();
commonSettings->m_Input.warp_mouse_on_move = m_warpMouseOnMove->GetValue();
commonSettings->m_Input.focus_follow_sch_pcb = m_focusFollowSchPcb->GetValue();
commonSettings->m_Input.immediate_actions = !m_NonImmediateActions->GetValue();
commonSettings->m_Input.warp_mouse_on_move = m_warpMouseOnMove->GetValue();
commonSettings->m_Backup.enabled = m_cbBackupEnabled->GetValue();
commonSettings->m_Backup.backup_on_autosave = m_cbBackupAutosave->GetValue();
commonSettings->m_Backup.limit_total_files = m_backupLimitTotalFiles->GetValue();
commonSettings->m_Backup.limit_daily_files = m_backupLimitDailyFiles->GetValue();
commonSettings->m_Backup.min_interval = m_backupMinInterval->GetValue() * 60;
commonSettings->m_Backup.limit_total_size = m_backupLimitTotalSize->GetValue() * 1024 * 1024;
commonSettings->m_Backup.enabled = m_cbBackupEnabled->GetValue();
commonSettings->m_Backup.backup_on_autosave = m_cbBackupAutosave->GetValue();
commonSettings->m_Backup.limit_total_files = m_backupLimitTotalFiles->GetValue();
commonSettings->m_Backup.limit_daily_files = m_backupLimitDailyFiles->GetValue();
commonSettings->m_Backup.min_interval = m_backupMinInterval->GetValue() * 60;
commonSettings->m_Backup.limit_total_size = m_backupLimitTotalSize->GetValue() * 1024 * 1024;
commonSettings->m_Session.remember_open_files = m_cbRememberOpenFiles->GetValue();
@ -384,6 +385,7 @@ void PANEL_COMMON_SETTINGS::applySettingsToPanel( COMMON_SETTINGS& aSettings )
double dimmingPercent = aSettings.m_Appearance.hicontrast_dimming_factor * 100.0f;
m_highContrastCtrl->SetValue( wxString::Format( "%.0f", dimmingPercent ) );
m_focusFollowSchPcb->SetValue( aSettings.m_Input.focus_follow_sch_pcb );
m_warpMouseOnMove->SetValue( aSettings.m_Input.warp_mouse_on_move );
m_NonImmediateActions->SetValue( !aSettings.m_Input.immediate_actions );

View File

@ -127,6 +127,11 @@ PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWind
bSizer81->Add( m_showScrollbars, 0, wxALIGN_LEFT|wxBOTTOM, 5 );
m_focusFollowSchPcb = new wxCheckBox( m_sbUserInterface->GetStaticBox(), wxID_ANY, _("Focus follows mouse between schematic and PCB editors"), wxDefaultPosition, wxDefaultSize, 0 );
m_focusFollowSchPcb->SetToolTip( _("If the mouse cursor is moved over the canvas of a schematic or PCB editor window, that window is raised.") );
bSizer81->Add( m_focusFollowSchPcb, 0, wxALIGN_LEFT|wxBOTTOM, 5 );
m_gbUserInterface->Add( bSizer81, wxGBPosition( 0, 0 ), wxGBSpan( 2, 4 ), wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxEXPAND, 5 );

View File

@ -1050,6 +1050,70 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_LEFT|wxBOTTOM</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Focus follows mouse between schematic and PCB editors</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_focusFollowSchPcb</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">If the mouse cursor is moved over the canvas of a schematic or PCB editor window, that window is raised.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="gbsizeritem" expanded="0">

View File

@ -55,6 +55,7 @@ class PANEL_COMMON_SETTINGS_BASE : public RESETTABLE_PANEL
wxGridBagSizer* m_gbUserInterface;
wxCheckBox* m_checkBoxIconsInMenus;
wxCheckBox* m_showScrollbars;
wxCheckBox* m_focusFollowSchPcb;
wxStaticText* m_stIconTheme;
wxRadioButton* m_rbIconThemeLight;
wxRadioButton* m_rbIconThemeDark;

View File

@ -227,6 +227,9 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
},
{} ) );
m_params.emplace_back( new PARAM<bool>( "input.focus_follow_sch_pcb",
&m_Input.focus_follow_sch_pcb, false ) );
m_params.emplace_back( new PARAM<bool>( "input.auto_pan", &m_Input.auto_pan, false ) );
m_params.emplace_back( new PARAM<int>( "input.auto_pan_acceleration",

View File

@ -39,6 +39,8 @@
#include <geometry/geometry_utils.h>
#include <widgets/ui_common.h>
#include <class_draw_panel_gal.h>
#include <eda_draw_frame.h>
#include <kiway.h>
#include <kiplatform/ui.h>
#include <wx/log.h>
@ -156,6 +158,7 @@ void WX_VIEW_CONTROLS::LoadSettings()
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
m_settings.m_warpCursor = cfg->m_Input.center_on_zoom;
m_settings.m_focusFollowSchPcb = cfg->m_Input.focus_follow_sch_pcb;
m_settings.m_autoPanSettingEnabled = cfg->m_Input.auto_pan;
m_settings.m_autoPanAcceleration = cfg->m_Input.auto_pan_acceleration;
m_settings.m_horizontalPan = cfg->m_Input.horizontal_pan;
@ -201,6 +204,30 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
int y = aEvent.GetY();
VECTOR2D mousePos( x, y );
// Automatic focus switching between SCH and PCB windows on canvas mouse motion
if( m_settings.m_focusFollowSchPcb )
{
if( EDA_DRAW_FRAME* frame = m_parentPanel->GetParentEDAFrame() )
{
KIWAY_PLAYER* otherFrame = nullptr;
if( frame->IsType( FRAME_PCB_EDITOR ) )
{
otherFrame = frame->Kiway().Player( FRAME_SCH, false );
}
else if( frame->IsType( FRAME_SCH ) )
{
otherFrame = frame->Kiway().Player( FRAME_PCB_EDITOR, false );
}
if( otherFrame && KIPLATFORM::UI::IsWindowActive( otherFrame )
&& !KIPLATFORM::UI::IsWindowActive( frame ) )
{
frame->Raise();
}
}
}
if( m_state != DRAG_PANNING && m_state != DRAG_ZOOMING )
handleCursorCapture( x, y );

View File

@ -78,6 +78,7 @@ public:
struct INPUT
{
bool focus_follow_sch_pcb;
bool auto_pan;
int auto_pan_acceleration;
bool center_on_zoom;

View File

@ -66,6 +66,9 @@ struct VC_SETTINGS
///< Flag for grabbing the mouse cursor.
bool m_grabMouse;
///< Flag for automatic focus switching between Schematic and PCB editors.
bool m_focusFollowSchPcb;
///< Flag for turning on autopanning.
bool m_autoPanEnabled;