Menu

#7 vslider with inverse direction

None
open
nobody
None
5
2014-08-07
2011-04-14
No

I propose to extend vslider (and hslider) to reverse the value direction, if minimum and maximum value are swapped.

wxSL_INVERSE :: Int
wxSL_INVERSE = 0x1000

vslider :: Window a -> Bool -> Int -> Int -> [Prop (Slider ())] -> IO (Slider ())
vslider parentW showLabels top bottom props =
  let (minV, maxV, dirFlags) =
    if top < bottom
    then (top, bottom, 0)
    else (bottom, top, wxSL_INVERSE)
  in sliderEx parentW minV maxV (wxVERTICAL .+. dirFlags .+. (if showLabels then wxSL_LABELS else 0)) props

At least, wxSL_INVERSE should be defined.

Discussion

  • Henk-Jan van Tuyl

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,19 +1,17 @@
     I propose to extend vslider \(and hslider\) to reverse the value direction, if minimum and maximum value are swapped.
    
    -wxSL\_INVERSE :: Int
    -wxSL\_INVERSE = 0x1000
    +~~~~
    +:::Haskell
    +wxSL_INVERSE :: Int
    +wxSL_INVERSE = 0x1000
    
    -vslider ::
    -Window a -&gt; Bool -&gt; Int -&gt; Int -&gt; \[Prop \(Slider \(\)\)\] -&gt; IO \(Slider \(\)\)
    +vslider :: Window a -> Bool -> Int -> Int -> [Prop (Slider ())] -> IO (Slider ())
     vslider parentW showLabels top bottom props =
    -let \(minV, maxV, dirFlags\) =
    -if top&lt;bottom
    -then \(top, bottom, 0\)
    -else \(bottom, top, wxSL\_INVERSE\)
    -in  sliderEx parentW minV maxV
    -\(wxVERTICAL .+. dirFlags
    -.+. \(if showLabels then wxSL\_LABELS else 0\)\)
    -props
    -
    +  let (minV, maxV, dirFlags) =
    +    if top < bottom
    +    then (top, bottom, 0)
    +    else (bottom, top, wxSL_INVERSE)
    +  in sliderEx parentW minV maxV (wxVERTICAL .+. dirFlags .+. (if showLabels then wxSL_LABELS else 0)) props
    +~~~~
    
     At least, wxSL\_INVERSE should be defined.
    
    • Group: --> None
     
  • Henk-Jan van Tuyl

    Changed formatting

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.