pharo icon indicating copy to clipboard operation
pharo copied to clipboard

Font in stylesheet is not applied to list

Open koendehondt opened this issue 6 months ago • 7 comments

Bug description

I like to apply a dark background color to a list and I like to apply a white font color. I would expect that a stylesheet as in the following code would yield the desired result, but is does not, as shown in the screenshot.

| box label list application |
label := SpLabelPresenter new
	label: 'Select a number:';
	yourself.
list := SpListPresenter new
	items: (1 to: 10);
	addStyle: 'listBackground';
	yourself.
box := SpBoxLayout newTopToBottom
	add: label expand: false;
	add: list;
	yourself.
application := SpApplication new
	addStyleSheetFromString: '.application [
		.listBackground [ Draw { #color: #16214A }, Font { #color: #FFFFFF } ]
	]';
	yourself.
SpPresenter new
	application: application;
	layout: box; open

Note that I clicked on number 6 and that the mouse pointer was hovering over number 9 when I took the screenshot.

How to set the list font color

Did I make a mistake in my code? According to what I read in the code, the stylesheet is correct, so I guess this is a bug.

It is also not clear to me how to apply a different selection color and a different hover color. Does Spec support that?

Version information:

  • OS: MacOS Sonoma
  • Version: 14.1.2
  • Pharo Version: 11

koendehondt avatar Dec 30 '23 17:12 koendehondt

Could you create your application first and add the application to create the presenters? There is a newApp: or something like that.

Ducasse avatar Dec 30 '23 17:12 Ducasse

@Ducasse

Do you mean like this?

| box label list application |
application := SpApplication new
	addStyleSheetFromString: '.application [
		.listBackground [ Draw { #color: #16214A }, Font { #color: #FFFFFF } ]
	]';
	yourself.
label := (SpLabelPresenter newApplication: application)
	label: 'Select a number:';
	yourself.
list := (SpListPresenter newApplication: application)
	items: (1 to: 10);
	addStyle: 'listBackground';
	yourself.
box := SpBoxLayout newTopToBottom
	add: label expand: false;
	add: list;
	yourself.
(SpPresenter newApplication: application)
	layout: box; open

It has the same result.

Screenshot 2023-12-30 at 22 58 01

koendehondt avatar Dec 30 '23 21:12 koendehondt

I did not check all presenters, but it does not work for SpTextInputFieldPresenter either. Consider this code:

| box input |
application := SpApplication new
	addStyleSheetFromString: '.application [
		.textBackground [ Draw { #color: #16214A }, Font { #color: #FFFFFF } ]
	]';
	yourself.
input := (SpTextInputFieldPresenter newApplication: application)
	text: 'Test';
	addStyle: 'textBackground';
	yourself.
box := SpBoxLayout newTopToBottom
	add: input expand: false;
	add: (SpListPresenter newApplication: application);
	yourself.
(SpPresenter newApplication: application)
	layout: box; open

At first, it looks like the white color is applied to the text:

Screenshot 2023-12-30 at 23 04 30

but let's select the text (all good so far):

Screenshot 2023-12-30 at 23 04 35

and let's start typing:

Screenshot 2023-12-30 at 23 04 49

Now the white text color is gone. The text color is black.

koendehondt avatar Dec 30 '23 22:12 koendehondt

Yes then I do not know. I really hope that soon we will have Toplo (the new widget library) so that people like you can spend time to improve it and let Morphic rest in peace. We should have a presentation of the new architecture end of Jan.

Ducasse avatar Dec 31 '23 16:12 Ducasse

Yes that would be great. I really look forward to Toplo. Do you think the presentation will be available by this month's Pharo Sprint? That would be a good time to talk about it.

koendehondt avatar Jan 01 '24 09:01 koendehondt

I don't know about Toplo, but this issue could be related to https://github.com/pharo-spec/Spec/issues/1256 So it could be closed here? @estebanlm

hernanmd avatar Feb 14 '24 19:02 hernanmd

@hernanmd @estebanlm This issue is related to https://github.com/pharo-spec/Spec/issues/1256, but it includes more issues than mentioned there. By closing this issue, that information would be lost. Should I add a comment to https://github.com/pharo-spec/Spec/issues/1256 with the extra issues mentioned here? Or is the link to this issue enough?

koendehondt avatar Feb 15 '24 05:02 koendehondt

Ultimately, the styling provided by the morphic backend is restrained to the limits of morphic itself. nothing in morphic allows to directly affect the row. this requires an enhancement on the way the style for lists/tables is applied, following what is implemented in SpMorphicProgressBarAdapter (which implements some "substyles" for the adapter).

estebanlm avatar Feb 20 '24 09:02 estebanlm