Skip to content

Commit

Permalink
Added signal itemGloballyActivatedChanged on RotoContext, triggered w…
Browse files Browse the repository at this point in the history
…hen RotoItem has globallyActivated changed, so UI can update when changed via Python (NatronGitHub#467)

fixes NatronGitHub#404
  • Loading branch information
splidje authored Apr 17, 2021
1 parent b761892 commit bbf95aa
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
6 changes: 6 additions & 0 deletions Engine/RotoContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2002,6 +2002,12 @@ RotoContext::onItemLockedChanged(const RotoItemPtr& item,
Q_EMIT itemLockedChanged( (int)reason );
}

void
RotoContext::onItemGloballyActivatedChanged(const RotoItemPtr& item)
{
Q_EMIT itemGloballyActivatedChanged(item);
}

void
RotoContext::onItemScriptNameChanged(const RotoItemPtr& item)
{
Expand Down
2 changes: 2 additions & 0 deletions Engine/RotoContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ class RotoContext
**/
std::string getRotoNodeName() const;

void onItemGloballyActivatedChanged(const RotoItemPtr& item);
void onItemScriptNameChanged(const RotoItemPtr& item);
void onItemLabelChanged(const RotoItemPtr& item);

Expand Down Expand Up @@ -437,6 +438,7 @@ class RotoContext

void itemLockedChanged(int reason);

void itemGloballyActivatedChanged(const RotoItemPtr&);
void itemScriptNameChanged(const RotoItemPtr&);
void itemLabelChanged(const RotoItemPtr&);

Expand Down
1 change: 1 addition & 0 deletions Engine/RotoItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ RotoItem::setGloballyActivated(bool a,
isDrawable->incrementNodesAge();
}
c->evaluateChange();
c->onItemGloballyActivatedChanged(shared_from_this());
}
}

Expand Down
25 changes: 11 additions & 14 deletions Gui/RotoPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,6 @@ struct RotoPanelPrivate

void insertSelectionRecursively(const RotoLayerPtr & layer);

void setChildrenActivatedRecursively(bool activated, QTreeWidgetItem* item);

void setChildrenLockedRecursively(bool locked, QTreeWidgetItem* item);

bool itemHasKey(const RotoItemPtr& item, double time) const;
Expand Down Expand Up @@ -507,6 +505,7 @@ RotoPanel::RotoPanel(const NodeGuiPtr& n,
QObject::connect( _imp->context.get(), SIGNAL(itemScriptNameChanged(RotoItemPtr)), this, SLOT(onItemScriptNameChanged(RotoItemPtr)) );
QObject::connect( _imp->context.get(), SIGNAL(itemLabelChanged(RotoItemPtr)), this, SLOT(onItemLabelChanged(RotoItemPtr)) );
QObject::connect( _imp->context.get(), SIGNAL(itemLockedChanged(int)), this, SLOT(onItemLockChanged(int)) );
QObject::connect( _imp->context.get(), SIGNAL(itemGloballyActivatedChanged(RotoItemPtr)), this, SLOT(onItemGloballyActivatedChanged(RotoItemPtr)) );
const QSize medButtonSize( TO_DPIX(NATRON_MEDIUM_BUTTON_SIZE), TO_DPIY(NATRON_MEDIUM_BUTTON_SIZE) );
const QSize medButtonIconSize( TO_DPIX(NATRON_MEDIUM_BUTTON_ICON_SIZE), TO_DPIY(NATRON_MEDIUM_BUTTON_ICON_SIZE) );

Expand Down Expand Up @@ -1482,9 +1481,7 @@ RotoPanel::onItemClicked(QTreeWidgetItem* item,
TreeItems::iterator found = _imp->findItem(selected[i]);
assert( found != _imp->items.end() );
found->rotoItem->setGloballyActivated(activated, true);
_imp->setChildrenActivatedRecursively(activated, found->treeItem);
}
_imp->context->emitRefreshViewerOverlays();
break;
}

Expand Down Expand Up @@ -1575,16 +1572,6 @@ RotoPanel::onItemColorDialogEdited(const QColor & color)
}
}

void
RotoPanelPrivate::setChildrenActivatedRecursively(bool activated,
QTreeWidgetItem* item)
{
item->setIcon(COL_ACTIVATED, activated ? iconVisible : iconUnvisible);
for (int i = 0; i < item->childCount(); ++i) {
setChildrenActivatedRecursively( activated, item->child(i) );
}
}

void
RotoPanel::onItemLockChanged(int reason)
{
Expand All @@ -1599,6 +1586,16 @@ RotoPanel::onItemLockChanged(int reason)
}
}

void
RotoPanel::onItemGloballyActivatedChanged(const RotoItemPtr& item)
{
TreeItems::iterator found = _imp->findItem(item);
if ( found != _imp->items.end() ) {
found->treeItem->setIcon(COL_ACTIVATED, item->isGloballyActivated() ? _imp->iconVisible : _imp->iconUnvisible);
}
_imp->context->emitRefreshViewerOverlays();
}

void
RotoPanelPrivate::setChildrenLockedRecursively(bool locked,
QTreeWidgetItem* item)
Expand Down
1 change: 1 addition & 0 deletions Gui/RotoPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public Q_SLOTS:

void onItemColorDialogEdited(const QColor & color);

void onItemGloballyActivatedChanged(const RotoItemPtr& item);
void onItemLabelChanged(const RotoItemPtr& item);
void onItemScriptNameChanged(const RotoItemPtr& item);

Expand Down

0 comments on commit bbf95aa

Please sign in to comment.