@@ -27,7 +27,10 @@ QtObject {
2727 /// Style object passed from the scope
2828 property var style: {}
2929
30− /// Calculate luminance of the passed color
30+ /*! \brief Calculate luminance of the passed color
31+
32+ \note If not fully opaque, luminance is dependant on blending.
33+ */
3134 function luminance(color) {
3235 return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
3336 }
@@ -36,6 +39,17 @@ QtObject {
3639 // FIXME: should be taken from the theme
3740 readonly property color foreground: style && "foreground-color" in style ? style["foreground-color"] : "grey"
3841
39− /// Color used for text and symbolic icons
42+ /// Color used for the overall background
4043 readonly property color background: style && "background-color" in style ? style["background-color"] : "transparent"
44+
45+ /*! \brief Luminance threshold for switching between fore and background color
46+
47+ \note If background colour is not fully opaque, it's not taken into account.
48+ */
49+ readonly property real threshold: background.a !== 1.0 ? d.foregroundLuminance : (d.foregroundLuminance + d.backgroundLuminance) / 2
50+
51+ property var d: QtObject {
52+ readonly property real foregroundLuminance: luminance(foreground)
53+ readonly property real backgroundLuminance: luminance(background)
54+ }
4155}