Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMSUSD-1002 repaint layer editor when layer muting changes #3725

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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