View Issue Details

IDProjectCategoryView StatusLast Update
0032779LazarusLCLpublic2017-12-16 10:35
ReporterHannah RittichAssigned ToMichl 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformGTK+OSDebian GNU/LinuxOS Version9
Product VersionProduct BuildSVN 
Target VersionFixed in Version1.9 (SVN) 
Summary0032779: TPanel has the wrong color when using clDefault.
DescriptionTPanels are often used to structure the GUI. Hence, it is usually assumed that the background color of the panel is the same as the background color of the form that owns the panel. However, when both, the panel and the form, are assigned the color clDefault, then the two colors are not the same.

In this case, the panel is assigned the color clBtnFace and the form is assigned clForm. When using a theme where these colors differ, many GUIs look odd.
Steps To ReproduceChoose a theme with different colors for clBtnFace and clForm. For example use the GTK+ theme Numix. Create a Form that contains a Panel and set the background color for both components to clDefault.
Additional InformationI have included a patch that corrects this behavior.
TagsNo tags attached.
Fixed in Revision56684
LazTarget-
Widgetset
Attached Files
  • fix-panel-color.diff (919 bytes)
    Index: lcl/widgetset/wscontrols.pp
    ===================================================================
    --- lcl/widgetset/wscontrols.pp    (Revision 56636)
    +++ lcl/widgetset/wscontrols.pp    (Arbeitskopie)
    @@ -50,6 +50,12 @@
      { dctBrush } clBtnFace,
      { dctFont  } clBtnText
       );
    +
    +  { Default Panel colors }
    +  DefPnlColors: array[TDefaultColorType] of TColor = (
    + { dctBrush } clForm,
    + { dctFont  } clWindowText
    +  );
     type
       { TWSDragImageList }
    
    Index: lcl/widgetset/wsextctrls.pp
    ===================================================================
    --- lcl/widgetset/wsextctrls.pp    (Revision 56636)
    +++ lcl/widgetset/wsextctrls.pp    (Arbeitskopie)
    @@ -343,7 +343,7 @@
    
     class function TWSCustomPanel.GetDefaultColor(const AControl: TControl; const ADefaultColorType: TDefaultColorType): TColor;
     begin
    -  Result := DefBtnColors[ADefaultColorType];
    +  Result := DefPnlColors[ADefaultColorType];
     end;
    
     end.
    
    fix-panel-color.diff (919 bytes)

Activities

Hannah Rittich

2017-12-05 20:49

reporter  

fix-panel-color.diff (919 bytes)
Index: lcl/widgetset/wscontrols.pp
===================================================================
--- lcl/widgetset/wscontrols.pp    (Revision 56636)
+++ lcl/widgetset/wscontrols.pp    (Arbeitskopie)
@@ -50,6 +50,12 @@
  { dctBrush } clBtnFace,
  { dctFont  } clBtnText
   );
+
+  { Default Panel colors }
+  DefPnlColors: array[TDefaultColorType] of TColor = (
+ { dctBrush } clForm,
+ { dctFont  } clWindowText
+  );
 type
   { TWSDragImageList }

Index: lcl/widgetset/wsextctrls.pp
===================================================================
--- lcl/widgetset/wsextctrls.pp    (Revision 56636)
+++ lcl/widgetset/wsextctrls.pp    (Arbeitskopie)
@@ -343,7 +343,7 @@

 class function TWSCustomPanel.GetDefaultColor(const AControl: TControl; const ADefaultColorType: TDefaultColorType): TColor;
 begin
-  Result := DefBtnColors[ADefaultColorType];
+  Result := DefPnlColors[ADefaultColorType];
 end;

 end.
fix-panel-color.diff (919 bytes)

Zeljan Rikalo

2017-12-07 00:05

developer   ~0104544

@Michl, you can apply that patch. It's safe and really fixes problem.

Michl

2017-12-07 08:05

developer   ~0104551

Last edited: 2017-12-07 08:09

View 3 revisions

Yes and no. After the patch, the canvas of the panel is shown with clForm (which is much better then current behaviour) but the color of the panel border still remain in the wrong color. I tested it on Linux Mint with a orange button color and a gray form color. Other apps, I checked, don't behave like this.

I also checked other widgetsets and controls and see some minor issues but I'm not finished yet.

PS: I would name it DefFrmColors, as these are the form colors. So it would be more clear, if other controls like TWSTabSheet, TWSStatusBar, TWSCustomStaticText etc. also take this colors, what colors are meant. But this is nitpick.

Zeljan Rikalo

2017-12-07 09:52

developer   ~0104559

With QtWidgetset: TPanel as clDefault uses clBackground while TForm uses clForm (same as inside Qt lib).
Now I see in your patch clForm. There should be clBackground instead of clForm.

Hannah Rittich

2017-12-07 15:56

reporter   ~0104568

I want to add a little to the discusstion.

The current behavior of TPanel is, that it takes the background color of the control that owns the panel. Only, if the owner color is set to clDefault, the panel uses clBtnFace as its color.

It might be possible to call the method GetDefaultColor on the owner of the control. I have not tried this, though.

Zeljan Rikalo

2017-12-08 22:26

developer   ~0104598

clBtnFace is NOT default color of panel under gtk2. clBackground is correct color.

Michl

2017-12-09 22:16

developer   ~0104614

@Zeljan: Sorry for the delay. As I can see, you already use this setting in Qt and Qt5 in:

class function TQtWSCustomPanel.GetDefaultColor(const AControl: TControl;
  const ADefaultColorType: TDefaultColorType): TColor;
const
  DefColors: array[TDefaultColorType] of TColor = (
 { dctBrush } clBackground,
 { dctFont } clBtnText
  );
begin
  Result := DefColors[ADefaultColorType];
end;

So I think this can be removed there, if we use the patch in WSControls or we do the same for: class function TGtk2WSCustomPanel.GetDefaultColor

What do you think?

Maybe I should assign this issue to you, as you are more capable here?!

Zeljan Rikalo

2017-12-10 01:15

developer   ~0104616

Just do the same for TGtk2WSCustomPanel.GetDefaultColor

Michl

2017-12-10 11:10

developer   ~0104620

Resolved, as Zeljan recommended, in trunk revision 56684. Please test and close if ok.

Hannah Rittich

2017-12-16 10:35

reporter   ~0104757

Thank you.

Issue History

Date Modified Username Field Change
2017-12-05 20:49 Hannah Rittich New Issue
2017-12-05 20:49 Hannah Rittich File Added: fix-panel-color.diff
2017-12-05 21:01 Marco van de Voort Project FPC => Lazarus
2017-12-05 23:32 Michl Assigned To => Michl
2017-12-05 23:32 Michl Status new => assigned
2017-12-07 00:05 Zeljan Rikalo LazTarget => -
2017-12-07 00:05 Zeljan Rikalo Note Added: 0104544
2017-12-07 00:05 Zeljan Rikalo Status assigned => confirmed
2017-12-07 08:05 Michl Note Added: 0104551
2017-12-07 08:09 Michl Note Edited: 0104551 View Revisions
2017-12-07 08:09 Michl Note Edited: 0104551 View Revisions
2017-12-07 09:52 Zeljan Rikalo Note Added: 0104559
2017-12-07 15:56 Hannah Rittich Note Added: 0104568
2017-12-08 22:26 Zeljan Rikalo Note Added: 0104598
2017-12-09 22:16 Michl Note Added: 0104614
2017-12-10 01:15 Zeljan Rikalo Note Added: 0104616
2017-12-10 11:10 Michl Fixed in Revision => 56684
2017-12-10 11:10 Michl Note Added: 0104620
2017-12-10 11:10 Michl Status confirmed => resolved
2017-12-10 11:10 Michl Fixed in Version => 1.9 (SVN)
2017-12-10 11:10 Michl Resolution open => fixed
2017-12-16 10:35 Hannah Rittich Note Added: 0104757