mirror of https://github.com/KLayout/klayout.git
Implemented solution for issue #1741 (Feature request: tooltip string for PCell parameter)
This commit is contained in:
parent
564861abe1
commit
a5b98f93ff
|
|
@ -118,6 +118,9 @@ Optional, named parameters are
|
||||||
@li
|
@li
|
||||||
@b:unit@/b: the unit string
|
@b:unit@/b: the unit string
|
||||||
@/li
|
@/li
|
||||||
|
@li
|
||||||
|
@btooltip@/b: the tool tip text displayed on the edit fields and labels
|
||||||
|
@/li
|
||||||
@li
|
@li
|
||||||
@b:min_value@/b: the minimum value (effective for numerical types and if no choices are present)
|
@b:min_value@/b: the minimum value (effective for numerical types and if no choices are present)
|
||||||
@/li
|
@/li
|
||||||
|
|
@ -378,6 +381,7 @@ module RBA
|
||||||
|
|
||||||
# set additional attributes of the parameters
|
# set additional attributes of the parameters
|
||||||
args[:default] && pdecl.default = args[:default]
|
args[:default] && pdecl.default = args[:default]
|
||||||
|
args[:tooltip] && pdecl.tooltip = args[:tooltip]
|
||||||
args[:hidden] && pdecl.hidden = args[:hidden]
|
args[:hidden] && pdecl.hidden = args[:hidden]
|
||||||
args[:readonly] && pdecl.readonly = args[:readonly]
|
args[:readonly] && pdecl.readonly = args[:readonly]
|
||||||
args[:unit] && pdecl.unit = args[:unit]
|
args[:unit] && pdecl.unit = args[:unit]
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,9 @@ Optional, named parameters are
|
||||||
@li
|
@li
|
||||||
@bunit@/b: the unit string
|
@bunit@/b: the unit string
|
||||||
@/li
|
@/li
|
||||||
|
@li
|
||||||
|
@btooltip@/b: the tool tip text displayed on the edit fields and labels
|
||||||
|
@/li
|
||||||
@li
|
@li
|
||||||
@bmin_value@/b: the minimum value (effective for numerical types and if no choices are present)
|
@bmin_value@/b: the minimum value (effective for numerical types and if no choices are present)
|
||||||
@/li
|
@/li
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,22 @@ public:
|
||||||
m_description = description;
|
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
|
* @brief Getter for the type property
|
||||||
*/
|
*/
|
||||||
|
|
@ -331,6 +347,7 @@ public:
|
||||||
m_type == d.m_type &&
|
m_type == d.m_type &&
|
||||||
m_name == d.m_name &&
|
m_name == d.m_name &&
|
||||||
m_description == d.m_description &&
|
m_description == d.m_description &&
|
||||||
|
m_tooltip == d.m_tooltip &&
|
||||||
m_unit == d.m_unit &&
|
m_unit == d.m_unit &&
|
||||||
m_min_value == d.m_min_value &&
|
m_min_value == d.m_min_value &&
|
||||||
m_max_value == d.m_max_value;
|
m_max_value == d.m_max_value;
|
||||||
|
|
@ -343,7 +360,7 @@ private:
|
||||||
bool m_hidden, m_readonly;
|
bool m_hidden, m_readonly;
|
||||||
type m_type;
|
type m_type;
|
||||||
std::string m_name;
|
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;
|
tl::Variant m_min_value, m_max_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -819,6 +819,14 @@ Class<db::PCellParameterDeclaration> decl_PCellParameterDeclaration ("db", "PCel
|
||||||
gsi::method ("description=", &db::PCellParameterDeclaration::set_description, gsi::arg ("description"),
|
gsi::method ("description=", &db::PCellParameterDeclaration::set_description, gsi::arg ("description"),
|
||||||
"@brief Sets the description\n"
|
"@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,
|
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"
|
"@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"
|
"By making a parameter hidden, it is possible to create internal parameters which cannot be\n"
|
||||||
|
|
|
||||||
|
|
@ -416,8 +416,7 @@ PCellParametersPage::setup (lay::LayoutViewBase *view, int cv_index, const db::P
|
||||||
leader = tl::sprintf ("[%s] ", p->get_name ());
|
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);
|
inner_grid->addWidget (l, row, 1);
|
||||||
m_all_widgets.back ().push_back (l);
|
m_all_widgets.back ().push_back (l);
|
||||||
|
|
||||||
|
|
@ -975,6 +974,7 @@ PCellParametersPage::update_widgets_from_states (const db::ParameterStates &stat
|
||||||
for (std::vector<db::PCellParameterDeclaration>::const_iterator p = pcp.begin (); p != pcp.end () && i < m_widgets.size (); ++p, ++i) {
|
for (std::vector<db::PCellParameterDeclaration>::const_iterator p = pcp.begin (); p != pcp.end () && i < m_widgets.size (); ++p, ++i) {
|
||||||
|
|
||||||
const std::string &name = p->get_name ();
|
const std::string &name = p->get_name ();
|
||||||
|
const std::string &static_tooltip = p->get_tooltip ();
|
||||||
const db::ParameterState &ps = states.parameter (name);
|
const db::ParameterState &ps = states.parameter (name);
|
||||||
|
|
||||||
if (m_widgets [i]) {
|
if (m_widgets [i]) {
|
||||||
|
|
@ -994,7 +994,11 @@ PCellParametersPage::update_widgets_from_states (const db::ParameterStates &stat
|
||||||
if (*w != m_icon_widgets [i]) {
|
if (*w != m_icon_widgets [i]) {
|
||||||
(*w)->setVisible (ps.is_visible ());
|
(*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]) {
|
if (m_icon_widgets [i]) {
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ class _PCellDeclarationHelperMixin:
|
||||||
self.layer = None
|
self.layer = None
|
||||||
self.cell = 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
|
Defines a parameter
|
||||||
name -> the short name of the parameter
|
name -> the short name of the parameter
|
||||||
|
|
@ -79,6 +79,7 @@ class _PCellDeclarationHelperMixin:
|
||||||
min_value -> the minimum value (only effective for numerical types and if no choices are present)
|
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)
|
max_value -> the maximum value (only effective for numerical types and if no choices are present)
|
||||||
default -> the default value
|
default -> the default value
|
||||||
|
tooltip -> tool tip text
|
||||||
choices -> ([ [ d, v ], ...) choice descriptions/value for choice type
|
choices -> ([ [ d, v ], ...) choice descriptions/value for choice type
|
||||||
this method defines accessor methods for the parameters
|
this method defines accessor methods for the parameters
|
||||||
{name} -> read accessor
|
{name} -> read accessor
|
||||||
|
|
@ -104,6 +105,8 @@ class _PCellDeclarationHelperMixin:
|
||||||
pdecl.readonly = readonly
|
pdecl.readonly = readonly
|
||||||
if not (default is None):
|
if not (default is None):
|
||||||
pdecl.default = default
|
pdecl.default = default
|
||||||
|
if not (tooltip is None):
|
||||||
|
pdecl.tooltip = tooltip
|
||||||
pdecl.min_value = min_value
|
pdecl.min_value = min_value
|
||||||
pdecl.max_value = max_value
|
pdecl.max_value = max_value
|
||||||
if not (unit is None):
|
if not (unit is None):
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,8 @@ class DBPCellAPI_TestClass < TestBase
|
||||||
assert_equal(decl.description, "d")
|
assert_equal(decl.description, "d")
|
||||||
decl.unit = "u"
|
decl.unit = "u"
|
||||||
assert_equal(decl.unit, "u")
|
assert_equal(decl.unit, "u")
|
||||||
|
decl.tooltip = "ttt"
|
||||||
|
assert_equal(decl.tooltip, "ttt")
|
||||||
decl.type = RBA::PCellParameterDeclaration::TypeBoolean
|
decl.type = RBA::PCellParameterDeclaration::TypeBoolean
|
||||||
assert_equal(decl.type, RBA::PCellParameterDeclaration::TypeBoolean)
|
assert_equal(decl.type, RBA::PCellParameterDeclaration::TypeBoolean)
|
||||||
decl.default = true
|
decl.default = true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue