From 0d90fab01b7317375fc037d6d52e3c3fbc2b91b7 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 18 Aug 2019 22:48:52 +0100 Subject: [PATCH] Add display setting preference pane for PLEditor. Fixes: lp:1839187 * https://bugs.launchpad.net/kicad/+bug/1839187 --- .../dialogs/panel_display_options.cpp | 17 ++++---- .../dialogs/panel_display_options.h | 14 +++---- eeschema/CMakeLists.txt | 2 +- eeschema/eeschema_config.cpp | 4 +- pagelayout_editor/CMakeLists.txt | 1 + pagelayout_editor/pl_editor_frame.cpp | 41 +++++++++++-------- pagelayout_editor/pl_editor_frame.h | 2 + 7 files changed, 44 insertions(+), 37 deletions(-) rename eeschema/dialogs/panel_libedit_display_options.cpp => common/dialogs/panel_display_options.cpp (75%) rename eeschema/dialogs/panel_libedit_display_options.h => common/dialogs/panel_display_options.h (75%) diff --git a/eeschema/dialogs/panel_libedit_display_options.cpp b/common/dialogs/panel_display_options.cpp similarity index 75% rename from eeschema/dialogs/panel_libedit_display_options.cpp rename to common/dialogs/panel_display_options.cpp index 0e0153c748..2a7a06e906 100644 --- a/eeschema/dialogs/panel_libedit_display_options.cpp +++ b/common/dialogs/panel_display_options.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2017-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -17,16 +17,15 @@ * with this program. If not, see . */ -#include -#include +#include +#include #include #include -#include +#include -PANEL_LIBEDIT_DISPLAY_OPTIONS::PANEL_LIBEDIT_DISPLAY_OPTIONS( LIB_EDIT_FRAME* aFrame, - PAGED_DIALOG* aParent ) : +PANEL_DISPLAY_OPTIONS::PANEL_DISPLAY_OPTIONS( EDA_DRAW_FRAME* aFrame, PAGED_DIALOG* aParent ) : wxPanel( aParent->GetTreebook(), wxID_ANY ), m_frame( aFrame ) { @@ -45,19 +44,19 @@ PANEL_LIBEDIT_DISPLAY_OPTIONS::PANEL_LIBEDIT_DISPLAY_OPTIONS( LIB_EDIT_FRAME* aF } -bool PANEL_LIBEDIT_DISPLAY_OPTIONS::TransferDataToWindow() +bool PANEL_DISPLAY_OPTIONS::TransferDataToWindow() { m_galOptsPanel->TransferDataToWindow(); return true; } -bool PANEL_LIBEDIT_DISPLAY_OPTIONS::TransferDataFromWindow() +bool PANEL_DISPLAY_OPTIONS::TransferDataFromWindow() { m_galOptsPanel->TransferDataFromWindow(); // refresh view - KIGFX::SCH_VIEW* view = m_frame->GetCanvas()->GetView(); + KIGFX::VIEW* view = m_frame->GetCanvas()->GetView(); view->RecacheAllItems(); view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); m_frame->GetCanvas()->Refresh(); diff --git a/eeschema/dialogs/panel_libedit_display_options.h b/common/dialogs/panel_display_options.h similarity index 75% rename from eeschema/dialogs/panel_libedit_display_options.h rename to common/dialogs/panel_display_options.h index bc03444b04..d233ef21e5 100644 --- a/eeschema/dialogs/panel_libedit_display_options.h +++ b/common/dialogs/panel_display_options.h @@ -18,26 +18,26 @@ */ -#ifndef KICAD_PANEL_LIBEDIT_DISPLAY_OPTIONS_H -#define KICAD_PANEL_LIBEDIT_DISPLAY_OPTIONS_H +#ifndef PANEL_DISPLAY_OPTIONS_H +#define PANEL_DISPLAY_OPTIONS_H #include class GAL_OPTIONS_PANEL; -class LIB_EDIT_FRAME; +class EDA_DRAW_FRAME; class PAGED_DIALOG; -class PANEL_LIBEDIT_DISPLAY_OPTIONS : public wxPanel +class PANEL_DISPLAY_OPTIONS : public wxPanel { public: - PANEL_LIBEDIT_DISPLAY_OPTIONS( LIB_EDIT_FRAME* aParent, PAGED_DIALOG* aWindow ); + PANEL_DISPLAY_OPTIONS( EDA_DRAW_FRAME* aParent, PAGED_DIALOG* aWindow ); private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - LIB_EDIT_FRAME* m_frame; + EDA_DRAW_FRAME* m_frame; GAL_OPTIONS_PANEL* m_galOptsPanel; }; -#endif //KICAD_PANEL_LIBEDIT_DISPLAY_OPTIONS_H +#endif //PANEL_DISPLAY_OPTIONS_H diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 7076a63f3a..429ba84a61 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -94,7 +94,6 @@ set( EESCHEMA_DLGS dialogs/panel_eeschema_display_options_base.cpp dialogs/panel_eeschema_settings.cpp dialogs/panel_eeschema_settings_base.cpp - dialogs/panel_libedit_display_options.cpp dialogs/panel_libedit_settings.cpp dialogs/panel_libedit_settings_base.cpp dialogs/panel_sym_lib_table.cpp @@ -237,6 +236,7 @@ set( EESCHEMA_SRCS set( EESCHEMA_COMMON_SRCS ../common/dialogs/dialog_page_settings.cpp + ../common/dialogs/panel_display_options.cpp ../common/base_screen.cpp ../common/base_units.cpp ../common/eda_text.cpp diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 917f4964aa..62b8b92299 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -461,7 +461,7 @@ void LIB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, wxTreebook* book = aParent->GetTreebook(); book->AddPage( new PANEL_LIBEDIT_SETTINGS( this, book ), _( "Symbol Editor" ) ); - book->AddSubPage( new PANEL_LIBEDIT_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); + book->AddSubPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); aHotkeysPanel->AddHotKeys( GetToolManager() ); } diff --git a/pagelayout_editor/CMakeLists.txt b/pagelayout_editor/CMakeLists.txt index df6e57617e..06e372f0ed 100644 --- a/pagelayout_editor/CMakeLists.txt +++ b/pagelayout_editor/CMakeLists.txt @@ -43,6 +43,7 @@ set( PL_EDITOR_EXTRA_SRCS ../common/base_units.cpp ../common/eda_text.cpp ../common/dialogs/dialog_page_settings.cpp + ../common/dialogs/panel_display_options.cpp ../common/page_info.cpp ) diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 25d8f8ae2d..3479ffe2e4 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -36,6 +36,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -54,7 +57,6 @@ #include #include - BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME ) EVT_CLOSE( PL_EDITOR_FRAME::OnCloseWindow ) EVT_MENU( wxID_CLOSE, PL_EDITOR_FRAME::OnExit ) @@ -117,11 +119,6 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU(); SetScreen( new PL_EDITOR_SCREEN( pageSizeIU ) ); - if( !GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) ) - m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1MM - ID_POPUP_GRID_LEVEL_1000; - - GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ); - setupTools(); ReCreateMenuBar(); ReCreateHToolbar(); @@ -186,6 +183,11 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : wxPoint originCoord = ReturnCoordOriginCorner(); SetGridOrigin( originCoord ); + if( !GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) ) + m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1MM - ID_POPUP_GRID_LEVEL_1000; + + GetToolManager()->RunAction( "common.Control.gridPreset", true, m_LastGridSizeId ); + // Initialize the current page layout WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance(); #if 0 //start with empty layout @@ -388,6 +390,17 @@ double PL_EDITOR_FRAME::BestZoom() } +void PL_EDITOR_FRAME::InstallPreferences( PAGED_DIALOG* aParent, + PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) +{ + wxTreebook* book = aParent->GetTreebook(); + + book->AddPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); + + aHotkeysPanel->AddHotKeys( GetToolManager() ); +} + + static const wxChar propertiesFrameWidthKey[] = wxT( "PropertiesFrameWidth" ); static const wxChar cornerOriginChoiceKey[] = wxT( "CornerOriginChoice" ); static const wxChar blackBgColorKey[] = wxT( "BlackBgColor" ); @@ -550,17 +563,9 @@ void PL_EDITOR_FRAME::DisplayGridMsg() switch( m_userUnits ) { - case INCHES: - gridformatter = "grid %.3f"; - break; - - case MILLIMETRES: - gridformatter = "grid %.4f"; - break; - - default: - gridformatter = "grid %f"; - break; + case INCHES: gridformatter = "grid %.3f"; break; + case MILLIMETRES: gridformatter = "grid %.4f"; break; + default: gridformatter = "grid %f"; break; } wxRealPoint curr_grid_size = GetScreen()->GetGridSize(); @@ -681,7 +686,7 @@ void PL_EDITOR_FRAME::HardRedraw() PL_SELECTION_TOOL* selTool = m_toolManager->GetTool(); PL_SELECTION& selection = selTool->GetSelection(); - WS_DATA_ITEM* item = nullptr; + WS_DATA_ITEM* item = nullptr; if( selection.GetSize() == 1 ) item = static_cast( selection.Front() )->GetPeer(); diff --git a/pagelayout_editor/pl_editor_frame.h b/pagelayout_editor/pl_editor_frame.h index 66a10ec3de..716c392b4b 100644 --- a/pagelayout_editor/pl_editor_frame.h +++ b/pagelayout_editor/pl_editor_frame.h @@ -206,6 +206,8 @@ public: */ void UpdateTitleAndInfo(); + void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; + /** * Populates the applicatios settings list. * (list of parameters that must be saved in project parameters)