Merge pull request #350 from KLayout/issue-343

Issue 343
This commit is contained in:
Matthias Köfferlein 2019-09-08 20:05:14 +02:00 committed by GitHub
commit 06cff5fa8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 484 additions and 18 deletions

View File

@ -17,4 +17,33 @@
Bookmarks" and "Save Bookmarks" functions from the "Bookmarks" menu.
</p>
<p>
The bookmark list is available as a dockable tool window as well:
check the "View/Bookmark List" option to enable this dock window.
The bookmark list by default is shown at the bottom right side of
the layout view.
</p>
<h2>Dockable Bookmark List</h2>
<p>
To navigate to a bookmark from the dockable bookmark list, double-click
the entry.
From the context menu (right mouse click) you can select these functions:
</p>
<ul>
<li><b>Follow Selection</b>: if this option is checked, the selected
bookmark will immediately change the view accordingly. With this
option, you can browse the bookmark list with the arrow keys
while the view updates automatically.
</li>
<li><b>Manage bookmarks</b>: opens the bookmark management dialog (same
as from the "Bookmarks" menu).
</li>
<li><b>Load bookmarks</b> and <b>Save bookmarks</b>: loads or saves the
bookmarks to a file (same function as from the "Bookmarks" menu).
</li>
</ul>
</doc>

View File

@ -50,6 +50,7 @@ static const std::string cfg_navigator_show_images ("navigator-show-images");
static const std::string cfg_show_layer_toolbox ("show-layer-toolbox");
static const std::string cfg_show_hierarchy_panel ("show-hierarchy-panel");
static const std::string cfg_show_libraries_view ("show-libraries-view");
static const std::string cfg_show_bookmarks_view ("show-bookmarks-view");
static const std::string cfg_show_layer_panel ("show-layer-panel");
static const std::string cfg_window_state ("window-state");
static const std::string cfg_layout_file_watcher_enabled ("layout-file-watcher-enabled");

View File

@ -69,6 +69,7 @@ public:
options.push_back (std::pair<std::string, std::string> (cfg_show_layer_toolbox, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_show_hierarchy_panel, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_show_libraries_view, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_show_bookmarks_view, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_show_layer_panel, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_layout_file_watcher_enabled, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_window_state, ""));

View File

@ -513,6 +513,13 @@ 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_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");
mp_bm_dock_widget->setWidget (mp_bm_stack);
connect (mp_bm_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool)));
m_bm_visible = true;
mp_view_stack = new ViewWidgetStack (mp_main_frame);
mp_view_stack->setObjectName (QString::fromUtf8 ("view_stack"));
vbl->addWidget (mp_view_stack);
@ -545,6 +552,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::RightDockWidgetArea, mp_bm_dock_widget);
addDockWidget(Qt::RightDockWidgetArea, mp_lp_dock_widget);
addDockWidget(Qt::RightDockWidgetArea, mp_layer_toolbox_dock_widget);
@ -865,6 +873,7 @@ MainWindow::init_menu ()
MenuLayoutEntry ("show_layer_toolbox", tl::to_string (QObject::tr ("Layer Toolbox")), std::make_pair (cfg_show_layer_toolbox, "?")),
MenuLayoutEntry ("show_hierarchy_panel", tl::to_string (QObject::tr ("Cells")), std::make_pair (cfg_show_hierarchy_panel, "?")),
MenuLayoutEntry ("show_libraries_view", tl::to_string (QObject::tr ("Libraries")), std::make_pair (cfg_show_libraries_view, "?")),
MenuLayoutEntry ("show_bookmarks_view", tl::to_string (QObject::tr ("Bookmarks")), std::make_pair (cfg_show_bookmarks_view, "?")),
MenuLayoutEntry ("reset_window_state", tl::to_string (QObject::tr ("Restore Window")), SLOT (cm_reset_window_state ())),
MenuLayoutEntry::separator ("selection_group"),
MenuLayoutEntry ("transient_selection", tl::to_string (QObject::tr ("Highlight Object Under Mouse")), std::make_pair (cfg_sel_transient_mode, "?")),
@ -1092,6 +1101,8 @@ MainWindow::dock_widget_visibility_changed (bool /*visible*/)
plugin_root ()->config_set (cfg_show_hierarchy_panel, tl::to_string (!mp_hp_dock_widget->isHidden ()));
} else if (sender () == mp_libs_dock_widget) {
plugin_root ()->config_set (cfg_show_libraries_view, tl::to_string (!mp_libs_dock_widget->isHidden ()));
} else if (sender () == mp_bm_dock_widget) {
plugin_root ()->config_set (cfg_show_bookmarks_view, tl::to_string (!mp_bm_dock_widget->isHidden ()));
} else if (sender () == mp_navigator_dock_widget) {
plugin_root ()->config_set (cfg_show_navigator, tl::to_string (!mp_navigator_dock_widget->isHidden ()));
} else if (sender () == mp_layer_toolbox_dock_widget) {
@ -1257,6 +1268,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_bm_stack->removeWidget (mp_views.size ());
mp_view_stack->removeWidget (mp_views.size ());
delete view;
@ -1716,6 +1728,17 @@ MainWindow::configure (const std::string &name, const std::string &value)
return true;
} else if (name == cfg_show_bookmarks_view) {
tl::from_string (value, m_bm_visible);
if (m_bm_visible) {
mp_bm_dock_widget->show ();
} else {
mp_bm_dock_widget->hide ();
}
return true;
} else if (name == cfg_show_layer_panel) {
tl::from_string (value, m_lp_visible);
@ -1829,6 +1852,7 @@ MainWindow::read_dock_widget_state ()
plugin_root ()->config_set (cfg_show_layer_panel, tl::to_string (!mp_lp_dock_widget->isHidden ()));
plugin_root ()->config_set (cfg_show_hierarchy_panel, tl::to_string (!mp_hp_dock_widget->isHidden ()));
plugin_root ()->config_set (cfg_show_libraries_view, tl::to_string (!mp_libs_dock_widget->isHidden ()));
plugin_root ()->config_set (cfg_show_bookmarks_view, tl::to_string (!mp_bm_dock_widget->isHidden ()));
plugin_root ()->config_set (cfg_show_navigator, tl::to_string (!mp_navigator_dock_widget->isHidden ()));
plugin_root ()->config_set (cfg_show_layer_toolbox, tl::to_string (!mp_layer_toolbox_dock_widget->isHidden ()));
}
@ -1848,6 +1872,12 @@ MainWindow::update_dock_widget_state ()
mp_libs_dock_widget->hide ();
}
if (m_bm_visible) {
mp_bm_dock_widget->show ();
} else {
mp_bm_dock_widget->hide ();
}
if (m_lp_visible) {
mp_lp_dock_widget->show ();
} else {
@ -3347,6 +3377,7 @@ MainWindow::select_view (int index)
mp_hp_stack->raiseWidget (index);
mp_lp_stack->raiseWidget (index);
mp_libs_stack->raiseWidget (index);
mp_bm_stack->raiseWidget (index);
mp_setup_form->setup ();
}
@ -3766,6 +3797,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_bm_stack->addWidget (view->bookmarks_frame ());
bool f = m_disable_tab_selected;
m_disable_tab_selected = true;
@ -4013,6 +4045,7 @@ MainWindow::close_view (int index)
mp_lp_stack->removeWidget (index);
mp_hp_stack->removeWidget (index);
mp_libs_stack->removeWidget (index);
mp_bm_stack->removeWidget (index);
view_closed_event (int (index));
@ -4392,6 +4425,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_bm_stack->addWidget (mp_views.back ()->bookmarks_frame ());
bool f = m_disable_tab_selected;
m_disable_tab_selected = true;
@ -4454,6 +4488,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_bm_stack->addWidget (mp_views.back ()->bookmarks_frame ());
bool f = m_disable_tab_selected;
m_disable_tab_selected = true;

View File

@ -875,9 +875,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;
ControlWidgetStack *mp_hp_stack, *mp_lp_stack, *mp_libs_stack;
bool m_hp_visible, m_lp_visible, m_libs_visible, m_navigator_visible, m_layer_toolbox_visible;
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_layer_toolbox_dock_widget;
lay::LayerToolbox *mp_layer_toolbox;
ViewWidgetStack *mp_view_stack;

View File

@ -25,6 +25,8 @@
#include "tlXMLParser.h"
#include <fstream>
#include <cstdlib>
#include <cctype>
namespace lay
{
@ -86,6 +88,33 @@ BookmarkList::save (const std::string &fn) const
tl::log << "Saved bookmarks to " << fn;
}
std::string
BookmarkList::propose_new_bookmark_name () const
{
int n = 0;
for (const_iterator b = begin (); b != end (); ++b) {
const std::string &name = b->name ();
if (! name.empty ()) {
const char *cp = name.c_str () + name.size ();
while (cp != name.c_str ()) {
if (! isdigit (cp [-1])) {
break;
}
--cp;
}
int nn = atoi (cp);
n = std::max (nn, n);
}
}
return "B" + tl::to_string (n + 1);
}
}

View File

@ -27,6 +27,7 @@
#include "laybasicCommon.h"
#include "layDisplayState.h"
#include "tlObject.h"
#include <vector>
#include <string>
@ -89,6 +90,7 @@ public:
* @brief The list of bookmarks
*/
class LAYBASIC_PUBLIC BookmarkList
: public tl::Object
{
public:
typedef std::vector<BookmarkListElement> bookmark_list_type;
@ -182,6 +184,11 @@ public:
return m_list [index];
}
/**
* @brief Propose a new bookmark name
*/
std::string propose_new_bookmark_name () const;
/**
* @brief Save the list
*/

View File

@ -53,7 +53,7 @@ private:
// ------------------------------------------------------------
BookmarkManagementForm::BookmarkManagementForm (QWidget *parent, const char *name, const lay::BookmarkList &bookmarks)
BookmarkManagementForm::BookmarkManagementForm (QWidget *parent, const char *name, const lay::BookmarkList &bookmarks, const std::set<size_t> &selected)
: QDialog (parent), Ui::BookmarkManagementForm (),
m_bookmarks (bookmarks)
{
@ -61,8 +61,18 @@ BookmarkManagementForm::BookmarkManagementForm (QWidget *parent, const char *nam
Ui::BookmarkManagementForm::setupUi (this);
QListWidgetItem *first_item = 0;
for (size_t i = 0; i < m_bookmarks.size (); ++i) {
new BookmarkListLVI (bookmark_list, m_bookmarks.name (i), m_bookmarks.state (i));
QListWidgetItem *item = new BookmarkListLVI (bookmark_list, m_bookmarks.name (i), m_bookmarks.state (i));
item->setSelected (selected.find (i) != selected.end ());
if (! first_item && item->isSelected ()) {
first_item = item;
}
}
if (first_item) {
bookmark_list->scrollToItem (first_item);
}
connect (delete_button, SIGNAL (clicked ()), this, SLOT (delete_pressed ()));

View File

@ -26,8 +26,11 @@
#include <QObject> // required during the dependency pass
#include "ui_BookmarkManagementForm.h"
#include "layLayoutView.h"
#include <set>
namespace lay
{
@ -37,7 +40,7 @@ class BookmarkManagementForm
Q_OBJECT
public:
BookmarkManagementForm (QWidget *parent, const char *name, const lay::BookmarkList &bookmarks);
BookmarkManagementForm (QWidget *parent, const char *name, const lay::BookmarkList &bookmarks, const std::set<size_t> &selected);
/**
* @brief Obtain the bookmark list

View File

@ -0,0 +1,211 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2019 Matthias Koefferlein
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 Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "layBookmarksView.h"
#include "layLayoutView.h"
#include "layAbstractMenu.h"
#include "layAbstractMenuProvider.h"
#include "laybasicConfig.h"
#include <QVBoxLayout>
namespace lay
{
// --------------------------------------------------------------------------------------------
class BookmarkListModel
: public QAbstractItemModel
{
public:
BookmarkListModel (const lay::BookmarkList *bookmarks)
: mp_bookmarks (bookmarks)
{
// .. nothing yet ..
}
int rowCount (const QModelIndex &index) const
{
return index.isValid () ? 0 : int (mp_bookmarks->size ());
}
int columnCount (const QModelIndex &) const
{
return 1;
}
QVariant data (const QModelIndex &index, int role) const
{
if (role == Qt::DisplayRole && index.row () >= 0 && index.row () < int (mp_bookmarks->size ())) {
return tl::to_qstring (mp_bookmarks->name (size_t (index.row ())));
}
return QVariant ();
}
QModelIndex index (int row, int column, const QModelIndex &parent) const
{
if (parent.isValid ()) {
return QModelIndex ();
} else {
return createIndex (row, column, 0);
}
}
QModelIndex parent(const QModelIndex &) const
{
return QModelIndex ();
}
void refresh ()
{
dataChanged (createIndex (0, 0, 0), createIndex (rowCount (QModelIndex ()), 1, 0));
}
private:
const lay::BookmarkList *mp_bookmarks;
};
// --------------------------------------------------------------------------------------------
BookmarksView::BookmarksView (LayoutView *view, QWidget *parent, const char *name)
: QFrame (parent), m_follow_selection (false)
{
setObjectName (QString::fromUtf8 (name));
mp_view = view;
QVBoxLayout *layout = new QVBoxLayout ();
layout->setMargin (0);
setLayout (layout);
mp_bookmarks = new QListView (this);
layout->addWidget (mp_bookmarks);
mp_bookmarks->setModel (new BookmarkListModel (&view->bookmarks ()));
mp_bookmarks->setSelectionMode (QAbstractItemView::ExtendedSelection);
mp_bookmarks->setContextMenuPolicy (Qt::CustomContextMenu);
connect (mp_bookmarks, SIGNAL (customContextMenuRequested (const QPoint &)), this, SLOT (context_menu (const QPoint &)));
connect (mp_bookmarks, SIGNAL (doubleClicked (const QModelIndex &)), this, SLOT (bookmark_triggered (const QModelIndex &)));
connect (mp_bookmarks->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (current_bookmark_changed (const QModelIndex &)));
}
BookmarksView::~BookmarksView ()
{
// .. nothing yet ..
}
std::set<size_t>
BookmarksView::selected_bookmarks ()
{
QModelIndexList sel = mp_bookmarks->selectionModel ()->selectedIndexes ();
std::set<size_t> res;
for (QModelIndexList::const_iterator i = sel.begin (); i != sel.end (); ++i) {
res.insert (int (i->row ()));
}
return res;
}
void
BookmarksView::follow_selection (bool f)
{
m_follow_selection = f;
}
void
BookmarksView::init_menu (lay::AbstractMenu &menu)
{
MenuLayoutEntry context_menu [] = {
MenuLayoutEntry ("follow_selection", tl::to_string (QObject::tr ("Follow Selection")), std::make_pair (cfg_bookmarks_follow_selection, "?")),
MenuLayoutEntry::separator ("ops_group"),
MenuLayoutEntry ("manage_bookmarks", tl::to_string (QObject::tr ("Manage Bookmarks")), SLOT (cm_manage_bookmarks ())),
MenuLayoutEntry ("load_bookmarks", tl::to_string (QObject::tr ("Load Bookmarks")), SLOT (cm_load_bookmarks ())),
MenuLayoutEntry ("save_bookmarks", tl::to_string (QObject::tr ("Save Bookmarks")), SLOT (cm_save_bookmarks ())),
MenuLayoutEntry::last ()
};
MenuLayoutEntry main_menu [] = {
MenuLayoutEntry ("@bookmarks_context_menu", "", context_menu),
MenuLayoutEntry::last ()
};
menu.init (main_menu);
}
void
BookmarksView::set_background_color (QColor c)
{
QPalette pl (mp_bookmarks->palette ());
pl.setColor (QPalette::Base, c);
mp_bookmarks->setPalette (pl);
}
void
BookmarksView::set_text_color (QColor c)
{
QPalette pl (mp_bookmarks->palette ());
pl.setColor (QPalette::Text, c);
mp_bookmarks->setPalette (pl);
}
void
BookmarksView::refresh ()
{
BookmarkListModel *model = dynamic_cast<BookmarkListModel *> (mp_bookmarks->model ());
if (model) {
model->refresh ();
}
}
void
BookmarksView::context_menu (const QPoint &p)
{
tl_assert (lay::AbstractMenuProvider::instance () != 0);
QListView *bm_list = dynamic_cast<QListView *> (sender ());
if (bm_list) {
QMenu *ctx_menu = lay::AbstractMenuProvider::instance ()->menu ()->detached_menu ("bookmarks_context_menu");
ctx_menu->exec (bm_list->mapToGlobal (p));
}
}
void
BookmarksView::current_bookmark_changed (const QModelIndex &index)
{
if (m_follow_selection) {
bookmark_triggered (index);
}
}
void
BookmarksView::bookmark_triggered (const QModelIndex &index)
{
if (index.row () >= 0 && index.row () < int (mp_view->bookmarks ().size ())) {
mp_view->goto_view (mp_view->bookmarks ().state (index.row ()));
}
}
}

View File

@ -0,0 +1,78 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2019 Matthias Koefferlein
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 Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef HDR_layBookmarksView
#define HDR_layBookmarksView
#include "laybasicCommon.h"
#include "layBookmarkList.h"
#include <QFrame>
#include <QListView>
#include <set>
namespace lay
{
class LayoutView;
class AbstractMenu;
/**
* @brief A widget to display a bookmark list
*/
class LAYBASIC_PUBLIC BookmarksView
: public QFrame
{
Q_OBJECT
public:
BookmarksView (LayoutView *view, QWidget *parent, const char *name);
~BookmarksView ();
void set_background_color (QColor c);
void set_text_color (QColor c);
void follow_selection (bool f);
std::set<size_t> selected_bookmarks ();
void refresh ();
static void init_menu (lay::AbstractMenu &menu);
public slots:
void bookmark_triggered (const QModelIndex &index);
void current_bookmark_changed (const QModelIndex &index);
void context_menu (const QPoint &p);
private:
LayoutView *mp_view;
QListView *mp_bookmarks;
bool m_follow_selection;
};
} // namespace lay
#endif

View File

@ -68,6 +68,7 @@
#include "layParsedLayerSource.h"
#include "layBookmarkManagementForm.h"
#include "layNetlistBrowserDialog.h"
#include "layBookmarksView.h"
#include "dbLayout.h"
#include "dbLayoutUtils.h"
#include "dbRecursiveShapeIterator.h"
@ -359,7 +360,9 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/)
mp_hierarchy_panel = 0;
mp_hierarchy_frame = 0;
mp_libraries_view = 0;
mp_bookmarks_view = 0;
mp_libraries_frame = 0;
mp_bookmarks_frame = 0;
mp_min_hier_spbx = 0;
mp_max_hier_spbx = 0;
m_from_level = 0;
@ -506,6 +509,20 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/)
}
if ((m_options & LV_NoBookmarksView) == 0 && (m_options & LV_Naked) == 0) {
QFrame *bookmarks_frame = new QFrame (0);
bookmarks_frame->setObjectName (QString::fromUtf8 ("bookmarks_frame"));
mp_bookmarks_frame = bookmarks_frame;
QVBoxLayout *left_frame_ly = new QVBoxLayout (bookmarks_frame);
left_frame_ly->setMargin (0);
left_frame_ly->setSpacing (0);
mp_bookmarks_view = new lay::BookmarksView (this, bookmarks_frame, "bookmarks");
left_frame_ly->addWidget (mp_bookmarks_view, 1 /*stretch*/);
}
if ((m_options & LV_NoLibrariesView) == 0 && (m_options & LV_Naked) == 0) {
QFrame *libraries_frame = new QFrame (0);
@ -654,6 +671,12 @@ LayoutView::~LayoutView ()
}
mp_libraries_frame = 0;
mp_libraries_view = 0;
if (mp_bookmarks_frame) {
delete mp_bookmarks_frame;
}
mp_bookmarks_frame = 0;
mp_bookmarks_view = 0;
}
void LayoutView::hideEvent (QHideEvent *)
@ -817,6 +840,7 @@ LayoutView::init_menu (lay::AbstractMenu &menu)
lay::LayerControlPanel::init_menu (menu);
lay::HierarchyControlPanel::init_menu (menu);
lay::LibrariesView::init_menu (menu);
lay::BookmarksView::init_menu (menu);
}
void
@ -987,6 +1011,15 @@ LayoutView::configure (const std::string &name, const std::string &value)
}
return true;
} else if (name == cfg_bookmarks_follow_selection) {
bool f;
tl::from_string (value, f);
if (mp_bookmarks_view) {
mp_bookmarks_view->follow_selection (f);
}
return true;
} else if (name == cfg_current_lib_view) {
if (mp_libraries_view) {
@ -3771,10 +3804,12 @@ LayoutView::cancel ()
void
LayoutView::bookmark_current_view ()
{
QString proposed_name = tl::to_qstring (m_bookmarks.propose_new_bookmark_name ());
while (true) {
bool ok = false;
QString text = QInputDialog::getText (this, QObject::tr ("Enter Bookmark Name"), QObject::tr ("Bookmark name"),
QLineEdit::Normal, QString::null, &ok);
QLineEdit::Normal, proposed_name, &ok);
if (! ok) {
break;
} else if (text.isEmpty ()) {
@ -3789,7 +3824,12 @@ LayoutView::bookmark_current_view ()
void
LayoutView::manage_bookmarks ()
{
BookmarkManagementForm dialog (this, "bookmark_form", bookmarks ());
std::set<size_t> selected_bm;
if (mp_bookmarks_frame->isVisible ()) {
selected_bm = mp_bookmarks_view->selected_bookmarks ();
}
BookmarkManagementForm dialog (this, "bookmark_form", bookmarks (), selected_bm);
if (dialog.exec ()) {
bookmarks (dialog.bookmarks ());
}
@ -3799,6 +3839,7 @@ void
LayoutView::bookmarks (const BookmarkList &b)
{
m_bookmarks = b;
mp_bookmarks_view->refresh ();
emit menu_needs_update ();
}
@ -3807,6 +3848,7 @@ LayoutView::bookmark_view (const std::string &name)
{
DisplayState state (box (), get_min_hier_levels (), get_max_hier_levels (), m_cellviews);
m_bookmarks.add (name, state);
mp_bookmarks_view->refresh ();
emit menu_needs_update ();
}
@ -4526,6 +4568,11 @@ LayoutView::background_color (QColor c)
mp_libraries_view->set_text_color (contrast);
}
if (mp_bookmarks_view) {
mp_bookmarks_view->set_background_color (c);
mp_bookmarks_view->set_text_color (contrast);
}
if (mp_selection_service) {
mp_selection_service->set_colors (c, contrast);
}

View File

@ -71,6 +71,7 @@ class AbstractMenu;
class LayerControlPanel;
class HierarchyControlPanel;
class LibrariesView;
class BookmarksView;
class MouseTracker;
class ZoomService;
class SelectionService;
@ -170,13 +171,14 @@ public:
LV_NoLayers = 1,
LV_NoHierarchyPanel = 2,
LV_NoLibrariesView = 4,
LV_Naked = 8,
LV_NoZoom = 16,
LV_NoGrid = 32,
LV_NoMove = 64,
LV_NoTracker = 128,
LV_NoSelection = 256,
LV_NoPlugins = 512,
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_NoServices = LV_NoMove + LV_NoTracker + LV_NoSelection + LV_NoPlugins
};
@ -246,6 +248,14 @@ public:
return mp_libraries_frame;
}
/**
* @brief Gets the container with the bookmarks view
*/
QWidget *bookmarks_frame ()
{
return mp_bookmarks_frame;
}
/**
* @brief Pastes from clipboard
*
@ -2748,7 +2758,8 @@ private:
lay::LayerControlPanel *mp_control_panel;
lay::HierarchyControlPanel *mp_hierarchy_panel;
lay::LibrariesView *mp_libraries_view;
QWidget *mp_control_frame, *mp_hierarchy_frame, *mp_libraries_frame;
lay::BookmarksView *mp_bookmarks_view;
QWidget *mp_control_frame, *mp_hierarchy_frame, *mp_libraries_frame, *mp_bookmarks_frame;
QSpinBox *mp_min_hier_spbx;
QSpinBox *mp_max_hier_spbx;
std::list <CellView> m_cellviews;

View File

@ -176,7 +176,8 @@ SOURCES = \
layIndexedNetlistModel.cc \
layNetlistCrossReferenceModel.cc \
layNetlistBrowserTreeModel.cc \
layLibrariesView.cc
layLibrariesView.cc \
layBookmarksView.cc
HEADERS = \
gtf.h \
@ -273,7 +274,8 @@ HEADERS = \
layIndexedNetlistModel.h \
layNetlistCrossReferenceModel.h \
layNetlistBrowserTreeModel.h \
layLibrariesView.h
layLibrariesView.h \
layBookmarksView.h
INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC
DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC

View File

@ -130,6 +130,8 @@ static const std::string cfg_cell_list_sorting ("cell-list-sorting");
static const std::string cfg_split_lib_views ("split-lib-views");
static const std::string cfg_current_lib_view ("current-lib-view");
static const std::string cfg_bookmarks_follow_selection ("bookmarks-follow-selection");
static const std::string cfg_pan_distance ("pan-distance");
static const std::string cfg_paste_display_mode ("paste-display-mode");