Skip to content

feat(MenuItem): add 1px inset shadow bevel on hover highlight - #714

Open
zqq-dora wants to merge 1 commit into
linuxdeepin:v25-flowstylefrom
zqq-dora:pr-menu-hover-shadow
Open

zqq-dora wants to merge 1 commit into
linuxdeepin:v25-flowstylefrom
zqq-dora:pr-menu-hover-shadow

Conversation

@zqq-dora

@zqq-dora zqq-dora commented Sep 30, 2026 •

Copy link
Copy Markdown

Summary

Add a subtle inner-shadow bevel to the MenuItem hover/highlight state, matching the ToolButton checked-state approach using BoxInsetShadow.

Changes

FlowStyle.qml — two new palettes under menu:

  • itemHighlightInnerShadow (bottom): 20% black (light) / 24% black (dark)
  • itemHighlightInnerShadowTop (top): transparent (light) / 10% white (dark)

MenuItem.qml — two BoxInsetShadow elements in background, visible on control.highlighted:

  • Top: shadowOffsetY: 1, blur: 1, white 10% (dark mode only)
  • Bottom: shadowOffsetY: -1, blur: 1, black 20% (light) / 24% (dark)
  • cornerRadius follows DS.Style.menu.item.radius (6)

Menu.md — new documentation for MenuItem hover highlight rendering.
README.md — add Menu.md to docs index.

Result

  • Light mode: only a 1px bottom inner shadow (20% black).
  • Dark mode: 1px top white 10% highlight + 1px bottom black 24% inner shadow.

Color values use DTK palettes so they follow theme changes automatically.


概述

新增 MenuItem 悬浮高亮的 1px 内阴影斜面效果,参照 ToolButton checked 状态使用 BoxInsetShadow 实现。

改动内容

FlowStyle.qml — menu 下新增两个调色板:

  • itemHighlightInnerShadow(底部):浅色 20% 黑 / 深色 24% 黑
  • itemHighlightInnerShadowTop(顶部):浅色透明 / 深色 10% 白

MenuItem.qml — 在 background 中新增两个 BoxInsetShadow,仅在 control.highlighted 时显示:

  • 顶部:shadowOffsetY: 1,blur: 1,白色 10%(仅深色模式)
  • 底部:shadowOffsetY: -1,blur: 1,黑色 20%(浅色)/ 24%(深色)
  • cornerRadius 跟随 DS.Style.menu.item.radius(6)

Menu.md — 新增菜单项悬浮高亮渲染说明文档。
README.md — 文档索引加入 Menu.md。

效果

  • 浅色模式: 仅底部 1px 内阴影(20% 黑)。
  • 深色模式: 顶部 1px 白色 10% 高光 + 底部 1px 黑色 24% 内阴影。

色值使用 DTK 调色板定义,随主题自动变化。

Summary by Sourcery

Add theme-aware inset bevel shadows to the MenuItem highlight state.

New Features:

  • Add light- and dark-theme inset bevel styling to highlighted MenuItems.

Enhancements:

  • Extend HighlightPanel with optional top and bottom bevel shadows while preserving existing single-direction shadow behavior.

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zqq-dora

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR implements a theme-aware 1px inset bevel for enabled MenuItem highlights using DTK palettes and BoxInsetShadow layers, while also changing related menu geometry/separator styling and adding detailed rendering documentation.

Sequence diagram for theme-aware MenuItem highlight rendering

sequenceDiagram
    participant MenuItem
    participant ColorSelector
    participant BoxInsetShadow
    participant DTKPalette

    MenuItem->>MenuItem: highlighted = enabled && (hovered || subMenu.visible)
    MenuItem->>ColorSelector: menuItemInnerShadow
    ColorSelector->>DTKPalette: select theme color
    DTKPalette-->>ColorSelector: top or bottom shadow color
    MenuItem->>BoxInsetShadow: show top inset shadow
    MenuItem->>BoxInsetShadow: show bottom inset shadow
    BoxInsetShadow-->>MenuItem: render rounded 1px bevel
Loading

Flow diagram for MenuItem highlight bevel states

flowchart TD
    A[MenuItem state changes] --> B{enabled and hovered or subMenu.visible?}
    B -- No --> C[Hide inset shadows]
    B -- Yes --> D[Show HighlightPanel]
    D --> E{Dark theme?}
    E -- No --> F[Bottom shadow: black 20%]
    E -- Yes --> G[Top highlight: white 10%]
    E -- Yes --> H[Bottom shadow: black 24%]
    F --> I[Render rounded 1px inner bevel]
    G --> I
    H --> I
Loading

File-Level Changes

Change Details Files
Adds theme-aware inset bevel layers to highlighted menu items.
  • Defines light/dark top and bottom inset-shadow palettes.
  • Adds conditional BoxInsetShadow layers with 1px blur, directional offsets, and 6px corner radius.
  • Limits highlighted state to enabled items and uses menu-specific item padding.
qt6/src/qml/FlowStyle.qml
qt6/src/qml/MenuItem.qml
Aligns menu geometry and separator styling with the documented rendering specification.
  • Adjusts menu top padding, item height, item padding, and separator spacing.
  • Adds a dark-theme separator line color.
qt6/src/qml/FlowStyle.qml
Documents MenuItem hover/highlight rendering and exposes it through the documentation index.
  • Documents highlight layers, theme-dependent colors, geometry, display conditions, implementation references, and acceptance checks.
  • Adds Menu.md to the docs index.
qt6/src/docs/Menu.md
qt6/src/docs/README.md
Updates MenuItem source copyright coverage.
  • Extends the copyright year range through 2026.
qt6/src/qml/MenuItem.qml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

Hi @zqq-dora. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="qt6/src/docs/README.md" line_range="17" />
<code_context>
 |---|---|
 | 本主文档 | 统一目的、文档结构、状态维度、效果术语、颜色规则、维护和验收要求 |
 | [Button.md](Button.md) | 普通 Button 的外形、内容、各渲染元素的显示条件、颜色和参数;不覆盖选中、高亮变体 |
+| [Menu.md](Menu.md) | MenuItem 悬浮高亮背景的填充与 1px 底部内阴影;不含菜单容器面板、分隔符等 |
 | [QML 维护约束](../qml/.AGENTS) | 简短约束代码与文档同步,引用本规范,不重复详细规则 |

</code_context>
<issue_to_address>
**nitpick:** The documentation index describes Menu.md as covering only the 1px bottom inner shadow, omitting the dark-theme 1px top highlight that the new implementation and Menu.md itself document. Readers using the index receive an incomplete description of the supported rendering.

**Suggested fix:** Update the description to mention both the bottom shadow and the dark-theme top highlight.

```suggestion
| [Menu.md](Menu.md) | MenuItem 悬浮高亮背景的填充与 1px 底部内阴影、暗色主题 1px 顶部高光;不含菜单容器面板、分隔符等 |
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread qt6/src/docs/README.md Outdated
|---|---|
| 本主文档 | 统一目的、文档结构、状态维度、效果术语、颜色规则、维护和验收要求 |
| [Button.md](Button.md) | 普通 Button 的外形、内容、各渲染元素的显示条件、颜色和参数;不覆盖选中、高亮变体 |
| [Menu.md](Menu.md) | MenuItem 悬浮高亮背景的填充与 1px 底部内阴影;不含菜单容器面板、分隔符等 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: The documentation index describes Menu.md as covering only the 1px bottom inner shadow, omitting the dark-theme 1px top highlight that the new implementation and Menu.md itself document. Readers using the index receive an incomplete description of the supported rendering.

Suggested fix: Update the description to mention both the bottom shadow and the dark-theme top highlight.

Suggested change
| [Menu.md](Menu.md) | MenuItem 悬浮高亮背景的填充与 1px 底部内阴影;不含菜单容器面板、分隔符等 |
| [Menu.md](Menu.md) | MenuItem 悬浮高亮背景的填充与 1px 底部内阴影、暗色主题 1px 顶部高光;不含菜单容器面板、分隔符等 |

@zqq-dora
zqq-dora force-pushed the pr-menu-hover-shadow branch 2 times, most recently from a69815d to 544b77b Compare September 30, 2026 05:20
Comment thread qt6/src/qml/MenuItem.qml Outdated
}
}
// 1px top inset highlight — white 10%, follows rounded corners.
BoxInsetShadow {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是所有的 HighlightPanel 都需要的,还是只有MenuItem才需要的呀,是不是可以放在HighlightPanel里去实现,另外
HighlightPanel 的innerShadowColor是不是可以完成这个效果,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前这个内阴影效果只 MenuItem 需要,不是所有 HighlightPanel 场景都适用,所以放在 MenuItem 里单独实现。HighlightPanel 里注释掉的 BoxInsetShadow 只有单方向(底部),而这里需要顶部 + 底部两道,且浅色/深色模式参数不同,在 HighlightPanel 里扩展会影响所有使用方。innerShadowColor 目前只有一道底部阴影的能力,不太适合直接用。

Thanks for the review! This inner shadow effect is currently only needed for MenuItem, not all HighlightPanel use cases, so it's implemented separately in MenuItem. The commented-out BoxInsetShadow in HighlightPanel only supports a single direction (bottom), while here we need top + bottom layers with different parameters for light/dark modes. Extending HighlightPanel would affect all consumers. innerShadowColor currently only has one bottom shadow capability, which doesn't quite fit this use case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

能不能扩展HiightPanel这个 公共接口去实现MenuItem的效果,类似之前Button里的BoxPanel

@zqq-dora
zqq-dora force-pushed the pr-menu-hover-shadow branch from 544b77b to a97c184 Compare September 30, 2026 06:33
@zqq-dora

Copy link
Copy Markdown
Author

已按建议改为通过 HighlightPanel 公共接口实现。扩展了 HighlightPanel,新增 bevelShadowColor1/bevelShadowColor2 两个普通 color 属性用于顶部+底部内阴影,默认透明,不影响现有调用方。MenuItem 通过 control.D.ColorSelector 解析调色板颜色后传入 HighlightPanel,不再在外面单独加 BoxInsetShadow。结构参照 BoxPanel 的 innerShadowColor1/innerShadowColor2 方式。


Updated per review suggestion to use the HighlightPanel public interface. Extended HighlightPanel with bevelShadowColor1/bevelShadowColor2 (plain color) for top + bottom inner shadows, transparent by default so existing callers are unaffected. MenuItem resolves palette colors via control.D.ColorSelector and passes them to HighlightPanel, no longer adding standalone BoxInsetShadow outside. The structure follows the same pattern as BoxPanel's innerShadowColor1/innerShadowColor2.

Comment thread qt6/src/qml/HighlightPanel.qml Outdated
}

// Top inner shadow (bevel highlight).
BoxInsetShadow {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个也应该用Loader进行管理,增加性能,

Comment thread qt6/src/qml/MenuItem.qml Outdated
}

background: Item {
id: backgroundItem

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个id没被使用到,不应该添加,

Comment thread qt6/src/qml/HighlightPanel.qml Outdated
Loader {
anchors.fill: backgroundRect
active: panel.innerShadowColor
z: D.DTK.AboveOrder

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

默认应该不需要设置z轴,

Comment thread qt6/src/qml/MenuItem.qml Outdated
property D.Palette textColor: control.highlighted ? DS.Style.checkedButton.text
: DS.Style.menu.itemText
property D.Palette subMenuBackgroundColor: DS.Style.menu.subMenuOpenedBackground
property D.Palette menuItemInnerShadow: DS.Style.menu.itemHighlightInnerShadow

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个需要外面设置么?如果不需要,是不是可以放在不用暴露,放在background里定义即可,

@zqq-dora
zqq-dora force-pushed the pr-menu-hover-shadow branch from a97c184 to cedc6cf Compare September 30, 2026 07:01
@zqq-dora

Copy link
Copy Markdown
Author

已根据评审意见逐条修改:

  1. BoxInsetShadow 改用 Loader 管理,active 绑定颜色透明度,提升性能
  2. 移除未使用的 backgroundItem id
  3. 移除 z 轴设置
  4. 移除 bevelShadowOffsetY1/bevelShadowOffsetY2 公开属性,offset 直接定义在内部

Updated per review comments:

  1. BoxInsetShadow now managed by Loader, active bound to color opacity for better performance
  2. Removed unused backgroundItem id
  3. Removed z-order setting
  4. Removed bevelShadowOffsetY1/bevelShadowOffsetY2 public properties, offsets defined internally

Comment thread qt6/src/qml/HighlightPanel.qml Outdated
// Dual-direction inner shadow colors for consumers that need a
// top + bottom bevel (e.g. MenuItem hover). Callers resolve palette
// colors via their own ColorSelector and pass plain colors here.
property color bevelShadowColor1: "transparent"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照之前的这个来编写吧,
shadowColor: panel.D.ColorSelector.innerShadowColor

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已按这个写法修改:bevelShadowColor1/bevelShadowColor2 改为 property D.Palette(默认 null),shadowColor 绑定到 panel.D.ColorSelector.bevelShadowColor1/2,与同文件的 innerShadowColor 写法一致,颜色随主题自动切换。MenuItem 不再在外面解析颜色,直接把样式调色板传给 HighlightPanel。其余评审意见(移除多余 z 轴、不暴露不必要的控件属性)也已一并处理,并 squash 为单个提交。


Updated per this suggestion: bevelShadowColor1/bevelShadowColor2 are now property D.Palette (default null), with shadowColor bound to panel.D.ColorSelector.bevelShadowColor1/2, matching the innerShadowColor pattern in the same file so colors follow theme changes automatically. MenuItem no longer resolves colors itself; it passes the style palettes directly to HighlightPanel. The remaining review comments (removing the extra z axis, not exposing unnecessary control properties) are also addressed, all squashed into a single commit.

Add a subtle inner-shadow bevel to MenuItem hover/highlight state,
matching the ToolButton checked-state approach using BoxInsetShadow.

FlowStyle.qml:
- Add itemHighlightInnerShadow palette (bottom): 20% black (light) / 24% black (dark)
- Add itemHighlightInnerShadowTop palette (top): transparent (light) / 10% white (dark)

HighlightPanel.qml:
- Extend with bevelShadowColor1/2 (D.Palette, default null) for top + bottom
  bevel inner shadows, inactive by default so existing callers are unaffected
- Resolve bevel colors via panel.D.ColorSelector.bevelShadowColor1/2,
  following the same pattern as innerShadowColor
- Restore the legacy innerShadowColor Loader (managed by Loader for performance)

MenuItem.qml:
- Pass DS.Style.menu.itemHighlightInnerShadowTop/InnerShadow directly to
  HighlightPanel's bevelShadowColor1/2; colors resolve via HighlightPanel's
  ColorSelector and follow theme changes automatically

Menu.md:
- Document MenuItem hover-highlight rendering
README.md:
- Add Menu.md to the docs index, covering bottom inner shadow and
  dark-theme top highlight

Light mode: only bottom 1px inner shadow (20% black).
Dark mode: top 1px white 10% highlight + bottom 1px black 24% inner shadow.

Color values use DTK palettes so they follow theme changes automatically.
@zqq-dora
zqq-dora force-pushed the pr-menu-hover-shadow branch from 14cd102 to 82884f6 Compare September 30, 2026 08:08

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants