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

Un-shared stage and its sublayers will appear as system lock #3654

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
13 changes: 13 additions & 0 deletions lib/usd/ui/layerEditor/layerEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ void LayerEditorWidget::updateButtons()
{
if (_sessionState.commandHook()->isProxyShapeSharedStage(
_sessionState.stageEntry()._proxyShapePath)) {
if (_buttons._dirtyCountBadge) {
_buttons._dirtyCountBadge->setVisible(true);
}
if (_buttons._saveStageButton) {
_buttons._saveStageButton->setVisible(true);
}
const auto layers = _treeView->layerTreeModel()->getAllNeedsSavingLayers();
int count = static_cast<int>(layers.size());
for (auto layer : layers) {
Expand All @@ -284,6 +290,13 @@ void LayerEditorWidget::updateButtons()
_buttons._dirtyCountBadge->updateCount(count);
bool disable = count == 0;
QtUtils::disableHIGButton(_buttons._saveStageButton, disable);
} else {
if (_buttons._dirtyCountBadge) {
_buttons._dirtyCountBadge->setVisible(false);
}
if (_buttons._saveStageButton) {
_buttons._saveStageButton->setVisible(false);
}
}
_updateButtonsOnIdle = false;
}
Expand Down
8 changes: 6 additions & 2 deletions lib/usd/ui/layerEditor/layerTreeItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ bool LayerTreeItem::sublayerOfShared() const
return false;
}

bool LayerTreeItem::isReadOnly() const { return (_isSharedLayer); }
bool LayerTreeItem::isReadOnly() const { return (_isSharedLayer) || sublayerOfShared(); }

bool LayerTreeItem::isMovable() const
{
Expand All @@ -293,7 +293,11 @@ bool LayerTreeItem::appearsLocked() const
return false;
}

bool LayerTreeItem::isSystemLocked() const { return MayaUsd::isLayerSystemLocked(_layer); }
bool LayerTreeItem::isSystemLocked() const
{
// When a layer is being externally driven, it should appear as system-locked.
return MayaUsd::isLayerSystemLocked(_layer) || isReadOnly();
}

bool LayerTreeItem::appearsSystemLocked() const
{
Expand Down
3 changes: 2 additions & 1 deletion lib/usd/ui/layerEditor/layerTreeItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ class LayerTreeItem : public QStandardItem
bool isMuted() const;
// check if this layer is muted, or any of its parent
bool appearsMuted() const;
// check if this layer is readonly
// check if this layer is readonly (whether it is a shared layer or a sublayer of a shared
// stage)
bool isReadOnly() const;
// true if dirty, but look at needsSaving for UI feedback
bool isDirty() const { return _layer ? _layer->IsDirty() : false; }
Expand Down
26 changes: 23 additions & 3 deletions lib/usd/ui/layerEditor/layerTreeItemDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,10 @@ void LayerTreeItemDelegate::paint_drawOneAction(
// MAYA 84884: Created a background rectangle underneath the icon to extend the mouse coverage
// region

const bool hover = QtUtils::isMouseInRectangle(_treeView, actionRect);
const bool active = actionInfo._checked;
const bool hover = QtUtils::isMouseInRectangle(_treeView, actionRect);
bool appearsChecked = actionAppearsChecked(actionInfo, ctx);
const bool active = appearsChecked;

const QPixmap* icon = nullptr;
if (hover) {
icon = active ? &actionInfo._pixmap_on_hover : &actionInfo._pixmap_off_hover;
Expand Down Expand Up @@ -362,9 +364,11 @@ void LayerTreeItemDelegate::paint_ActionIcon(
LayerActionInfo action;
ctx.item->getActionButton(actionType, action);

bool appearsChecked = actionAppearsChecked(action, ctx);

// Draw the icon if it is checked or if the mouse is over the item.
const bool shouldDraw
= (action._checked || QtUtils::isMouseInRectangle(_treeView, ctx.itemRect));
= (appearsChecked || QtUtils::isMouseInRectangle(_treeView, ctx.itemRect));
if (!shouldDraw)
return;

Expand All @@ -389,6 +393,22 @@ void LayerTreeItemDelegate::paint_ActionIcons(QPainter* painter, const ItemPaint
paint_ActionIcon(painter, ctx, LayerActionType::Mute);
}

bool LayerTreeItemDelegate::actionAppearsChecked(
const LayerActionInfo& actionInfo,
const ItemPaintContext& ctx) const
{
if (actionInfo._checked) {
return true;
}

// This is used to display un-sharable layers as system-locked
if (actionInfo._actionType == LayerActionType::Lock && ctx.isSystemLocked) {
return true;
}

return false;
}

void LayerTreeItemDelegate::paint(
QPainter* painter,
const QStyleOptionViewItem& option,
Expand Down
2 changes: 2 additions & 0 deletions lib/usd/ui/layerEditor/layerTreeItemDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class LayerTreeItemDelegate : public QStyledItemDelegate
const LayerActionInfo& action,
const ItemPaintContext& ctx) const;
void drawStdIcon(QPainter* painter, int left, int top, const QPixmap& pixmap) const;
// Returns true if an action should appear as checked on a layer tree item.
bool actionAppearsChecked(const LayerActionInfo& actionInfo, const ItemPaintContext& ctx) const;
};

} // namespace UsdLayerEditor
Expand Down