ui/qt/entry.cpp

changeset 561
5798e3a28c59
parent 560
9e302b8a6c37
child 597
fc85ca42a7ce
--- a/ui/qt/entry.cpp	Wed Apr 09 21:17:26 2025 +0200
+++ b/ui/qt/entry.cpp	Thu Apr 10 21:18:14 2025 +0200
@@ -108,7 +108,20 @@
         } else if(var->type == UI_VAR_RANGE) {
             UiRange *value = (UiRange*)var->value;
             value->obj = widget;
-            // TODO
+            QDoubleSpinBox *spinbox = (QDoubleSpinBox*)widget;
+            if(value->value != 0) {
+                spinbox->setValue(value->value);
+            }
+            if(value->min != value->max) {
+                spinbox->setRange(value->min, value->max);
+            }
+            if(value->extent != 0) {
+                spinbox->setSingleStep(value->extent);
+            }
+            value->get = ui_spinbox_range_get;
+            value->set = ui_spinbox_range_set;
+            value->setrange = ui_spinbox_range_setrange;
+            value->setextent = ui_spinbox_range_setextent;
         }
     }
     
@@ -140,3 +153,28 @@
     spinbox->setValue(value);
     d->value = spinbox->value();
 }
+
+double ui_spinbox_range_get(UiRange *range) {
+    QDoubleSpinBox *spinbox = (QDoubleSpinBox*)range->obj;
+    range->value = spinbox->value();
+    return range->value;
+}
+
+void ui_spinbox_range_set(UiRange *range, double value) {
+    QDoubleSpinBox *spinbox = (QDoubleSpinBox*)range->obj;
+    spinbox->setValue(value);
+    range->value = spinbox->value();
+}
+
+void ui_spinbox_range_setrange(UiRange *range, double min, double max) {
+    QDoubleSpinBox *spinbox = (QDoubleSpinBox*)range->obj;
+    spinbox->setRange(min, max);
+    range->min = min;
+    range->max = max;
+}
+
+void ui_spinbox_range_setextent(UiRange *range, double extent) {
+    QDoubleSpinBox *spinbox = (QDoubleSpinBox*)range->obj;
+    spinbox->setSingleStep(extent);
+    range->extent = extent;
+}

mercurial