Repository navigation
fix(editor): render dropdown arrows as vectors to keep them sharp under fractional scaling #734
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // SPDX-FileCopyrightText: 2017 - 2023 UnionTech Software Technology Co., Ltd. | ||
| // SPDX-FileCopyrightText: 2017 - 2026 UnionTech Software Technology Co., Ltd. | ||
| // | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
|
|
||
|
|
@@ -372,7 +372,6 @@ QIcon DDropdownMenu::createIcon() | |
| arrowPixmap = setSvgColor(color); | ||
| }else { | ||
| textColor = dpalette.color(DPalette::WindowText); | ||
| arrowPixmap = m_arrowPixmap; | ||
| } | ||
|
|
||
| // 根据字体大小设置icon大小,按计算的字体高度,而非从字体文件中读取的高度(部分字体中英文高度不同) | ||
|
|
@@ -409,7 +408,17 @@ QIcon DDropdownMenu::createIcon() | |
| //arrowPixmap=arrowPixmap.scaled(iconW,iconH,Qt::IgnoreAspectRatio,Qt::SmoothTransformation); | ||
|
|
||
| //qDebug()<<"==================="<<arrowPixmap.rect().height(); | ||
| painter.drawPixmap(QRectF(fontWidth,(totalHeigth-iconH)/2,iconW,iconH),arrowPixmap,arrowPixmap.rect()); | ||
| if (m_bPressed) { | ||
| painter.drawPixmap(QRectF(fontWidth,(totalHeigth-iconH)/2,iconW,iconH),arrowPixmap,arrowPixmap.rect()); | ||
| } else { | ||
| // 箭头直接按当前图标密度矢量渲染,与文字密度保持一致。 | ||
| // 原实现使用构造期按当时缩放比缓存的位图,分数倍缩放比在窗口创建后 | ||
| // 才被主题层异步应用,缓存位图被拉伸显示而模糊(PMS 171749)。 | ||
| // 注意:不可改用 devicePixelRatioF() 自行光栅化——分数缩放下该值不可靠。 | ||
| const QString arrowTheme = (dpalette.color(QPalette::Background).lightness() < 128) ? "dark" : "light"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 High · Arrows use the wrong theme color When the editor theme differs from the button or application palette, Select the normal-state SVG from the theme supplied to Also at Prompt for AI agentsIn `src/widgets/ddropdownmenu.cpp` at line 418:
**Arrows use the wrong theme color**
When the editor theme differs from the button or application palette, `createIcon()` selects the SVG from the button palette, while `BottomBar::setPalette()` assigns the application palette to the buttons and supplies the editor theme separately to `setTheme()`. The normal-state arrow therefore uses the wrong light/dark asset and can lose contrast against the bottom bar.
Select the normal-state SVG from the theme supplied to `setTheme()` rather than from the button palette.
Also at `src/widgets/ddropdownmenu.cpp:419`. |
||
| QSvgRenderer svgRender(QString(":/images/dropdown_arrow_%1.svg").arg(arrowTheme)); | ||
| svgRender.render(&painter, QRectF(fontWidth, (totalHeigth-iconH)/2.0, iconW, iconH)); | ||
| } | ||
|
|
||
| painter.end(); | ||
| return icon; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · Pressed arrows blur during scaling
When a dropdown is pressed before the fractional scale factor has finished applying,
setSvgColor()rasterizes the pressed-state arrow usingdevicePixelRatioF(), which can still reflect the old scale, so the arrow appears blurry while pressed.Render the pressed-state arrow through the vector-based path instead of using the bitmap rasterized by
setSvgColor().Prompt for AI agents