Merge branch 'issue-1259'

This commit is contained in:
Matthias Koefferlein 2023-01-29 17:18:25 +01:00
commit 115b89c711
6 changed files with 40 additions and 21 deletions

View File

@ -2931,6 +2931,7 @@ MainWindow::close_view (int index)
// last view closed
lay::LayoutView::set_current (0);
current_view_changed ();
clear_current_pos ();

View File

@ -86,7 +86,7 @@ TechnologyController::initialized (lay::Dispatcher *dispatcher)
tl_assert (dispatcher == mp_dispatcher);
update_menu (mp_dispatcher);
connect_events ();
view_changed ();
if (lay::SaltController::instance ()) {
connect (lay::SaltController::instance (), SIGNAL (salt_changed ()), this, SLOT (sync_with_external_sources ()));
@ -121,8 +121,10 @@ TechnologyController::get_menu_entries (std::vector<lay::MenuEntry> &menu_entrie
}
void
TechnologyController::connect_events ()
TechnologyController::view_changed ()
{
update_active_technology ();
// NOTE: the whole concept is a but strange here: the goal is to
// connect to the current view's active_cellview_changed event and
// the active cellview's technology_changed event. We could register
@ -140,15 +142,13 @@ TechnologyController::connect_events ()
// NOTE: the "real" call needs to come before the re-connect handler because
// the latter will remove the update call
mp_mw->current_view_changed_event.add (this, &TechnologyController::update_active_technology);
mp_mw->current_view_changed_event.add (this, &TechnologyController::connect_events);
mp_mw->current_view_changed_event.add (this, &TechnologyController::view_changed);
if (mp_mw->current_view ()) {
// NOTE: the "real" call needs to come before the re-connect handler because
// the latter will remove the update call
mp_mw->current_view ()->active_cellview_changed_event.add (this, &TechnologyController::update_active_technology);
mp_mw->current_view ()->active_cellview_changed_event.add (this, &TechnologyController::connect_events);
mp_mw->current_view ()->active_cellview_changed_event.add (this, &TechnologyController::view_changed);
if (mp_mw->current_view ()->active_cellview_index () >= 0 && mp_mw->current_view ()->active_cellview_index () <= int (mp_mw->current_view ()->cellviews ())) {
mp_mw->current_view ()->active_cellview ()->technology_changed_event.add (this, &TechnologyController::update_active_technology);
@ -178,20 +178,19 @@ TechnologyController::update_active_technology ()
}
if (mp_active_technology != active_tech) {
mp_active_technology = active_tech;
mp_active_technology = active_tech;
if (mp_mw) {
if (active_tech) {
mp_mw->tech_message (tech_string_from_name (active_tech->name ()));
} else {
mp_mw->tech_message (std::string ());
}
if (mp_mw) {
if (active_tech) {
mp_mw->tech_message (tech_string_from_name (active_tech->name ()));
} else {
mp_mw->tech_message (std::string ());
}
}
if (mp_active_technology != active_tech) {
emit active_technology_changed ();
}
#if 0

View File

@ -138,7 +138,7 @@ private:
db::Technology *mp_active_technology;
void update_active_technology ();
void connect_events ();
void view_changed ();
void technologies_changed ();
void technology_changed (db::Technology *);
bool configure (const std::string &name, const std::string &value);

View File

@ -3231,12 +3231,12 @@ LayoutViewBase::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview,
std::vector <db::cell_index_type> p;
p.push_back (*top);
select_cell (p, cv_index);
} else {
// even if there is no cell, select the cellview item
// to support applications with an active cellview (that is however invalid)
set_active_cellview_index (cv_index);
}
// even if there is no cell, select the cellview item
// to support applications with an active cellview (that is however invalid)
set_active_cellview_index (cv_index);
if (initialize_layers) {
bool add_other_layers = m_add_other_layers;
@ -3315,7 +3315,7 @@ LayoutViewBase::create_layout (const std::string &technology, bool add_cellview,
{
const db::Technology *tech = db::Technologies::instance ()->technology_by_name (technology);
db::Layout *layout = new db::Layout (manager ());
db::Layout *layout = new db::Layout (m_editable, manager ());
if (tech) {
layout->dbu (tech->dbu ());
}
@ -3405,6 +3405,9 @@ LayoutViewBase::load_layout (const std::string &filename, const db::LoadLayoutOp
select_cell (p, cv_index);
}
// force "active_cellview_changed" event
m_active_cellview_index = -1;
// even if there is no cell, select the cellview item
// to support applications with an active cellview (that is however invalid)
set_active_cellview_index (cv_index);

View File

@ -1309,6 +1309,7 @@ TEST (16)
int cv1 = view.create_layout ("", true, false);
db::Layout &ly1 = view.cellview (cv1)->layout ();
EXPECT_EQ (ly1.is_editable (), is_editable ());
ly1.insert_layer (db::LayerProperties (1, 0));
ly1.insert_layer (db::LayerProperties (2, 0));

View File

@ -535,6 +535,21 @@ class LAYLayoutView_TestClass < TestBase
end
# issue-1259
def test_7
# standalone layout view
lv = RBA::LayoutView::new(true)
assert_equal(lv.is_editable, true)
lv.create_layout(true)
layout = lv.active_cellview.layout
assert_equal(layout.is_editable, true)
end
end
load("test_epilogue.rb")