Dual Thumps TrackBar Gadget

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Dual Thumps TrackBar Gadget

Post by RASHAD »

Hi
I tried my best to make it cross platform(I hope)
Feel free to modify it for your needs
Have fun with PureBasic

Code: Select all

Global tbwidth,twin,timg,tframe,mytrack,tbmin,tbmax,thump_1,thump_2, thump_1_tt,thump_2_tt,tbtrim.f

Procedure _TrackBarGadget(x,y,width,height,min,max,Flags)
  timg = CreateImage(#PB_Any,width,height+10,24,$CBFEFC)
  StartDrawing(ImageOutput(timg))
    Box(5,5,width-10,height-10,$EEEEEE)
    DrawingMode(#PB_2DDrawing_Outlined )
    Box(1,1,width-2,height+8,$CDCDCD)
    Box(5,5,width-10,height-10,$C6C6C6)
    For xp = 5 To width-5 Step 10
      LineXY(xp,height-3,xp,height,$C0C0C0)
    Next
  StopDrawing()
  UseGadgetList(WindowID(twin))
  tframe = ImageGadget(#PB_Any,x,y,width,height,ImageID(timg))
  DisableGadget(tframe,1)  
  thimg = CreateImage(#PB_Any,8,14,24,$FA9336)
  thump_1 = CanvasGadget(#PB_Any,x+10,y+4,8,14)
  thump_2 = CanvasGadget(#PB_Any,x+width-15,y+4,8,14)
  thump_1_tt = TextGadget(#PB_Any,0,0,0,0,"",#PB_Text_Center)
  ;SetGadgetColor(thump_1_tt,#PB_Gadget_BackColor,$CBFEFC)
  ;SetGadgetColor(thump_1_tt,#PB_Gadget_FrontColor,$0000FF)
  thump_2_tt = TextGadget(#PB_Any,0,0,0,0,"",#PB_Text_Center)
  ;SetGadgetColor(thump_2_tt,#PB_Gadget_BackColor,$CBFEFC)
  ;SetGadgetColor(thump_2_tt,#PB_Gadget_FrontColor,$0000FF)  
  SetGadgetAttribute(thump_1, #PB_Canvas_Image ,ImageID(thimg))
  SetGadgetAttribute(thump_2, #PB_Canvas_Image ,ImageID(thimg))
  tbwidth = width :tbmin = min :tbmax = max
  tbtrim =tbwidth/(tbmax-tbmin)
EndProcedure

Procedure _GetGadgetState(Gadget)
  Debug Str(tbmin+(GadgetX(gadget)-16)/tbtrim)
EndProcedure

Procedure _SetGadgetState(Gadget,value)
  value = value * tbtrim -tbmin
  ResizeGadget(Gadget,value,#PB_Ignore,#PB_Ignore,#PB_Ignore)
EndProcedure

twin = OpenWindow(#PB_Any,0,0,400,300,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered| #PB_Window_MaximizeGadget| #PB_Window_SizeGadget)
_TrackBarGadget(10,10,380,20,50,300,0)

_SetGadgetState(thump_2,200)
    
Repeat       
  Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
            Quit = 1       
     
      Case #PB_Event_Menu
          Select EventMenu()
           Case 1            
          EndSelect
      
      Case #PB_Event_Gadget
          Select EventGadget()
           Case thump_1
              If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(thump_1, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
                 If WindowMouseX(twin)-2 < tbwidth And WindowMouseX(twin)-2 > GadgetX(tframe)+5 And WindowMouseX(twin)-2 < GadgetX(thump_2)-8
                   ResizeGadget(thump_1,WindowMouseX(twin)-2,#PB_Ignore,#PB_Ignore,#PB_Ignore)
                   If GadgetX(thump_1) < tbwidth/2
                     ResizeGadget(thump_1_tt,GadgetX(thump_1)+14,GadgetY(thump_1)+20,30, 14)
                   Else
                     ResizeGadget(thump_1_tt,GadgetX(thump_1)-30,GadgetY(thump_1)+20,30,14)
                   EndIf
                   SetGadgetText(thump_1_tt,Str(tbmin+(WindowMouseX(twin)-16)/tbtrim))
                EndIf
              Else
                 ResizeGadget(thump_1_tt,0,0,0,0)
              EndIf
              _GetGadgetState(thump_1)
              
           Case thump_2
              If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(thump_2, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
                 If WindowMouseX(twin)-2 < tbwidth-2 And WindowMouseX(twin)-2 > GadgetX(tframe)+5 And WindowMouseX(twin)-2 > GadgetX(thump_1)+8
                  ResizeGadget(thump_2,WindowMouseX(twin)-2,#PB_Ignore,#PB_Ignore,#PB_Ignore)
                   If GadgetX(thump_2) < tbwidth/2
                     ResizeGadget(thump_2_tt,GadgetX(thump_2)+14,GadgetY(thump_2)+20,30, 14)
                   Else
                     ResizeGadget(thump_2_tt,GadgetX(thump_2)-30,GadgetY(thump_2)+20,30,14)
                   EndIf
                  SetGadgetText(thump_2_tt,Str(tbmin+WindowMouseX(twin)/tbtrim))
                EndIf
              Else
                 ResizeGadget(thump_2_tt,0,0,0,0)
              EndIf            
          EndSelect          
            
  EndSelect 

Until Quit = 1
End
Edit :Code Modified
Last edited by RASHAD on Thu Jan 21, 2016 3:40 pm, edited 2 times in total.
Egypt my love
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Dual Thumps TrackBar Gadget

Post by davido »

@RASHAD,
Looks and works ok on Windows 10 with PureBasic 5.41LTS

Looks ok on my MacBook Pro until the 'blue marker' is moved and then the 'red number' flickers badly.
The flickering stops if the mouse is dragged vertically down and then horizontally!
DE AA EB
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Dual Thumps TrackBar Gadget

Post by RASHAD »

Hi davido
Previous post updated
ToolTip color canceled
See if it is OK with Mac
Egypt my love
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Dual Thumps TrackBar Gadget

Post by davido »

Hi RASHAD,

Just checked it again.
Sorry, but the problem still exists.
I've narrowed it down a bit:
If the mouse is over the 'blue marker', whilst moving the 'marker' the number flickers.
If the mouse is dragged off the 'blue marker' the 'marker' can be moved rapidly without any of the flickering.
DE AA EB
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Dual Thumps TrackBar Gadget

Post by RASHAD »

Hi davido
I got some rest
Changed the ToolTip approach
Check

Code: Select all

Global tbwidth,twin,twtip,timg,tframe,tbmin,tbmax,thump_1,thump_2,thump_tt, tbtrim.f

Procedure _TrackBarGadget(x,y,width,height,min,max,Flags)
  timg = CreateImage(#PB_Any,width,height+10,24,0)
  StartDrawing(ImageOutput(timg))
    Box(5,5,width-10,height-10,$DDDDDD)
    DrawingMode(#PB_2DDrawing_Outlined )
    Box(1,1,width-2,height+8,$CDCDCD)
    Box(5,5,width-10,height-10,$C6C6C6)
    For xp = 5 To width-5 Step 10
      LineXY(xp,height-3,xp,height,$DDDDDD)
    Next
  StopDrawing()
  UseGadgetList(WindowID(twin))
  tframe = ImageGadget(#PB_Any,x,y,width,height,ImageID(timg))
  DisableGadget(tframe,1)  
  thimg = CreateImage(#PB_Any,8,14,24,$FA9336)
  thump_1 = CanvasGadget(#PB_Any,x+10,y+4,8,14)
  thump_2 = CanvasGadget(#PB_Any,x+width-15,y+4,8,14)
  twtip = OpenWindow(#PB_Any,0,0,30,16,"", #PB_Window_BorderLess,WindowID(twin))
  SetWindowColor(twtip,0)
  UseGadgetList(WindowID(twtip))
  thump_tt = TextGadget(#PB_Any,1,1,28,14,"",#PB_Text_Center);|#PB_Text_Border)
  SetGadgetColor(thump_tt,#PB_Gadget_BackColor,$CBFEFC)
  SetGadgetColor(thump_tt,#PB_Gadget_FrontColor,$0000FF)
;   thump_2_tt = TextGadget(#PB_Any,0,0,0,0,"",#PB_Text_Center)
;   SetGadgetColor(thump_2_tt,#PB_Gadget_BackColor,$CBFEFC)
;   SetGadgetColor(thump_2_tt,#PB_Gadget_FrontColor,$0000FF)  
  SetGadgetAttribute(thump_1, #PB_Canvas_Image ,ImageID(thimg))
  SetGadgetAttribute(thump_2, #PB_Canvas_Image ,ImageID(thimg))
  tbwidth = width :tbmin = min :tbmax = max
  tbtrim =tbwidth/(tbmax-tbmin)
EndProcedure

Procedure _GetGadgetState(Gadget)
  Debug Str(tbmin+(GadgetX(gadget)-16)/tbtrim)
EndProcedure

Procedure _SetGadgetState(Gadget,value)
  value = value * tbtrim -tbmin
  ResizeGadget(Gadget,value,#PB_Ignore,#PB_Ignore,#PB_Ignore)
EndProcedure

twin = OpenWindow(#PB_Any,0,0,400,300,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered| #PB_Window_MaximizeGadget| #PB_Window_SizeGadget)
_TrackBarGadget(10,10,380,20,50,300,0)

_SetGadgetState(thump_2,200)
    
Repeat       
  Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
            Quit = 1       
     
      Case #PB_Event_Menu
          Select EventMenu()
           Case 1            
          EndSelect
      
      Case #PB_Event_Gadget
          Select EventGadget()
           Case thump_1              
              If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(thump_1, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
                xx = WindowMouseX(twin)
                ttip = tbmin+(xx-16)/tbtrim
                If xx-2 < tbwidth And xx-2 > GadgetX(tframe)+5 And xx-2 < GadgetX(thump_2)-8
                   ResizeGadget(thump_1,xx-2,#PB_Ignore,#PB_Ignore,#PB_Ignore)
                   HideWindow(twtip,0)
                   ResizeWindow(twtip,GadgetX(thump_1,#PB_Gadget_ScreenCoordinate)+10, GadgetY(thump_1,#PB_Gadget_ScreenCoordinate)-14,30,16)
                   SetGadgetText(thump_tt,Str(ttip))
                EndIf
              Else
                  HideWindow(twtip,1)
              EndIf
              _GetGadgetState(thump_1)
              
           Case thump_2
              If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(thump_2, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
                xx =  WindowMouseX(twin)
                ttip = tbmin+(xx-16)/tbtrim
                If xx-2 < tbwidth-2 And xx-2 > GadgetX(tframe)+5 And xx-2 > GadgetX(thump_1)+8
                  ResizeGadget(thump_2,xx-2,#PB_Ignore,#PB_Ignore, #PB_Ignore)
                  HideWindow(twtip,0)
                  ResizeWindow(twtip,GadgetX(thump_2,#PB_Gadget_ScreenCoordinate)+10, GadgetY(thump_2,#PB_Gadget_ScreenCoordinate)-14,30,16)
                  SetGadgetText(thump_tt,Str(ttip))
                EndIf
              Else
                  HideWindow(twtip,1)
              EndIf            
          EndSelect          
            
  EndSelect 

Until Quit = 1
End
Egypt my love
User avatar
Lord
Addict
Addict
Posts: 907
Joined: Tue May 26, 2009 2:11 pm

Re: Dual Thumps TrackBar Gadget

Post by Lord »

Hello Rashad!

I like your Dual Thumps TrackBar Gadget! :D
I am right now looking for something like this:
http://www.purebasic.fr/english/viewtop ... 65#p480465

Your code is almost what I need right now.

But there is still room to improve.
Try for example your code with

Code: Select all

_TrackBarGadget(10,10,380,20,2,32,0)
_SetGadgetState(thump_2,32)
The right slider is not visible. A setting of 31 shows
the slider just outside the gadget.

It would also be nice, if the tics would be set according the
slider settings and the slider would 'snap' to their value after
releasing. Try

Code: Select all

_TrackBarGadget(10,10,380,20,1,6,0)
_SetGadgetState(thump_2,4)
In your example you missed

Code: Select all

              _GetGadgetState(thump_2)
for thump_2 in the event loop.

I also like BindGadgetEvent(), so I would rearrange your code like this

Code: Select all

Global tbwidth,twin,twtip,timg,tframe,tbmin,tbmax,thump_1,thump_2,thump_tt, tbtrim.f

Procedure _TrackBarGadget(x,y,width,height,min,max,Flags)
  timg = CreateImage(#PB_Any,width,height+10,24,0)
  StartDrawing(ImageOutput(timg))
    Box(5,5,width-10,height-10,$DDDDDD)
    DrawingMode(#PB_2DDrawing_Outlined )
    Box(1,1,width-2,height+8,$CDCDCD)
    Box(5,5,width-10,height-10,$C6C6C6)
    For xp = 5 To width-5 Step 10
      LineXY(xp,height-3,xp,height,$DDDDDD)
    Next
  StopDrawing()
  UseGadgetList(WindowID(twin))
  tframe = ImageGadget(#PB_Any,x,y,width,height,ImageID(timg))
  DisableGadget(tframe,1) 
  thimg = CreateImage(#PB_Any,8,14,24,$FA9336)
  thump_1 = CanvasGadget(#PB_Any,x+10,y+4,8,14)
  thump_2 = CanvasGadget(#PB_Any,x+width-15,y+4,8,14)
  twtip = OpenWindow(#PB_Any,0,0,30,16,"", #PB_Window_BorderLess,WindowID(twin))
  SetWindowColor(twtip,0)
  UseGadgetList(WindowID(twtip))
  thump_tt = TextGadget(#PB_Any,1,1,28,14,"",#PB_Text_Center);|#PB_Text_Border)
  SetGadgetColor(thump_tt,#PB_Gadget_BackColor,$CBFEFC)
  SetGadgetColor(thump_tt,#PB_Gadget_FrontColor,$0000FF)
;   thump_2_tt = TextGadget(#PB_Any,0,0,0,0,"",#PB_Text_Center)
;   SetGadgetColor(thump_2_tt,#PB_Gadget_BackColor,$CBFEFC)
;   SetGadgetColor(thump_2_tt,#PB_Gadget_FrontColor,$0000FF) 
  SetGadgetAttribute(thump_1, #PB_Canvas_Image ,ImageID(thimg))
  SetGadgetAttribute(thump_2, #PB_Canvas_Image ,ImageID(thimg))
  tbwidth = width :tbmin = min :tbmax = max
  tbtrim =tbwidth/(tbmax-tbmin)
EndProcedure

Procedure _GetGadgetState(Gadget)
  Debug Str(tbmin+(GadgetX(gadget)-16)/tbtrim)
EndProcedure

Procedure _SetGadgetState(Gadget,value)
  value = value * tbtrim -tbmin
  ResizeGadget(Gadget,value,#PB_Ignore,#PB_Ignore,#PB_Ignore)
EndProcedure

Procedure TBGthump1()
  Static OldLowerSlider.i
  If EventType() = #PB_EventType_LeftButtonDown Or
     (EventType() = #PB_EventType_MouseMove And
      GetGadgetAttribute(thump_1, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
    xx = WindowMouseX(twin)
    ttip = tbmin+(xx-16)/tbtrim
    If xx-2 < tbwidth And xx-2 > GadgetX(tframe)+5 And xx-2 < GadgetX(thump_2)-8
      ResizeGadget(thump_1,xx-2,#PB_Ignore,#PB_Ignore,#PB_Ignore)
      HideWindow(twtip,0)
      ResizeWindow(twtip,GadgetX(thump_1,#PB_Gadget_ScreenCoordinate)+10,
                   GadgetY(thump_1,#PB_Gadget_ScreenCoordinate)-14,30,16)
      SetGadgetText(thump_tt,Str(ttip))
    EndIf
  Else
    HideWindow(twtip,1)
  EndIf
  LowerSlider=(tbmin+(GadgetX(thump_1)-16)/tbtrim)
  If LowerSlider<>OldLowerSlider
    OldLowerSlider=LowerSlider
    Debug LowerSlider; or do something else
  EndIf
EndProcedure
Procedure TBGthump2()
  Static OldUpperSlider.i
  If EventType() = #PB_EventType_LeftButtonDown Or 
     (EventType() = #PB_EventType_MouseMove And 
      GetGadgetAttribute(thump_2, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
    xx =  WindowMouseX(twin)
    ttip = tbmin+(xx-16)/tbtrim
    If xx-2 < tbwidth-2 And xx-2 > GadgetX(tframe)+5 And xx-2 > GadgetX(thump_1)+8
      ResizeGadget(thump_2,xx-2,#PB_Ignore,#PB_Ignore, #PB_Ignore)
      HideWindow(twtip,0)
      ResizeWindow(twtip,GadgetX(thump_2,#PB_Gadget_ScreenCoordinate)+10,
                   GadgetY(thump_2,#PB_Gadget_ScreenCoordinate)-14,30,16)
      SetGadgetText(thump_tt,Str(ttip))
    EndIf
  Else
    HideWindow(twtip,1)
  EndIf
  UpperSlider=(tbmin+(GadgetX(thump_2)-16)/tbtrim)
  If UpperSlider<>OldUpperSlider
    OldUpperSlider=UpperSlider
    Debug UpperSlider; or do something else
  EndIf
  
EndProcedure

  
twin = OpenWindow(#PB_Any,0,0,400,300,"Test",
                  #PB_Window_SystemMenu| #PB_Window_ScreenCentered| #PB_Window_MaximizeGadget| PB_Window_SizeGadget)

_TrackBarGadget(10,10,380,20,2,32,0)

_SetGadgetState(thump_1,2)
_SetGadgetState(thump_2,32)

BindGadgetEvent(thump_1, @TBGthump1())
BindGadgetEvent(thump_2, @TBGthump2())



Repeat       
  Select WaitWindowEvent()
      
    Case #PB_Event_CloseWindow
      Quit = 1       
  EndSelect
  
Until Quit = 1

End
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Dual Thumps TrackBar Gadget

Post by RASHAD »

Hi Lord
Progress :)
You can add Error message or correct the value direct
I am still of something more accurate
Waiting for davido response on Mac

Code: Select all

Procedure _SetGadgetState(Gadget,value)
  If value >= tbmax
     value = tbmax - 2
  EndIf
  If value <= tbmin
     value = tbmin
  EndIf 
  value = value * tbtrim -tbmin
  ResizeGadget(Gadget,value,#PB_Ignore,#PB_Ignore,#PB_Ignore)
EndProcedure
Egypt my love
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Dual Thumps TrackBar Gadget

Post by RASHAD »

Big improvments

Code: Select all

Global win,tbwidth,tbheight,tbmin,tbmax,twtip,timg,tframe,thump_1, thump_2, thump_tt,tbtrim.f,xx

Procedure _TrackBarGadget(win,x,y,width,height,min,max,Flags)
  If flags = 1
    Swap width,height
    timg = CreateImage(#PB_Any,width+10,height,24,0)
  Else
    timg = CreateImage(#PB_Any,width,height+10,24,0)
  EndIf
  StartDrawing(ImageOutput(timg))
    Box(5,5,width-10,height-10,$DDDDDD)
    DrawingMode(#PB_2DDrawing_Outlined )
    Box(1,1,width-2,height+8,$CDCDCD)
    Box(5,5,width-10,height-10,$C6C6C6)
    If flags = 1
      For xp = 5 To height-5 Step 10
        LineXY(width+5,xp,width,xp,$DDDDDD)
      Next
    Else 
      For xp = 5 To width-5 Step 10
        LineXY(xp,height-4,xp,height+4,$DDDDDD)
      Next
    EndIf
  StopDrawing()
  canv = 8
  If flags = 1    
    Swap height,canv
  EndIf
  UseGadgetList(WindowID(win))
  tframe = ImageGadget(#PB_Any,x,y,width,height,ImageID(timg))
  DisableGadget(tframe,1)  
  thimg = CreateImage(#PB_Any,canv,height,24,$FA9336)
  height - 8
  
  thump_1 = CanvasGadget(#PB_Any,x+10,y+4,canv,height)
  thump_2 = CanvasGadget(#PB_Any,x+width-15,y+4,canv,height)
  twtip = OpenWindow(#PB_Any,0,0,30,16,"",#PB_Window_BorderLess,WindowID(win))
  SetWindowColor(twtip,0)
  UseGadgetList(WindowID(twtip))
  thump_tt = TextGadget(#PB_Any,1,1,28,14,"",#PB_Text_Center);|#PB_Text_Border)
  SetGadgetColor(thump_tt,#PB_Gadget_BackColor,$CBFEFC)
  SetGadgetColor(thump_tt,#PB_Gadget_FrontColor,$0000FF)
  SetGadgetAttribute(thump_1, #PB_Canvas_Image ,ImageID(thimg))
  SetGadgetAttribute(thump_2, #PB_Canvas_Image ,ImageID(thimg))
  tbmin = min : tbmax = max
  tbtrim =width/(tbmax-tbmin)
  UseGadgetList(WindowID(win))
  SetActiveWindow(win)
  tbwidth = width :tbheight = height
EndProcedure

Procedure _GetGadgetState(Gadget)
  Debug Str(tbmin+(xx-16)/tbtrim)
EndProcedure

Procedure _SetGadgetState(Gadget,value)
  If value >= tbmax     
     value = tbmax - 2
  EndIf
  If value <= tbmin
     value = tbmin
  EndIf 
  value = value * tbtrim -tbmin
  ResizeGadget(Gadget,value,#PB_Ignore,#PB_Ignore,#PB_Ignore)
EndProcedure

win = OpenWindow(#PB_Any,0,0,400,300,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered| #PB_Window_MaximizeGadget| #PB_Window_SizeGadget)
_TrackBarGadget(win,10,10,300,30,2,32,0)  ;win , x,y ,width ,height ,min ,max ,flags = 0 for now
 Button = ButtonGadget(#PB_Any,10,270,80,20,"TEST")
_SetGadgetState(thump_2,20)
    
Repeat       
  Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
            Quit = 1       
     
      Case #PB_Event_Menu
          Select EventMenu()
           Case 1            
          EndSelect          
      
      Case #PB_Event_Gadget
        Select EventGadget()
          Case Button
              Debug "Button"
              
          Case thump_1
              SetActiveWindow(win)
              If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(thump_1, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
                  xx = WindowMouseX(win)
                  ttip = tbmin+(xx-16)/tbtrim
                  If xx < 16
                     xx = 16
                  ElseIf xx > GadgetX(thump_2) - 8
                    xx = GadgetX(thump_2) - 8 
                  EndIf                
                  ResizeGadget(thump_1,xx,#PB_Ignore,#PB_Ignore,#PB_Ignore)
                  HideWindow(twtip,0)
                  ResizeWindow(twtip,GadgetX(thump_1,#PB_Gadget_ScreenCoordinate)+10, GadgetY(thump_1,#PB_Gadget_ScreenCoordinate)-14,30,16)
                  SetGadgetText(thump_tt,Str(ttip))
                Else
                    HideWindow(twtip,1)
                EndIf
                _GetGadgetState(thump_1)
            
          Case thump_2
                SetActiveWindow(win)
                If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(thump_2, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
                  xx = WindowMouseX(win) 
                  ttip = tbmin+(xx-16)/tbtrim
                  If xx > tbwidth
                     xx = tbwidth
                  ElseIf xx < GadgetX(thump_1) + 8
                    xx = GadgetX(thump_1) + 8 
                  EndIf
                    ResizeGadget(thump_2,xx,#PB_Ignore,#PB_Ignore,#PB_Ignore)
                    HideWindow(twtip,0)
                    ResizeWindow(twtip,GadgetX(thump_2,#PB_Gadget_ScreenCoordinate)+10, GadgetY(thump_2,#PB_Gadget_ScreenCoordinate)-14,30,16)
                    SetGadgetText(thump_tt,Str(ttip))
                Else
                    HideWindow(twtip,1)
                EndIf
        EndSelect
                  ;_GetGadgetState(thump_2)    
  EndSelect
Until Quit = 1
End
Edit : More progress
Egypt my love
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Dual Thumps TrackBar Gadget

Post by davido »

HI RASHAD,
You've been busy! While I've been relaxing. :)

Looks really nice.

As you requested, I've checked it on the Mac:
On the Mac there are two problems:
1. The flickering still exists. But it is made worse by the whole window flickering.
2. If I drag the left-hand marker to the centre, then drag the right-hand marker it stops when it meets the left-hand marker at the centre, however then numbers keep decrementing as the mouse is moved past the two stationary markers.
DE AA EB
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Dual Thumps TrackBar Gadget

Post by Kwai chang caine »

Very nice and works fine on XP and v5.40
Thanks for this great sharing 8)
ImageThe happiness is a road...
Not a destination
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Re: Dual Thumps TrackBar Gadget

Post by RichardL »

Hi,

If you are watching this thread you may also like to check out:
http://www.purebasic.fr/english/viewtop ... 12&t=64845

RichardL
Post Reply