Skip to content

Commit f7a8eea

Browse files
authored
UIFORM: Fix slider default display and add color customization (#375)
1 parent 12f73e5 commit f7a8eea

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

apps/DemoUIForm/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0
1+
1.1

apps/DemoUIForm/main.scm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7676
(spacer)
7777
;; Button with action callback that returns the page you want to go to
7878
(button h 75 size header indent 0.05 rounded #t text "Go Back" action ,(lambda () 'main))
79+
(spacer)
80+
;; slider
81+
(slider id sliderval number #t min 0 max 100 default 50 labels ("min" "max"))
7982
(spacer)
8083
(label text "For more features that you can include in a script see the LNhealth app \"Demo Widgets\". Look at the main.sx file in the sandbox folder which is located at https://github.com/part-cw/LNhealth/tree/master/apps/WidgetDemo" align left size small)
8184
)

modules/uiform/uiform.scm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,8 +1546,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15461546
(stepnum (fx- max min))
15471547
(stepvalues (make-list-natural min (+ 1 stepnum)))
15481548
(defaultvalue (glgui:uiform-arg args 'default (/ stepnum 2)))
1549-
(value (xxget loc id defaultvalue))
1550-
(boxcolor (glgui:uiform-arg args 'boxcolor (uiget 'color-default))))
1549+
(value (xxget loc id #f))
1550+
(boxcolor (glgui:uiform-arg args 'boxcolor (uiget 'color-default)))
1551+
(selcolor (glgui:uiform-arg args 'selcolor (uiget 'color-select)))
1552+
(numcolor (glgui:uiform-arg args 'numbercolor (uiget 'color-low))))
15511553
(uiset idvalues stepvalues)
15521554
(if req
15531555
(uiform-required-set id (abs (- (abs y) (uiget 'offset 0) h))))
@@ -1563,9 +1565,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15631565
(positions (make-list-increment (* w 0.1) (+ 1 stepnum) i)))
15641566
(uiset idpositions positions)
15651567
(glgui:draw-box (+ x (* w 0.1)) (+ by (/ bh 4)) sw (/ bh 2) boxcolor) ;; Horizontal bar
1566-
(glgui:draw-box bx by bw bh (if value White boxcolor)) ;; Slider box
1568+
(glgui:draw-box bx by bw bh (if value selcolor boxcolor)) ;; Slider box
15671569
(if (and shownumber value)
1568-
(glgui:draw-text-center bx by bw bh (number->string v) fnt Black))
1570+
(glgui:draw-text-center bx by bw bh (number->string v) fnt numcolor))
15691571
;; draw labels if set
15701572
(if (fx> (length labels) 1) (begin
15711573
(glgui:draw-text-left (+ x (* w 0.1)) (+ by (- h fnth)) (- (* w 0.8) bw) fnth (car labels) fnt White)

0 commit comments

Comments
 (0)