diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index 5ac536d89..f0fab85b2 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -402,20 +402,137 @@ static LayerPropertiesConstIteratorWrapper each_layer2 (lay::LayoutView *view, u return LayerPropertiesConstIteratorWrapper (view->begin_layers (list_index)); } -static lay::LayoutView *new_view () +static lay::LayoutView *new_view (QWidget *parent, bool editable, db::Manager *manager, unsigned int options) { - return new lay::LayoutView (0, false, 0); + lay::LayoutView *lv = new lay::LayoutView (manager, editable, 0 /*plugin parent*/, parent, "view", options); + if (parent) { + // transfer ownership to the parent + lv->keep (); + } + return lv; } Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutView", - gsi::constructor ("new", &new_view, + gsi::constructor ("new", &new_view, gsi::arg ("parent", (QWidget *) 0), gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0), gsi::arg ("options", (unsigned int) 0), "@brief Creates a standalone view\n" "\n" "This constructor is for special purposes only. To create a view in the context of a main window, " "use \\MainWindow#create_view and related methods.\n" "\n" + "@param parent The parent widget in which to embed the view\n" + "@param editable True to make the view editable\n" + "@param manager The \\Manager object to enable undo/redo\n" + "@param options A combination of the values in the LV_... constants\n" + "\n" "This constructor has been introduced in version 0.25.\n" + "It has been enhanced with the arguments in version 0.26.4.\n" ) + + gsi::constant ("LV_NoLayers", (unsigned int) laybasic::LayoutView::LV_NoLayers, + "@brief With this option, no layers view will be provided (see \\layer_control_frame)\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoHierarchyPanel", (unsigned int) laybasic::LayoutView::LV_NoHierarchyPanel, + "@brief With this option, no cell hierarchy view will be provided (see \\hierarchy_control_frame)\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoLibrariesView", (unsigned int) laybasic::LayoutView::LV_NoLibrariesView, + "@brief With this option, no library view will be provided (see \\libraries_frame)\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoBookmarksView", (unsigned int) laybasic::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" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_Naked", (unsigned int) laybasic::LayoutView::LV_Naked, + "@brief With this option, no separate views will be provided\n" + "Use this value with the constructor's 'options' argument.\n" + "This option is basically equivalent to using \\LV_NoLayers+\\LV_NoHierarchyPanel+\\LV_NoLibrariesView+\\LV_NoBookmarksView\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoZoom", (unsigned int) laybasic::LayoutView::LV_NoZoom, + "@brief With this option, zooming is disabled\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoGrid", (unsigned int) laybasic::LayoutView::LV_NoGrid, + "@brief With this option, the grid background is not shown\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoMove", (unsigned int) laybasic::LayoutView::LV_NoMove, + "@brief With this option, move operations are not supported\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoTracker", (unsigned int) laybasic::LayoutView::LV_NoTracker, + "@brief With this option, mouse position tracking is not supported\n" + "Use this value with the constructor's 'options' argument.\n" + "This option is not useful currently as no mouse tracking support is provided.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoSelection", (unsigned int) laybasic::LayoutView::LV_NoSelection, + "@brief With this option, objects cannot be selected\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoPlugins", (unsigned int) laybasic::LayoutView::LV_NoPlugins, + "@brief With this option, all plugins are disabled\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoServices", (unsigned int) laybasic::LayoutView::LV_NoServices, + "@brief This option disables all services except the ones for pure viewing\n" + "Use this value with the constructor's 'options' argument.\n" + "With this option, all manipulation features are disabled, except zooming.\n" + "It is equivalent to \\LV_NoMove + \\LV_NoTracker + \\LV_NoSelection + \\LV_NoPlugins.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + +#if defined(HAVE_QTBINDINGS) + gsi::method ("layer_control_frame", &lay::LayoutView::layer_control_frame, + "@brief Gets the layer control side widget\n" + "A 'side widget' is a widget attached to the view. It does not have a parent, so you can " + "embed it into a different context. Please note that with embedding through 'setParent' it will be " + "destroyed when your parent widget gets destroyed. It will be lost then to the view.\n" + "\n" + "The side widget can be configured through the views configuration interface.\n" + "\n" + "This method has been introduced in version 0.26.4\n" + ) + + gsi::method ("hierarchy_control_frame", &lay::LayoutView::hierarchy_control_frame, + "@brief Gets the cell view (hierarchy view) side widget\n" + "For details about side widgets see \\layer_control_frame.\n" + "\n" + "This method has been introduced in version 0.26.4\n" + ) + + gsi::method ("libraries_frame", &lay::LayoutView::libraries_frame, + "@brief Gets the library view side widget\n" + "For details about side widgets see \\layer_control_frame.\n" + "\n" + "This method has been introduced in version 0.26.4\n" + ) + + gsi::method ("bookmarks_frame", &lay::LayoutView::bookmarks_frame, + "@brief Gets the bookmarks side widget\n" + "For details about side widgets see \\layer_control_frame.\n" + "\n" + "This method has been introduced in version 0.26.4\n" + ) + +#endif gsi::method ("current", &lay::LayoutView::current, "@brief Returns the current view\n" "The current view is the one that is shown in the current tab. Returns nil if no layout is loaded.\n" diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index eda3aa1d4..c3c419ff2 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -477,6 +477,7 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) connect (mp_hierarchy_panel, SIGNAL (cell_selected (cell_path_type, int)), this, SLOT (select_cell_dispatch (cell_path_type, int))); connect (mp_hierarchy_panel, SIGNAL (active_cellview_changed (int)), this, SLOT (active_cellview_changed (int))); + connect (mp_hierarchy_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); QFrame *levels_frame = new QFrame (hierarchy_frame); levels_frame->setObjectName (QString::fromUtf8 ("lvl_frame")); @@ -521,6 +522,8 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) mp_bookmarks_view = new lay::BookmarksView (this, bookmarks_frame, "bookmarks"); left_frame_ly->addWidget (mp_bookmarks_view, 1 /*stretch*/); + connect (mp_bookmarks_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); + } if ((m_options & LV_NoLibrariesView) == 0 && (m_options & LV_Naked) == 0) { @@ -536,6 +539,7 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) left_frame_ly->addWidget (mp_libraries_view, 1 /*stretch*/); connect (mp_libraries_view, SIGNAL (active_library_changed (int)), this, SLOT (active_library_changed (int))); + connect (mp_libraries_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); } @@ -559,6 +563,7 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) mp_control_panel = new lay::LayerControlPanel (this, manager (), 0, "lcp"); mp_control_frame = mp_control_panel; + connect (mp_control_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); connect (mp_control_panel, SIGNAL (tab_changed ()), this, SLOT (layer_tab_changed ())); connect (mp_control_panel, SIGNAL (order_changed ()), this, SLOT (layer_order_changed ())); /* @@ -679,6 +684,23 @@ LayoutView::~LayoutView () mp_bookmarks_view = 0; } +void LayoutView::side_panel_destroyed () +{ + if (sender () == mp_control_frame) { + mp_control_frame = 0; + mp_control_panel = 0; + } else if (sender () == mp_hierarchy_frame) { + mp_hierarchy_frame = 0; + mp_hierarchy_panel = 0; + } else if (sender () == mp_libraries_frame) { + mp_libraries_frame = 0; + mp_libraries_view = 0; + } else if (sender () == mp_bookmarks_frame) { + mp_bookmarks_frame = 0; + mp_bookmarks_view = 0; + } +} + void LayoutView::hideEvent (QHideEvent *) { hide_event (); diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 172d1bc46..feab2526a 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -2685,6 +2685,7 @@ private slots: void active_cellview_changed (int index); void active_library_changed (int index); void goto_bookmark (); + void side_panel_destroyed (); signals: /**