WIP: some refactoring

This commit is contained in:
Matthias Koefferlein 2026-01-14 12:48:51 +01:00
parent 6666b2b68c
commit ca9a3198f5
17 changed files with 255 additions and 199 deletions

View File

@ -898,6 +898,17 @@ EditorOptionsInstPCellParam::update_pcell_parameters (const std::vector <tl::Var
}
}
// ------------------------------------------------------------------
// Registrations
// unspecific editor options - used for all plugins that want it
static tl::RegisteredClass<lay::EditorOptionsPageFactoryBase> s_factory_generic (new lay::EditorOptionsPageFactory<EditorOptionsGeneric> (), 0);
static tl::RegisteredClass<lay::EditorOptionsPageFactoryBase> s_factory_texts (new lay::EditorOptionsPageFactory<edt::EditorOptionsText> ("edt::Service(Texts)"), 0);
static tl::RegisteredClass<lay::EditorOptionsPageFactoryBase> s_factory_paths (new lay::EditorOptionsPageFactory<edt::EditorOptionsPath> ("edt::Service(Paths)"), 0);
static tl::RegisteredClass<lay::EditorOptionsPageFactoryBase> s_factory_insts (new lay::EditorOptionsPageFactory<edt::EditorOptionsInstPCellParam> ("edt::Service(CellInstances)"), 0);
static tl::RegisteredClass<lay::EditorOptionsPageFactoryBase> s_factory_insts_pcell (new lay::EditorOptionsPageFactory<edt::EditorOptionsInst> ("edt::Service(CellInstances)"), 0);
}
#endif

View File

@ -49,24 +49,6 @@
namespace edt
{
#if defined(HAVE_QT)
edt::RecentConfigurationPage::ConfigurationDescriptor shape_cfg_descriptors[] =
{
edt::RecentConfigurationPage::ConfigurationDescriptor ("", tl::to_string (tr ("Layer")), edt::RecentConfigurationPage::Layer),
};
#endif
#if defined(HAVE_QT)
static
void get_shape_editor_options_pages (std::vector<lay::EditorOptionsPage *> &ret, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
{
ret.push_back (new edt::RecentConfigurationPage (view, dispatcher, "edit-recent-shape-param",
&shape_cfg_descriptors[0], &shape_cfg_descriptors[sizeof (shape_cfg_descriptors) / sizeof (shape_cfg_descriptors[0])]));
}
#else
static void get_shape_editor_options_pages () { }
#endif
static
void get_text_options (std::vector < std::pair<std::string, std::string> > &options)
{
@ -76,27 +58,6 @@ void get_text_options (std::vector < std::pair<std::string, std::string> > &opti
options.push_back (std::pair<std::string, std::string> (cfg_edit_text_valign, "bottom"));
}
#if defined(HAVE_QT)
static
void get_text_editor_options_pages (std::vector<lay::EditorOptionsPage *> &ret, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
{
static edt::RecentConfigurationPage::ConfigurationDescriptor text_cfg_descriptors[] =
{
edt::RecentConfigurationPage::ConfigurationDescriptor ("", tl::to_string (tr ("Layer")), edt::RecentConfigurationPage::Layer),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_text_string, tl::to_string (tr ("Text")), edt::RecentConfigurationPage::Text),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_text_size, tl::to_string (tr ("Size")), edt::RecentConfigurationPage::Double),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_text_halign, tl::to_string (tr ("Hor. align")), edt::RecentConfigurationPage::Text),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_text_valign, tl::to_string (tr ("Vert. align")), edt::RecentConfigurationPage::Text)
};
ret.push_back (new edt::RecentConfigurationPage (view, dispatcher, "edit-recent-text-param",
&text_cfg_descriptors[0], &text_cfg_descriptors[sizeof (text_cfg_descriptors) / sizeof (text_cfg_descriptors[0])]));
ret.push_back (new edt::EditorOptionsText (view, dispatcher));
}
#else
static void get_text_editor_options_pages () { }
#endif
static
void get_path_options (std::vector < std::pair<std::string, std::string> > &options)
{
@ -106,27 +67,6 @@ 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"));
}
#if defined(HAVE_QT)
static
void get_path_editor_options_pages (std::vector<lay::EditorOptionsPage *> &ret, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
{
static 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)
};
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 (view, dispatcher));
}
#else
static void get_path_editor_options_pages () { }
#endif
static
void get_inst_options (std::vector < std::pair<std::string, std::string> > &options)
{
@ -148,58 +88,17 @@ void get_inst_options (std::vector < std::pair<std::string, std::string> > &opti
options.push_back (std::pair<std::string, std::string> (cfg_edit_show_shapes_of_instances, "true"));
}
#if defined(HAVE_QT)
static
void get_inst_editor_options_pages (std::vector<lay::EditorOptionsPage *> &ret, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
{
static edt::RecentConfigurationPage::ConfigurationDescriptor inst_cfg_descriptors[] =
{
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_lib_name, tl::to_string (tr ("Library")), edt::RecentConfigurationPage::CellLibraryName),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_cell_name, tl::to_string (tr ("Cell")), edt::RecentConfigurationPage::CellDisplayName),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_angle, tl::to_string (tr ("Angle")), edt::RecentConfigurationPage::Double),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_mirror, tl::to_string (tr ("Mirror")), edt::RecentConfigurationPage::Bool),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_scale, tl::to_string (tr ("Scale")), edt::RecentConfigurationPage::Double),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_array, tl::to_string (tr ("Array")), edt::RecentConfigurationPage::ArrayFlag),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_rows, tl::to_string (tr ("Rows")), edt::RecentConfigurationPage::IntIfArray),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_row_x, tl::to_string (tr ("Row step (x)")), edt::RecentConfigurationPage::DoubleIfArray),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_row_y, tl::to_string (tr ("Row step (y)")), edt::RecentConfigurationPage::DoubleIfArray),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_columns, tl::to_string (tr ("Columns")), edt::RecentConfigurationPage::IntIfArray),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_column_x, tl::to_string (tr ("Column step (x)")), edt::RecentConfigurationPage::DoubleIfArray),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_column_y, tl::to_string (tr ("Column step (y)")), edt::RecentConfigurationPage::DoubleIfArray),
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_pcell_parameters, tl::to_string (tr ("PCell parameters")), edt::RecentConfigurationPage::PCellParameters)
};
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 (view, dispatcher));
ret.push_back (new EditorOptionsInst (view, dispatcher));
}
#else
static void get_inst_editor_options_pages () { }
#endif
template <class Svc>
class PluginDeclaration
: public PluginDeclarationBase
{
public:
#if defined(HAVE_QT)
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 <lay::EditorOptionsPage *> &, lay::LayoutViewBase *, lay::Dispatcher *) = 0)
: m_title (title), m_mouse_mode (mouse_mode), mp_option_get_f (option_get_f), mp_pages_f (pages_f)
void (*option_get_f) (std::vector < std::pair<std::string, std::string> > &) = 0)
: m_title (title), m_mouse_mode (mouse_mode), mp_option_get_f (option_get_f)
{
// .. nothing yet ..
}
#else
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) () = 0)
: m_title (title), m_mouse_mode (mouse_mode), mp_option_get_f (option_get_f), mp_pages_f (pages_f)
{
// .. nothing yet ..
}
#endif
virtual void get_options (std::vector < std::pair<std::string, std::string> > &options) const
{
@ -220,19 +119,6 @@ public:
// .. nothing yet ..
}
#if defined(HAVE_QT)
virtual void get_editor_options_pages (std::vector<lay::EditorOptionsPage *> &pages, lay::LayoutViewBase *view, lay::Dispatcher *root) const
{
if (mp_pages_f != 0) {
size_t nstart = pages.size ();
(*mp_pages_f) (pages, view, root);
while (nstart < pages.size ()) {
pages [nstart++]->set_plugin_declaration (this);
}
}
}
#endif
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const
{
Svc *service = new Svc (manager, view);
@ -261,40 +147,35 @@ private:
std::string m_mouse_mode;
void (*mp_option_get_f) (std::vector < std::pair<std::string, std::string> > &options);
#if defined(HAVE_QT)
void (*mp_pages_f) (std::vector <lay::EditorOptionsPage *> &, lay::LayoutViewBase *, lay::Dispatcher *);
#else
void (*mp_pages_f) ();
#endif
};
static tl::RegisteredClass<lay::PluginDeclaration> config_decl1 (
new edt::PluginDeclaration<edt::PolygonService> (tl::to_string (tr ("Polygons")), "polygon:edit_mode\t" + tl::to_string (tr ("Polygon")) + "<:polygon_24px.png>" + tl::to_string (tr ("{Create a polygon}")), 0, &get_shape_editor_options_pages),
new edt::PluginDeclaration<edt::PolygonService> (tl::to_string (tr ("Polygons")), "polygon:edit_mode\t" + tl::to_string (tr ("Polygon")) + "<:polygon_24px.png>" + tl::to_string (tr ("{Create a polygon}")), 0),
4010,
"edt::Service(Polygons)"
);
static tl::RegisteredClass<lay::PluginDeclaration> config_decl2 (
new edt::PluginDeclaration<edt::BoxService> (tl::to_string (tr ("Boxes")), "box:edit_mode\t" + tl::to_string (tr ("Box")) + "\t<:box_24px.png>" + tl::to_string (tr ("{Create a box}")), 0, &get_shape_editor_options_pages),
new edt::PluginDeclaration<edt::BoxService> (tl::to_string (tr ("Boxes")), "box:edit_mode\t" + tl::to_string (tr ("Box")) + "\t<:box_24px.png>" + tl::to_string (tr ("{Create a box}")), 0),
4011,
"edt::Service(Boxes)"
);
static tl::RegisteredClass<lay::PluginDeclaration> config_decl3 (
new edt::PluginDeclaration<edt::TextService> (tl::to_string (tr ("Texts")), "text:edit_mode\t" + tl::to_string (tr ("Text")) + "\t<:text_24px.png>" + tl::to_string (tr ("{Create a text object}")), &get_text_options, &get_text_editor_options_pages),
new edt::PluginDeclaration<edt::TextService> (tl::to_string (tr ("Texts")), "text:edit_mode\t" + tl::to_string (tr ("Text")) + "\t<:text_24px.png>" + tl::to_string (tr ("{Create a text object}")), &get_text_options),
4012,
"edt::Service(Texts)"
);
static tl::RegisteredClass<lay::PluginDeclaration> config_decl4 (
new edt::PluginDeclaration<edt::PathService> (tl::to_string (tr ("Paths")), "path:edit_mode\t" + tl::to_string (tr ("Path")) + "\t<:path_24px.png>" + tl::to_string (tr ("{Create a path}")), &get_path_options, &get_path_editor_options_pages),
new edt::PluginDeclaration<edt::PathService> (tl::to_string (tr ("Paths")), "path:edit_mode\t" + tl::to_string (tr ("Path")) + "\t<:path_24px.png>" + tl::to_string (tr ("{Create a path}")), &get_path_options),
4013,
"edt::Service(Paths)"
);
static tl::RegisteredClass<lay::PluginDeclaration> config_decl5 (
new edt::PluginDeclaration<edt::PointService> (tl::to_string (tr ("Points")), std::string (), 0, &get_shape_editor_options_pages),
new edt::PluginDeclaration<edt::PointService> (tl::to_string (tr ("Points")), std::string (), 0),
4014,
"edt::Service(Points)"
);
static tl::RegisteredClass<lay::PluginDeclaration> config_decl6 (
new edt::PluginDeclaration<edt::InstService> (tl::to_string (tr ("Instances")), "instance:edit_mode\t" + tl::to_string (tr ("Instance")) + "\t<:instance_24px.png>" + tl::to_string (tr ("{Create a cell instance}")), &get_inst_options, &get_inst_editor_options_pages),
new edt::PluginDeclaration<edt::InstService> (tl::to_string (tr ("Instances")), "instance:edit_mode\t" + tl::to_string (tr ("Instance")) + "\t<:instance_24px.png>" + tl::to_string (tr ("{Create a cell instance}")), &get_inst_options),
4020,
"edt::Service(CellInstances)"
);
@ -413,15 +294,6 @@ public:
return false;
}
#if defined(HAVE_QT)
virtual void get_editor_options_pages (std::vector<lay::EditorOptionsPage *> &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) const
{
// NOTE: we do not set plugin_declaration which makes the page unspecific
EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (view, dispatcher);
pages.push_back (generic_opt);
}
#endif
virtual void initialize (lay::Dispatcher *root)
{
lay::Dispatcher *mp = lay::Dispatcher::instance ();
@ -519,16 +391,6 @@ public:
// .. nothing yet ..
}
virtual void get_options (std::vector < std::pair<std::string, std::string> > & /*options*/) const
{
// .. nothing yet ..
}
virtual void get_editor_options_pages (std::vector<lay::EditorOptionsPage *> & /*pages*/, lay::LayoutViewBase * /*view*/, lay::Dispatcher * /*root*/) const
{
// .. no specific ones ..
}
virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const
{
return new edt::PartialService (manager, view, root);

View File

@ -23,6 +23,7 @@
#if defined(HAVE_QT)
#include "edtRecentConfigurationPage.h"
#include "edtConfig.h"
#include "layDispatcher.h"
#include "layLayoutViewBase.h"
#include "layLayerTreeModel.h"
@ -497,6 +498,92 @@ RecentConfigurationPage::config_recent_for_layer (lay::Dispatcher *root, const d
}
}
// ------------------------------------------------------------------
// Configurations and registrations
namespace {
class RecentShapeConfigurationPage
: public edt::RecentConfigurationPage
{
public:
RecentShapeConfigurationPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
: edt::RecentConfigurationPage (view, dispatcher, "edit-recent-shape-param")
{
add (edt::RecentConfigurationPage::ConfigurationDescriptor ("", tl::to_string (tr ("Layer")), edt::RecentConfigurationPage::Layer));
init ();
}
};
class RecentTextConfigurationPage
: public edt::RecentConfigurationPage
{
public:
RecentTextConfigurationPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
: edt::RecentConfigurationPage (view, dispatcher, "edit-recent-text-param")
{
add (edt::RecentConfigurationPage::ConfigurationDescriptor ("", tl::to_string (tr ("Layer")), edt::RecentConfigurationPage::Layer));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_text_string, tl::to_string (tr ("Text")), edt::RecentConfigurationPage::Text));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_text_size, tl::to_string (tr ("Size")), edt::RecentConfigurationPage::Double));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_text_halign, tl::to_string (tr ("Hor. align")), edt::RecentConfigurationPage::Text));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_text_valign, tl::to_string (tr ("Vert. align")), edt::RecentConfigurationPage::Text));
init ();
}
};
class RecentPathConfigurationPage
: public edt::RecentConfigurationPage
{
public:
RecentPathConfigurationPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
: edt::RecentConfigurationPage (view, dispatcher, "edit-recent-path-param")
{
add (edt::RecentConfigurationPage::ConfigurationDescriptor ("", tl::to_string (tr ("Layer")), edt::RecentConfigurationPage::Layer));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_path_width, tl::to_string (tr ("Width")), edt::RecentConfigurationPage::Double));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_path_ext_type, tl::to_string (tr ("Ends")), edt::RecentConfigurationPage::Int));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_path_ext_var_begin, tl::to_string (tr ("Begin ext.")), edt::RecentConfigurationPage::Double));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_path_ext_var_end, tl::to_string (tr ("End ext.")), edt::RecentConfigurationPage::Double));
init ();
}
};
class RecentInstConfigurationPage
: public edt::RecentConfigurationPage
{
public:
RecentInstConfigurationPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
: edt::RecentConfigurationPage (view, dispatcher, "edit-recent-inst-param")
{
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_lib_name, tl::to_string (tr ("Library")), edt::RecentConfigurationPage::CellLibraryName));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_cell_name, tl::to_string (tr ("Cell")), edt::RecentConfigurationPage::CellDisplayName));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_angle, tl::to_string (tr ("Angle")), edt::RecentConfigurationPage::Double));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_mirror, tl::to_string (tr ("Mirror")), edt::RecentConfigurationPage::Bool));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_scale, tl::to_string (tr ("Scale")), edt::RecentConfigurationPage::Double));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_array, tl::to_string (tr ("Array")), edt::RecentConfigurationPage::ArrayFlag));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_rows, tl::to_string (tr ("Rows")), edt::RecentConfigurationPage::IntIfArray));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_row_x, tl::to_string (tr ("Row step (x)")), edt::RecentConfigurationPage::DoubleIfArray));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_row_y, tl::to_string (tr ("Row step (y)")), edt::RecentConfigurationPage::DoubleIfArray));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_columns, tl::to_string (tr ("Columns")), edt::RecentConfigurationPage::IntIfArray));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_column_x, tl::to_string (tr ("Column step (x)")), edt::RecentConfigurationPage::DoubleIfArray));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_column_y, tl::to_string (tr ("Column step (y)")), edt::RecentConfigurationPage::DoubleIfArray));
add (edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_inst_pcell_parameters, tl::to_string (tr ("PCell parameters")), edt::RecentConfigurationPage::PCellParameters));
init ();
}
};
}
static tl::RegisteredClass<lay::EditorOptionsPageFactoryBase> s_factory_polygons (new lay::EditorOptionsPageFactory<RecentShapeConfigurationPage> ("edt::Service(Polygons)"), 0);
static tl::RegisteredClass<lay::EditorOptionsPageFactoryBase> s_factory_boxes (new lay::EditorOptionsPageFactory<RecentShapeConfigurationPage> ("edt::Service(Boxes)"), 0);
static tl::RegisteredClass<lay::EditorOptionsPageFactoryBase> s_factory_points (new lay::EditorOptionsPageFactory<RecentShapeConfigurationPage> ("edt::Service(Points)"), 0);
static tl::RegisteredClass<lay::EditorOptionsPageFactoryBase> s_factory_texts (new lay::EditorOptionsPageFactory<RecentTextConfigurationPage> ("edt::Service(Texts)"), 0);
static tl::RegisteredClass<lay::EditorOptionsPageFactoryBase> s_factory_paths (new lay::EditorOptionsPageFactory<RecentPathConfigurationPage> ("edt::Service(Paths)"), 0);
static tl::RegisteredClass<lay::EditorOptionsPageFactoryBase> s_factory_insts (new lay::EditorOptionsPageFactory<RecentInstConfigurationPage> ("edt::Service(CellInstances)"), 0);
}
#endif

View File

@ -82,11 +82,10 @@ public:
ConfigurationRendering rendering;
};
template <class Iter>
RecentConfigurationPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher, const std::string &recent_cfg_name, Iter begin_cfg, Iter end_cfg)
: EditorOptionsPageWidget (view, dispatcher), m_recent_cfg_name (recent_cfg_name), m_cfg (begin_cfg, end_cfg), dm_update_list (this, &RecentConfigurationPage::update_list)
RecentConfigurationPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher, const std::string &recent_cfg_name)
: EditorOptionsPageWidget (view, dispatcher), m_recent_cfg_name (recent_cfg_name), dm_update_list (this, &RecentConfigurationPage::update_list)
{
init ();
// .. nothing yet ..
}
virtual ~RecentConfigurationPage ();
@ -98,6 +97,21 @@ public:
virtual void commit_recent (lay::Dispatcher *root);
virtual void config_recent_for_layer (lay::Dispatcher *root, const db::LayerProperties &lp, int cv_index);
protected:
/**
* @brief Adds a configuration descriptors
* Use this method in the constructor to add descriptors.
*/
void add (const ConfigurationDescriptor &cfg)
{
m_cfg.push_back (cfg);
}
/**
* @brief Initializes the widget after the configuration items have been added
*/
void init ();
private slots:
void item_clicked (QTreeWidgetItem *item);
@ -107,7 +121,6 @@ private:
QTreeWidget *mp_tree_widget;
tl::DeferredMethod<RecentConfigurationPage> dm_update_list;
void init ();
void update_list (const std::list<std::vector<std::string> > &stored_values);
void update_list ();
std::list<std::vector<std::string> > get_stored_values () const;

View File

@ -29,22 +29,6 @@
namespace lay
{
// ------------------------------------------------------------------
// EditorOptionsFactoryBase implementation
lay::EditorOptionsPage *
EditorOptionsPageFactoryBase::create_page_by_name (const std::string &name, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
{
auto reg = tl::Registrar<lay::EditorOptionsPageFactoryBase>::get_instance ();
for (auto i = reg->begin (); i != reg->end (); ++i) {
if (i.current_name () == name) {
return i->create_page (view, dispatcher);
}
}
return 0;
}
// ------------------------------------------------------------------
// EditorOptionsPageCollection implementation

View File

@ -154,12 +154,29 @@ private:
class LAYBASIC_PUBLIC EditorOptionsPageFactoryBase
{
public:
EditorOptionsPageFactoryBase () { }
EditorOptionsPageFactoryBase (const char *plugin_name)
: m_plugin_name (plugin_name)
{
// .. nothing yet ..
}
EditorOptionsPageFactoryBase ()
: m_plugin_name ()
{
// .. nothing yet ..
}
virtual ~EditorOptionsPageFactoryBase () { }
const std::string &plugin_name () const
{
return m_plugin_name;
}
virtual lay::EditorOptionsPage *create_page (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) = 0;
static lay::EditorOptionsPage *create_page_by_name (const std::string &name, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher);
private:
std::string m_plugin_name;
};
/**
@ -179,7 +196,18 @@ class LAYBASIC_PUBLIC_TEMPLATE EditorOptionsPageFactory
: public EditorOptionsPageFactoryBase
{
public:
EditorOptionsPageFactory () { }
EditorOptionsPageFactory (const char *plugin_name)
: EditorOptionsPageFactoryBase (plugin_name)
{
// .. nothing yet ..
}
EditorOptionsPageFactory ()
: EditorOptionsPageFactoryBase ()
{
// .. nothing yet ..
}
virtual ~EditorOptionsPageFactory () { }
virtual lay::EditorOptionsPage *create_page (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)

View File

@ -465,15 +465,6 @@ public:
{
return new MoveService (view);
}
virtual void get_editor_options_pages (std::vector<lay::EditorOptionsPage *> &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) const
{
lay::EditorOptionsPage *page = lay::EditorOptionsPageFactoryBase::create_page_by_name (move_editor_options_name, view, dispatcher);
if (page) {
page->set_plugin_declaration (this);
pages.push_back (page);
}
}
};
static tl::RegisteredClass<lay::PluginDeclaration> move_service_decl (new MoveServiceDeclaration (), -970, "laybasic::MoveServicePlugin");

View File

@ -30,6 +30,7 @@
#include "layPlugin.h"
#include "layDispatcher.h"
#include "layEditorOptionsPage.h"
#include "tlExceptions.h"
#include "tlClassRegistry.h"
@ -317,6 +318,57 @@ PluginDeclaration::register_plugin ()
}
}
std::string
PluginDeclaration::name () const
{
auto plugin_reg = tl::Registrar<lay::PluginDeclaration>::get_instance ();
for (auto i = plugin_reg->begin (); i != plugin_reg->end (); ++i) {
if (i.operator-> () == this) {
return i.current_name ();
}
}
return std::string ();
}
void
PluginDeclaration::get_editor_options_pages (std::vector<lay::EditorOptionsPage *> &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) const
{
std::string n = name ();
if (n.empty ()) {
return;
}
auto reg = tl::Registrar<lay::EditorOptionsPageFactoryBase>::get_instance ();
for (auto i = reg->begin (); i != reg->end (); ++i) {
lay::EditorOptionsPage *page = 0;
if (i->plugin_name () == n) {
page = i->create_page (view, dispatcher);
if (page) {
page->set_plugin_declaration (this);
}
}
if (page) {
pages.push_back (page);
}
}
}
void
PluginDeclaration::get_catchall_editor_options_pages (std::vector<lay::EditorOptionsPage *> &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
{
auto reg = tl::Registrar<lay::EditorOptionsPageFactoryBase>::get_instance ();
for (auto i = reg->begin (); i != reg->end (); ++i) {
lay::EditorOptionsPage *page = 0;
if (i->plugin_name ().empty ()) {
page = i->create_page (view, dispatcher);
if (page) {
pages.push_back (page);
}
}
}
}
// ----------------------------------------------------------------
// Plugin implementation

View File

@ -170,6 +170,14 @@ public:
*/
virtual ~PluginDeclaration ();
/**
* @brief Gets the name under which the declaration was registered
*
* This is the name used in tl::RegisteredClass.
* If the plugin declaration is not registered, an empty string is returned.
*/
std::string name () const;
/**
* @brief This method is supposed to deliver the option names available
*
@ -323,7 +331,6 @@ public:
return false;
}
#if defined(HAVE_QT)
/**
* @brief Gets the editor options pages
*
@ -331,11 +338,21 @@ public:
* and these will be shown in tabs inside this widget.
*
* The new pages are returned in the "pages" vector. The layout view will take ownership of these pages.
*
* The default implementation collects pages registered through editor options page factories.
*/
virtual void get_editor_options_pages (std::vector<lay::EditorOptionsPage *> & /*pages*/, lay::LayoutViewBase * /*view*/, lay::Dispatcher * /*dispatcher*/) const
{
// .. no pages in the default implementation ..
}
void get_editor_options_pages (std::vector<lay::EditorOptionsPage *> &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) const;
/**
* @brief Gets the "catchall" editor options pages
*
* These are editor options pages not associated with a specific plugin.
*
* The new pages are returned in the "pages" vector. The layout view will take ownership of these pages.
*
* The implementation collects pages registered through editor options page factories.
*/
static void get_catchall_editor_options_pages (std::vector<lay::EditorOptionsPage *> &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher);
/**
* @brief Gets a value indicating whether "catchall" editor options pages shall be included
@ -348,7 +365,6 @@ public:
{
return true;
}
#endif
/**
* @brief Tells if the plugin implements a "lay::ViewService" active mouse mode

View File

@ -36,8 +36,6 @@ SOURCES += \
gsiDeclLayTextInfo.cc \
gsiDeclLayTlAdded.cc \
gsiDeclLayRdbAdded.cc \
gsiDeclLayPlugin.cc \
gsiDeclLayPluginFactory.cc \
layAbstractMenu.cc \
layEditorOptionsPage.cc \
layEditorUtils.cc \

View File

@ -53,6 +53,7 @@ EditorOptionsFrame::populate (LayoutViewBase *view)
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
cls->get_editor_options_pages (editor_options_pages, view, view->dispatcher ());
}
lay::PluginDeclaration::get_catchall_editor_options_pages (editor_options_pages, view, view->dispatcher ());
for (std::vector<lay::EditorOptionsPage *>::const_iterator op = editor_options_pages.begin (); op != editor_options_pages.end (); ++op) {
(*op)->activate (false);

View File

@ -51,7 +51,7 @@ struct EOPCompareOp
};
EditorOptionsPages::EditorOptionsPages (QWidget *parent, lay::LayoutViewBase *view, const std::vector<lay::EditorOptionsPage *> &pages)
: QFrame (parent), mp_view (view)
: QFrame (parent), mp_view (view), m_update_enabled (true)
{
mp_modal_pages = new EditorOptionsModalPages (this);
@ -161,15 +161,25 @@ EditorOptionsPages::exec_modal (EditorOptionsPage *page)
void
EditorOptionsPages::activate (const lay::Plugin *plugin)
{
m_update_enabled = false;
for (auto op = m_pages.begin (); op != m_pages.end (); ++op) {
bool is_active = false;
if (op->plugin_declaration () == 0) {
is_active = (plugin && plugin->plugin_declaration ()->enable_catchall_editor_options_pages ());
} else if (plugin && plugin->plugin_declaration () == op->plugin_declaration ()) {
is_active = true;
}
BEGIN_PROTECTED
op->activate (is_active);
END_PROTECTED
}
m_update_enabled = true;
update (0);
}
void
@ -220,6 +230,13 @@ EditorOptionsPages::activate_page (lay::EditorOptionsPage *page)
void
EditorOptionsPages::update (lay::EditorOptionsPage *page)
{
if (! m_update_enabled) {
return;
}
int index = mp_pages->currentIndex ();
int modal_index = -1;
std::vector <lay::EditorOptionsPageWidget *> sorted_pages;
for (auto p = m_pages.begin (); p != m_pages.end (); ++p) {
if (p->widget ()) {
@ -228,10 +245,6 @@ EditorOptionsPages::update (lay::EditorOptionsPage *page)
}
std::sort (sorted_pages.begin (), sorted_pages.end (), EOPCompareOp ());
if (! page && m_pages.size () > 0) {
page = m_pages.back ();
}
while (mp_pages->count () > 0) {
mp_pages->removeTab (0);
}
@ -240,9 +253,6 @@ EditorOptionsPages::update (lay::EditorOptionsPage *page)
mp_modal_pages->remove_page (0);
}
int index = -1;
int modal_index = -1;
for (auto p = sorted_pages.begin (); p != sorted_pages.end (); ++p) {
if ((*p)->active ()) {
if ((*p)->is_toolbox_widget ()) {
@ -264,7 +274,7 @@ EditorOptionsPages::update (lay::EditorOptionsPage *page)
}
if (index < 0) {
index = mp_pages->currentIndex ();
index = 0;
}
if (index >= int (mp_pages->count ())) {
index = mp_pages->count () - 1;

View File

@ -81,6 +81,7 @@ private:
lay::LayoutViewBase *mp_view;
QTabWidget *mp_pages;
EditorOptionsModalPages *mp_modal_pages;
bool m_update_enabled;
void update (lay::EditorOptionsPage *page);
void focusInEvent (QFocusEvent *event);

View File

@ -111,7 +111,7 @@ MoveEditorOptionsPage::configure (const std::string &name, const std::string &va
}
}
// registers the factory for the move plugin
static tl::RegisteredClass<lay::EditorOptionsPageFactoryBase> s_factory (new lay::EditorOptionsPageFactory<MoveEditorOptionsPage> (), 0, move_editor_options_name.c_str ());
// registers the factory for the move editor options page
static tl::RegisteredClass<lay::EditorOptionsPageFactoryBase> s_factory (new lay::EditorOptionsPageFactory<MoveEditorOptionsPage> ("laybasic::MoveServicePlugin"), 0);
}

View File

@ -11,13 +11,15 @@ RESOURCES = \
SOURCES = \
gsiDeclLayEditorOptionsPage.cc \
gsiDeclLayConfigPage.cc \
gsiDeclLayPluginFactory.cc \
gsiDeclLayPlugin.cc \
gsiDeclLayAdditional.cc \
layEditorOptionsPageWidget.cc \
layGridNet.cc \
layEditorOptionsFrame.cc \
layEditorOptionsPages.cc \
layMoveEditorOptionsPage.cc \
layviewForceLink.cc \
gsiDeclLayAdditional.cc \
HEADERS = \
gsiDeclLayEditorOptionsPage.h \