@@ -3,6 +3,7 @@ import QtQuick.Controls
33import QtQuick.Layouts
44
55import Controls 1.0
6+ import Utils 1.0
67
78FloatingPane {
89 id: root
@@ -16,8 +17,8 @@ FloatingPane {
1617
1718
1819 property real slidersPowerValue: 4.0
19- property real gainValue: Math .pow (gainCtrl .value , slidersPowerValue)
20- property real gammaValue: Math .pow (gammaCtrl .value , slidersPowerValue)
20+ property real gainValue: Math .pow (gainCtrl .value , slidersPowerValue). toFixed ( 2 )
21+ property real gammaValue: Math .pow (gammaCtrl .value , slidersPowerValue). toFixed ( 2 )
2122 property alias channelModeValue: channelsCtrl .value
2223 property variant colorRGBA: null
2324 property variant mousePosition: ({x: 0 , y: 0 })
@@ -112,21 +113,32 @@ FloatingPane {
112113
113114 onClicked: {
114115 gainCtrl .value = gainDefaultValue
116+ gainLabel .reset (gainValue)
115117 }
116118 }
117- TextField {
119+ ExpressionTextField {
118120 id: gainLabel
119121
120122 ToolTip .visible : ToolTip .text && hovered
121123 ToolTip .delay : 100
122124 ToolTip .text : " Color Gain (in linear colorspace)"
123125
124- text: gainValue .toFixed (2 )
126+ text: gainValue
127+ decimals: 2
125128 Layout .preferredWidth : textMetrics_gainValue .width
126129 selectByMouse: true
127- validator: doubleValidator
128130 onAccepted: {
129- gainCtrl .value = Math .pow (Number (gainLabel .text ), 1.0 / slidersPowerValue)
131+ if (! gainLabel .hasExprError ) {
132+ if (gainLabel .evaluatedValue <= 0 ) {
133+ gainLabel .evaluatedValue = 0
134+ gainCtrl .value = gainLabel .evaluatedValue
135+ } else {
136+ gainCtrl .value = Math .pow (Number (gainLabel .evaluatedValue ), 1.0 / slidersPowerValue)
137+ }
138+ } else {
139+ gainLabel .evaluatedValue = 0
140+ gainCtrl .value = gainLabel .evaluatedValue
141+ }
130142 }
131143 }
132144 Slider {
@@ -136,6 +148,7 @@ FloatingPane {
136148 to: 2
137149 value: gainDefaultValue
138150 stepSize: 0.01
151+ onMoved: gainLabel .reset (Math .pow (value, slidersPowerValue))
139152 }
140153 }
141154
@@ -152,21 +165,32 @@ FloatingPane {
152165
153166 onClicked: {
154167 gammaCtrl .value = gammaDefaultValue;
168+ gammaLabel .reset (gammaValue)
155169 }
156170 }
157- TextField {
171+ ExpressionTextField {
158172 id: gammaLabel
159173
160174 ToolTip .visible : ToolTip .text && hovered
161175 ToolTip .delay : 100
162176 ToolTip .text : " Apply Gamma (after Gain and in linear colorspace)"
163177
164- text: gammaValue .toFixed (2 )
178+ text: gammaValue
179+ decimals: 2
165180 Layout .preferredWidth : textMetrics_gainValue .width
166181 selectByMouse: true
167- validator: doubleValidator
168182 onAccepted: {
169- gammaCtrl .value = Math .pow (Number (gammaLabel .text ), 1.0 / slidersPowerValue)
183+ if (! gammaLabel .hasExprError ) {
184+ if (gammaLabel .evaluatedValue <= 0 ) {
185+ gammaLabel .evaluatedValue = 0
186+ gammaCtrl .value = gammaLabel .evaluatedValue
187+ } else {
188+ gammaCtrl .value = Math .pow (Number (gammaLabel .evaluatedValue ), 1.0 / slidersPowerValue)
189+ }
190+ } else {
191+ gainLabel .evaluatedValue = 0
192+ gainCtrl .value = gainLabel .evaluatedValue
193+ }
170194 }
171195 }
172196 Slider {
@@ -176,6 +200,7 @@ FloatingPane {
176200 to: 2
177201 value: gammaDefaultValue
178202 stepSize: 0.01
203+ onMoved: gammaLabel .reset (Math .pow (value, slidersPowerValue))
179204 }
180205 }
181206
0 commit comments