← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Pass preferences from pcbnew to footprint editor/viewer and from eeschema to lib editor/viewer

 

Suggestion implemented. New version attached.

Jon Neal

On Fri, Aug 7, 2015 at 4:39 AM, Maciej Sumiński <maciej.suminski@xxxxxxx>
wrote:

> If I may suggest something, how about wrapping the 4 lines to load
> preferences into a function (e.g. EDA_DRAW_PANEL::LoadPreferences( const
> EDA_DRAW_PANEL* aOther ))?
>
> Regards,
> Orson
>
> On 08/07/2015 03:01 AM, Jon Neal wrote:
> > 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
> >
> >
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~kicad-developers
> > Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~kicad-developers
> > More help   : https://help.launchpad.net/ListHelp
> >
>
>
>
diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp
index 1b5d3ad..e9cfb86 100644
--- a/common/draw_frame.cpp
+++ b/common/draw_frame.cpp
@@ -745,6 +745,16 @@ void EDA_DRAW_FRAME::UpdateMsgPanel()
         SetMsgPanel( item );
 }
 
+// FIXME: There needs to be a better way for child windows to load preferences.
+//        This function pushes four preferences from a parent window to a child window
+//        i.e. from eeschema to the schematic symbol editor
+void EDA_DRAW_FRAME::PushPreferences( const EDA_DRAW_PANEL* aParentCanvas )
+{
+    m_canvas->SetEnableZoomNoCenter( aParentCanvas->GetEnableZoomNoCenter() );
+    m_canvas->SetEnableMiddleButtonPan( aParentCanvas->GetEnableMiddleButtonPan() );
+    m_canvas->SetMiddleButtonPanLimited( aParentCanvas->GetMiddleButtonPanLimited() );
+    m_canvas->SetEnableAutoPan( aParentCanvas->GetEnableAutoPan() );
+}
 
 wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils ) const
 {
diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp
index f8a4fe2..52898e8 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,8 @@ void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
 {
     LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, true );
 
+    viewlibFrame->PushPreferences( m_canvas );
+
     // 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..5e1c9d7 100644
--- a/eeschema/schframe.cpp
+++ b/eeschema/schframe.cpp
@@ -1123,6 +1123,8 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
         libeditFrame->Show( true );
     }
 
+    libeditFrame->PushPreferences( m_canvas );
+
     // On Windows, Raise() does not bring the window on screen, when iconized
     if( libeditFrame->IsIconized() )
         libeditFrame->Iconize( false );
diff --git a/include/draw_frame.h b/include/draw_frame.h
index d88ca5c..6abdb05 100644
--- a/include/draw_frame.h
+++ b/include/draw_frame.h
@@ -726,6 +726,15 @@ public:
     virtual void UpdateMsgPanel();
 
     /**
+     * Function PushPreferences
+     * Pushes a few preferences from a parent window to a child window.
+     * (i.e. from eeschema to schematic symbol editor)
+     *
+     * @param aParentCanvas is the parent canvas to push preferences from.
+     */
+    void PushPreferences( const EDA_DRAW_PANEL* aParentCanvas );
+
+    /**
      * Function PrintPage
      * used to print a page
      * Print the page pointed by current screen, set by the calling print function
diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp
index 8335d04..59ffffc 100644
--- a/pcbnew/edit.cpp
+++ b/pcbnew/edit.cpp
@@ -218,6 +218,8 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
                 if( wxWindow::FindFocus() != editor )
                     editor->SetFocus();
             }
+
+            editor->PushPreferences( m_canvas );
         }
         break;
 
@@ -244,6 +246,8 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
                 if( wxWindow::FindFocus() != viewer )
                     viewer->SetFocus();
             }
+
+            viewer->PushPreferences( m_canvas );
         }
         break;
 

Follow ups

References