Unexpected z-order behaviour

Just starting out? Need help? Post your questions and find answers here.
WishMaster
Enthusiast
Enthusiast
Posts: 277
Joined: Fri Jun 17, 2005 7:13 pm
Location: Franconia
Contact:

Unexpected z-order behaviour

Post by WishMaster »

Code: Select all

OpenWindow(1, 0, 0, 500, 500, "")
CreateGadgetList(WindowID(1))
CreateImage(1, 500, 500)
CreateImage(2, 100, 100)
StartDrawing(ImageOutput(2))
Box(0, 0, 100, 100, RGB(255, 0, 255))
StopDrawing()
ImageGadget(1, 0, 0, 500, 500, ImageID(1))
ButtonImageGadget(2, 0, 0, 100, 100, ImageID(2))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Where is the ButtonImageGadget?
Image Image
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

PB is not designed to handle overlapping gadgets.
quidquid Latine dictum sit altum videtur
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 575
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Post by bembulak »

So all the Skinned Win32 Apps written in PureBasic are not working and just look good?
;)
cheers,

bembulak
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

... I guess, the Imagegadget has a built in "always on top" feature.. :roll:
it's the only gadget I'd found so far with this behavior and I'm not sure if this is a PB issue or a GTK one...

If changing the ImageGadget to a ButtonImageGadget... it works as expected... even when using two ImageGadgets its (visually) working as expected....

anyway... in my opinion as a "normal" Gadget the ImageGadget should behave like the other's... if possible.... and take care of the Z-order
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

GTk doesn't have a concept of z-order for widgets (if I'm correctly informated).
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Trond is right.

In fact, the usual way to organize widgets in gtk is not even by x/y positions and fixed sizes,
but by nesting them into layout containers and letting gtk decide the best size.
In this concept, overlapped widgets simply cannot appear, so there is no need for a z-order.

PB uses a GtkFixed to allow the fixed positioning, but the z-order issue remains.
Even PB on windows has some z-order issues, which is why we decided not
to support it in PB.
Simply avoid overlapping the Gadgets... it makes more sense in many ways anyway.
quidquid Latine dictum sit altum videtur
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 575
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Post by bembulak »

Ok, I can live with that answer. It's more explainable.

I do have the problem, because I _want_ the Gadgets to overlap (Button on an Image).
But I know the Window --> Frame --> Gadgets in Frame - stuff of GTK, or better: I heard of it.
Now it makes sense. It's not a bug, but a feature here, isn't it?

So I have to redesign a program....

Thanks for the answer.
cheers,

bembulak
CSAUER
Enthusiast
Enthusiast
Posts: 188
Joined: Mon Oct 18, 2004 7:23 am
Location: Germany

Post by CSAUER »

I cannot live with that answer. See following post: http://www.purebasic.fr/english/viewtop ... ght=zorder
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Unexpected z-order behaviour

Post by PB »

> Where is the ButtonImageGadget?

Here:

Code: Select all

OpenWindow(1, 0, 0, 500, 500, "")
CreateGadgetList(WindowID(1))
CreateImage(1, 500, 500)
CreateImage(2, 100, 100)
StartDrawing(ImageOutput(2))
Box(0, 0, 100, 100, RGB(255, 0, 255))
StopDrawing()
ImageGadget(1, 0, 0, 500, 500, ImageID(1))
ButtonImageGadget(2, 10, 10, 90, 90, ImageID(2))
SetWindowLong_(GadgetID(1), #GWL_STYLE, GetWindowLong_(GadgetID(1), #GWL_STYLE) | #WS_CLIPSIBLINGS)
SetWindowPos_(GadgetID(1), GadgetID(2), 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
You can thank Sparkie for the API calls that made this work. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
bender-rulez
User
User
Posts: 49
Joined: Mon Mar 14, 2005 11:30 am

Post by bender-rulez »

I can commit that the ImageGadget under Linux with GTK2 is always on top!

Before PB 4.xx it was not!

I got the problem with a selfmade grid (generated gridimage) for drag and drop buttongadgets on it!

Fact is:
PB 4.xx -> ImageGadget is always on top
PB 3.9x -> ImageGadget z-order is like the order in code....
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

You can use this function to force a gadget to be drawn on top.

http://www.purebasic.fr/english/viewtop ... ght=zdepth
Post Reply