Skip to content

Commit

Permalink
EMSUSD-877 Update the look of the Layer Editor.
Browse files Browse the repository at this point in the history
- Make the action buttons only be drawn when active or when the mouse is over the layer item in the layer editor.
- Change all the layer item action icons with the new provided images.
- Make the text, icons all be draw muted when the item is disabled.
- Use different images for on/off and hover.
- Don't draw a background rectangle under the action icons.
- Make each layer item row be 24 pixels high.
- Adjust action icon centering for narrower rows.
- Use same code to paint edit target and action icons.
- Show the mouse cursor with the context menu marker in the layer editor.
- Move save count badge to the left of the save button and adjust its rendering.
- Remove the 1-pixel offset when an layer item is selected.
- Pass multiple data needed to draw an item in struct to simplify calls.
- Adjust the offset of the disable striped background so that it aligns between rows.
- Adjust the striped background positioning taking into consideration the position of the item and its indentation.
- Adjust background color of the layer editor.
- Add hover highlight of the layer row.
- Update striped background.
- Fixed the problems that some tooltips were not showing.
- Simplified the tooltip handling code..
- Elide the name of layers with ellipsis when too long to fit.
  • Loading branch information
pierrebai-adsk committed Feb 29, 2024
1 parent 4d4c036 commit 1b29020
Show file tree
Hide file tree
Showing 91 changed files with 364 additions and 273 deletions.
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

0 comments on commit 1b29020

Please sign in to comment.