mirror of
https://github.com/KLayout/klayout.git
synced 2026-09-03 16:30:20 +02:00
Implemented solution for issue #1249 (persist layer properties in session)
This commit is contained in:
@@ -1189,6 +1189,16 @@ Class<lay::LayerPropertiesNode> decl_LayerPropertiesNode (
|
||||
"Unlike the name suggests, this node will still contain a hierarchy of nodes below if the original "
|
||||
"node did so."
|
||||
) +
|
||||
method ("is_expanded?", &lay::LayerPropertiesNode::expanded,
|
||||
"@brief Gets a value indicating whether the layer tree node is expanded.\n"
|
||||
"This predicate has been introduced in version 0.28.6."
|
||||
) +
|
||||
method ("expanded=", &lay::LayerPropertiesNode::set_expanded, gsi::arg ("ex"),
|
||||
"@brief Set a value indicating whether the layer tree node is expanded.\n"
|
||||
"Setting this value to 'true' will expand (open) the tree node. Setting it to 'false' will collapse the node.\n"
|
||||
"\n"
|
||||
"This predicate has been introduced in version 0.28.6."
|
||||
) +
|
||||
method_ext ("add_child", &add_child0,
|
||||
"@brief Add a child entry\n"
|
||||
"@return A reference to the node created\n"
|
||||
|
||||
@@ -591,6 +591,12 @@ LayerProperties::need_realize (unsigned int flags, bool /*force*/)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LayerProperties::expanded_state_changed ()
|
||||
{
|
||||
// .. no effect ..
|
||||
}
|
||||
|
||||
void
|
||||
LayerProperties::do_realize (const LayoutViewBase *view) const
|
||||
{
|
||||
@@ -651,7 +657,7 @@ static unsigned int s_unique_id = 0;
|
||||
|
||||
LayerPropertiesNode::LayerPropertiesNode ()
|
||||
: LayerProperties (),
|
||||
m_list_index (0)
|
||||
m_list_index (0), m_expanded (false)
|
||||
{
|
||||
m_id = ++s_unique_id;
|
||||
}
|
||||
@@ -663,7 +669,7 @@ LayerPropertiesNode::~LayerPropertiesNode ()
|
||||
|
||||
LayerPropertiesNode::LayerPropertiesNode (const LayerProperties &d)
|
||||
: LayerProperties (d),
|
||||
m_list_index (0)
|
||||
m_list_index (0), m_expanded (false)
|
||||
{
|
||||
m_id = ++s_unique_id;
|
||||
}
|
||||
@@ -671,6 +677,7 @@ LayerPropertiesNode::LayerPropertiesNode (const LayerProperties &d)
|
||||
LayerPropertiesNode::LayerPropertiesNode (const LayerPropertiesNode &d)
|
||||
: LayerProperties (d), tl::Object (),
|
||||
m_list_index (0),
|
||||
m_expanded (d.m_expanded),
|
||||
m_children (d.m_children),
|
||||
m_id (d.m_id)
|
||||
{
|
||||
@@ -687,6 +694,7 @@ LayerPropertiesNode::operator= (const LayerPropertiesNode &d)
|
||||
LayerProperties::operator= (d);
|
||||
|
||||
m_children = d.m_children;
|
||||
m_expanded = d.m_expanded;
|
||||
m_id = d.m_id;
|
||||
|
||||
for (iterator c = m_children.begin (); c != m_children.end (); ++c) {
|
||||
@@ -705,7 +713,7 @@ LayerPropertiesNode::operator== (const LayerPropertiesNode &d) const
|
||||
if (! LayerProperties::operator== (d)) {
|
||||
return false;
|
||||
}
|
||||
return m_children == d.m_children;
|
||||
return m_children == d.m_children && m_expanded == d.m_expanded;
|
||||
}
|
||||
|
||||
LayoutViewBase *LayerPropertiesNode::view() const
|
||||
@@ -713,6 +721,15 @@ LayoutViewBase *LayerPropertiesNode::view() const
|
||||
return const_cast<lay::LayoutViewBase *> (mp_view.get ());
|
||||
}
|
||||
|
||||
void
|
||||
LayerPropertiesNode::set_expanded (bool ex)
|
||||
{
|
||||
if (expanded () != ex) {
|
||||
m_expanded = ex;
|
||||
expanded_state_changed ();
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
LayerPropertiesNode::list_index () const
|
||||
{
|
||||
@@ -740,6 +757,12 @@ LayerPropertiesNode::realize_source () const
|
||||
do_realize (mp_view.get ());
|
||||
}
|
||||
|
||||
void
|
||||
LayerPropertiesNode::expanded_state_changed ()
|
||||
{
|
||||
touch ();
|
||||
}
|
||||
|
||||
void
|
||||
LayerPropertiesNode::need_realize (unsigned int flags, bool force)
|
||||
{
|
||||
@@ -1763,8 +1786,9 @@ struct LineStyleIndexConverter
|
||||
static const tl::XMLElementList layer_element = tl::XMLElementList (
|
||||
// HINT: these make_member calls want to be qualified: otherwise an internal error
|
||||
// was observed ..
|
||||
tl::make_member<tl::color_t, LayerPropertiesNode> (&LayerPropertiesNode::frame_color_loc, &LayerPropertiesNode::set_frame_color_code, "frame-color", UIntColorConverter ()) +
|
||||
tl::make_member<tl::color_t, LayerPropertiesNode> (&LayerPropertiesNode::fill_color_loc, &LayerPropertiesNode::set_fill_color_code, "fill-color", UIntColorConverter ()) +
|
||||
tl::make_member<bool, LayerPropertiesNode> (&LayerPropertiesNode::expanded, &LayerPropertiesNode::set_expanded, "expanded") +
|
||||
tl::make_member<tl::color_t, LayerPropertiesNode> (&LayerPropertiesNode::frame_color_loc, &LayerPropertiesNode::set_frame_color_code, "frame-color", UIntColorConverter ()) +
|
||||
tl::make_member<tl::color_t, LayerPropertiesNode> (&LayerPropertiesNode::fill_color_loc, &LayerPropertiesNode::set_fill_color_code, "fill-color", UIntColorConverter ()) +
|
||||
tl::make_member<int, LayerPropertiesNode> (&LayerPropertiesNode::frame_brightness_loc, &LayerPropertiesNode::set_frame_brightness, "frame-brightness") +
|
||||
tl::make_member<int, LayerPropertiesNode> (&LayerPropertiesNode::fill_brightness_loc, &LayerPropertiesNode::set_fill_brightness, "fill-brightness") +
|
||||
tl::make_member<int, LayerPropertiesNode> (&LayerPropertiesNode::dither_pattern_loc, &LayerPropertiesNode::set_dither_pattern, "dither-pattern", DitherPatternIndexConverter ()) +
|
||||
@@ -2061,6 +2085,16 @@ LayerPropertiesNodeRef::need_realize (unsigned int flags, bool force)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LayerPropertiesNodeRef::expanded_state_changed ()
|
||||
{
|
||||
LayerPropertiesNode::expanded_state_changed ();
|
||||
|
||||
if (is_valid ()) {
|
||||
view ()->set_layer_node_expanded (m_iter, expanded ());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LayerPropertiesNodeRef::refresh () const
|
||||
{
|
||||
|
||||
@@ -919,6 +919,11 @@ protected:
|
||||
*/
|
||||
virtual void need_realize (unsigned int flags, bool force = false);
|
||||
|
||||
/**
|
||||
* @brief indicates a change of the collapsed/expanded state
|
||||
*/
|
||||
virtual void expanded_state_changed ();
|
||||
|
||||
/**
|
||||
* @brief Fetches the current status from the original properties for the LayerPropertiesNodeRef implementation
|
||||
*/
|
||||
@@ -1069,6 +1074,20 @@ public:
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the expanded state of the layer properties tree node
|
||||
*/
|
||||
void set_expanded (bool ex);
|
||||
|
||||
/**
|
||||
* @brief Gets the expanded state of the layer properties node
|
||||
*/
|
||||
bool expanded () const
|
||||
{
|
||||
refresh ();
|
||||
return m_expanded;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Child layers: begin iterator
|
||||
*/
|
||||
@@ -1207,14 +1226,21 @@ public:
|
||||
virtual void realize_source () const;
|
||||
virtual void realize_visual () const;
|
||||
|
||||
void set_expanded_silent (bool ex)
|
||||
{
|
||||
m_expanded = ex;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void need_realize (unsigned int flags, bool force);
|
||||
virtual void expanded_state_changed ();
|
||||
void set_parent (const LayerPropertiesNode *);
|
||||
|
||||
private:
|
||||
// A reference to the view
|
||||
tl::weak_ptr<lay::LayoutViewBase> mp_view;
|
||||
unsigned int m_list_index;
|
||||
bool m_expanded;
|
||||
// the parent node
|
||||
tl::weak_ptr<LayerPropertiesNode> mp_parent;
|
||||
// the list of children
|
||||
@@ -2009,8 +2035,9 @@ private:
|
||||
tl::weak_ptr<LayerPropertiesNode> mp_node;
|
||||
size_t m_synched_gen_id;
|
||||
|
||||
void need_realize (unsigned int flags, bool force);
|
||||
void refresh () const;
|
||||
virtual void need_realize (unsigned int flags, bool force);
|
||||
virtual void expanded_state_changed ();
|
||||
virtual void refresh () const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1880,6 +1880,21 @@ LayoutViewBase::replace_layer_node (unsigned int index, const LayerPropertiesCon
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LayoutViewBase::set_layer_node_expanded (unsigned int index, const LayerPropertiesConstIterator &iter, bool ex)
|
||||
{
|
||||
if (ex != iter->expanded ()) {
|
||||
|
||||
LayerPropertiesIterator non_const_iter (get_properties (index), iter.uint ());
|
||||
non_const_iter->set_expanded (ex);
|
||||
|
||||
if (index == current_layer_list ()) {
|
||||
layer_list_changed_event (8 /*expanded state needs update*/);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerProperties &props)
|
||||
{
|
||||
|
||||
@@ -335,6 +335,17 @@ public:
|
||||
set_properties (current_layer_list (), iter, props);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets a value indicating whether the given node is expanded in the layer tree
|
||||
*
|
||||
* @param iter Points to the layer node to be modified
|
||||
* @param ex True if the layer node shall be expanded, false if it shall be collapsed
|
||||
*/
|
||||
void set_layer_node_expanded (const LayerPropertiesConstIterator &iter, bool ex)
|
||||
{
|
||||
set_layer_node_expanded (current_layer_list (), iter, ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the layer properties of a layer with the given position (by iterator) for the layer list with the given index
|
||||
*
|
||||
@@ -344,6 +355,15 @@ public:
|
||||
*/
|
||||
void set_properties (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerProperties &props);
|
||||
|
||||
/**
|
||||
* @brief Sets a value indicating whether the given node is expanded in the layer tree
|
||||
*
|
||||
* @param index The layer list's index
|
||||
* @param iter Points to the layer node to be modified
|
||||
* @param ex True if the layer node shall be expanded, false if it shall be collapsed
|
||||
*/
|
||||
void set_layer_node_expanded (unsigned int index, const LayerPropertiesConstIterator &iter, bool ex);
|
||||
|
||||
/**
|
||||
* @brief Expand the layer properties of all tabs
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user