From cdce2cb1510cbe0dbc474e302d3d48707aa54ce6 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 8 Aug 2020 21:10:01 +0200 Subject: [PATCH] WIP: put the editor options into a separate dockable widget --- src/edt/edt/EditorOptionsDialog.ui | 139 ------------- src/edt/edt/EditorOptionsPath.ui | 188 ++++++++++-------- src/edt/edt/edt.pro | 1 - src/edt/edt/edtEditorOptionsPages.cc | 69 ++++--- src/edt/edt/edtEditorOptionsPages.h | 16 +- src/edt/edt/edtMainService.cc | 6 +- src/edt/edt/edtMainService.h | 10 +- src/edt/edt/edtPlugin.cc | 120 +++++------ src/edt/edt/edtPlugin.h | 4 +- src/edt/edt/edtService.cc | 8 +- src/edt/edt/edtServiceImpl.cc | 6 +- src/lay/lay/layMainWindow.cc | 56 ++++++ src/lay/lay/layMainWindow.h | 6 +- src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 6 + src/laybasic/laybasic/layLayoutView.cc | 22 ++ src/laybasic/laybasic/layLayoutView.h | 27 ++- .../laybasic/layLayoutViewFunctions.cc | 2 +- 17 files changed, 318 insertions(+), 368 deletions(-) delete mode 100644 src/edt/edt/EditorOptionsDialog.ui diff --git a/src/edt/edt/EditorOptionsDialog.ui b/src/edt/edt/EditorOptionsDialog.ui deleted file mode 100644 index e34cea275..000000000 --- a/src/edt/edt/EditorOptionsDialog.ui +++ /dev/null @@ -1,139 +0,0 @@ - - EditorOptionsDialog - - - - 0 - 0 - 642 - 572 - - - - Object Editor Options - - - - 9 - - - 6 - - - - - 0 - - - - Tab 2 - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 6 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Ok - - - - - - - Apply - - - - - - - Cancel - - - - - - - - - - - - cancel_pb - clicked() - EditorOptionsDialog - reject() - - - 506 - 388 - - - 276 - 205 - - - - - ok_pb - clicked() - EditorOptionsDialog - accept() - - - 344 - 388 - - - 276 - 205 - - - - - diff --git a/src/edt/edt/EditorOptionsPath.ui b/src/edt/edt/EditorOptionsPath.ui index 543354380..ac184b089 100644 --- a/src/edt/edt/EditorOptionsPath.ui +++ b/src/edt/edt/EditorOptionsPath.ui @@ -1,7 +1,8 @@ - + + EditorOptionsPath - - + + 0 0 @@ -9,44 +10,60 @@ 289 - + Form - - - 9 - - + + 6 + + 9 + + + 9 + + + 9 + + + 9 + - - + + QFrame::NoFrame - + QFrame::Raised - - - 0 - - + + 6 + + 0 + + + 0 + + + 0 + + + 0 + - - + + Width - - - - 0 - 0 + + + 0 0 @@ -54,18 +71,18 @@ - - - micron + + + µm - + Qt::Horizontal - + 21 20 @@ -77,31 +94,38 @@ - - - - 5 - 0 + + + 0 0 - + Extensions - - + + 9 - + + 9 + + + 9 + + + 9 + + 6 - + - + Qt::Horizontal - + 21 81 @@ -109,100 +133,94 @@ - - - - micron + + + + µm - - - - micron + + + + µm - - - - - 0 - 0 + + + + 1 0 - - - + + + end = - - - + + + start = - - - - - 0 - 0 + + + + 1 0 - - - + + + Variable - - - - - 5 - 0 + + + + 0 0 - + Flush - + Square - + Variable - + Round - - - + + + Type @@ -212,10 +230,10 @@ - + Qt::Vertical - + 271 63 diff --git a/src/edt/edt/edt.pro b/src/edt/edt/edt.pro index c9f440dca..9a1d11c75 100644 --- a/src/edt/edt/edt.pro +++ b/src/edt/edt/edt.pro @@ -30,7 +30,6 @@ FORMS = \ CopyModeDialog.ui \ ChangeLayerOptionsDialog.ui \ EditablePathPropertiesPage.ui \ - EditorOptionsDialog.ui \ EditorOptionsGeneric.ui \ EditorOptionsInst.ui \ EditorOptionsPath.ui \ diff --git a/src/edt/edt/edtEditorOptionsPages.cc b/src/edt/edt/edtEditorOptionsPages.cc index bd1940467..3362dd49c 100644 --- a/src/edt/edt/edtEditorOptionsPages.cc +++ b/src/edt/edt/edtEditorOptionsPages.cc @@ -25,10 +25,10 @@ #include "dbLibrary.h" #include "dbLibraryManager.h" #include "dbPCellHeader.h" -#include "edtEditorOptionsPages.h" #include "edtPCellParametersPage.h" #include "edtConfig.h" #include "edtService.h" +#include "edtEditorOptionsPages.h" #include "tlExceptions.h" #include "layPlugin.h" #include "layLayoutView.h" @@ -39,6 +39,11 @@ #include "ui_EditorOptionsText.h" #include "ui_EditorOptionsInst.h" +#include +#include +#include +#include + namespace edt { @@ -87,13 +92,27 @@ struct EOPCompareOp } }; -EditorOptionsPages::EditorOptionsPages (const std::vector &pages, lay::Dispatcher *root) - : mp_root (root) +EditorOptionsPages::EditorOptionsPages (QWidget *parent, const std::vector &pages, lay::Dispatcher *root) + : QFrame (parent), mp_root (root) { - mp_ui = new Ui::EditorOptionsDialog (); - mp_ui->setupUi (this); + QVBoxLayout *ly1 = new QVBoxLayout (this); + ly1->setMargin (0); - connect (mp_ui->apply_pb, SIGNAL (clicked ()), this, SLOT (apply ())); + mp_pages = new QTabWidget (this); + ly1->addWidget (mp_pages); + + QFrame *f = new QFrame (this); + ly1->addWidget (f); + + QToolButton *apply_pb = new QToolButton (f); + apply_pb->setText (tr ("Apply")); + + QHBoxLayout *ly2 = new QHBoxLayout (f); + ly2->setMargin (0); + ly2->addStretch (1); + ly2->addWidget (apply_pb); + + connect (apply_pb, SIGNAL (clicked ()), this, SLOT (apply ())); m_pages = pages; for (std::vector ::const_iterator p = m_pages.begin (); p != m_pages.end (); ++p) { @@ -107,11 +126,8 @@ EditorOptionsPages::EditorOptionsPages (const std::vector 0) { - delete m_pages [0]; + delete m_pages.front (); } - - delete mp_ui; - mp_ui = 0; } void @@ -131,16 +147,14 @@ void EditorOptionsPages::activate_page (edt::EditorOptionsPage *page) { try { - page->setup (mp_root); + if (page->active ()) { + page->setup (mp_root); + } } catch (...) { // catch any errors related to configuration file errors etc. } - update (page); - if (isVisible ()) { - activateWindow (); - raise (); - } + update (page); } void @@ -148,13 +162,13 @@ EditorOptionsPages::update (edt::EditorOptionsPage *page) { std::sort (m_pages.begin (), m_pages.end (), EOPCompareOp ()); - while (mp_ui->pages->count () > 0) { - mp_ui->pages->removeTab (0); + while (mp_pages->count () > 0) { + mp_pages->removeTab (0); } int index = -1; for (std::vector ::iterator p = m_pages.begin (); p != m_pages.end (); ++p) { if ((*p)->active ()) { - mp_ui->pages->addTab ((*p)->q_frame (), tl::to_qstring ((*p)->title ())); + mp_pages->addTab ((*p)->q_frame (), tl::to_qstring ((*p)->title ())); if ((*p) == page) { index = int (std::distance (m_pages.begin (), p)); } @@ -163,12 +177,12 @@ EditorOptionsPages::update (edt::EditorOptionsPage *page) } } if (index < 0) { - index = mp_ui->pages->currentIndex (); + index = mp_pages->currentIndex (); } - if (index >= int (mp_ui->pages->count ())) { - index = mp_ui->pages->count () - 1; + if (index >= int (mp_pages->count ())) { + index = mp_pages->count () - 1; } - mp_ui->pages->setCurrentIndex (index); + mp_pages->setCurrentIndex (index); } void @@ -209,15 +223,6 @@ BEGIN_PROTECTED END_PROTECTED_W (this) } -void -EditorOptionsPages::accept () -{ -BEGIN_PROTECTED - do_apply (); - QDialog::accept (); -END_PROTECTED_W (this) -} - // ------------------------------------------------------------------ // EditorOptionsGeneric implementation diff --git a/src/edt/edt/edtEditorOptionsPages.h b/src/edt/edt/edtEditorOptionsPages.h index 65145212f..68222ccc8 100644 --- a/src/edt/edt/edtEditorOptionsPages.h +++ b/src/edt/edt/edtEditorOptionsPages.h @@ -26,10 +26,12 @@ #include -#include +#include #include #include +class QTabWidget; + namespace Ui { class EditorOptionsDialog; @@ -87,26 +89,30 @@ private: * @brief The object properties dialog */ class EditorOptionsPages - : public QDialog + : public QFrame { Q_OBJECT public: - EditorOptionsPages (const std::vector &pages, lay::Dispatcher *root); + EditorOptionsPages (QWidget *parent, const std::vector &pages, lay::Dispatcher *root); ~EditorOptionsPages (); void unregister_page (edt::EditorOptionsPage *page); void activate_page (edt::EditorOptionsPage *page); + const std::vector &pages () const + { + return m_pages; + } + public slots: void apply (); void setup (); - void accept (); private: std::vector m_pages; - Ui::EditorOptionsDialog *mp_ui; lay::Dispatcher *mp_root; + QTabWidget *mp_pages; void update (edt::EditorOptionsPage *page); void do_apply (); diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index 71b210ac7..548b1b855 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -150,8 +150,6 @@ MainService::menu_activated (const std::string &symbol) cm_descend (); } else if (symbol == "edt::ascend") { cm_ascend (); - } else if (symbol == "edt::edit_options") { - cm_edit_options (); } else if (symbol == "edt::sel_align") { cm_align (); } else if (symbol == "edt::sel_distribute") { @@ -2272,9 +2270,9 @@ MainService::cm_change_layer () } void -MainService::cm_edit_options () +MainService::show_editor_options () { - show_editor_options_dialog (); + show_editor_options_page (view ()); } void diff --git a/src/edt/edt/edtMainService.h b/src/edt/edt/edtMainService.h index 76a733ee5..5313da97f 100644 --- a/src/edt/edt/edtMainService.h +++ b/src/edt/edt/edtMainService.h @@ -94,11 +94,6 @@ public: */ void cm_ascend (); - /** - * @brief Edit object options - */ - void cm_edit_options (); - /** * @brief Change the layer of the shapes in the selection */ @@ -194,6 +189,11 @@ public: */ void cm_tap (); + /** + * @brief Shows the editor options + */ + void show_editor_options (); + /** * @brief "paste" operation */ diff --git a/src/edt/edt/edtPlugin.cc b/src/edt/edt/edtPlugin.cc index e7bd816c3..d9f241d8f 100644 --- a/src/edt/edt/edtPlugin.cc +++ b/src/edt/edt/edtPlugin.cc @@ -31,6 +31,7 @@ #include "edtEditorOptionsPages.h" #include +#include namespace edt { @@ -189,7 +190,7 @@ class MainPluginDeclaration { public: MainPluginDeclaration (const std::string &title) - : mp_root (0), m_title (title), mp_obj_prop_dialog (0) + : mp_root (0), m_title (title) { // .. nothing yet .. } @@ -218,8 +219,6 @@ public: menu_entries.push_back (lay::menu_item ("edt::descend", "descend", "zoom_menu.end", tl::to_string (QObject::tr ("Descend")) + "(Ctrl+D)")); menu_entries.push_back (lay::menu_item ("edt::ascend", "ascend", "zoom_menu.end", tl::to_string (QObject::tr ("Ascend")) + "(Ctrl+A)")); - menu_entries.push_back (lay::separator ("edit_options_group:edit_mode", "edit_menu.end")); - menu_entries.push_back (lay::menu_item ("edt::edit_options", "edit_options:edit_mode", "edit_menu.end", tl::to_string (QObject::tr ("Editor Options")) + "(F3)")); menu_entries.push_back (lay::menu_item ("edt::sel_make_array", "make_array:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Array")))); menu_entries.push_back (lay::separator ("selection_group:edit_mode", "edit_menu.selection_menu.end")); menu_entries.push_back (lay::menu_item ("edt::sel_change_layer", "change_layer:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Change Layer")))); @@ -279,24 +278,6 @@ public: mp_root = root; - // create the editor options dialog - m_prop_dialog_pages.push_back (new edt::EditorOptionsGeneric ()); - - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - const PluginDeclarationBase *pd_base = dynamic_cast (&*cls); - if (pd_base) { - pd_base->get_editor_options_pages (m_prop_dialog_pages, root); - } - } - - mp_obj_prop_dialog = new edt::EditorOptionsPages (m_prop_dialog_pages, root); - - for (std::vector::const_iterator op = m_prop_dialog_pages.begin (); op != m_prop_dialog_pages.end (); ++op) { - if ((*op)->plugin_declaration () != 0) { - (*op)->activate (false); - } - } - // add entries to the combine mode dialog mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_add", new lay::ConfigureAction (tl::to_string (QObject::tr ("Add<:/cm_add.png>{Add shapes}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Add))); mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_merge", new lay::ConfigureAction (tl::to_string (QObject::tr ("Merge<:/cm_merge.png>{Merge shapes with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Merge))); @@ -334,42 +315,6 @@ public: } } - virtual void uninitialize (lay::Dispatcher *) - { - if (mp_obj_prop_dialog) { - delete mp_obj_prop_dialog; - mp_obj_prop_dialog = 0; - } - } - - virtual void config_finalize () - { - if (mp_obj_prop_dialog && mp_obj_prop_dialog->isVisible ()) { - mp_obj_prop_dialog->setup (); - } - } - - void show_dialog () const - { - if (mp_obj_prop_dialog) { - if (! mp_obj_prop_dialog->isVisible ()) { - mp_obj_prop_dialog->setup (); - mp_obj_prop_dialog->show (); - } - mp_obj_prop_dialog->activateWindow (); - mp_obj_prop_dialog->raise (); - } - } - - void activate (const lay::PluginDeclaration *pd, bool active) const - { - for (std::vector::const_iterator op = m_prop_dialog_pages.begin (); op != m_prop_dialog_pages.end (); ++op) { - if ((*op)->plugin_declaration () == pd) { - (*op)->activate (active); - } - } - } - void initialized (lay::Dispatcher *root) { lay::Dispatcher *mp = lay::Dispatcher::instance (); @@ -398,38 +343,63 @@ public: private: lay::Dispatcher *mp_root; std::string m_title; - edt::EditorOptionsPages *mp_obj_prop_dialog; - std::vector m_prop_dialog_pages; }; +static tl::RegisteredClass config_decl_main (new edt::MainPluginDeclaration (tl::to_string (QObject::tr ("Instances and shapes"))), 4000, "edt::MainService"); + void -show_editor_options_dialog () +show_editor_options_page (lay::LayoutView *view) { - // look for the plugin declaration and show the dialog + if (! view->editor_options_frame ()) { + return; + } + + std::vector prop_dialog_pages; + EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (); + generic_opt->setup (view->dispatcher ()); + prop_dialog_pages.push_back (generic_opt); + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - const MainPluginDeclaration *main_pd = dynamic_cast (&*cls); - if (main_pd) { - main_pd->show_dialog (); - break; + const PluginDeclarationBase *pd_base = dynamic_cast (&*cls); + if (pd_base) { + pd_base->get_editor_options_pages (prop_dialog_pages, view->dispatcher ()); } } + + for (std::vector::const_iterator op = prop_dialog_pages.begin (); op != prop_dialog_pages.end (); ++op) { + (*op)->activate (false); + } + + QObjectList children = view->editor_options_frame ()->children (); + for (QObjectList::iterator c = children.begin (); c != children.end (); ++c) { + if (dynamic_cast (*c)) { + delete *c; + } + } + + edt::EditorOptionsPages *pages = new edt::EditorOptionsPages (view->editor_options_frame (), prop_dialog_pages, view->dispatcher ()); + view->editor_options_frame ()->layout ()->addWidget (pages); } void -activate_service (const lay::PluginDeclaration *pd, bool active) +activate_service (lay::LayoutView *view, const lay::PluginDeclaration *pd, bool active) { - // look for the plugin declaration and show the dialog - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - const MainPluginDeclaration *main_pd = dynamic_cast (&*cls); - if (main_pd) { - main_pd->activate (pd, active); - break; - } + // TODO: is there a better way to find the editor options pages? + edt::EditorOptionsPages *eo_pages = 0; + QObjectList children = view->editor_options_frame ()->children (); + for (QObjectList::iterator c = children.begin (); c != children.end () && !eo_pages; ++c) { + eo_pages = dynamic_cast (*c); + } + + if (!eo_pages) { + return; + } + + for (std::vector::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) { + (*op)->activate (((*op)->plugin_declaration () == pd || ! (*op)->plugin_declaration ()) && active); } } -static tl::RegisteredClass config_decl20 (new edt::MainPluginDeclaration (tl::to_string (QObject::tr ("Instances and shapes"))), 4000, "edt::MainService"); - class PartialPluginDeclaration : public lay::PluginDeclaration { diff --git a/src/edt/edt/edtPlugin.h b/src/edt/edt/edtPlugin.h index f75dec8dd..86898c714 100644 --- a/src/edt/edt/edtPlugin.h +++ b/src/edt/edt/edtPlugin.h @@ -52,14 +52,14 @@ namespace edt * * This dialog is a global resource which is managed by the main plugin declaration */ - void show_editor_options_dialog (); + void show_editor_options_page (lay::LayoutView *view); /** * @brief Activate or deactivate a certain service * * This will show or hide the editor properties pages for the respective service. */ - void activate_service (const lay::PluginDeclaration *pd, bool active); + void activate_service (lay::LayoutView *view, const lay::PluginDeclaration *pd, bool active); } #endif diff --git a/src/edt/edt/edtService.cc b/src/edt/edt/edtService.cc index f8dd7ee84..493387153 100644 --- a/src/edt/edt/edtService.cc +++ b/src/edt/edt/edtService.cc @@ -795,22 +795,22 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio void Service::activated () { - // make all editor option pages visible - activate_service (plugin_declaration (), true); - if (view ()->is_editable ()) { view ()->cancel (); // cancel any pending edit operations and clear the selection set_edit_marker (0); m_immediate = do_activated (); m_editing = false; } + + // make all editor option pages visible + activate_service (view (), plugin_declaration (), true); } void Service::deactivated () { // make all editor option pages visible - activate_service (plugin_declaration (), false); + activate_service (view (), plugin_declaration (), false); edit_cancel (); diff --git a/src/edt/edt/edtServiceImpl.cc b/src/edt/edt/edtServiceImpl.cc index 8e73c2775..e4a15b635 100644 --- a/src/edt/edt/edtServiceImpl.cc +++ b/src/edt/edt/edtServiceImpl.cc @@ -752,7 +752,7 @@ TextService::do_activated () // Show editor options dialog to allow entering of width std::vector edt_main_services = view ()->get_plugins (); if (edt_main_services.size () > 0) { - edt_main_services [0]->cm_edit_options (); + edt_main_services [0]->show_editor_options (); } return true; // start editing immediately @@ -918,7 +918,7 @@ PathService::do_activated () // Show editor options dialog to allow entering of width std::vector edt_main_services = view ()->get_plugins (); if (edt_main_services.size () > 0) { - edt_main_services [0]->cm_edit_options (); + edt_main_services [0]->show_editor_options (); } return false; // don't start editing immediately @@ -1123,7 +1123,7 @@ InstService::do_activated () // Show editor options dialog to allow entering of parameters std::vector edt_main_services = view ()->get_plugins (); if (edt_main_services.size () > 0) { - edt_main_services [0]->cm_edit_options (); + edt_main_services [0]->show_editor_options (); } m_cv_index = view ()->active_cellview_index (); diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index 2e8f23f11..26eefba7a 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -500,6 +500,14 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha connect (mp_libs_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool))); m_libs_visible = true; + mp_eo_dock_widget = new QDockWidget (QObject::tr ("Editor Options"), this); + mp_eo_dock_widget->hide (); + mp_eo_dock_widget->setObjectName (QString::fromUtf8 ("eo_dock_widget")); + mp_eo_stack = new ControlWidgetStack (mp_eo_dock_widget, "eo_stack"); + mp_eo_dock_widget->setWidget (mp_eo_stack); + connect (mp_eo_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool))); + m_eo_visible = false; + mp_bm_dock_widget = new QDockWidget (QObject::tr ("Bookmarks"), this); mp_bm_dock_widget->setObjectName (QString::fromUtf8 ("bookmarks_dock_widget")); mp_bm_stack = new ControlWidgetStack (mp_bm_dock_widget, "bookmarks_stack"); @@ -539,6 +547,7 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha addDockWidget(Qt::LeftDockWidgetArea, mp_navigator_dock_widget); addDockWidget(Qt::LeftDockWidgetArea, mp_hp_dock_widget); addDockWidget(Qt::LeftDockWidgetArea, mp_libs_dock_widget); + addDockWidget(Qt::LeftDockWidgetArea, mp_eo_dock_widget); addDockWidget(Qt::RightDockWidgetArea, mp_bm_dock_widget); addDockWidget(Qt::RightDockWidgetArea, mp_lp_dock_widget); addDockWidget(Qt::RightDockWidgetArea, mp_layer_toolbox_dock_widget); @@ -925,6 +934,7 @@ MainWindow::close_all () mp_lp_stack->removeWidget (mp_views.size ()); mp_hp_stack->removeWidget (mp_views.size ()); mp_libs_stack->removeWidget (mp_views.size ()); + mp_eo_stack->removeWidget (mp_views.size ()); mp_bm_stack->removeWidget (mp_views.size ()); mp_view_stack->removeWidget (mp_views.size ()); @@ -1518,6 +1528,12 @@ MainWindow::update_dock_widget_state () mp_libs_dock_widget->hide (); } + if (m_eo_visible) { + mp_eo_dock_widget->show (); + } else { + mp_eo_dock_widget->hide (); + } + if (m_bm_visible) { mp_bm_dock_widget->show (); } else { @@ -1856,6 +1872,30 @@ MainWindow::select_mode (int m) } } + // if the current mode supports editing, show the editor options panel + + const lay::PluginDeclaration *pd_sel = 0; + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + const lay::PluginDeclaration *pd = cls.operator-> (); + if (pd->id () == m_mode) { + pd_sel = pd; + } + } + + bool editable = false; + if (pd_sel) { + editable = pd_sel->editable_enabled (); + } + + if (editable != m_eo_visible) { + m_eo_visible = editable; + if (m_eo_visible) { + mp_eo_dock_widget->show (); + } else { + mp_eo_dock_widget->hide (); + } + } + } } @@ -2526,6 +2566,7 @@ MainWindow::select_view (int index) mp_hp_stack->raiseWidget (index); mp_lp_stack->raiseWidget (index); mp_libs_stack->raiseWidget (index); + mp_eo_stack->raiseWidget (index); mp_bm_stack->raiseWidget (index); mp_setup_form->setup (); @@ -2717,6 +2758,7 @@ MainWindow::clone_current_view () mp_lp_stack->addWidget (view->layer_control_frame ()); mp_hp_stack->addWidget (view->hierarchy_control_frame ()); mp_libs_stack->addWidget (view->libraries_frame ()); + mp_eo_stack->addWidget (view->editor_options_frame ()); mp_bm_stack->addWidget (view->bookmarks_frame ()); bool f = m_disable_tab_selected; @@ -2965,6 +3007,7 @@ MainWindow::close_view (int index) mp_lp_stack->removeWidget (index); mp_hp_stack->removeWidget (index); mp_libs_stack->removeWidget (index); + mp_eo_stack->removeWidget (index); mp_bm_stack->removeWidget (index); view_closed_event (int (index)); @@ -3286,6 +3329,7 @@ MainWindow::create_view () mp_lp_stack->addWidget (mp_views.back ()->layer_control_frame ()); mp_hp_stack->addWidget (mp_views.back ()->hierarchy_control_frame ()); mp_libs_stack->addWidget (mp_views.back ()->libraries_frame ()); + mp_eo_stack->addWidget (mp_views.back ()->editor_options_frame ()); mp_bm_stack->addWidget (mp_views.back ()->bookmarks_frame ()); bool f = m_disable_tab_selected; @@ -3349,6 +3393,7 @@ MainWindow::create_or_load_layout (const std::string *filename, const db::LoadLa mp_lp_stack->addWidget (mp_views.back ()->layer_control_frame ()); mp_hp_stack->addWidget (mp_views.back ()->hierarchy_control_frame ()); mp_libs_stack->addWidget (mp_views.back ()->libraries_frame ()); + mp_eo_stack->addWidget (mp_views.back ()->editor_options_frame ()); mp_bm_stack->addWidget (mp_views.back ()->bookmarks_frame ()); bool f = m_disable_tab_selected; @@ -3824,6 +3869,13 @@ MainWindow::menu_activated (const std::string &symbol) cm_help_about (); } else if (symbol == "cm_help_about_qt") { cm_help_about_qt (); + } else if (symbol == "cm_edit_options") { + + if (!m_eo_visible) { + mp_eo_dock_widget->show (); + m_eo_visible = true; + } + } else { // Try the plugin declarations @@ -4189,6 +4241,10 @@ public: menu_entries.push_back (lay::submenu ("@secrets", at, tl::to_string (QObject::tr ("Secret Features")))); menu_entries.push_back (lay::submenu ("@toolbar", at, std::string ())); + at = "edit_menu.end"; + menu_entries.push_back (lay::separator ("edit_options_group:edit_mode", "edit_menu.end")); + menu_entries.push_back (lay::menu_item ("cm_edit_options", "edit_options:edit_mode", "edit_menu.end", tl::to_string (QObject::tr ("Editor Options")) + "(F3)")); + at = "file_menu.end"; menu_entries.push_back (lay::menu_item ("cm_new_layout", "new_layout:edit:edit_mode", at, tl::to_string (QObject::tr ("New Layout")))); menu_entries.push_back (lay::menu_item ("cm_new_panel", "new_panel:edit:edit_mode", at, tl::to_string (QObject::tr ("New Panel")))); diff --git a/src/lay/lay/layMainWindow.h b/src/lay/lay/layMainWindow.h index 6ffa374e2..eb24021d5 100644 --- a/src/lay/lay/layMainWindow.h +++ b/src/lay/lay/layMainWindow.h @@ -680,9 +680,9 @@ private: QToolBar *mp_tool_bar; QDockWidget *mp_navigator_dock_widget; lay::Navigator *mp_navigator; - QDockWidget *mp_hp_dock_widget, *mp_lp_dock_widget, *mp_libs_dock_widget, *mp_bm_dock_widget; - ControlWidgetStack *mp_hp_stack, *mp_lp_stack, *mp_libs_stack, *mp_bm_stack; - bool m_hp_visible, m_lp_visible, m_libs_visible, m_bm_visible, m_navigator_visible, m_layer_toolbox_visible; + QDockWidget *mp_hp_dock_widget, *mp_lp_dock_widget, *mp_libs_dock_widget, *mp_eo_dock_widget, *mp_bm_dock_widget; + ControlWidgetStack *mp_hp_stack, *mp_lp_stack, *mp_libs_stack, *mp_eo_stack, *mp_bm_stack; + bool m_hp_visible, m_lp_visible, m_libs_visible, m_eo_visible, m_bm_visible, m_navigator_visible, m_layer_toolbox_visible; QDockWidget *mp_layer_toolbox_dock_widget; lay::LayerToolbox *mp_layer_toolbox; ViewWidgetStack *mp_view_stack; diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index eae19ef72..a2f1d7cb7 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -467,6 +467,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This constant has been introduced in version 0.27.\n" ) + + gsi::constant ("LV_NoEditorOptionsPanel", (unsigned int) lay::LayoutView::LV_NoEditorOptionsPanel, + "@brief With this option, no editor options panel will be provided (see \\editor_options_frame)\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.27.\n" + ) + gsi::constant ("LV_NoBookmarksView", (unsigned int) lay::LayoutView::LV_NoBookmarksView, "@brief With this option, no bookmarks view will be provided (see \\bookmarks_frame)\n" "Use this value with the constructor's 'options' argument.\n" diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 62a8566a3..9302623f3 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -390,6 +390,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) mp_libraries_view = 0; mp_bookmarks_view = 0; mp_libraries_frame = 0; + mp_editor_options_frame = 0; mp_bookmarks_frame = 0; mp_min_hier_spbx = 0; mp_max_hier_spbx = 0; @@ -557,6 +558,20 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) } + if (is_editable () && (m_options & LV_NoEditorOptionsPanel) == 0 && (m_options & LV_Naked) == 0) { + + QFrame *editor_options_frame = new QFrame (0); + editor_options_frame->setObjectName (QString::fromUtf8 ("editor_options_frame")); + mp_editor_options_frame = editor_options_frame; + + QVBoxLayout *left_frame_ly = new QVBoxLayout (editor_options_frame); + left_frame_ly->setMargin (0); + left_frame_ly->setSpacing (0); + + connect (mp_editor_options_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); + + } + // occupy services and editables: // these services get deleted by the canvas destructor automatically: if ((m_options & LV_NoTracker) == 0) { @@ -686,6 +701,11 @@ LayoutView::~LayoutView () mp_libraries_frame = 0; mp_libraries_view = 0; + if (mp_editor_options_frame) { + delete mp_editor_options_frame; + } + mp_editor_options_frame = 0; + if (mp_bookmarks_frame) { delete mp_bookmarks_frame; } @@ -709,6 +729,8 @@ void LayoutView::side_panel_destroyed () } else if (sender () == mp_libraries_frame) { mp_libraries_frame = 0; mp_libraries_view = 0; + } else if (sender () == mp_editor_options_frame) { + mp_editor_options_frame = 0; } else if (sender () == mp_bookmarks_frame) { mp_bookmarks_frame = 0; mp_bookmarks_view = 0; diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 0081684b4..46938886a 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -175,14 +175,15 @@ public: LV_NoLayers = 1, LV_NoHierarchyPanel = 2, LV_NoLibrariesView = 4, - LV_NoBookmarksView = 8, - LV_Naked = 16, - LV_NoZoom = 32, - LV_NoGrid = 64, - LV_NoMove = 128, - LV_NoTracker = 256, - LV_NoSelection = 512, - LV_NoPlugins = 1024, + LV_NoEditorOptionsPanel = 8, + LV_NoBookmarksView = 16, + LV_Naked = 32, + LV_NoZoom = 64, + LV_NoGrid = 128, + LV_NoMove = 256, + LV_NoTracker = 512, + LV_NoSelection = 1024, + LV_NoPlugins = 2048, LV_NoServices = LV_NoMove + LV_NoTracker + LV_NoSelection + LV_NoPlugins }; @@ -268,6 +269,14 @@ public: return mp_libraries_frame; } + /** + * @brief Gets the container with the editor options + */ + QWidget *editor_options_frame () + { + return mp_editor_options_frame; + } + /** * @brief Gets the container with the bookmarks view */ @@ -2708,7 +2717,7 @@ private: lay::HierarchyControlPanel *mp_hierarchy_panel; lay::LibrariesView *mp_libraries_view; lay::BookmarksView *mp_bookmarks_view; - QWidget *mp_control_frame, *mp_hierarchy_frame, *mp_libraries_frame, *mp_bookmarks_frame; + QWidget *mp_control_frame, *mp_hierarchy_frame, *mp_libraries_frame, *mp_editor_options_frame, *mp_bookmarks_frame; QSpinBox *mp_min_hier_spbx; QSpinBox *mp_max_hier_spbx; std::list m_cellviews; diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.cc b/src/laybasic/laybasic/layLayoutViewFunctions.cc index c7198ac11..89e963c06 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.cc +++ b/src/laybasic/laybasic/layLayoutViewFunctions.cc @@ -2065,7 +2065,7 @@ public: menu_entries.push_back (lay::menu_item ("cm_select_next_item", "select_next_item:edit", at, tl::to_string (QObject::tr ("Select Next Item(Space)")))); menu_entries.push_back (lay::menu_item ("cm_select_next_item_add", "select_next_item_add:edit", at, tl::to_string (QObject::tr ("Select Next Item too(Shift+Space)")))); - at = "edit_menu.end"; + at = "edit_menu.edit_options_group"; menu_entries.push_back (lay::menu_item ("cm_undo", "undo:edit", at, tl::to_string (QObject::tr ("Undo(Ctrl+Z)")))); menu_entries.push_back (lay::menu_item ("cm_redo", "redo:edit", at, tl::to_string (QObject::tr ("Redo(Ctrl+Y)"))));