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