Customisable Scrollbar

Share your advanced PureBasic knowledge/code with the community.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Customisable Scrollbar

Post by collectordave »

Needed events from scrollbar that were not available and also to have different scrollbar designs so created one.

Hopefully all works fine as it does for me. The code for the scrollBar is here:-

https://github.com/collectordave/PureBa ... -Scrollbar

The scrollbar appearance can also be changed by creating your own drawing functions and changing the ones supplied by me.

I have written a small piece of code to help this is here:-

http://www.purebasic.fr/english/viewtop ... 12&t=67394

Anybody have any problems or new scrollbar designs please post. If needed I will change drawing procedures to work with the scrollbar code.

I wonder how many different scrollbars can be created.

I do not have access to my MAC at the moment so if someone could kindly test these two on a MAC and on Linux just to let me know.

Still working on the code only accepts 0 as minimum and 100 as maximum at the moment just changing it to accept any integer values.

Enjoy

cd
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Customisable Scrollbar

Post by collectordave »

Updated example with two scrollbar designs one must be the simplest scrollbar possible both displayed and working in the example.

All works fine on Windows and MAC with just one problem on the MAC the code to set the background colour seems to not work on the MAC.

Asked for help here http://www.purebasic.fr/english/viewtop ... 13&t=67418

Quick update help appreciated background colour now working. Thanks to all. Will post update to same link ASAP.

Regards

cd
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
uweb
User
User
Posts: 98
Joined: Wed Mar 15, 2006 9:40 am
Location: Germany

Re: Customisable Scrollbar

Post by uweb »

Thank you!
It looks good but sometime the ship in the vertical scrollbar disappears and
[08:29:09] Executable-Typ: Windows - x86 (32bit, Unicode)
[08:29:09] Executable gestartet.
[08:29:41] [ERROR] CGScrollBar01.pbi (Zeile: 373)
[08:29:41] [ERROR] StartDrawing(): StopDrawing() muss vor einem erneuten StartDrawing() aufgerufen werden.
[08:29:41] Die Programmausführung ist abgeschlossen.
means StopDrawing() have to be called bevor new StartDrawing()

After changing

Code: Select all

Delay(5) 
in Procedure ActionTimer in CGScrollBar01.pbi to 3 it works. After this I tries with 4 and set it back to 5. Now it works for a short test. I can't reproduce the error. But i did not change anything else.
I use Win 7 x64 with PB 5.50 on a i7-3930K. There was a big Download in Background.
Please pardon my English, my native tongue is German.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Customisable Scrollbar

Post by collectordave »

Hi

Managed to recreate a similar fault\bug.

It appears to be the way I am handling the thread. This is the first time I have used a thread just learning. Will look a little deeper after learning a little more.

Maybe the delay setting is a little high as well. Try Delay(1) it is there just let other programs have a chance.

Kind Regards

cd
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Customisable Scrollbar

Post by collectordave »

Ok

Sorry it took so long to update.

First thanks to wolfram for the pointers towards anti-aliasing etc these improvements are now included.

Thanks to oma and all others for the advice on other posts around.

This is an update. The bug with the thread has, i think been resolved, I was setting the end condition for the thread at the same time as killing the thread. This was causing a race where I had no idea which was going to win. All kill thread statements removed. a second thing was that the thread was created on every click in the gadget, this has now been restricted so that the thread is only triggered when the user clicks inside the small rise or fall boxes not on the main track. Works ok on my MAC now. Another was that all elements were redrawn every time. This is now restricted to a single draw at the initialisation stage of the gadget.

I have also included another scrollbar design in the download using the vector drawing commands with, to my amazement using the linear and circular gradient parts of the vector drawing library.

Add code to get the background colour where the scrollbar is drawn. Moved the clear scrollbar out to a function so it doesn't intefere with the scroll bar operation.

Please try and let me know of any problems.

regards

cd
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply