From 414a06c70febf61e1f760b5fbf317ba6d1cc566e Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 2 Mar 2025 20:54:00 +0100 Subject: [PATCH] Bugfix: tab title was not updated when current cell is renamed --- .../laybasic/gsiDeclLayLayoutViewBase.cc | 2 +- src/laybasic/laybasic/layLayoutViewBase.cc | 99 ++++++++++--------- src/laybasic/laybasic/layLayoutViewBase.h | 7 +- 3 files changed, 57 insertions(+), 51 deletions(-) diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc index da561762c..15925208b 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc @@ -607,7 +607,7 @@ LAYBASIC_PUBLIC Class decl_LayoutViewBase ("lay", "LayoutVi "\n" "See \\set_title and \\title for a description about how titles are handled." ) + - gsi::method ("title", static_cast (&lay::LayoutViewBase::title), + gsi::method ("title", static_cast (&lay::LayoutViewBase::title), "@brief Returns the view's title string\n" "\n" "@return The title string\n" diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 38fa9ab69..cd9534e00 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -539,7 +539,7 @@ void LayoutViewBase::update_event_handlers () cellview (i)->layout ().dbu_changed_event.add (this, &LayoutViewBase::signal_bboxes_changed); cellview (i)->layout ().prop_ids_changed_event.add (this, &LayoutViewBase::signal_prop_ids_changed); cellview (i)->layout ().layer_properties_changed_event.add (this, &LayoutViewBase::signal_layer_properties_changed); - cellview (i)->layout ().cell_name_changed_event.add (this, &LayoutViewBase::signal_cell_name_changed); + cellview (i)->layout ().cell_name_changed_event.add (this, &LayoutViewBase::signal_cell_name_changed, i); cellview (i)->apply_technology_with_sender_event.add (this, &LayoutViewBase::signal_apply_technology); } @@ -685,13 +685,30 @@ LayoutViewBase::is_dirty () const return m_dirty; } -std::string +const std::string & LayoutViewBase::title () const +{ + return m_current_title; +} + +void +LayoutViewBase::update_title () { if (! m_title.empty ()) { - return m_title; + + if (m_title != m_current_title) { + m_current_title = m_title; + emit_title_changed (); + } + } else if (cellviews () == 0) { - return tl::to_string (tr ("")); + + static std::string empty_title = tl::to_string (tr ("")); + if (m_current_title != empty_title) { + m_current_title = empty_title; + emit_title_changed (); + } + } else { int cv_index = active_cellview_index (); @@ -714,27 +731,25 @@ LayoutViewBase::title () const t += " ..."; } - return t; - + if (t != m_current_title) { + m_current_title = t; + emit_title_changed (); + } } } void LayoutViewBase::set_title (const std::string &t) { - if (m_title != t) { - m_title = t; - emit_title_changed (); - } + m_title = t; + update_title (); } void LayoutViewBase::reset_title () { - if (! m_title.empty ()) { - m_title = ""; - emit_title_changed (); - } + m_title.clear (); + update_title (); } bool @@ -1977,9 +1992,9 @@ LayoutViewBase::replace_layer_node (unsigned int index, const LayerPropertiesCon manager ()->clear (); } - if (index == current_layer_list ()) { - begin_layer_updates (); - } + if (index == current_layer_list ()) { + begin_layer_updates (); + } LayerPropertiesIterator non_const_iter (get_properties (index), iter.uint ()); *non_const_iter = node; @@ -2342,9 +2357,13 @@ LayoutViewBase::signal_bboxes_changed () } void -LayoutViewBase::signal_cell_name_changed () +LayoutViewBase::signal_cell_name_changed (unsigned int cv_index) { - cell_visibility_changed_event (); // HINT: that is not what actually is intended, but it serves the function ... + cellview_changed_event (int (cv_index)); + + // Because the title reflects the active cell, emit a title changed event + update_title (); + redraw_later (); // needs redraw } @@ -2489,10 +2508,7 @@ LayoutViewBase::erase_cellview (unsigned int index) finish_cellviews_changed (); update_content (); - - if (m_title.empty ()) { - emit_title_changed (); - } + update_title (); } void @@ -2522,9 +2538,7 @@ LayoutViewBase::clear_cellviews () finish_cellviews_changed (); - if (m_title.empty ()) { - emit_title_changed (); - } + update_title (); } const CellView & @@ -2592,9 +2606,7 @@ LayoutViewBase::set_layout (const lay::CellView &cv, unsigned int cvindex) // the layouts are released as far as possible. This is important for reload () for example. update_content_for_cv (cvindex); - if (m_title.empty ()) { - emit_title_changed (); - } + update_title (); } void @@ -4866,9 +4878,7 @@ LayoutViewBase::cellview_changed (unsigned int index) cellview_changed_event (index); - if (m_title.empty ()) { - emit_title_changed (); - } + update_title (); } const lay::CellView & @@ -4961,10 +4971,8 @@ LayoutViewBase::enable_active_cellview_changed_event (bool enable, bool silent) active_cellview_changed_with_index_event (*i); } - // Because the title reflects the active one, emit a title changed event - if (title_string ().empty ()) { - emit_title_changed (); - } + // Because the title reflects the active cell, emit a title changed event + update_title (); } @@ -4987,10 +4995,8 @@ LayoutViewBase::active_cellview_changed (int index) active_cellview_changed_event (); active_cellview_changed_with_index_event (index); - // Because the title reflects the active one, emit a title changed event - if (title_string ().empty ()) { - emit_title_changed (); - } + // Because the title reflects the active cell, emit a title changed event + update_title (); } else { m_active_cellview_changed_events.insert (index); @@ -5936,14 +5942,11 @@ LayoutViewBase::update_content_for_cv (int /*cellview_index*/) void LayoutViewBase::rename_cellview (const std::string &name, int cellview_index) { - if (cellview_index >= 0 && cellview_index < int (m_cellviews.size ())) { - if ((*cellview_iter (cellview_index))->name () != name) { - (*cellview_iter (cellview_index))->rename (name); - update_content_for_cv (cellview_index); - if (m_title.empty ()) { - emit_title_changed (); - } - } + if (cellview_index >= 0 && cellview_index < int (m_cellviews.size ()) && + (*cellview_iter (cellview_index))->name () != name) { + (*cellview_iter (cellview_index))->rename (name); + update_content_for_cv (cellview_index); + update_title (); } } diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 51531e9be..ee40f9f85 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -2614,7 +2614,7 @@ public: /** * @brief Gets the window title of the view */ - std::string title () const; + const std::string &title () const; /** * @brief Sets the window title to an explicit string @@ -2837,7 +2837,7 @@ private: void signal_bboxes_changed (); void signal_prop_ids_changed (); void signal_layer_properties_changed (); - void signal_cell_name_changed (); + void signal_cell_name_changed (unsigned int cv_index); void signal_annotations_changed (); void signal_plugin_enabled_changed (); void signal_apply_technology (lay::LayoutHandle *layout_handle); @@ -2853,6 +2853,7 @@ private: lay::AnnotationShapes m_annotation_shapes; std::vector > m_hidden_cells; std::string m_title; + std::string m_current_title; tl::vector m_rdbs; tl::vector m_l2ndbs; std::string m_def_lyp_file; @@ -3005,6 +3006,8 @@ private: void init_layer_properties (LayerProperties &props, const LayerPropertiesList &lp_list) const; void merge_dither_pattern (lay::LayerPropertiesList &props); + void update_title (); + protected: /** * @brief Constructor for calling from a LayoutView