Image Priority

Blitz3D Forums/Blitz3D Programming/Image Priority

spriteman(Posted 2006) [#1]
I am creating a GUI and was wondering if there is a command to perform Image priority, so that if you clicked on one image it would draw that on top of the other and hide the previous image and related hotspots underneath. This means the image underneath may be partially obscured by the one on top and classed as inactive.

Is there a way of managing the partial obscurity so that if I clicked on the partially seen image underneath, it would appear on top and become active......If you know what i mean...


spriteman(Posted 2006) [#2]
So no help on this?

I am not sure its possible but there may be a workaround?

If it is unclear, I can try and clarify...


big10p(Posted 2006) [#3]
This should be pretty simple.

I'd make each image thingy a type so that the postition of each one in the list represents it's 'priority': the first in the list has lowest priority (is drawn first) and the last has highest (drawn last). You can then just use a For/Each loop to draw them in the correct order.

You can then run through the type list backwards to check for a click on each one. As soon as you find an image that has been clicked, make it top priority by moving it to the end of the type list (using 'Insert clicked_thingy After Last thingy_type'). Doing so this way will automatically handle overlapping images correctly.

[edit] OK, I got bored so here's a simple demo of the technique I'm talking about. :)



spriteman(Posted 2006) [#4]
Hi big10p

Thanks for the response. I have the priority part working. What I am having trouble with is managing the hotspots associated with the images.

For instance at the top of the image I have a bar which can be clicked on (hotspot) to bring that image to the front. If it comes to the top and an another image is hidden behind, the hotspots on the underneath image can still be activated. Is there a way of preventing this if the top image obscures the bottom. Could imageoverlap help?

PPS - Thanks of the code example, I will have a go at this..


big10p(Posted 2006) [#5]
Have you tried the demo I just posted? You may have missed it as we posted at about the same time.

I think it does what you want, or maybe I'm still not getting what you mean? :)


spriteman(Posted 2006) [#6]
Fantastic, this is just the ticket. Incredible type management!!!

I am just exploring the benefits of types. I was a bit unsure on how to manage the list of images. It solves the problem...:-)

It may be a good idea to put this in the code examples section.

Thanks big10p


big10p(Posted 2006) [#7]
No problem. OK, I'll stick it in the code archives for anyone else who may find it useful. :)


spriteman(Posted 2006) [#8]
Sorry to ask again big10p (or anyone) but is there an easy way to modify the code so that if I clicked on the topthingy shape, you would be able to move it around the screen to a new location. i.e mousedown, drag then releasemouse to drop.

From my own thinking, I could add an extra field to the Type, something like Field id% to track which shape thing in the type is on top, then move it. Is this the best way?

Thanks


Yan(Posted 2006) [#9]
Here's some code, it's pretty ancient, so probably not the best example but it should give you some sort of idea...


spriteman(Posted 2006) [#10]
Yan,

Thanks for the post. A good example of Z priority for 2D windowing. I see you are using an ID system to manage the state of the windows and gadgets and tracking this...

Instead of drawing the windows I will be using images of certain sizes.

This gives me a good idea. Thanks again.


big10p(Posted 2006) [#11]
Spriteman, in the code I posted, there's no need to store IDs to track the top thingy/window. Because of the way the list is organized, the top thingy is always the last one in the list, so, to get it, just do something like:
top_thingy.thingyT = Last thingyT



big10p(Posted 2006) [#12]
OK, here's my amended code to allow the thingies to be dragged around.