Skip to content

Commit

Permalink
chore: tweak menu animation
Browse files Browse the repository at this point in the history
1.add antialising
2.add shadow
3.add submenu background

Log:
  • Loading branch information
wangfei committed Aug 22, 2024
1 parent 14e15ef commit 742403b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions styleplugins/chameleon/chameleonstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3002,6 +3002,7 @@ ChameleonMovementAnimation *ChameleonStyle::drawMenuItemBackground(const QStyleO
return nullptr;
}


if (!selected) {
do {
color = option->palette.window().color();
Expand Down Expand Up @@ -3064,6 +3065,12 @@ ChameleonMovementAnimation *ChameleonStyle::drawMenuItemBackground(const QStyleO
if (selected)
animation->setTargetRect(option->rect);
}

if (type == QStyleOptionMenuItem::SubMenu) {
color = DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType ?
QColor(0, 0, 0, 255 * 0.15): QColor(255, 255, 255, 255 * 0.2);
}

const int round = 6;
if (animation && animation->isRuning()) {
painter->save();
Expand All @@ -3072,15 +3079,19 @@ ChameleonMovementAnimation *ChameleonStyle::drawMenuItemBackground(const QStyleO
painter->setOpacity(1.0);
painter->setBrush(color);
painter->setPen(Qt::NoPen);
painter->setRenderHint(QPainter::Antialiasing);
painter->drawRoundedRect(animation->currentRect(), round, round);
painter->setOpacity(opacity);
painter->restore();

return animation;
} else if (selected) {
const QMargins &margins = frameExtentMargins();
drawShadow(painter, option->rect - margins, getColor(option, QPalette::Shadow));
painter->save();
painter->setBrush(color);
painter->setPen(Qt::NoPen);
painter->setRenderHint(QPainter::Antialiasing);
painter->drawRoundedRect(option->rect, round, round);
painter->restore();
}
Expand Down

0 comments on commit 742403b

Please sign in to comment.