14.11: the Layers footer's buttons in the primary ink, dimmed as the menus

This commit is contained in:
ZacharyZhang-NY committed 2026-10-11 07:01:32 -04:00
1 parent e0ba02707e
commit 9611cfa11c
6 files changed
+88 -9

No files matched your search

+2 -1
View File
@@ -1,5 +1,6 @@
#include "UI/LayerMaskMenu.h"
#include "UI/LayerIcons.h"
#include "UI/LayersPanel.h"
#include <QEvent>
#include <QGuiApplication>
#include <QHBoxLayout>
@@ -23,7 +24,7 @@ void LayerMaskMenu::synchronize()
setEnabled(m_session.canEditMask() && !(active && active->mask));
setToolTip(m_session.selection() ? QStringLiteral("Add layer mask revealing the selection (Alt-click to hide it)")
: QStringLiteral("Add layer mask (Alt-click for a black mask)"));
setIcon(LayerIcons::pixmap(LayerIcon::addMask, 16, palette().color(QPalette::PlaceholderText), devicePixelRatio()));
setIcon(footerIcon(LayerIcon::addMask, *this));
}
void LayerMaskMenu::changeEvent(QEvent *event)
+19 -4
View File
@@ -1,6 +1,8 @@
#include "UI/LayersPanel.h"
#include "UI/LayerAppearanceControls.h"
#include "UI/LayerIcons.h"
#include <QStyle>
#include <QStyleOption>
#include "UI/LayerMaskMenu.h"
#include "UI/NativeLayerList.h"
#include <QEvent>
@@ -107,23 +109,36 @@ LayersPanel::LayersPanel(EditorSession &session, QWidget *parent)
synchronize();
}
QIcon footerIcon(LayerIcon icon, const QWidget &button)
{
// Disabled, the menus' own dimmed ink: Qt dims their icons.
QStyleOption option;
option.initFrom(&button);
const QPixmap menuInk = LayerIcons::pixmap(icon, 16, button.palette().color(QPalette::Active, QPalette::PlaceholderText), button.devicePixelRatio());
QIcon made(LayerIcons::pixmap(icon, 16, button.palette().color(QPalette::Active, QPalette::WindowText), button.devicePixelRatio()));
made.addPixmap(button.style()->generatedIconPixmap(QIcon::Disabled, menuInk, &option), QIcon::Disabled);
return made;
}
// The icons take the palette's ink, again after each theme.
void LayersPanel::applyIcons()
{
const QColor ink = palette().color(QPalette::PlaceholderText);
m_emptyIcon->setPixmap(LayerIcons::pixmap(LayerIcon::layers, 25, ink, devicePixelRatio()));
m_addBlankLayer->setIcon(LayerIcons::pixmap(LayerIcon::newLayer, 16, ink, devicePixelRatio()));
m_group->setIcon(LayerIcons::pixmap(LayerIcon::newFolder, 16, ink, devicePixelRatio()));
// Buttons in the primary ink; the two menus keep theirs.
m_addBlankLayer->setIcon(footerIcon(LayerIcon::newLayer, *m_addBlankLayer));
m_group->setIcon(footerIcon(LayerIcon::newFolder, *m_group));
m_effects->setIcon(LayerIcons::pixmap(LayerIcon::sparkles, 16, ink, devicePixelRatio()));
m_adjustments->setIcon(LayerIcons::pixmap(LayerIcon::halfFilledCircle, 16, ink, devicePixelRatio()));
m_delete->setIcon(LayerIcons::pixmap(LayerIcon::trash, 16, ink, devicePixelRatio()));
m_delete->setIcon(footerIcon(LayerIcon::trash, *m_delete));
}
void LayersPanel::changeEvent(QEvent *event)
{
QWidget::changeEvent(event);
// Once the buttons carry the new palette too.
if (event->type() == QEvent::PaletteChange)
applyIcons();
QMetaObject::invokeMethod(this, &LayersPanel::applyIcons, Qt::QueuedConnection);
}
QToolButton *LayersPanel::footerButton(const QString &name, const QString &label, const QString &tip, const std::function<void()> &run)
+6
View File
@@ -1,5 +1,7 @@
#pragma once
#include "Document/EditorSession.h"
#include "UI/LayerIcons.h"
#include <QIcon>
#include <QLabel>
#include <QStackedWidget>
#include <QToolButton>
@@ -7,7 +9,11 @@
class NativeLayerList;
// Swift's FooterIcon: full ink; disabled, as dim as menus.
QIcon footerIcon(LayerIcon icon, const QWidget &button);
// The layers panel: heading, appearance, the rows, the footer.
class LayersPanel : public QWidget {
Q_OBJECT
public: