WIP: recent editor options also for paths.

This commit is contained in:
Matthias Koefferlein 2020-08-18 00:39:19 +02:00
parent 9a19ced4e0
commit 263e04c754
5 changed files with 78 additions and 16 deletions

View File

@ -47,7 +47,7 @@ void get_text_options (std::vector < std::pair<std::string, std::string> > &opti
}
static
void get_text_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::Dispatcher *dispatcher)
void get_text_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::LayoutView *, lay::Dispatcher *dispatcher)
{
ret.push_back (new edt::EditorOptionsText (dispatcher));
}
@ -61,9 +61,20 @@ void get_path_options (std::vector < std::pair<std::string, std::string> > &opti
options.push_back (std::pair<std::string, std::string> (cfg_edit_path_ext_var_end, "0.0"));
}
static
void get_path_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::Dispatcher *dispatcher)
edt::RecentConfigurationPage::ConfigurationDescriptor path_cfg_descriptors[] =
{
edt::RecentConfigurationPage::ConfigurationDescriptor ("", tl::to_string (tr ("Layer")), edt::RecentConfigurationPage::Layer),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_path_width, tl::to_string (tr ("Width")), edt::RecentConfigurationPage::Double),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_path_ext_type, tl::to_string (tr ("Ends")), edt::RecentConfigurationPage::Int),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_path_ext_var_begin, tl::to_string (tr ("Begin ext.")), edt::RecentConfigurationPage::Double),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_path_ext_var_end, tl::to_string (tr ("End ext.")), edt::RecentConfigurationPage::Double)
};
static
void get_path_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher)
{
ret.push_back (new RecentConfigurationPage (view, dispatcher, "edit-recent-path-param",
&path_cfg_descriptors[0], &path_cfg_descriptors[sizeof (path_cfg_descriptors) / sizeof (path_cfg_descriptors[0])]));
ret.push_back (new EditorOptionsPath (dispatcher));
}
@ -103,10 +114,10 @@ edt::RecentConfigurationPage::ConfigurationDescriptor inst_cfg_descriptors[] =
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_pcell_parameters, tl::to_string (tr ("PCell parameters")), edt::RecentConfigurationPage::PCellParameters)
};
static
void get_inst_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::Dispatcher *dispatcher)
static
void get_inst_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher)
{
ret.push_back (new RecentConfigurationPage (dispatcher, "edit-recent-inst-param",
ret.push_back (new RecentConfigurationPage (view, dispatcher, "edit-recent-inst-param",
&inst_cfg_descriptors[0], &inst_cfg_descriptors[sizeof (inst_cfg_descriptors) / sizeof (inst_cfg_descriptors[0])]));
ret.push_back (new EditorOptionsInstPCellParam (dispatcher));
ret.push_back (new EditorOptionsInst (dispatcher));
@ -119,7 +130,7 @@ class PluginDeclaration
public:
PluginDeclaration (const std::string &title, const std::string &mouse_mode,
void (*option_get_f) (std::vector < std::pair<std::string, std::string> > &) = 0,
void (*pages_f) (std::vector <edt::EditorOptionsPage *> &, lay::Dispatcher *) = 0)
void (*pages_f) (std::vector <edt::EditorOptionsPage *> &, lay::LayoutView *, lay::Dispatcher *) = 0)
: m_title (title), m_mouse_mode (mouse_mode), mp_option_get_f (option_get_f), mp_pages_f (pages_f)
{
// .. nothing yet ..
@ -142,11 +153,11 @@ public:
// .. nothing yet ..
}
virtual void get_editor_options_pages (std::vector<edt::EditorOptionsPage *> &pages, lay::Dispatcher *root) const
virtual void get_editor_options_pages (std::vector<edt::EditorOptionsPage *> &pages, lay::LayoutView *view, lay::Dispatcher *root) const
{
if (mp_pages_f != 0) {
size_t nstart = pages.size ();
(*mp_pages_f) (pages, root);
(*mp_pages_f) (pages, view, root);
while (nstart < pages.size ()) {
pages [nstart++]->set_plugin_declaration (this);
}
@ -177,7 +188,7 @@ private:
std::string m_mouse_mode;
void (*mp_option_get_f) (std::vector < std::pair<std::string, std::string> > &options);
void (*mp_pages_f) (std::vector <edt::EditorOptionsPage *> &, lay::Dispatcher *);
void (*mp_pages_f) (std::vector <edt::EditorOptionsPage *> &, lay::LayoutView *, lay::Dispatcher *);
};
static tl::RegisteredClass<lay::PluginDeclaration> config_decl1 (
@ -382,7 +393,7 @@ show_editor_options_page (lay::LayoutView *view)
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
const PluginDeclarationBase *pd_base = dynamic_cast<const PluginDeclarationBase *> (&*cls);
if (pd_base) {
pd_base->get_editor_options_pages (prop_dialog_pages, view->dispatcher ());
pd_base->get_editor_options_pages (prop_dialog_pages, view, view->dispatcher ());
}
}

View File

@ -44,7 +44,7 @@ namespace edt
: public lay::PluginDeclaration
{
public:
virtual void get_editor_options_pages (std::vector<edt::EditorOptionsPage *> &, lay::Dispatcher *) const = 0;
virtual void get_editor_options_pages (std::vector<edt::EditorOptionsPage *> &, lay::LayoutView *, lay::Dispatcher *) const = 0;
};
/**

View File

@ -23,6 +23,7 @@
#include "edtRecentConfigurationPage.h"
#include "edtUtils.h"
#include "layDispatcher.h"
#include "layLayoutView.h"
#include "dbLibraryManager.h"
#include "dbLibrary.h"
@ -263,9 +264,28 @@ RecentConfigurationPage::item_clicked (QTreeWidgetItem *item)
{
int column = 0;
for (std::list<ConfigurationDescriptor>::const_iterator c = m_cfg.begin (); c != m_cfg.end (); ++c, ++column) {
std::string v = tl::to_string (item->data (column, Qt::UserRole).toString ());
dispatcher ()->config_set (c->cfg_name, v);
if (c->rendering == Layer) {
// "getting" a layer means making it current
db::LayerProperties lp;
tl::Extractor ex (v.c_str ());
lp.read (ex);
int cv_index = 0;
if (ex.test ("@")) {
ex.read (cv_index);
}
mp_view->set_current_layer (cv_index, lp);
} else {
dispatcher ()->config_set (c->cfg_name, v);
}
}
dispatcher ()->config_end ();
}
@ -275,7 +295,30 @@ RecentConfigurationPage::commit_recent (lay::Dispatcher *root)
std::vector<std::string> values;
values.reserve (m_cfg.size ());
for (std::list<ConfigurationDescriptor>::const_iterator c = m_cfg.begin (); c != m_cfg.end (); ++c) {
values.push_back (root->config_get (c->cfg_name));
if (c->rendering == Layer) {
std::string s;
if (mp_view->current_layer ()->is_visual ()) {
int cv_index = mp_view->current_layer ()->cellview_index ();
const lay::CellView &cv = mp_view->cellview (cv_index);
int li = mp_view->current_layer ()->layer_index ();
if (cv.is_valid () && cv->layout ().is_valid_layer (li)) {
s = cv->layout ().get_properties (li).to_string ();
if (cv_index > 0) {
s += "@" + tl::to_string (cv_index);
}
}
}
values.push_back (s);
} else {
values.push_back (root->config_get (c->cfg_name));
}
}
std::list<std::vector<std::string> > stored_values = get_stored_values ();

View File

@ -29,6 +29,11 @@
#include <list>
#include <QTreeWidget>
namespace lay
{
class LayoutView;
}
namespace edt
{
@ -71,8 +76,8 @@ public:
};
template <class Iter>
RecentConfigurationPage (lay::Dispatcher *dispatcher, const std::string &recent_cfg_name, Iter begin_cfg, Iter end_cfg)
: EditorOptionsPage (dispatcher), m_recent_cfg_name (recent_cfg_name), m_cfg (begin_cfg, end_cfg)
RecentConfigurationPage (lay::LayoutView *view, lay::Dispatcher *dispatcher, const std::string &recent_cfg_name, Iter begin_cfg, Iter end_cfg)
: EditorOptionsPage (dispatcher), mp_view (view), m_recent_cfg_name (recent_cfg_name), m_cfg (begin_cfg, end_cfg)
{
init ();
}
@ -89,6 +94,7 @@ private slots:
void item_clicked (QTreeWidgetItem *item);
private:
lay::LayoutView *mp_view;
std::string m_recent_cfg_name;
std::list<ConfigurationDescriptor> m_cfg;
QTreeWidget *mp_tree_widget;

View File

@ -965,6 +965,8 @@ PathService::do_finish_edit ()
m_points.pop_back ();
deliver_shape (get_path ());
commit_recent (view ());
}
void