openhab / openhab-core

Core framework of openHAB
https://www.openhab.org/
Eclipse Public License 2.0
929 stars 428 forks source link

Add a (dynamic) background property to LinkableWidget #4017

Open jimtng opened 10 months ago

jimtng commented 10 months ago

Feature request: add a background property to org.openhab.core.model.sitemap.sitemap.LinkableWidget, which can be set to:

Use the same dynamic syntax as icon, which means based on the condition, the background can change to any of the above.

This will affect the Sitemap.xtext, and all the UI implementations.

Coordination between maintainers

Notify maintainers of other UIs: @openhab/webui-maintainers @openhab/android-maintainers @openhab/ios-maintainers

Checklist for implementation:

lolodomo commented 10 months ago

As a reminder, the syntax defines 4 widgets as LinkableWidget, text, group, image and frame. Text, group and image show the text/group/image and allow to sub page when clicking on it. Frame is a particular case, it contains a set of other widgets. What is your logic to consider only these widgets ?

What would be exactly the zone to be considered for the background ? The full zone containing the icon, the label, the value and controls ?

Regarding the linkable image widget, wouldn't it be strange to define a background image while the purpose is to render an image as foreground ?

Or is your idea to define a property not for the widget itself but for the sub page that is opened when clicking on the widget ?

Maybe a good idea for frame at least.

jimtng commented 10 months ago

Ideally we can choose whether the colours would apply to either the widget before it opens the subpage, or to the subpage.

But also I think it could be applied to other widgets too, e.g.switch, setpoint, etc. so perhaps not just to LinkableWidget

It's basically a way to attract attention to specific (set of) controls and a more visual grouping of controls (e.g. when applied to a frame)

What would be exactly the zone to be considered for the background ? The full zone containing the icon, the label, the value and controls ?

It would be the full zone containing the icon, label, value, and controls, yes.

Regarding the linkable image widget, wouldn't it be strange to define a background image while the purpose is to render an image as foreground ?

Perhaps so, but that is up to the sitemap creator to decide. It could be beneficial actually, e.g. to provide contrast to the image, e.g. a dark / black background against mostly bright images and vice versa, just as an example of one scenario. Of course this is optional and one can always not set the background, leaving it the same as it is now.

jimtng commented 10 months ago

Example (but please pardon my poor choice of colors, just needed to whip up something quick)

image

Contrast that with a sea of buttons here in a uniform background

image

I realise that this is a matter of taste though.

maniac103 commented 10 months ago

Maybe a good idea for frame at least.

Not sure. In the case of the Android app, a frame is rendered just as a title bar. I don't see how we could display one image below all rows belonging to that frame (frame header + all children).

As for the request in general, I don't really see it work well with e.g. day/night theme switching. Maybe one could do it when restricting to a given color set (like the font colors), which then could be mapped to a theme dependent color. But I'm really unsure whether it's worth the effort, at least as long as there isn't a more compelling use case than the one above ;-)