Advanced slider controls

Post

Posted
Rating:
#1 (In Topic #1260)
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
Some years (possibly many) I posted a question on the forum about how to create a slider control with two moveable dots. The general purpose was to define a "band filter" with an upper and lower cutoff points. The results were, in those days, pretty poor and in the end I resorted to using two sliders. It worked but was visually unappealing and user-unfriendly.

This beast has raised its head again this week. In fact it has grown even another head  :(  This time I need a slider with three active points. It's proposed use is to model a "service life" vs "usable life" for a product. (Service life being the period over which the manufacturer will build and service the commodity and usable life being the period over which the commodity will actually function. Consider an electric toaster, it typically has a short service life as the manufacturer updates the "look" of the product say every two years but in fact it has a much longer usable life as any given item will probably (possibly?) last near ten years. Then it is pretty hard for the manufacturer to drive new model purchases unless they introduce features so far outweighing the utility of the previous model, say a toaster that talks? So, my query is..

in the intervening years and the use of the Draw features, has anyone come up with such a band filter control?

I asking before I commit myself to weeks of work learning how to build it or indeed whether it is possible nowadays.

tia
bruce

Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’
…for a slider with three indicators, perhaps you could think of a code like the :? following:

Code (gambas)

  1. Private DrawingArea1 As DrawingArea
  2.  
  3.  
  4. Public Sub Form_Open()
  5.  
  6.  With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1"
  7.    .X = 20
  8.    .Y = 20
  9.    .W = 310
  10.    .H = 20
  11.    .Border = Border.Solid
  12.  
  13.  With bt1 = New Button(DrawingArea1) As "BT"
  14.    If Not Even(DrawingArea1.W * 0.03) Then .W = (DrawingArea1.W * 0.03) + 1
  15.    .H = DrawingArea1.H
  16.    .X = 0
  17.    .Y = 0
  18.    .Text = String.Chr(&2193)
  19.  With bt2 = New Button(DrawingArea1) As "BT"
  20.    .W = bt1.W
  21.    .H = DrawingArea1.H
  22.    .X = DrawingArea1.W - (DrawingArea1.W / 2)
  23.    .Y = 0
  24.    .Text = String.Chr(&2193)
  25.  With bt3 = New Button(DrawingArea1) As "BT"
  26.    .W = bt1.W
  27.    .H = DrawingArea1.H
  28.    .X = DrawingArea1.W - .W
  29.    .Y = 0
  30.    .Text = String.Chr(&2193)
  31.  
  32.  Me.Title = "Min = " & CStr(bt1.X) & "   Med =" & CStr(bt2.X) & "   Max =" & CStr(bt3.X)
  33.  
  34.  
  35. Public Sub DrawingArea1_Draw()
  36.  
  37.  With Paint
  38.    .Brush = Paint.Color(Color.Green)
  39.    .Rectangle(bt1.X + bt1.W, 0, (DrawingArea1.W - bt1.X) - (DrawingArea1.W - bt2.X), DrawingArea1.H)
  40.    .Fill
  41.    .Brush = Paint.Color(Color.Orange)
  42.    .Rectangle(bt2.X + bt2.W, 0, (DrawingArea1.W - bt2.X) - (DrawingArea1.W - bt3.X), DrawingArea1.H)
  43.    .Fill
  44.    .End
  45.  
  46.  
  47. Public Sub BT_MouseMove()
  48.  
  49.    .X = .X + Mouse.X - Mouse.StartX
  50.    .Y = .Y + Mouse.Y - Mouse.StartY
  51.  
  52.  If Last.Y <> 0 Then Last.Y = 0
  53.  
  54.    Case bt1.Id
  55.      If bt1.X < 0 Then bt1.X = 0
  56.      If bt1.X > bt2.X - bt1.W Then bt1.X = bt2.X - bt1.W
  57.    Case bt2.Id
  58.      If bt2.X < (bt1.X + bt1.W) Then bt2.X = bt1.X + bt1.W
  59.      If (bt2.X + bt2.W) > bt3.X Then bt2.X = bt3.X - bt2.W
  60.    Case bt3.Id
  61.      If bt3.X < (bt2.X + bt2.W) Then bt3.X = bt2.X + bt2.W
  62.      If (bt3.X + bt3.W) > DrawingArea1.W Then bt3.X = DrawingArea1.W - bt3.W
  63.  
  64.  DrawingArea1.Refresh
  65.  
  66.  Me.Title = "Min = " & CStr(bt1.X) & "   Med = " & CStr(bt2.X) & "   Max = " & CStr(bt3.X)
  67.  

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
 Does it need to be a "Slider" , ie, settable with mouse?

Sounds more like you want just a visual thing to show multiple levels.
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
 Thank you Vuott, that's got me off to a good start. I have a lot to do yet.

&@BruceS
It does need to be an active control, not just for visualisation ("That would be too easy." said the requirements specifier)

b

Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
 Getting there! The picture is a variation where two ranges are supported (Min->Med and Min->Max) and shown as two bars. Pretty happy with the display.
Of course, for the "toaster" scenario, the usable life is typically a lot longer than the manufacturing period. The scenario where this two ranges is required is the "lightbulb" model. The commodity will be manufactured for as long as the production machinery is expected to last but the commodity has a usable lifetime that is much shorter. So the consumer has to keep buying replacements, so the manufacturer is overjoyed.

A colleague has just pointed out a third scenario involving "shelf life", for example a missile. Manufacturer only produces for a short time according to contract, the commodity sits around for a certain time before it rusts, the commodity itself has a usable life of about 4 minutes. Hmm, unless he can come up with another example, I think I'll just ignore this one as it would mean a slider with 4 buttons. Or even more…

Image

(Click to enlarge)


Online now: No Back to the top
1 guest and 0 members have just viewed this.