From 5e99d8fd86de94a28cd7c6228aa50cf693913ee4 Mon Sep 17 00:00:00 2001
From: Jeff Young <jeff@rokeby.ie>
Date: Mon, 19 Feb 2018 19:26:02 +0000
Subject: [PATCH 5/5] Dialog changes to go with ModEdit menu update.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.14.3 (Apple Git-98)"

This is a multi-part message in MIME format.
--------------2.14.3 (Apple Git-98)
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 pcbnew/dialogs/dialog_modedit_display_options.cpp | 81 +----------------------
 pcbnew/dialogs/dialog_modedit_display_options.h   | 10 ---
 pcbnew/footprint_edit_frame.cpp                   | 28 ++++----
 pcbnew/footprint_edit_frame.h                     |  4 +-
 4 files changed, 18 insertions(+), 105 deletions(-)


--------------2.14.3 (Apple Git-98)
Content-Type: text/x-patch; name="0005-Dialog-changes-to-go-with-ModEdit-menu-update.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0005-Dialog-changes-to-go-with-ModEdit-menu-update.patch"

diff --git a/pcbnew/dialogs/dialog_modedit_display_options.cpp b/pcbnew/dialogs/dialog_modedit_display_options.cpp
index b57de67ab..693ddc489 100644
--- a/pcbnew/dialogs/dialog_modedit_display_options.cpp
+++ b/pcbnew/dialogs/dialog_modedit_display_options.cpp
@@ -42,8 +42,7 @@ bool DIALOG_MODEDIT_DISPLAY_OPTIONS::Invoke( FOOTPRINT_EDIT_FRAME& aCaller )
 
 DIALOG_MODEDIT_DISPLAY_OPTIONS::DIALOG_MODEDIT_DISPLAY_OPTIONS( FOOTPRINT_EDIT_FRAME& aParent ) :
     DIALOG_SHIM( &aParent, wxID_ANY, _( "Display Options" ) ),
-    m_parent( aParent ),
-    m_last_scale( -1 )
+    m_parent( aParent )
 {
     auto mainSizer = new wxBoxSizer( wxVERTICAL );
     SetSizer( mainSizer );
@@ -54,28 +53,6 @@ DIALOG_MODEDIT_DISPLAY_OPTIONS::DIALOG_MODEDIT_DISPLAY_OPTIONS( FOOTPRINT_EDIT_F
     m_galOptsPanel = new GAL_OPTIONS_PANEL( this, galOptions );
     mainSizer->Add( m_galOptsPanel, 1, wxEXPAND, 0 );
 
-    auto fgsizer = new wxFlexGridSizer( 3 );
-    fgsizer->AddGrowableCol( 1 );
-    fgsizer->SetFlexibleDirection( wxBOTH );
-    fgsizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
-    fgsizer->Add(
-            new wxStaticText( this, wxID_ANY, _( "Icon scale:" ) ),
-            0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 3 );
-    m_scaleSlider = new STEPPED_SLIDER( this, wxID_ANY, 50, 50, 275,
-            wxDefaultPosition, wxDefaultSize,
-            wxSL_AUTOTICKS | wxSL_HORIZONTAL | wxSL_LABELS );
-    m_scaleSlider->SetStep( 25 );
-    fgsizer->Add( m_scaleSlider, 1, wxLEFT | wxRIGHT | wxEXPAND, 3 );
-    fgsizer->Add(
-            new wxStaticText( this, wxID_ANY, "%" ),
-            0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 3 );
-    fgsizer->AddSpacer( 0 );
-    m_scaleAuto = new wxCheckBox( this, wxID_ANY, _( "Auto" ) );
-    fgsizer->Add( m_scaleAuto, wxLEFT | wxRIGHT | wxEXPAND, 3 );
-    fgsizer->AddSpacer( 0 );
-
-    mainSizer->Add( fgsizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 5 );
-
     auto btnSizer = new wxStdDialogButtonSizer();
     mainSizer->Add( btnSizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 5 );
 
@@ -84,21 +61,6 @@ DIALOG_MODEDIT_DISPLAY_OPTIONS::DIALOG_MODEDIT_DISPLAY_OPTIONS( FOOTPRINT_EDIT_F
 
     btnSizer->Realize();
 
-    std::vector<wxEventTypeTag<wxScrollEvent>> scroll_events = {
-        wxEVT_SCROLL_TOP, wxEVT_SCROLL_BOTTOM, wxEVT_SCROLL_LINEUP, wxEVT_SCROLL_LINEDOWN,
-        wxEVT_SCROLL_PAGEUP, wxEVT_SCROLL_PAGEDOWN, wxEVT_SCROLL_THUMBTRACK,
-        wxEVT_SCROLL_THUMBRELEASE };
-
-    for( auto evt : scroll_events )
-        m_scaleSlider->Connect(
-                evt, wxScrollEventHandler( DIALOG_MODEDIT_DISPLAY_OPTIONS::OnScaleSlider ),
-                NULL, this );
-
-    m_scaleAuto->Connect(
-            wxEVT_COMMAND_CHECKBOX_CLICKED,
-            wxCommandEventHandler( DIALOG_MODEDIT_DISPLAY_OPTIONS::OnScaleAuto ),
-            NULL, this );
-
     GetSizer()->SetSizeHints( this );
     Centre();
 }
@@ -108,20 +70,6 @@ bool DIALOG_MODEDIT_DISPLAY_OPTIONS::TransferDataToWindow()
 {
     // update GAL options
     m_galOptsPanel->TransferDataToWindow();
-
-    const int scale_fourths = m_parent.GetIconScale();
-
-    if( scale_fourths <= 0 )
-    {
-        m_scaleAuto->SetValue( true );
-        m_scaleSlider->SetValue( 25 * KiIconScale( &m_parent ) );
-    }
-    else
-    {
-        m_scaleAuto->SetValue( false );
-        m_scaleSlider->SetValue( scale_fourths * 25 );
-    }
-
     return true;
 }
 
@@ -131,11 +79,6 @@ bool DIALOG_MODEDIT_DISPLAY_OPTIONS::TransferDataFromWindow()
     // update GAL options
     m_galOptsPanel->TransferDataFromWindow();
 
-    const int scale_fourths = m_scaleAuto->GetValue() ? -1 : m_scaleSlider->GetValue() / 25;
-
-    if( m_parent.GetIconScale() != scale_fourths )
-        m_parent.SetIconScale( scale_fourths );
-
     // refresh view
     KIGFX::VIEW* view = m_parent.GetGalCanvas()->GetView();
     view->RecacheAllItems();
@@ -144,25 +87,3 @@ bool DIALOG_MODEDIT_DISPLAY_OPTIONS::TransferDataFromWindow()
 
     return true;
 }
-
-
-void DIALOG_MODEDIT_DISPLAY_OPTIONS::OnScaleSlider( wxScrollEvent& aEvent )
-{
-    m_scaleAuto->SetValue( false );
-    aEvent.Skip();
-}
-
-
-void DIALOG_MODEDIT_DISPLAY_OPTIONS::OnScaleAuto( wxCommandEvent& aEvent )
-{
-    if( m_scaleAuto->GetValue() )
-    {
-        m_last_scale = m_scaleSlider->GetValue();
-        m_scaleSlider->SetValue( 25 * KiIconScale( GetParent() ) );
-    }
-    else
-    {
-        if( m_last_scale >= 0 )
-            m_scaleSlider->SetValue( m_last_scale );
-    }
-}
diff --git a/pcbnew/dialogs/dialog_modedit_display_options.h b/pcbnew/dialogs/dialog_modedit_display_options.h
index 73aca949b..811e49dc8 100644
--- a/pcbnew/dialogs/dialog_modedit_display_options.h
+++ b/pcbnew/dialogs/dialog_modedit_display_options.h
@@ -21,8 +21,6 @@
 
 class GAL_OPTIONS_PANEL;
 class FOOTPRINT_EDIT_FRAME;
-class STEPPED_SLIDER;
-class wxCheckBox;
 
 class DIALOG_MODEDIT_DISPLAY_OPTIONS : public DIALOG_SHIM
 {
@@ -31,10 +29,6 @@ public:
 
     static bool Invoke( FOOTPRINT_EDIT_FRAME& aCaller );
 
-protected:
-    void OnScaleSlider( wxScrollEvent& aEvent );
-    void OnScaleAuto( wxCommandEvent& aEvent );
-
 private:
 
     bool TransferDataToWindow() override;
@@ -44,8 +38,4 @@ private:
 
     // subpanel
     GAL_OPTIONS_PANEL* m_galOptsPanel;
-
-    int m_last_scale;
-    wxCheckBox* m_scaleAuto;
-    STEPPED_SLIDER* m_scaleSlider;
 };
diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp
index 247025c49..bff1994b0 100644
--- a/pcbnew/footprint_edit_frame.cpp
+++ b/pcbnew/footprint_edit_frame.cpp
@@ -230,6 +230,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
     wxIcon icon;
     icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
     SetIcon( icon );
+    m_iconScale = -1;
 
     // Show a title (frame title + footprint name):
     updateTitle();
@@ -1028,20 +1029,19 @@ void FOOTPRINT_EDIT_FRAME::UseGalCanvas( bool aEnable )
 
 int FOOTPRINT_EDIT_FRAME::GetIconScale()
 {
-    int scale = 0;
-    Kiface().KifaceSettings()->Read( IconScaleEntry, &scale, 0 );
-    return scale;
-}
+    // All environmental settings will move to app for 6.0, so just inherit from pcbnew
+    // for now.
+    if( m_iconScale == -1 )
+    {
+        bool isBoardEditorRunning = Kiway().Player( FRAME_PCB, false ) != nullptr;
+        PCB_BASE_FRAME* pcbFrame = static_cast<PCB_BASE_FRAME*>( Kiway().Player( FRAME_PCB, true ) );
+        m_iconScale = pcbFrame->GetIconScale();
 
+        if( !isBoardEditorRunning )
+            pcbFrame->Destroy();
+    }
 
-void FOOTPRINT_EDIT_FRAME::SetIconScale( int aScale )
-{
-    Kiface().KifaceSettings()->Write( IconScaleEntry, aScale );
-    ReCreateMenuBar();
-    ReCreateHToolbar();
-    ReCreateAuxiliaryToolbar();
-    ReCreateVToolbar();
-    ReCreateOptToolbar();
-    Layout();
-    SendSizeEvent();
+    return m_iconScale;
 }
+
+
diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h
index 06ac29a96..11e549d4b 100644
--- a/pcbnew/footprint_edit_frame.h
+++ b/pcbnew/footprint_edit_frame.h
@@ -483,7 +483,6 @@ public:
     bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
 
     int GetIconScale() override;
-    void SetIconScale( int aScale ) override;
 
     DECLARE_EVENT_TABLE()
 
@@ -497,6 +496,9 @@ protected:
     /// List of footprint editor configuration parameters.
     PARAM_CFG_ARRAY   m_configParams;
 
+    /// Pretty much what it says on the tin.
+    int               m_iconScale;
+
     /**
      * Function UpdateTitle
      * updates window title according to getLibNickName().

--------------2.14.3 (Apple Git-98)--


