From dd165ac285bc3c1c211f3090e800d3e415bced75 Mon Sep 17 00:00:00 2001
From: CABEL Tristan <tristan.cabel@inria.fr>
Date: Fri, 15 Apr 2022 15:34:47 +0200
Subject: [PATCH] input slider value on keyboard

---
 examples/gallery/main.drawer.qml    | 64 ++++++++++++++---------------
 qml/crossQuick/Numeric.qml          | 21 ++++++----
 qml/crossQuick/ParameterNumeric.qml |  4 +-
 3 files changed, 46 insertions(+), 43 deletions(-)

diff --git a/examples/gallery/main.drawer.qml b/examples/gallery/main.drawer.qml
index 2fde4ee..595d849 100644
--- a/examples/gallery/main.drawer.qml
+++ b/examples/gallery/main.drawer.qml
@@ -1,7 +1,7 @@
 import QtQuick            2.15
 import QtQuick.Controls   2.15
 import QtQuick.Layouts    1.15
-import QtGraphicalEffects 1.15
+//import QtGraphicalEffects 1.15
 
 // import Qt5Compat.GraphicalEffects
 
@@ -41,37 +41,37 @@ Pane {
             }
         }
     }
-
-    Rectangle {
-        color: "#00000000";
-
-        anchors.fill: parent;
-
-        visible: window.inPortrait;
-
-        ShaderEffectSource {
-            id: _source
-
-            sourceItem: window
-            width: parent.width;
-            height: parent.height;
-            sourceRect: Qt.rect(x,y, width, height)
-        }
-
-        FastBlur{
-            id: _blur;
-            anchors.fill: _source
-            source: _source
-            radius: 128
-        }
-
-        ColorOverlay
-        {
-            anchors.fill: parent
-            source: _blur;
-            color: "#ee000000";
-        }
-    }
+//
+    //Rectangle {
+    //    color: "#00000000";
+//
+    //    anchors.fill: parent;
+//
+    //    visible: window.inPortrait;
+//
+    //    ShaderEffectSource {
+    //        id: _source
+//
+    //        sourceItem: window
+    //        width: parent.width;
+    //        height: parent.height;
+    //        sourceRect: Qt.rect(x,y, width, height)
+    //    }
+//
+    //    FastBlur{
+    //        id: _blur;
+    //        anchors.fill: _source
+    //        source: _source
+    //        radius: 128
+    //    }
+//
+        //ColorOverlay
+       // {
+        //    anchors.fill: parent
+        //    source: _blur;
+        //    color: "#ee000000";
+       // }
+    //}
 
     X.LabelHeadline5 {
 
diff --git a/qml/crossQuick/Numeric.qml b/qml/crossQuick/Numeric.qml
index 47dc3a5..e811c56 100644
--- a/qml/crossQuick/Numeric.qml
+++ b/qml/crossQuick/Numeric.qml
@@ -22,14 +22,12 @@ Control {
 				id: _param
 				param: _root.param
 				value: _slid.value
-				// min: _slid.from
-				// max: _slid.to
 			}
 
 			from: _param.min
 			to: _param.max
 			value: _param.param.value;
-			stepSize: (param.decimals == undefined) ? 1 : .0/Math.pow(10, param.decimals)
+			stepSize: (_param.param.decimals == undefined) ? 1 : .0/Math.pow(10, param.decimals)
 
 			X.ToolTip {
 				parent: _slid.handle
@@ -45,13 +43,17 @@ Control {
 				anchors.left: parent.left;
 			}
 
-			X.Label {
-				id: _label
-				text: _slid.value.toFixed(param.decimals)
-				color: "white"
-
+			TextInput {
+				id: _label; 
 				anchors.bottom: parent.top;
 				x: _slid.leftPadding + _slid.visualPosition * (_slid.availableWidth - width)
+
+				text: _slid.value
+				color: "white"
+				validator: DoubleValidator{bottom: _param.min; top: _param.max; decimals: (_param.decimals) ? _param.decimals : 0 ; notation: DoubleValidator.StandardNotation}
+				onTextChanged: {
+                   _slid.value =  parseInt(text);
+                }
 			}
 
 			X.Label {
@@ -96,7 +98,8 @@ Control {
 		X.LabelCaption { text: param.label }
 
 		Loader {
-			sourceComponent: paramType == "dtk::d_real" ? spinbox : slider
+			//sourceComponent: paramType == "dtkCoreParameterNumeric<double>" ? spinbox : slider
+			sourceComponent: slider
 			Layout.fillWidth: true
 		}
 	}
diff --git a/qml/crossQuick/ParameterNumeric.qml b/qml/crossQuick/ParameterNumeric.qml
index 4081f39..06990e7 100644
--- a/qml/crossQuick/ParameterNumeric.qml
+++ b/qml/crossQuick/ParameterNumeric.qml
@@ -14,11 +14,11 @@ Item {
     property var value: param.value;
     property var min: param.min;
     property var max: param.max;
-    //property var decimals: param.decimals;    
+    property var decimals: param.decimals;    
 
     Binding { target: _root.param; property: "value"; value: _root.value}
     Binding { target: _root.param; property: "min"; value: _root.min}
     Binding { target: _root.param; property: "max"; value: _root.max}
-    //Binding { target: _root.param; property: "decimals"; value: _root.decimals; when:paramType == "dtk::d_real"}
+    Binding { target: _root.param; property: "decimals"; value: _root.decimals; when:paramType == "dtkCoreParameterNumeric<double>"}
 
 }
\ No newline at end of file
-- 
GitLab