Ruler Gadget - Beta 1 sourcecode library

Share your advanced PureBasic knowledge/code with the community.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Finished the gadget, details in first post. It's actually usable now. I think there's something wrong in Tailbite as it compiles the lib fine but generates an IMA in ExamineTabStops() at runtime. The code in that proc is simple and clean and runs perfectly compiled with PureBasic.

I appreciate anyone testing the gadget and reporting anything it does that doesn't seem right, any and all reports are welcome.
BERESHEIT
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

That's very cool.
Any chance of seeing that as a Userlib? :D
techjunkie
Addict
Addict
Posts: 1126
Joined: Wed Oct 15, 2003 12:40 am
Location: Sweden
Contact:

Post by techjunkie »

Wow! I'm going to have a wet dream about this gadget tonight! :lol: Great work!!
Image
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

I must confess that an increase in laundry bills was not anticipated as a side effect of using this. For a temporary workaround, you could consider printing out a screenshot of the gadget and pasting it to your wife's forehead. At least until a proper fix is implemented.
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

@netmaestro, move the 'Static Newlist' command to the init procedure and it then works fine with Tailbite.

Code: Select all

ProcedureDLL RulerGadget_Init()
  Global NewList tabs() 
EndProcedure
Actually, simply replacing Static by Global in the NewList() seems to work, and without using the _init procedure. :)
I may look like a mule, but I'm not a complete ass.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Thanks a million srod! You saved me a lot of time. I'd traced the error to the static list and was going to replace it with a self-managed block of allocated memory, which would have taken some fiddly coding. I'd like to avoid globals in libs if possible, it's not a problem for the compiled lib but for .pbi files it's important not to use globals and name them something basic like tabs() as it might conflict with something else a coder is doing. One alternative is to use two sources, one to compile with Tailbite and one to use as .pbi, but that gets to be a pain pretty quick. I compromised by keeping the codebases identical and changing the name of the list to RG_gTabs().

New download available: Library installer, details in first post.

@byo: yup.
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You could define a constant and then use some compiler directives within the underlying procedure:

Code: Select all

;#RulerGadget_StaticLib = 1 ;Uncomment if compiling a static lib.

Code: Select all

CompilerIf Defined(RulerGadget_StaticLib, #PB_Constant)
  Global NewList Tabs()
CompilerElse
  Static NewList Tabs()
CompilerEndIf
I may look like a mule, but I'm not a complete ass.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Performance update, no new features but the drawing routine for the tabstops is retooled with the following problems fixed:

- If you moved a tabstop under a slider and held it there, the slider would flicker intermittently

- If you dropped several tabstops on top of each other under a slider, they would overwrite the rightmost 2 pixels of the slider, leaving an ugly effect that would stay until the slider was moved

- The tabstops could be dragged downwards, this was to allow them to be removed by dragging off the gadget. This has been changed so that they don't move down at all but will be removed if the mouse pointer goes below a certain distance under the gadget. This is exactly the behavior of Microsoft's (inferior) version, and after much experimentation, I like it better.

- All discernible flicker has now been removed with this update, here at least

Both posted code and library installer are updated with the improvements
BERESHEIT
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Significant update today, the ruler now generates events for everything that happens on it. Details in first post. Sorry for the lack of a helpfile, but you should find your way easily if you study the eventloop of the example program.
BERESHEIT
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Little did I know what it would involve -

netmaestro, you've outdone yourself.

Magnifico.

(and many thanks)
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

You're most welcome :wink:
Little did I know what it would involve -
Me too! I went into it with the idea that it's little more than an ownerdrawn scrollbar with a couple extras added on, now a week and 800 lines of code later I'm still not finished! I'm doing RulerUndo(#actions) today, then a help file and it really should be done. I actually held off a couple of days before starting it because I figured there was a good chance a) something off-the-shelf was around, or b) your fellow Buckeye would take up the cause. But I guess he's snoozing in front of old WKRP reruns or something... :lol:
BERESHEIT
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

netmaestro wrote: snip b) your fellow Buckeye would take up the cause. But I guess he's snoozing in front of old WKRP reruns or something... :lol:
ROF :lol: - he probably had a better idea what would be involved :wink:

I figured between the two of you something would be made. But I actually expected something based off a control and API's. I had no idea it would be quite this involved or I would have felt too guilty to ask :oops:

This is 'legacy' code - and I don't mean that in the mainframe sense.

cheers
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Compiled version of the library for PureBasic 4.10 available, link added to first post

Compiled version for 4.02 is still there too for now until 4.10 goes release.
BERESHEIT
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

@netmaestro
Could you update the installer in firt link?
It gives to me several errors and don't install anything.
Thans in advanced.
QuimV
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Sorry, should work now. If you're using PB v4.10 you should use the link from June 1. For 4.02 the first link should be fine. It works as an Include file too, the posted code does.
BERESHEIT
Post Reply