Skip to content

Commit

Permalink
Merge pull request #3725 from Autodesk/bailp/EMSUSD-1002/undo-mute-re…
Browse files Browse the repository at this point in the history
…paint

EMSUSD-1002 repaint layer editor when layer muting changes
  • Loading branch information
seando-adsk authored Apr 18, 2024
2 parents fb98e50 + 3923223 commit b925c8c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/usd/ui/layerEditor/layerTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ LayerTreeView::LayerTreeView(SessionState* in_sessionState, QWidget* in_parent)

_refreshCallback = std::make_shared<LayerTreeViewRefreshCallback>(this);
UsdUfe::registerUICallback(PXR_NS::TfToken("onRefreshSystemLock"), _refreshCallback);

TfWeakPtr<LayerTreeView> me(this);
_layerMutingNoticeKey = TfNotice::Register(me, &LayerTreeView::onLayerMutingChanged);
}

LayerTreeView::~LayerTreeView()
Expand All @@ -157,8 +160,13 @@ LayerTreeView::~LayerTreeView()
UsdUfe::unregisterUICallback(PXR_NS::TfToken("onRefreshSystemLock"), _refreshCallback);
_refreshCallback.reset();
}

// Stop listening to layer muting.
TfNotice::Revoke(_layerMutingNoticeKey);
}

void LayerTreeView::onLayerMutingChanged(const UsdNotice::LayerMutingChanged&) { repaint(); }

LayerTreeItem* LayerTreeView::layerItemFromIndex(const QModelIndex& index) const
{
return _model->layerItemFromIndex(index);
Expand Down
11 changes: 10 additions & 1 deletion lib/usd/ui/layerEditor/layerTreeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

#include <usdUfe/utils/uiCallback.h>

#include <pxr/base/tf/weakBase.h>
#include <pxr/usd/usd/notice.h>

#include <QtCore/QPointer>
#include <QtWidgets/QTreeView>

Expand Down Expand Up @@ -68,7 +71,9 @@ class LayerViewMemento
* @brief Implements the Qt TreeView for USD layers. This widget is owned by the LayerEditorWidget.
*
*/
class LayerTreeView : public QTreeView
class LayerTreeView
: public QTreeView
, public PXR_NS::TfWeakBase
{
Q_OBJECT
public:
Expand Down Expand Up @@ -122,6 +127,9 @@ class LayerTreeView : public QTreeView
void onMuteLayerButtonPushed();
void onLockLayerButtonPushed();

// Notice listener method for layer muting changes.
void onLayerMutingChanged(const UsdNotice::LayerMutingChanged& notice);

bool shouldExpandOrCollapseAll() const;
void expandChildren(const QModelIndex& index);
void collapseChildren(const QModelIndex& index);
Expand All @@ -132,6 +140,7 @@ class LayerTreeView : public QTreeView
LayerTreeViewStyle _treeViewStyle;
QPointer<LayerTreeModel> _model;
LayerTreeItemDelegate* _delegate;
TfNotice::Key _layerMutingNoticeKey;

std::unique_ptr<LayerViewMemento> _cachedModelState;

Expand Down

0 comments on commit b925c8c

Please sign in to comment.