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-877 Update the look of the Layer Editor. #3643

Merged
merged 4 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 5 additions & 9 deletions lib/usd/ui/layerEditor/dirtyLayersCountBadge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void DirtyLayersCountBadge::paintEvent(QPaintEvent* event)
QPainter painter(this);
auto oldPen = painter.pen();
QString textToDraw;
if (_dirtyCount > 99) {
textToDraw = "99+";
if (_dirtyCount > 999) {
textToDraw = "999+";
} else {
textToDraw = QString::number(_dirtyCount);
}
Expand All @@ -60,16 +60,12 @@ void DirtyLayersCountBadge::paintEvent(QPaintEvent* event)
painter.setBrush(QBrush(QColor(HIG_YELLOW)));

int size = DPIScale(14);
int buttonRightEdge = DPIScale(16);
QRect drawRect(0, 0, size, size);
int topPos = (thisRect.height() - size) / 2;
QRect drawRect(0, topPos, size, size);
int charLen = textToDraw.length();
int extraWidth = (charLen - 1) * DPIScale(6);
drawRect.adjust(0, 0, extraWidth, 0);

drawRect.moveTopLeft(QPoint(buttonRightEdge, 0));
if (drawRect.right() >= thisRect.right()) {
drawRect.moveTopRight(thisRect.topRight());
}
drawRect.moveRight(thisRect.right());

painter.drawRoundedRect(drawRect, size / 2.0, size / 2.0);

Expand Down
37 changes: 23 additions & 14 deletions lib/usd/ui/layerEditor/layerEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ namespace UsdLayerEditor {
LayerEditorWidget::LayerEditorWidget(SessionState& in_sessionState, QMainWindow* in_parent)
: QWidget(in_parent)
, _sessionState(in_sessionState)
, _saveButtonParent(nullptr)
{
setupLayout();
::setupDefaultMenu(&in_sessionState, in_parent);
Expand Down Expand Up @@ -161,15 +160,30 @@ QLayout* LayerEditorWidget::setupLayout_toolbar()

toolbar->addStretch();

{ // save stage button: contains a push button and a "badge" widget
_saveButtonParent = new QWidget();
QWidget* saveContainer = new QWidget;
auto saveLayout = new QHBoxLayout(saveContainer);
saveLayout->setContentsMargins(0, 0, 0, 0);
saveLayout->setSpacing(0);
saveLayout->addStretch();
{
auto badgeYOffset = DPIScale(4);
auto dirtyCountBadge = new DirtyLayersCountBadge(nullptr);
auto badgeSize = QSize(buttonSize + DPIScale(12), buttonSize + badgeYOffset);
dirtyCountBadge->setFixedSize(badgeSize);

saveLayout->addWidget(dirtyCountBadge, 0, Qt::AlignRight);
_buttons._dirtyCountBadge = dirtyCountBadge;
}

// save stage button: contains a push button and a "badge" widget
{
auto saveButtonYOffset = DPIScale(4);
auto saveButtonSize = QSize(buttonSize + DPIScale(12), buttonSize + saveButtonYOffset);
_saveButtonParent->setFixedSize(saveButtonSize);
auto saveStageBtn = new QPushButton(_saveButtonParent);
saveStageBtn->move(0, saveButtonYOffset);
auto saveStageBtn = new QPushButton();
saveStageBtn->setFixedSize(saveButtonSize);
QtUtils::setupButtonWithHIGBitmaps(saveStageBtn, ":/UsdLayerEditor/LE_save_all");
saveStageBtn->setFixedSize(buttonSize, buttonSize);

saveStageBtn->setToolTip(
StringResources::getAsQString(StringResources::kSaveAllEditsInLayerStack));
connect(
Expand All @@ -178,14 +192,12 @@ QLayout* LayerEditorWidget::setupLayout_toolbar()
this,
&LayerEditorWidget::onSaveStageButtonClicked);

auto dirtyCountBadge = new DirtyLayersCountBadge(_saveButtonParent);
dirtyCountBadge->setFixedSize(saveButtonSize);
toolbar->addWidget(_saveButtonParent, 0, buttonAlignment);

saveLayout->addWidget(saveStageBtn, 0, buttonAlignment);
_buttons._saveStageButton = saveStageBtn;
_buttons._dirtyCountBadge = dirtyCountBadge;
}

toolbar->addWidget(saveContainer, 0, buttonAlignment);

// update buttons on stage change for example dirty count
connect(
_treeView->model(),
Expand Down Expand Up @@ -256,7 +268,6 @@ void LayerEditorWidget::updateButtons()
{
if (_sessionState.commandHook()->isProxyShapeSharedStage(
_sessionState.stageEntry()._proxyShapePath)) {
_saveButtonParent->setVisible(true);
const auto layers = _treeView->layerTreeModel()->getAllNeedsSavingLayers();
int count = static_cast<int>(layers.size());
for (auto layer : layers) {
Expand All @@ -274,8 +285,6 @@ void LayerEditorWidget::updateButtons()
_buttons._dirtyCountBadge->updateCount(count);
bool disable = count == 0;
QtUtils::disableHIGButton(_buttons._saveStageButton, disable);
} else {
_saveButtonParent->setVisible(false);
}
_updateButtonsOnIdle = false;
}
Expand Down
1 change: 0 additions & 1 deletion lib/usd/ui/layerEditor/layerEditorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public Q_SLOTS:
void setupLayout();
QLayout* setupLayout_toolbar();
SessionState& _sessionState;
QWidget* _saveButtonParent { nullptr };
struct
{
QPushButton* _newLayer;
Expand Down
30 changes: 27 additions & 3 deletions lib/usd/ui/layerEditor/layerTreeItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ namespace UsdLayerEditor {
// delegate Action API for command buttons
LayerActionDefinitions LayerTreeItem::_actionButtons;

static void createPixmapPair(const QString& name, QPixmap& normal, QPixmap& hover)
{
normal = utils->createPNGResPixmap(utils->getDPIPixmapName(name));
hover = utils->createPNGResPixmap(utils->getDPIPixmapName(name + QString("_hover")));
}

const LayerActionDefinitions& LayerTreeItem::actionButtonsDefinition()
{
if (_actionButtons.size() == 0) {
Expand All @@ -39,7 +45,16 @@ const LayerActionDefinitions& LayerTreeItem::actionButtonsDefinition()
muteActionInfo._actionType = LayerActionType::Mute;
muteActionInfo._layerMask = LayerMasks::LayerMasks_SubLayer;
muteActionInfo._tooltip = StringResources::getAsQString(StringResources::kMuteUnmuteLayer);
muteActionInfo._pixmap = utils->createPNGResPixmap("RS_disable");

createPixmapPair(
":/UsdLayerEditor/LE_mute_off",
muteActionInfo._pixmap_off,
muteActionInfo._pixmap_off_hover);
createPixmapPair(
":/UsdLayerEditor/LE_mute_on",
muteActionInfo._pixmap_on,
muteActionInfo._pixmap_on_hover);

_actionButtons.insert(std::make_pair(muteActionInfo._actionType, muteActionInfo));

LayerActionInfo lockActionInfo;
Expand All @@ -49,7 +64,16 @@ const LayerActionDefinitions& LayerTreeItem::actionButtonsDefinition()
lockActionInfo._layerMask = static_cast<LayerMasks>(
LayerMasks::LayerMasks_SubLayer | LayerMasks::LayerMasks_Root);
lockActionInfo._tooltip = StringResources::getAsQString(StringResources::kLockUnlockLayer);
lockActionInfo._pixmap = utils->createPNGResPixmap("lock");

createPixmapPair(
":/UsdLayerEditor/LE_lock_off",
lockActionInfo._pixmap_off,
lockActionInfo._pixmap_off_hover);
createPixmapPair(
":/UsdLayerEditor/LE_lock_on",
lockActionInfo._pixmap_on,
lockActionInfo._pixmap_on_hover);

_actionButtons.insert(std::make_pair(lockActionInfo._actionType, lockActionInfo));
}
return _actionButtons;
Expand Down Expand Up @@ -213,7 +237,7 @@ QVariant LayerTreeItem::data(int role) const
case Qt::BackgroundRole: return QColor(71, 71, 71);
case Qt::TextAlignmentRole:
return (static_cast<int>(Qt::AlignLeft) + static_cast<int>(Qt::AlignVCenter));
case Qt::SizeHintRole: return QSize(0, DPIScale(30));
case Qt::SizeHintRole: return QSize(0, DPIScale(24));
default: return QStandardItem::data(role);
}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/usd/ui/layerEditor/layerTreeItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ struct LayerActionInfo
{
QString _name;
QString _tooltip;
QPixmap _pixmap;
QPixmap _pixmap_off;
QPixmap _pixmap_off_hover;
QPixmap _pixmap_on;
QPixmap _pixmap_on_hover;
int _extraPadding = 0;
QColor _borderColor;
bool _checked = false;
Expand Down
Loading