From cdaf34cd778cc9fc74feed96bfa787f522f1520e Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 2 Dec 2025 00:05:38 +0100 Subject: [PATCH] Implementing change of layer accross all shape types Plus: simplify behavior of "change all" button, so it is not turned on or off. --- src/edt/edt/edtPropertiesPageUtils.cc | 6 ++++++ src/edt/edt/edtPropertiesPageUtils.h | 1 + src/edt/edt/edtPropertiesPages.cc | 30 ++++++++++++++++++++++++++ src/edt/edt/edtPropertiesPages.h | 3 ++- src/laybasic/laybasic/layProperties.cc | 2 +- src/laybasic/laybasic/layProperties.h | 27 +++++++++++++++++++++++ src/layui/layui/layPropertiesDialog.cc | 14 +++--------- src/layui/layui/layPropertiesDialog.h | 12 +++++++++-- 8 files changed, 80 insertions(+), 15 deletions(-) diff --git a/src/edt/edt/edtPropertiesPageUtils.cc b/src/edt/edt/edtPropertiesPageUtils.cc index 89cc47dcf..5561ee577 100644 --- a/src/edt/edt/edtPropertiesPageUtils.cc +++ b/src/edt/edt/edtPropertiesPageUtils.cc @@ -120,6 +120,12 @@ db::Instance ChangePropertiesApplicator::do_apply_inst (db::Cell &cell, const db // ------------------------------------------------------------------------- // ChangeLayerApplicator implementation +ChangeLayerApplicator::ChangeLayerApplicator (const ChangeLayerApplicator &other) + : ChangeApplicator (), m_cv_index (other.m_cv_index), m_new_layer (other.m_new_layer), m_skipped_layers (other.m_skipped_layers) +{ + // .. nothing yet ... +} + ChangeLayerApplicator::ChangeLayerApplicator (unsigned int cv_index, unsigned int new_layer) : m_cv_index (cv_index), m_new_layer (new_layer) { diff --git a/src/edt/edt/edtPropertiesPageUtils.h b/src/edt/edt/edtPropertiesPageUtils.h index ea724e763..11811ce9a 100644 --- a/src/edt/edt/edtPropertiesPageUtils.h +++ b/src/edt/edt/edtPropertiesPageUtils.h @@ -121,6 +121,7 @@ class ChangeLayerApplicator : public ChangeApplicator { public: + ChangeLayerApplicator (const ChangeLayerApplicator &other); ChangeLayerApplicator (unsigned int cv_index, unsigned int new_layer); bool supports_relative_mode () const { return false; } diff --git a/src/edt/edt/edtPropertiesPages.cc b/src/edt/edt/edtPropertiesPages.cc index cb43c96e5..35bbb25fb 100644 --- a/src/edt/edt/edtPropertiesPages.cc +++ b/src/edt/edt/edtPropertiesPages.cc @@ -261,6 +261,7 @@ ShapePropertiesPage::do_apply (bool current_only, bool relative, bool commit) } std::unique_ptr applicator; + std::unique_ptr other_applicator; unsigned int cv_index = m_selection_ptrs [m_indexes.front ()]->cv_index (); @@ -277,6 +278,9 @@ ShapePropertiesPage::do_apply (bool current_only, bool relative, bool commit) if (m_prop_id != pos->shape ().prop_id ()) { applicator.reset (new CombinedChangeApplicator (applicator.release (), new ChangePropertiesApplicator (m_prop_id))); + if (! current_only) { + other_applicator.reset (new ChangePropertiesApplicator (m_prop_id)); + } } int new_layer = layer_selector ()->current_layer (); @@ -285,6 +289,9 @@ ShapePropertiesPage::do_apply (bool current_only, bool relative, bool commit) ChangeLayerApplicator *cla = new ChangeLayerApplicator (cv_index, (unsigned int) new_layer); cla->skip_layer (gs_layer); applicator.reset (new CombinedChangeApplicator (applicator.release (), cla)); + if (! current_only) { + other_applicator.reset (new CombinedChangeApplicator (other_applicator.release (), new ChangeLayerApplicator (*cla))); + } } } @@ -292,6 +299,29 @@ ShapePropertiesPage::do_apply (bool current_only, bool relative, bool commit) return; } + apply_change (applicator.get (), cv_index, current_only, relative, commit); + + if (other_applicator.get () && page_set ()) { + + // apply to other pages + auto pages = page_set ()->properties_pages (); + for (auto p = pages.begin (); p != pages.end (); ++p) { + ShapePropertiesPage *sp = dynamic_cast (*p); + if (sp && sp != this) { + sp->apply_change (other_applicator.get (), cv_index, current_only, relative, commit); + } + } + + } +} + +void +ShapePropertiesPage::apply_change (const ChangeApplicator *applicator, unsigned int cv_index, bool current_only, bool relative, bool commit) +{ + if (m_indexes.empty ()) { + return; + } + // Ask whether to use relative or absolute mode bool relative_mode = false; if (! current_only && applicator->supports_relative_mode ()) { diff --git a/src/edt/edt/edtPropertiesPages.h b/src/edt/edt/edtPropertiesPages.h index 237c601b1..1a2fc50aa 100644 --- a/src/edt/edt/edtPropertiesPages.h +++ b/src/edt/edt/edtPropertiesPages.h @@ -68,8 +68,9 @@ private: virtual void apply (bool commit); virtual void apply_to_all (bool relative, bool commit); virtual bool can_apply_to_all () const; - virtual void do_apply (bool current_only, bool relative, bool commit); + void do_apply (bool current_only, bool relative, bool commit); void recompute_selection_ptrs (const std::vector &new_sel); + void apply_change (const ChangeApplicator *applicator, unsigned int cv_index, bool current_only, bool relative, bool commit); protected: std::string m_description; diff --git a/src/laybasic/laybasic/layProperties.cc b/src/laybasic/laybasic/layProperties.cc index 87be24fdf..f63b37939 100644 --- a/src/laybasic/laybasic/layProperties.cc +++ b/src/laybasic/laybasic/layProperties.cc @@ -28,7 +28,7 @@ namespace lay { PropertiesPage::PropertiesPage (QWidget *parent, db::Manager *manager, lay::Editable *editable) - : QFrame (parent), mp_manager (manager), mp_editable (editable) + : QFrame (parent), mp_manager (manager), mp_editable (editable), mp_page_set (0) { // .. nothing else .. } diff --git a/src/laybasic/laybasic/layProperties.h b/src/laybasic/laybasic/layProperties.h index fc0e7cb08..1d1d91c1c 100644 --- a/src/laybasic/laybasic/layProperties.h +++ b/src/laybasic/laybasic/layProperties.h @@ -41,6 +41,16 @@ namespace lay class Editable; +/** + * @brief An interface delivering all properties pages + */ +class LAYBASIC_PUBLIC PropertiesPageSet +{ +public: + virtual ~PropertiesPageSet () { } + virtual const std::vector &properties_pages () const = 0; +}; + /** * @brief The properties page object * @@ -211,6 +221,22 @@ public: return mp_manager; } + /** + * @brief Gets the page set + */ + const PropertiesPageSet *page_set () const + { + return mp_page_set; + } + + /** + * @brief Sets the page set + */ + void set_page_set (PropertiesPageSet *page_set) + { + mp_page_set = page_set; + } + signals: /** * @brief This signal is emitted if a value has been changed @@ -220,6 +246,7 @@ signals: private: db::Manager *mp_manager; tl::weak_ptr mp_editable; + PropertiesPageSet *mp_page_set; }; } diff --git a/src/layui/layui/layPropertiesDialog.cc b/src/layui/layui/layPropertiesDialog.cc index 6c1e2100c..b531d64bd 100644 --- a/src/layui/layui/layPropertiesDialog.cc +++ b/src/layui/layui/layPropertiesDialog.cc @@ -214,6 +214,7 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager, delete *p; } else { mp_properties_pages.push_back (*p); + (*p)->set_page_set (this); } } } @@ -263,7 +264,7 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager, update_controls (); - mp_ui->apply_to_all_cbx->setChecked (false); + mp_ui->apply_to_all_cbx->setChecked (true); // TODO: persist mp_ui->relative_cbx->setChecked (true); fetch_config (); @@ -321,13 +322,7 @@ PropertiesDialog::disconnect () void PropertiesDialog::apply_to_all_pressed () { - m_signals_enabled = false; - if (mp_ui->apply_to_all_cbx->isChecked ()) { - mp_ui->tree->setCurrentIndex (mp_tree_model->index_for (m_index)); - } else if (! m_object_indexes.empty ()) { - mp_ui->tree->setCurrentIndex (mp_tree_model->index_for (m_index, int (m_object_indexes.front ()))); - } - m_signals_enabled = true; + mp_ui->relative_cbx->setEnabled (mp_ui->apply_to_all_cbx->isEnabled () && mp_ui->apply_to_all_cbx->isChecked ()); } void @@ -495,7 +490,6 @@ PropertiesDialog::current_index_changed (const QModelIndex &index, const QModelI } else { m_index = index.row (); - mp_ui->apply_to_all_cbx->setChecked (mp_properties_pages [m_index]->can_apply_to_all ()); if (mp_properties_pages [m_index]->can_apply_to_all ()) { @@ -537,8 +531,6 @@ PropertiesDialog::update_controls () } m_prev_index = m_index; - mp_ui->apply_to_all_cbx->setChecked (m_object_indexes.size () > 1); - if (m_index < 0 || m_index >= int (mp_properties_pages.size ())) { mp_stack->setCurrentWidget (mp_none); diff --git a/src/layui/layui/layPropertiesDialog.h b/src/layui/layui/layPropertiesDialog.h index 88836860c..c4b563d52 100644 --- a/src/layui/layui/layPropertiesDialog.h +++ b/src/layui/layui/layPropertiesDialog.h @@ -26,6 +26,7 @@ #define HDR_layPropertiesDialog #include "layuiCommon.h" +#include "layProperties.h" #include @@ -52,7 +53,6 @@ namespace lay class Editable; class Editables; -class PropertiesPage; class MainWindow; class PropertiesTreeModel; @@ -65,7 +65,7 @@ class PropertiesTreeModel; */ class LAYUI_PUBLIC PropertiesDialog - : public QDialog + : public QDialog, public lay::PropertiesPageSet { Q_OBJECT @@ -80,6 +80,14 @@ public: */ ~PropertiesDialog (); + /** + * @brief Implementation of PropertiesPageSet + */ + virtual const std::vector &properties_pages () const + { + return mp_properties_pages; + } + private: friend class PropertiesTreeModel;