diff --git a/src/db/db/built-in-macros/pcell_declaration_helper.lym b/src/db/db/built-in-macros/pcell_declaration_helper.lym index ba97fac7d4..98901fd3c2 100644 --- a/src/db/db/built-in-macros/pcell_declaration_helper.lym +++ b/src/db/db/built-in-macros/pcell_declaration_helper.lym @@ -118,6 +118,9 @@ Optional, named parameters are @li @b:unit@/b: the unit string @/li + @li + @btooltip@/b: the tool tip text displayed on the edit fields and labels + @/li @li @b:min_value@/b: the minimum value (effective for numerical types and if no choices are present) @/li @@ -378,6 +381,7 @@ module RBA # set additional attributes of the parameters args[:default] && pdecl.default = args[:default] + args[:tooltip] && pdecl.tooltip = args[:tooltip] args[:hidden] && pdecl.hidden = args[:hidden] args[:readonly] && pdecl.readonly = args[:readonly] args[:unit] && pdecl.unit = args[:unit] diff --git a/src/db/db/built-in-pymacros/pcell_declaration_helper.lym b/src/db/db/built-in-pymacros/pcell_declaration_helper.lym index 2b3113ca05..39b4c4807b 100644 --- a/src/db/db/built-in-pymacros/pcell_declaration_helper.lym +++ b/src/db/db/built-in-pymacros/pcell_declaration_helper.lym @@ -127,6 +127,9 @@ Optional, named parameters are @li @bunit@/b: the unit string @/li + @li + @btooltip@/b: the tool tip text displayed on the edit fields and labels + @/li @li @bmin_value@/b: the minimum value (effective for numerical types and if no choices are present) @/li diff --git a/src/db/db/dbPCellDeclaration.h b/src/db/db/dbPCellDeclaration.h index 3687ef71aa..364f79b9d1 100644 --- a/src/db/db/dbPCellDeclaration.h +++ b/src/db/db/dbPCellDeclaration.h @@ -168,6 +168,22 @@ class DB_PUBLIC PCellParameterDeclaration m_description = description; } + /** + * @brief Getter for the tooltip property + */ + const std::string &get_tooltip () const + { + return m_tooltip; + } + + /** + * @brief Setter for the tooltip property + */ + void set_tooltip (const std::string &tooltip) + { + m_tooltip = tooltip; + } + /** * @brief Getter for the type property */ @@ -331,6 +347,7 @@ class DB_PUBLIC PCellParameterDeclaration m_type == d.m_type && m_name == d.m_name && m_description == d.m_description && + m_tooltip == d.m_tooltip && m_unit == d.m_unit && m_min_value == d.m_min_value && m_max_value == d.m_max_value; @@ -343,7 +360,7 @@ class DB_PUBLIC PCellParameterDeclaration bool m_hidden, m_readonly; type m_type; std::string m_name; - std::string m_description, m_unit; + std::string m_description, m_tooltip, m_unit; tl::Variant m_min_value, m_max_value; }; diff --git a/src/db/db/gsiDeclDbLibrary.cc b/src/db/db/gsiDeclDbLibrary.cc index 3bd66a6c56..a476dfba05 100644 --- a/src/db/db/gsiDeclDbLibrary.cc +++ b/src/db/db/gsiDeclDbLibrary.cc @@ -819,6 +819,14 @@ Class decl_PCellParameterDeclaration ("db", "PCel gsi::method ("description=", &db::PCellParameterDeclaration::set_description, gsi::arg ("description"), "@brief Sets the description\n" ) + + gsi::method ("tooltip", &db::PCellParameterDeclaration::get_tooltip, + "@brief Gets the tool tip text\n" + "This attribute has been introduced in version 0.29.3." + ) + + gsi::method ("tooltip=", &db::PCellParameterDeclaration::set_tooltip, gsi::arg ("tooltip"), + "@brief Sets the tool tip text\n" + "This attribute has been introduced in version 0.29.3." + ) + gsi::method ("hidden?", &db::PCellParameterDeclaration::is_hidden, "@brief Returns true, if the parameter is a hidden parameter that should not be shown in the user interface\n" "By making a parameter hidden, it is possible to create internal parameters which cannot be\n" diff --git a/src/edt/edt/edtPCellParametersPage.cc b/src/edt/edt/edtPCellParametersPage.cc index bcd9ae8a25..762b13799a 100644 --- a/src/edt/edt/edtPCellParametersPage.cc +++ b/src/edt/edt/edtPCellParametersPage.cc @@ -416,8 +416,7 @@ PCellParametersPage::setup (lay::LayoutViewBase *view, int cv_index, const db::P leader = tl::sprintf ("[%s] ", p->get_name ()); } - QLabel *l = new QLabel (tl::to_qstring (leader + description + range), inner_frame); - + QLabel *l = new QLabel (tl::to_qstring (leader + description + range), inner_frame); inner_grid->addWidget (l, row, 1); m_all_widgets.back ().push_back (l); @@ -975,6 +974,7 @@ PCellParametersPage::update_widgets_from_states (const db::ParameterStates &stat for (std::vector::const_iterator p = pcp.begin (); p != pcp.end () && i < m_widgets.size (); ++p, ++i) { const std::string &name = p->get_name (); + const std::string &static_tooltip = p->get_tooltip (); const db::ParameterState &ps = states.parameter (name); if (m_widgets [i]) { @@ -994,7 +994,11 @@ PCellParametersPage::update_widgets_from_states (const db::ParameterStates &stat if (*w != m_icon_widgets [i]) { (*w)->setVisible (ps.is_visible ()); } - (*w)->setToolTip (tl::to_qstring (ps.tooltip ())); + if (ps.tooltip ().empty ()) { + (*w)->setToolTip (tl::to_qstring (static_tooltip)); + } else { + (*w)->setToolTip (tl::to_qstring (ps.tooltip ())); + } } if (m_icon_widgets [i]) { diff --git a/src/pymod/distutils_src/klayout/db/pcell_declaration_helper.py b/src/pymod/distutils_src/klayout/db/pcell_declaration_helper.py index 5beff20439..ab432550d7 100644 --- a/src/pymod/distutils_src/klayout/db/pcell_declaration_helper.py +++ b/src/pymod/distutils_src/klayout/db/pcell_declaration_helper.py @@ -66,7 +66,7 @@ def __init__(self, *args, **kwargs): self.layer = None self.cell = None - def param(self, name, value_type, description, hidden = False, readonly = False, unit = None, default = None, choices = None, min_value = None, max_value = None): + def param(self, name, value_type, description, hidden = False, readonly = False, unit = None, default = None, choices = None, min_value = None, max_value = None, tooltip = None): """ Defines a parameter name -> the short name of the parameter @@ -79,6 +79,7 @@ def param(self, name, value_type, description, hidden = False, readonly = False, min_value -> the minimum value (only effective for numerical types and if no choices are present) max_value -> the maximum value (only effective for numerical types and if no choices are present) default -> the default value + tooltip -> tool tip text choices -> ([ [ d, v ], ...) choice descriptions/value for choice type this method defines accessor methods for the parameters {name} -> read accessor @@ -104,6 +105,8 @@ def param(self, name, value_type, description, hidden = False, readonly = False, pdecl.readonly = readonly if not (default is None): pdecl.default = default + if not (tooltip is None): + pdecl.tooltip = tooltip pdecl.min_value = min_value pdecl.max_value = max_value if not (unit is None): diff --git a/testdata/ruby/dbPCells.rb b/testdata/ruby/dbPCells.rb index d651506188..05422c3da8 100644 --- a/testdata/ruby/dbPCells.rb +++ b/testdata/ruby/dbPCells.rb @@ -226,6 +226,8 @@ def test_1 assert_equal(decl.description, "d") decl.unit = "u" assert_equal(decl.unit, "u") + decl.tooltip = "ttt" + assert_equal(decl.tooltip, "ttt") decl.type = RBA::PCellParameterDeclaration::TypeBoolean assert_equal(decl.type, RBA::PCellParameterDeclaration::TypeBoolean) decl.default = true