Page 2 of 4
Posted: Sat Oct 21, 2006 2:00 pm
by netmaestro
Thanks for testing it. I believe it's close enough to suit me. Unless there's a glaring bug in reasonably normal behaviour I'm happy. People holding multiple mouse buttons down and surfing around a screen on and off buttons shouldn't be too surprised by any result, imho. I appreciate your help, it's much tighter now.
Posted: Sat Oct 21, 2006 4:51 pm
by ts-soft
thx, very good!
how can i catch a event from custom-button with #PB_Any?
Code: Select all
ElseIf EventwParam() = mygadget
Debug "mygadget"
EndIf
doesn't work
Posted: Sun Oct 22, 2006 3:50 am
by netmaestro
There is an update to this library. It has a new (important, imho) feature: optional clipping mask. Here is an excerpt from the help file:
Optional Mask Image:
If you desire a clipping region, for an elliptical or polygonal-shaped button,
you may add a fifth image to your strip. This image serves as a clipping mask
and should be two colors: White to describe the 'hot' zone(s) and Black to
denote areas you'd like to exclude from collision testing.
This feature is especially useful for round buttons with a background size
larger than the ellipse, say to accomodate a drop shadow, etc. and if you include
a mask image your collision testing will be pixel-perfect on the button.
Images should appear in the strip left-to-right in this order:
Disabled, Unpressed, Hover, Pressed, Mask (optional)
Here's what an image strip utilizing the mask looks like:
There are no extra parameters to supply, if the mask is found the clipping region will be set to the white portion of the mask, else it will be the full rectangle of the button.
The demo is updated to show the difference in using the mask, one of the buttons uses it and the other doesn't. See how one button detects collisions from the corner when the mouse is still a few mm away. The other one works correctly as it uses the mask feature.
Posted: Sun Oct 22, 2006 9:44 am
by netmaestro
Fixed a couple bugs in the region scanner. Should be OK now.
@ts-soft: I can't reproduce that. If you could make a snippet that shows the failure it would help a great deal. Thanks.
Posted: Sun Oct 22, 2006 4:36 pm
by ts-soft
netmaestro wrote:
@ts-soft: I can't reproduce that. If you could make a snippet that shows the failure it would help a great deal. Thanks.
Code: Select all
;=================================
; test1.pb: Solid-color window
;=================================
LoadImage(0,"buttons2.bmp")
Transcolor = RGB(224,223,227) ; Background color of buttons2.bmp
OpenWindow(0,0,0,300,200,"",$C80001)
SetWindowColor(0, 14933984)
CreateGadgetList(WindowID(0))
mygadget = CustomButton(WindowID(0),#PB_Any,40,20,60,60,0,#CB_SolidBrush,Transcolor)
CustomButton(WindowID(0),1,120,20,60,60,0,#CB_SolidBrush,Transcolor)
CustomButton(WindowID(0),2,200,20,60,60,0,#CB_SolidBrush,Transcolor)
DisableGadget(mygadget,1)
Repeat
EventID=WaitWindowEvent()
If EventID = #CB_Button_Click ; This is how you check for button clicks
If EventwParam()=1 ; You don't use #PB_Event_Gadget, EventGadget()
DisableGadget(mygadget,0) ; or EventType(). They don't apply to
ElseIf EventwParam()=2 ; CustomButtons.
DisableGadget(mygadget,1)
ElseIf EventwParam() = mygadget
Debug "mygadget"
EndIf
EndIf
Until EventID=#WM_CLOSE
doesn't debug "mygadget"
Posted: Sun Oct 22, 2006 9:41 pm
by netmaestro
Hm. It's working here. Do you have a recent version of CustomButton installed, and if so, what is your OS?
Posted: Sun Oct 22, 2006 10:21 pm
by ts-soft
netmaestro wrote:Hm. It's working here. Do you have a recent version of CustomButton installed, and if so, what is your OS?
with updated version it works fine

Posted: Mon Oct 23, 2006 3:22 am
by Sparkie
Nice work netmaestro

Posted: Wed Nov 15, 2006 1:56 pm
by nicolaus
i have found a small bug. if you press the right mouse button you have the same events wat you have with the left mouse button.
Normal you dont have events if you press the right mouse button over a ButtonGadget.
regards,
Nico
Posted: Tue Apr 24, 2007 12:43 pm
by Padde
Are there any plans to support PNG alphachannel transparency
like DrawAlphaImage does? In my current project i frequently
use your custombuttons with different kind of shapes and especially
not rectangular ones looks crappy with single color transparency.
Almost all image tools like Adobe Photoshop and so on apply some
sort of antialias to give a smoother look and due to this the colors
messed up and you will see some kind of border around the button.
On the other side.. if you dont use antialias your buttons get a chiseled
look.
In the moment i use a dirty hack to use transparent buttons on different
background images without chiseled look or borders.
Code: Select all
button = LoadImage(#PB_Any,"C:\alphachannelimage.png")
background = LoadImage(#PB_Any,"c:\mybackground.bmp")
countofsubpictures = 5 ; disabled, normal, mouseover, pressed and the mask
buttonheight = ImageHeight(button)
buttonwidth = ImageWidth(button)/countofsubpictures
;get the part of the background image where the button will be placed
buttonbackground = GrabImage(background, #PB_Any, buttonx, buttony, buttonwidth, buttonheight)
;create the new button image with the smooth transparency for THIS background image
newbuttonimage = CreateImage(#PB_Any, ImageWidth(button), buttonheigth)
;walk through all button states in the button image and place them on the new buttonbackground with alphachannel
For x = 0 To countofsubpictures - 1
StartDrawing(ImageOutput(buttonbackground))
DrawAlphaImage(ImageID(button), -buttonwidth * x, 0)
StopDrawing()
StartDrawing(ImageOutput(newbuttonimage))
DrawImage(ImageID(buttonbackground),x*buttonwidth,0)
StopDrawing()
Next
; and finaly our custombutton
newcustombutton = CustomButton(WindowID(#mywindow), #PB_Any, buttonx, buttony, buttonwidth, buttonheight, newbuttonimage, #CB_SolidBrush, 0)
this is just a snippet and works well for my needs .. but if you
use some cool alphachannel tricks in a button state other than the
first one you will get some trouble because i drawing over and over
again on the same image.. so be warned
But moving that grabimage line inside the for-loop should fix this.. not tested
so still be warned
To cut a long story short... i really would appreciate a native alphachannel
buttonimage support for the custombuttons.
Thank you for your attention.. please enjoy your further forum ride

Posted: Sat Nov 10, 2007 9:22 pm
by mrjiles
Does anyone have these files available? Site appears down...
Thanks in advance!
Posted: Sat Nov 10, 2007 9:42 pm
by rsts
I believe (netmaestro may correct me) it's due to his currently using dial up.
He should have higher bandwidth capabilities soon and will probably resume hosting his site.
cheers
Posted: Sat Nov 10, 2007 10:02 pm
by mrjiles
I have a VPS I don't use much of so if anyone needs any temp space I can setup an FTP account...
Posted: Sat Nov 10, 2007 11:17 pm
by netmaestro
I don't have any connection to the internet at all since we moved to the farm. I get to the library or an internet cafe usually once a day for a half-hour or so and that's it. I could have signed up for a dialup account but that would have meant getting a landline phone which we haven't had for three years now. A communications company in our area is rolling out a rural broadband service via wireless hotpoints that will service our place and we're scheduled for an installation on the 15th of November, so I should have everything back up and running by then.
Posted: Sat Nov 10, 2007 11:23 pm
by srod
I wondered where you'd gotten to lately netmaestro? Looking forward to having you back soon lad.
