Lazarus

Using the Lazarus IDE => Designer => Topic started by: bpranoto on November 01, 2020, 12:24:06 pm

Title: Black background on object's inspector combobox options
Post by: bpranoto on November 01, 2020, 12:24:06 pm
I just installed lazarus 2.0.10/fpc 3.2.0

In the form's object inspector if I click the dropdown button of a property which is a combobox, the options displayed have a black on black color so the unhilited texts are invisible.

Please see the screenshot attached.

O/S: Linux ubuntu 18.04

What is the configuration option to fix it?

Title: Re: Black background on object's inspector combobox options
Post by: Sieben on December 01, 2020, 09:45:51 pm
Just want to raise this once more, because it is in fact sort of annoying and it does not seem to be fixed with trunk either. There has also been a bug report one and a half year ago:

https://bugs.freepascal.org/view.php?id=35375 (https://bugs.freepascal.org/view.php?id=35375)

though it is a bit misleading in that it mentions DBComboBox.

I can confirm this for Linux Ubuntu 16.04 / GTK2 as well, and as well did not find any settings yets to correct this with IDE / Objectinspector options.
Title: Re: Black background on object's inspector combobox options
Post by: winni on December 01, 2020, 11:47:41 pm
Hi!

Some people might think this is not fair, BUT:

Numer One in "This does not work - that does not work" is the rotten Apple. No discussion now.
But Numer Two is allways Ubuntu.

Based on Debian. Debian does not know nothing about desktops and is always too late with fixing errors. It is a good and stable server system. Point.

Ubuntu is know to be full of errors especialy concerning the desktop.

There are so many Linux around which bevave well, have knowledge about different desktops and cause less trouble with fpc/Lazarus.

In Germany Ubuntu is often used in school because it fits to the knowledge of the teachers.
But schools out forever. Become adult and use some other Linux.
I avoid name dropping.
It's about the problems of Ubuntu.

I have never seen such a dropdown-black-box like above.
With a lot of different Linux and Lazarus - even Debian.

So change your Linux-OS.
Not to start a  flame-war.
Just to reduce the problems.

Winni
Title: Re: Black background on object's inspector combobox options
Post by: lucamar on December 02, 2020, 12:37:53 am
I have never seen such a dropdown-black-box like above.
With a lot of different Linux and Lazarus - even Debian.

So change your Linux-OS.

I have never seen it in any Ubuntu system either, and I've been using quite a lot of them with quite a lot of differents desktops (Ubuntu, Xubuntu Lubuntu, Kubuntu, ...) since 2006 and I've heard of all kind of weird problems with other distros, so no: it's not fair.

This really seems to be just a weird iteraction between the system's theme and Lazarus widgetset, probably agravated by the use of Unity in Ubuntu 16. One small test you could perform would be to see if it also happens if you restart in a gnome-fallback session or if you update to, say, Ubuntu 18. Or change your theme; way easier than changing to another distro ;)
Title: Re: Black background on object's inspector combobox options
Post by: Zoran on December 02, 2020, 11:56:36 am
But... Changing the development distribution or desktop manager will not solve that, when you put a combo box on a form, you don't know if the bug will appear in your application on your user's desktop.

Title: Re: Black background on object's inspector combobox options
Post by: Sieben on December 04, 2020, 09:16:01 pm
Quote from: Zoran
But... Changing the development distribution or desktop manager will not solve that, when you put a combo box on a form, you don't know if the bug will appear in your application on your user's desktop.

It does not seem to be a bug with the component or widgetset - a standard TComboBox or TDBComboBox will draw correct with white text on black background. Had another look today and the problem seems to be due to the last line of this piece of code in TOICustomPropertyGrid.ValueComboBoxDrawItem in ObjectInspector.pp:

Code: Pascal  [Select][+][-]
  1.     FontColor := ValueComboBox.Canvas.Font.Color;
  2.     ValueComboBox.Canvas.Font.Assign(FDefaultValueFont);
  3.     if odSelected in State then
  4.       ValueComboBox.Canvas.Font.Color := FontColor
  5.     else
  6.       ValueComboBox.Canvas.Font.Color := clWindowText;
  7.  

which results in black on black with every theme that uses black as background color for combobox dropdowns. Changing that to clHighLightText at least fixes the problems with my setup here, but is not a general solution, of course...
Title: Re: Black background on object's inspector combobox options
Post by: wp on December 04, 2020, 10:58:15 pm
What's wrong with clWindowText? It is the color provided by the widgetset/themeServices for text on a window background painted in color clWindow. In bright themes, clWindow is bright (usually white), and clWindowText is dark (usually black). But in dark themes, clWindow is dark and clWindowText is bright.

I just checked it on a Mint VM - see following code and attached screenshots. So, nothing wrong with the cited piece of code.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Paintbox1Paint(Sender: TObject);
  2. begin
  3.   with Paintbox1 do
  4.   begin
  5.     Canvas.Brush.Color := clWindow;
  6.     Canvas.FillRect(0, 0, Width, Height);
  7.     Canvas.Pen.Color := clWindowText;
  8.     Canvas.Line(0, 0, Width,Height);
  9.     Canvas.Line(0, Height, Width, 0);
  10.   end;
  11. end;
Title: Re: Black background on object's inspector combobox options
Post by: Sieben on December 04, 2020, 11:18:16 pm
Please have a look at the picture the original OP provided with his first post. That's what's wrong with it. Problem is, this apparently isn't really a 'dark theme' - just the menu background and the background of dropdowns are black. So clWindowText on this theme is black as well and this results in black on black.
Title: Re: Black background on object's inspector combobox options
Post by: wp on December 05, 2020, 01:32:39 am
OK. Since this seems to be a buggy theme you should fix the colors in Tools > Options > Object Inspector > Color > Background/Highlight Font Color/Property Name/etc  instead of editing the font color in the Lazarus object inspector sources.
Title: Re: Black background on object's inspector combobox options
Post by: Sieben on December 05, 2020, 02:09:17 am
Been there, tried that but - as stated in my first post here (Reply#1) - couldn't find any combination of settings that would fix this. However, the buggy theme works for standard comboboxes. And it is the default theme of a standard install. 
Title: Re: Black background on object's inspector combobox options
Post by: Sieben on December 07, 2020, 10:19:09 pm
Tried to get some more info on this - the buggy theme apparently is Unity7 which came with Ubuntu Xenial and will, after all I've read, sort of fade away with it. What I don't know, however, is whether there are similar desktop designs which feature a 'bright' theme with dark combobox dropdowns or menus. So the questions is whether it's worth to put effort in this. On the other hand Xenial might be around for some more time than it's supported for afaik it's the last 32bit Ubuntu distribution.

Btw, this is what the colorbox in the IDE settings looks like, and this time the standard LCL TColorBox is affected as well:
Title: Re: Black background on object's inspector combobox options
Post by: JuhaManninen on December 08, 2020, 10:29:38 am
I guess it could be fixed by a new setting for IDE ComboBoxes somewhere. A patch would be applied.
I set issue :
 https://bugs.freepascal.org/view.php?id=34240
related to issue :
 https://bugs.freepascal.org/view.php?id=35375
although they are a little different.
#34240 is about a custom drawn CheckBox made for OI. Both are related to themes.
People who use different themes and these issues bother, please provide patches to fix them.
Title: Re: Black background on object's inspector combobox options
Post by: Sieben on December 08, 2020, 02:30:41 pm
As for the OI combobox issue - which is the most annoying imo - I still think it should be possible to somehow test the background of the dropdown for 'brightness' and set Font.Color to either clWindowText or clHighLightText accordingly in the OnDrawItem handler of objectinspector.pp as posted above in Reply #5 and without introducing new color settings. I'd post a suggestion if I weren't such a noob when it comes to graphics. Maybe someone more knowledgeable might jump in...?

The TColorBox issue is a bit different, however. While the standard LCL TComboBox draws ok, TColorBox doesn't. This is not just an IDE issue, but a LCL one. A similar approach as suggested above should fix this too, but imo would have to be done in TColorBox.DrawItem method. Should I file another report on this one and relate it to #35375...?
Title: Re: Black background on object's inspector combobox options
Post by: szlbz on May 28, 2022, 02:22:10 pm
I just installed lazarus 2.0.10/fpc 3.2.0

In the form's object inspector if I click the dropdown button of a property which is a combobox, the options displayed have a black on black color so the unhilited texts are invisible.

Please see the screenshot attached.

O/S: Linux ubuntu 18.04

What is the configuration option to fix it?

open /lcl/include/customcombobox.inc
Code: Pascal  [Select][+][-]
  1. procedure TCustomComboBox.DrawItem(Index: Integer; ARect: TRect;
  2.   State: TOwnerDrawState);
  3. begin
  4.   //TControlCanvas(FCanvas).UpdateTextFlags;
  5.   {$ifdef linux}
  6.   FCanvas.FillRect(ARect);//Add this line
  7.   {$endif}
  8.   if Assigned(FOnDrawItem) then
  9.     FOnDrawItem(Self, Index, ARect, State)
  10.   else
  11.   begin
  12.     if not (odBackgroundPainted in State) then
  13.       FCanvas.FillRect(ARect);
  14.     InternalDrawItem(Self, FCanvas, ARect, Items[Index])
  15.   end;
  16. end;
  17.  

After modification, the problems of Object Inspector and combobox and colorbox are solved。
Title: Re: Black background on object's inspector combobox options
Post by: AlexTP on May 28, 2022, 02:30:02 pm
@szlbz
Is this a patch for LCL which is always needed? If so we need it in the bugtracker.

But it must be not {$ifdef linux} but {$ifdef LCLgtk2}. Because BSD systems use the same GTK2.
Title: Re: Black background on object's inspector combobox options
Post by: szlbz on May 28, 2022, 02:40:27 pm
@szlbz
Is this a patch for LCL which is always needed? If so we need it in the bugtracker.

But it must be not {$ifdef linux} but {$ifdef LCLgtk2}. Because BSD systems use the same GTK2.
Just tested, lclgtk2 does not work
Title: Re: Black background on object's inspector combobox options
Post by: wp on May 28, 2022, 02:41:14 pm
Be careful with this code. As I see in this discussion the combobox is painted correctly normally except for some themes on some Linux versions. The {$IFDEF Linux} directive will introduce some background flicker also for those situations in which the background issue does not occur.
Title: Re: Black background on object's inspector combobox options
Post by: Thaddy on May 28, 2022, 03:30:43 pm
The $ifdef by itself can not cause flicker. I guess you mean the code it contains? DoubleBuffering should fix that.
Title: Re: Black background on object's inspector combobox options
Post by: wp on May 28, 2022, 04:45:51 pm
The $ifdef by itself can not cause flicker. I guess you mean the code it contains?
Of course...

DoubleBuffering should fix that.
Not sure if this really is an option. Why should all the many gtk2 Linuxes and themes which do not show this issue be slowed down because of these rare combinations?
Title: Re: Black background on object's inspector combobox options
Post by: Thaddy on May 28, 2022, 05:56:21 pm
Double buffering is per control, so should not be an issue.
Title: Re: Black background on object's inspector combobox options
Post by: Thaddy on May 28, 2022, 06:12:39 pm
Based on Debian. Debian does not know nothing about desktops and is always too late with fixing errors. It is a good and stable server system. Point.
Ubuntu is still an impatient version of Debian. Yes Debian is conservative. It is done when it is done, just like FreePascal which is also conservative (to the extreme, I would sometimes sigh) and with good reason: user expectation should not be ruined by plethora of bugs. It is already difficult to keep users in line.
(Knowing about new features and do not  want to wait for thorough testing)
TinyPortal © 2005-2018