mirror of https://github.com/KLayout/klayout.git
WIP: refactoring ongoing.
This commit is contained in:
parent
4210198179
commit
24ad1b2d26
8
TODO
8
TODO
|
|
@ -28,3 +28,11 @@ Plan:
|
|||
|
||||
10. Provide the layer toolbox for GSI
|
||||
|
||||
Tests:
|
||||
- compare menu layout
|
||||
- test every menu function
|
||||
- adding of new tech
|
||||
- adding of rulers/removing
|
||||
- ruby plugin (debugging, re-running)
|
||||
- changing of macro title, move macro to different place
|
||||
|
||||
|
|
|
|||
|
|
@ -182,10 +182,20 @@ gsi::Methods cm_method_decl ()
|
|||
"Use \"call_menu('" + std::string (cm_symbols[NUM]) + "')\" instead.");
|
||||
}
|
||||
|
||||
// NOTE: this avoids an issue with binding: C++ (at least clang
|
||||
// will resolve lay::MainWindow::menu to lay::Dispatcher::menu,
|
||||
// the method declaration will be based on "lay::Dispatcher", and
|
||||
// calling this on a MainWindow object fails, because Dispatcher
|
||||
// is not the first base class.
|
||||
static lay::AbstractMenu *menu (lay::MainWindow *mw)
|
||||
{
|
||||
return mw->menu ();
|
||||
}
|
||||
|
||||
Class<lay::MainWindow> decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "MainWindow",
|
||||
|
||||
// QMainWindow interface
|
||||
gsi::method ("menu", &lay::MainWindow::menu,
|
||||
gsi::method_ext ("menu", &menu,
|
||||
"@brief Returns a reference to the abstract menu\n"
|
||||
"\n"
|
||||
"@return A reference to an \\AbstractMenu object representing the menu system"
|
||||
|
|
|
|||
|
|
@ -402,11 +402,11 @@ CustomizeMenuConfigPage::apply (const std::vector<std::pair<std::string, std::st
|
|||
|
||||
// get the current bindings
|
||||
m_current_bindings.clear ();
|
||||
get_shortcuts (*lay::MainWindow::instance ()->menu (), std::string (), m_current_bindings, false);
|
||||
get_shortcuts (*lay::Dispatcher::instance ()->menu (), std::string (), m_current_bindings, false);
|
||||
|
||||
// get the default bindings
|
||||
std::map<std::string, std::string> default_bindings;
|
||||
get_shortcuts (*lay::MainWindow::instance ()->menu (), std::string (), default_bindings, true);
|
||||
get_shortcuts (*lay::Dispatcher::instance ()->menu (), std::string (), default_bindings, true);
|
||||
|
||||
m_enable_event = false;
|
||||
|
||||
|
|
@ -416,7 +416,7 @@ CustomizeMenuConfigPage::apply (const std::vector<std::pair<std::string, std::st
|
|||
for (std::map<std::string, std::string>::iterator kb = m_current_bindings.begin (); kb != m_current_bindings.end (); ++kb) {
|
||||
std::map<std::string, std::string>::iterator bb = b.find (kb->first);
|
||||
if (bb != b.end ()) {
|
||||
lay::Action a = lay::MainWindow::instance ()->menu ()->action (kb->first);
|
||||
lay::Action a = lay::Dispatcher::instance ()->menu ()->action (kb->first);
|
||||
kb->second = a.get_effective_shortcut_for (bb->second);
|
||||
} else {
|
||||
kb->second.clear ();
|
||||
|
|
@ -470,7 +470,7 @@ CustomizeMenuConfigPage::apply (const std::vector<std::pair<std::string, std::st
|
|||
|
||||
if (t->first == tl_menu) {
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem (top_level_item);
|
||||
lay::Action action = lay::MainWindow::instance ()->menu ()->action (cb->first);
|
||||
lay::Action action = lay::Dispatcher::instance ()->menu ()->action (cb->first);
|
||||
item->setData (0, Qt::ToolTipRole, tl::to_qstring (rem_path));
|
||||
item->setData (0, Qt::DisplayRole, tl::to_qstring (rem_path));
|
||||
item->setData (1, Qt::ToolTipRole, tl::to_qstring (action.get_title ()));
|
||||
|
|
@ -530,7 +530,7 @@ CustomizeMenuConfigPage::commit (lay::Dispatcher *root)
|
|||
for (std::vector<std::pair<std::string, std::string> >::iterator kb = key_bindings.begin (); kb != key_bindings.end (); ++kb) {
|
||||
std::map<std::string, std::string>::iterator cb = m_current_bindings.find (kb->first);
|
||||
if (cb != m_current_bindings.end ()) {
|
||||
lay::Action a = lay::MainWindow::instance ()->menu ()->action (kb->first);
|
||||
lay::Action a = lay::Dispatcher::instance ()->menu ()->action (kb->first);
|
||||
if (cb->second != a.get_default_shortcut ()) {
|
||||
if (cb->second.empty ()) {
|
||||
kb->second = lay::Action::no_shortcut ();
|
||||
|
|
@ -580,7 +580,7 @@ CustomizeMenuConfigPage::text_cleared ()
|
|||
}
|
||||
|
||||
std::string path = tl::to_string (item->data (0, Qt::UserRole).toString ());
|
||||
lay::Action a = lay::MainWindow::instance ()->menu ()->action (path);
|
||||
lay::Action a = lay::Dispatcher::instance ()->menu ()->action (path);
|
||||
|
||||
// "clear" reverts to default
|
||||
mp_ui->binding_le->setText (tl::to_qstring (a.get_default_shortcut ()));
|
||||
|
|
@ -634,7 +634,7 @@ CustomizeMenuConfigPage::update_list_item (QTreeWidgetItem *item)
|
|||
|
||||
bool is_default = false;
|
||||
|
||||
lay::Action a = lay::MainWindow::instance ()->menu ()->action (path);
|
||||
lay::Action a = lay::Dispatcher::instance ()->menu ()->action (path);
|
||||
std::string def_shortcut = a.get_default_shortcut ();
|
||||
|
||||
is_default = (def_shortcut == shortcut);
|
||||
|
|
@ -643,7 +643,7 @@ CustomizeMenuConfigPage::update_list_item (QTreeWidgetItem *item)
|
|||
item->setData (2, Qt::ForegroundRole, palette ().color (is_default ? QPalette::Disabled : QPalette::Normal, QPalette::Text));
|
||||
|
||||
// Set the aliases too
|
||||
const lay::AbstractMenu &menu = *lay::MainWindow::instance ()->menu ();
|
||||
const lay::AbstractMenu &menu = *lay::Dispatcher::instance ()->menu ();
|
||||
if (menu.is_valid (path)) {
|
||||
QAction *qaction = menu.action (path).qaction ();
|
||||
std::map<QAction *, std::vector<std::string> >::const_iterator a = m_paths_for_action.find (qaction);
|
||||
|
|
@ -688,7 +688,7 @@ CustomizeMenuConfigPage::current_changed (QTreeWidgetItem *current, QTreeWidgetI
|
|||
if (current && !current->data (0, Qt::UserRole).isNull ()) {
|
||||
|
||||
std::string path = tl::to_string (current->data (0, Qt::UserRole).toString ());
|
||||
if (lay::MainWindow::instance ()->menu ()->is_menu (path)) {
|
||||
if (lay::Dispatcher::instance ()->menu ()->is_menu (path)) {
|
||||
|
||||
mp_ui->binding_le->setText (QString ());
|
||||
#if QT_VERSION >= 0x40700
|
||||
|
|
@ -700,7 +700,7 @@ CustomizeMenuConfigPage::current_changed (QTreeWidgetItem *current, QTreeWidgetI
|
|||
|
||||
std::string shortcut = m_current_bindings[path];
|
||||
|
||||
lay::Action a = lay::MainWindow::instance ()->menu ()->action (path);
|
||||
lay::Action a = lay::Dispatcher::instance ()->menu ()->action (path);
|
||||
|
||||
std::string def_shortcut = a.get_default_shortcut ();
|
||||
|
||||
|
|
|
|||
|
|
@ -735,7 +735,7 @@ MainWindow::init_menu ()
|
|||
// make the plugins create their menu items
|
||||
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
|
||||
// TODO: get rid of the const_cast hack
|
||||
const_cast <lay::PluginDeclaration *> (&*cls)->init_menu (this);
|
||||
const_cast <lay::PluginDeclaration *> (&*cls)->init_menu (dispatcher ());
|
||||
}
|
||||
|
||||
// if in "viewer-only mode", hide all entries in the "hide_vo" group
|
||||
|
|
|
|||
|
|
@ -116,8 +116,13 @@ public:
|
|||
|
||||
/**
|
||||
* @brief Gets the AbstractMenu object
|
||||
*
|
||||
* This will deliver the actual menu - the one that is the root dispatcher's menu
|
||||
*/
|
||||
AbstractMenu *menu () { return &m_menu; }
|
||||
AbstractMenu *menu ()
|
||||
{
|
||||
return (dispatcher () == this) ? &m_menu : dispatcher ()->menu ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates a configuration action with the given title, parameter name and value
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin
|
|||
tl::DeferredMethodScheduler::instance ();
|
||||
|
||||
setObjectName (QString::fromUtf8 (name));
|
||||
init (manager, dispatcher (), parent);
|
||||
init (manager, parent);
|
||||
}
|
||||
|
||||
LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options)
|
||||
|
|
@ -293,7 +293,7 @@ LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool edit
|
|||
|
||||
m_annotation_shapes = source->m_annotation_shapes;
|
||||
|
||||
init (manager, dispatcher (), parent);
|
||||
init (manager, parent);
|
||||
|
||||
// set the handle reference and clear all cell related stuff
|
||||
m_cellviews = source->cellview_list ();
|
||||
|
|
@ -355,12 +355,12 @@ LayoutView::eventFilter(QObject *obj, QEvent *event)
|
|||
}
|
||||
|
||||
void
|
||||
LayoutView::init (db::Manager *mgr, lay::Dispatcher *dispatcher, QWidget * /*parent*/)
|
||||
LayoutView::init (db::Manager *mgr, QWidget * /*parent*/)
|
||||
{
|
||||
manager (mgr);
|
||||
|
||||
if (! dispatcher) {
|
||||
// build the context menus, nothing else so far.
|
||||
if (dispatcher () == this) {
|
||||
// if we're the root dispatcher build the context menus, nothing else so far.
|
||||
menu ()->build (0, 0);
|
||||
}
|
||||
|
||||
|
|
@ -6473,13 +6473,6 @@ LayoutView::intrinsic_mouse_modes (std::vector<std::string> *descriptions)
|
|||
return 2;
|
||||
}
|
||||
|
||||
AbstractMenu *
|
||||
LayoutView::menu ()
|
||||
{
|
||||
// NOTE: dispatcher is either this or the real end of the chain
|
||||
return dispatcher ()->menu ();
|
||||
}
|
||||
|
||||
int
|
||||
LayoutView::default_mode ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -220,12 +220,6 @@ public:
|
|||
*/
|
||||
static LayoutView *current ();
|
||||
|
||||
/**
|
||||
* @brief Gets the abstract menu object for this view
|
||||
* This is either the global menu object or the local one.
|
||||
*/
|
||||
AbstractMenu *menu ();
|
||||
|
||||
/**
|
||||
* @brief Determine if there is something to copy
|
||||
*
|
||||
|
|
@ -2892,7 +2886,7 @@ private:
|
|||
bool m_active_cellview_changed_event_enabled;
|
||||
tl::DeferredMethod<lay::LayoutView> dm_prop_changed;
|
||||
|
||||
void init (db::Manager *mgr, lay::Dispatcher *dispatcher, QWidget *parent);
|
||||
void init (db::Manager *mgr, QWidget *parent);
|
||||
|
||||
void do_prop_changed ();
|
||||
void do_redraw (int layer);
|
||||
|
|
|
|||
Loading…
Reference in New Issue