Gadgets Z Order

BlitzMax Forums/BlitzMax Programming/Gadgets Z Order

DredPirateRoberts(Posted 2005) [#1]
Is there a way to change the Z Ordering of Canvas gadgets ( or any gadget ) .. i have multiple canvas's and need to
be able to select the correct one but most of the time it selects one that is under another.


Beaker(Posted 2005) [#2]
http://www.blitzbasic.com/Community/posts.php?topic=53944


skidracer(Posted 2005) [#3]
Scott, I'll see if I can get something working for you.


DredPirateRoberts(Posted 2005) [#4]
That be great . cuz im making some custom gui gadgets for this program im workiing on . everything works but the zorder problem.


-Scott


LordChaos(Posted 2008) [#5]
Hi!

*push* I'm afraid I have the same problem: I have one big canvas with some canvas within it (like an MDI app). And I can't change the order of the inner canvas windows. :(

Is there a solution?


Brucey(Posted 2008) [#6]
You mean Panel, not Canvas, right?


LordChaos(Posted 2008) [#7]
I use a canvas because I draw some shades behind the windows with Max2D.
The background however is not a problem, but the sorting of the canvases in the big one!


Brucey(Posted 2008) [#8]
That's probably why it doesn't work properly then.

OpenGL especially doesn't like any controls on top of its context - it tends to draw over them, regardless.


LordChaos(Posted 2008) [#9]
Sorry, it's not so easy for me to explain! I'm talking about the inner canvases, who need to be sorted. (Like if I click one of them it should pop in front of all others)

The background is rendered probperly behind everything, regardless whether it is a canvas or panel, or GL or D3D7.


tonyg(Posted 2008) [#10]
How about posting some example code?


LordChaos(Posted 2008) [#11]
Very simplified. The order of the canvases (!?) can only be influenced by the order of the CreateCanvas commands.

SuperStrict



Local window:TGadget = CreateWindow("blub", 100, 100, 800, 600, Null, WINDOW_TITLEBAR | WINDOW_CLIENTCOORDS)



Local canvas:TGadget = CreateCanvas(0, 0, ClientWidth(window), ClientHeight(window), window)


Local window2:TGadget = CreateCanvas(200, 320, 100, 100, canvas)
Local window3:TGadget = CreateCanvas(280, 400, 150, 50, canvas)
Local window1:TGadget = CreateCanvas(100, 100, 300, 450, canvas)


CreateTimer(30)


Repeat

 WaitEvent()


 Select EventID()
   Case EVENT_TIMERTICK
    RedrawGadget(window2)
    RedrawGadget(window3)
    RedrawGadget(window1)

   Case EVENT_GADGETPAINT

    SetGraphics CanvasGraphics(TGadget(EventSource()))
    SetViewport 0, 0, GraphicsWidth(), GraphicsHeight()

    Select EventSource()

      Case canvas
        SetClsColor 0, 0, 0
      Case window1
        SetClsColor 255, 255, 255
      Case window2
        SetClsColor 255, 0, 0
      Case window3
        SetClsColor 0, 0, 255

    End Select

    Cls
    Flip

   Case EVENT_WINDOWCLOSE

    End

 End Select

Forever



Dreamora(Posted 2008) [#12]
that will not work.

Canvas is no valid gadget container, nor can you draw a canvas on top of another one with guaranteed behavior.

Use a single canvas and a graphic window system or whatever to get the same behavior (-> SetViewport for example)


Brucey(Posted 2008) [#13]
that will not work.

I already said that :-)


tonyg(Posted 2008) [#14]
that will not work
... and it is why he's posting. Do keep up!


LordChaos(Posted 2008) [#15]
The problem is that I use plugins (in form of external dlls) who need a hWnd. So I need real gadgets for each window and cannnot use only one.


Dreamora(Posted 2008) [#16]
Then you must change your plugin structure.
That attempt will not work you can only draw to a virtual area within the canvas if they must be "above each other".
the only other alternatives are what all apps do: create a new window with a new canvas on top.


LordChaos(Posted 2008) [#17]
That's very annoying, because it's not my plugin structure, but Steinbergs (I'm loading VSTs).


Dreamora(Posted 2008) [#18]
Thats not annoying, that how that whole stuff works for all applications.
The annoying part is that many devs here never spend the time to research on the technology before starting stuff and blaming others!

You can choose between developing your own plugin structure, write an intermediate wrapper for steinbergs that redirect the stuff that needs a hwnd into a "virtual canvas" within the real one while presenting an existing hwnd to the plugins or put them in an own place like a canvas within a new window or the like.


LordChaos(Posted 2008) [#19]
Finally: another solution (remarkable simple):

SetWindowPos (WinAPI function) has a hWndInsertAfter parameter, which can be set to HWND_TOP: Works perfectly. :)

Would it be possible to implement a parameter for SetGadgetShape which controls the z-order? (I dunno if it is possible, because I don't know how it works on Linux or Mac).

Would be very cool!