Skip to content
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

Failing to change the background color of a label #6

Closed
tmnyoni opened this issue Jul 10, 2021 · 1 comment
Closed

Failing to change the background color of a label #6

tmnyoni opened this issue Jul 10, 2021 · 1 comment

Comments

@tmnyoni
Copy link
Contributor

tmnyoni commented Jul 10, 2021

I seem to be failing to change the colour of the label. I wonder if I am doing it wrong or there is a bug.

This is my code:

widgets::label_builder fuel_caption(coupon_details_pane.get());
	fuel_caption()
		.text("Fuel")
		.color_text(caption_color_)
		.color_fill().green();

I also tried:

.color_fill({0, 0, 0, 100});

And:

.color_fill().get_green();
@alecmus
Copy link
Owner

alecmus commented Jul 10, 2021

Labels, by design, do not have a background. This is partly because the actual rectangular area used by a label is determined not by the co-ordinates specified through the .rect property, but by the actual contents of the label (the .rect property just defines the maximum area that the label is allowed to occupy). As such, if you need to add a background to a label you need to use the rectangle widget. Just add a rectangle and add a label on top of it (using same .rect coordinates).

To see that the .color_fill property is not used at all by the label check the implementation file here.

@tmnyoni tmnyoni closed this as completed Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants