kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #19682
[PATCH] Pass preferences from pcbnew to footprint editor/viewer and from eeschema to lib editor/viewer
This patch is to provide a general fix for bug #1468388. There is a patch
attached to that bug, but Chris Pavline and I decided that it doesn't make
as much sense as this patch.
The other patch adds a center on zoom option to the library editor
preferences. It would be bad UI to require someone to change the
preferences for all separate windows with a render. It was also missing
three other UI preferences (use middle mouse to pan, limit panning, and pan
while moving object).
I implemented this to send over these preferences from eeschema whenever
the lib editor or viewer are opened. Same for pcbnew and footprint
editor/viewer. Not the optimal solution since someone can leave the
editors/viewers open and change preferences in eeschema/pcbnew so I added
FIXME comments.
On a separate and related note, I noticed that the code to open the library
viewer:
https://github.com/KiCad/kicad-source-mirror/blob/master/eeschema/sch_base_frame.cpp#L50
doesn't do the same checks when opening the window as the others do as seen
here:
https://github.com/KiCad/kicad-source-mirror/blob/master/eeschema/schframe.cpp#L1120
Not sure if that check should be added to the library viewer code to
prevent any issues. Anyone know?
Thanks,
Jon Neal
diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp
index f8a4fe2..4ad0a0b 100644
--- a/eeschema/sch_base_frame.cpp
+++ b/eeschema/sch_base_frame.cpp
@@ -27,6 +27,7 @@
#include <libeditframe.h>
#include <base_units.h>
#include <kiway.h>
+#include <class_drawpanel.h>
// Sttaic members:
@@ -51,6 +52,15 @@ void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
{
LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, true );
+ //FIXME: We load these preferences when we create the window.
+ // This is because preferences don't get saved until a window is closed.
+ // So when eeschema preferences are saved the lib editor can't read them until
+ // the eeschema window is closed.
+ viewlibFrame->GetCanvas()->SetEnableZoomNoCenter( m_canvas->GetEnableZoomNoCenter() );
+ viewlibFrame->GetCanvas()->SetEnableMiddleButtonPan( m_canvas->GetEnableMiddleButtonPan() );
+ viewlibFrame->GetCanvas()->SetMiddleButtonPanLimited( m_canvas->GetMiddleButtonPanLimited() );
+ viewlibFrame->GetCanvas()->SetEnableAutoPan( m_canvas->GetEnableAutoPan() );
+
// On Windows, Raise() does not bring the window on screen, when iconized
if( viewlibFrame->IsIconized() )
viewlibFrame->Iconize( false );
diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp
index d0aa2f4..5ce5ab4 100644
--- a/eeschema/schframe.cpp
+++ b/eeschema/schframe.cpp
@@ -1123,6 +1123,15 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
libeditFrame->Show( true );
}
+ //FIXME: We load these preferences when we create the window.
+ // This is because preferences don't get saved until a window is closed.
+ // So when eeschema preferences are saved the lib editor can't read them until
+ // the eeschema window is closed.
+ libeditFrame->GetCanvas()->SetEnableZoomNoCenter( m_canvas->GetEnableZoomNoCenter() );
+ libeditFrame->GetCanvas()->SetEnableMiddleButtonPan( m_canvas->GetEnableMiddleButtonPan() );
+ libeditFrame->GetCanvas()->SetMiddleButtonPanLimited( m_canvas->GetMiddleButtonPanLimited() );
+ libeditFrame->GetCanvas()->SetEnableAutoPan( m_canvas->GetEnableAutoPan() );
+
// On Windows, Raise() does not bring the window on screen, when iconized
if( libeditFrame->IsIconized() )
libeditFrame->Iconize( false );
diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp
index 8335d04..38498f6 100644
--- a/pcbnew/edit.cpp
+++ b/pcbnew/edit.cpp
@@ -218,6 +218,15 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( wxWindow::FindFocus() != editor )
editor->SetFocus();
}
+
+ //FIXME: We load these preferences when we create the window.
+ // This is because preferences don't get saved until a window is closed.
+ // So when eeschema preferences are saved the lib editor can't read them until
+ // the eeschema window is closed.
+ editor->GetCanvas()->SetEnableZoomNoCenter( m_canvas->GetEnableZoomNoCenter() );
+ editor->GetCanvas()->SetEnableMiddleButtonPan( m_canvas->GetEnableMiddleButtonPan() );
+ editor->GetCanvas()->SetMiddleButtonPanLimited( m_canvas->GetMiddleButtonPanLimited() );
+ editor->GetCanvas()->SetEnableAutoPan( m_canvas->GetEnableAutoPan() );
}
break;
@@ -244,6 +253,15 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( wxWindow::FindFocus() != viewer )
viewer->SetFocus();
}
+
+ //FIXME: We load these preferences when we create the window.
+ // This is because preferences don't get saved until a window is closed.
+ // So when eeschema preferences are saved the lib editor can't read them until
+ // the eeschema window is closed.
+ viewer->GetCanvas()->SetEnableZoomNoCenter( m_canvas->GetEnableZoomNoCenter() );
+ viewer->GetCanvas()->SetEnableMiddleButtonPan( m_canvas->GetEnableMiddleButtonPan() );
+ viewer->GetCanvas()->SetMiddleButtonPanLimited( m_canvas->GetMiddleButtonPanLimited() );
+ viewer->GetCanvas()->SetEnableAutoPan( m_canvas->GetEnableAutoPan() );
}
break;
Follow ups