Bug 159358 - Incorrect background color for some dialog controls on Windows or with Qt-based VCL plugins
Summary: Incorrect background color for some dialog controls on Windows or with Qt-bas...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
24.8.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: KDE, KF5 Qt6 158531
  Show dependency treegraph
 
Reported: 2024-01-24 12:32 UTC by Heiko Tietze
Modified: 2024-09-20 15:24 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot (18.75 KB, image/png)
2024-01-24 12:32 UTC, Heiko Tietze
Details
Screenshot on Windows (38.61 KB, image/png)
2024-01-24 15:28 UTC, Michael Weghorn
Details
DialControl with COL_TRANSPARENT background (17.22 KB, image/png)
2024-01-25 15:36 UTC, Heiko Tietze
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Heiko Tietze 2024-01-24 12:32:08 UTC
Created attachment 192141 [details]
Screenshot

The render context using GetDialogColor() is supposed to blend into the dialog window. That works for gtk3 and gen but not qt5/qt6. An example is the DialControl (Shape: Properties > Rotation).

For better illustration I changed the Window Background via System Setting > Appearance > Color.
Comment 1 Heiko Tietze 2024-01-24 12:35:25 UTC
Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 52188252bb5d44e15266b84b771599a453438ba6
UI render: default; VCL: kf5/qt6/gen/gtk3 (cairo+xcb) (same for Wayland)
Comment 2 Rafael Lima 2024-01-24 13:35:57 UTC
I can confirm this case in the Rotation tab.

Tested with

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 52188252bb5d44e15266b84b771599a453438ba6
CPU threads: 12; OS: Linux 6.5; UI render: default; VCL: kf5 (cairo+wayland)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Calc: CL threaded
Comment 3 Michael Weghorn 2024-01-24 15:28:28 UTC
Created attachment 192151 [details]
Screenshot on Windows
Comment 4 Michael Weghorn 2024-01-24 15:56:01 UTC
This is similar on Windows, s. attachment 192151 [details] (with additional annotations for below).

(In reply to Heiko Tietze from comment #0)
> The render context using GetDialogColor() is supposed to blend into the
> dialog window. That works for gtk3 and gen but not qt5/qt6. An example is
> the DialControl (Shape: Properties > Rotation).
> 
> For better illustration I changed the Window Background via System Setting >
> Appearance > Color.

Earlier related discussion in Gerrit:
https://gerrit.libreoffice.org/c/core/+/160460/comments/fd492d75_aaddd02b

As mentioned there, I'm not sure that the dialog color is meant to be the same here.
The control is actually within a tab page, which has a different background from the dialog color.
It seems to me like it might be necessary to distinguish between two different colors, e.g.:

* the one used for dialogs in general
* the one used for tab pages/panes

attachment 192151 [details] shows what I mean.

For Qt-based VCL plugins, the background color of the tab page is drawn in QtGraphics_Controls::drawNativeControl , the `type == ControlType::TabPane && part == ControlPart::Entire`case, probably similar for Windows.

So if it's necessary to explicitly draw a background using a specific color, maybe it would be necessary to use/introduce a specific color for that, and not just use the dialog color?
(Or define more clearly what DialogColor is meant to be, maybe Qt and Win should set it differently, if it's not needed for what my screenshot labels dialog color or anything else.)

As mentioned in the discussion in the Gerrit change the existing, `GetActiveTabColor` sounds like it might be the right color, but at least currently doesn't behave as expected either for misc cases.

Having a way to avoid having to explicitly draw any background seems like it might be the most elegant solution to me if reasonably possible, not sure whether/how that already works.


One control that seems to do this right in a quick test is `SvxPageWindow`, s. `SvxPageWindow::DrawPage`, which seems to have some smart handling using `bResetBackground` to decide whether or not the background needs to be drawn explicitly.
In Writer: "Format" -> "Page Style" -> "Headers" tab (the preview of the page)


`TabPage::ImplInit` also has something that sounds like some approach along that line has been implemented for some case at least:
https://git.libreoffice.org/core/+/863a4cde77a5045d44b1da583f00c0a72762f19a/vcl/source/window/tabpage.cxx#67

    // if the tabpage is drawn (ie filled) by a native widget, make sure all controls will have transparent background
    // otherwise they will paint with a wrong background

The `IsNativeControlSupported` call there currently doesn't return `true` for the qt case, but doing so in a quick hack doesn't make any difference for the case of the specific widget mentioned here that explicitly draws a background.
Comment 5 Heiko Tietze 2024-01-25 15:36:51 UTC
Created attachment 192163 [details]
DialControl with COL_TRANSPARENT background

Using COL_TRANSPARENT is also not a success as it makes the background white for gtk3.

Quick and dirty test with

+++ b/svx/source/dialog/dialcontrol.cxx
@@ -112,7 +112,7 @@ void DialControlBmp::DrawElements( const OUString& rText, Degree100 nAngle )
 
 Color DialControlBmp::GetBackgroundColor() const
 {
-    return GetSettings().GetStyleSettings().GetDialogColor();
+    return COL_TRANSPARENT;// GetSettings().GetStyleSettings().GetDialogColor();
 }
Comment 6 Lebsack 2024-09-20 15:24:20 UTC Comment hidden (spam)