Manually setting Z-Index in GUI?

Get technical support about the C++ source code and about Lua scripts for maps, entities, GUIs, the console, materials, etc. Also covered are the Cafu libraries and APIs, as well as compiling, linking, and the build system.
Post Reply
User avatar
Haimi
Posts:85
Joined:2011-11-23, 09:28
Manually setting Z-Index in GUI?

Post by Haimi » 2012-04-05, 14:17

Hi @ll,

is there a way to oveeride the Z-Index Settings of WindowT instances? I have a Problem with the (almost finished!!!) Draggable Classes, that I cannot drag an element over a later created Element. So I need to Set the currently dragged element to the highest Z-Index.
Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
User avatar
Haimi
Posts:85
Joined:2011-11-23, 09:28

Re: Manually setting Z-Index in GUI?

Post by Haimi » 2012-04-05, 14:58

Okay, did the first part of the trick: The GuiSys now has a pointer to the currently dragged window. So when a window renders its children, the dragged window is ommited, and the main render call from the GuiSys renders the dragged window afterwards. So while dragging it is always the topmost element. But if I change the parent by dropping the window onto another, and the new parent has been rendered after the dragged one, the new parent is rendered AFTER the dragged window. That is kind of weird...
Have I forgotten something? I changed the parent by simply using

Code: Select all

WindowDropareaT* drop = this->FindValidDroparea();
if (drop != NULL) {
	this->Parent = drop;
}
with WindowDropareaT being a direct subtype of WindowT.
Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Manually setting Z-Index in GUI?

Post by Carsten » 2012-04-05, 18:08

Haimi wrote:But if I change the parent by dropping the window onto another, and the new parent has been rendered after the dragged one, the new parent is rendered AFTER the dragged window. That is kind of weird...
Have I forgotten something? I changed the parent by simply using

Code: Select all

WindowDropareaT* drop = this->FindValidDroparea();
if (drop != NULL) {
	this->Parent = drop;
}
with WindowDropareaT being a direct subtype of WindowT.
Hmmm. This looks dangerously incomplete to me:
Neither did you update drop's children, nor the related Lua internals, as indicated in the comment starting here. What you need instead is something like this.

In other words, it would be the easiest if from C++ you called some window's Lua-implemented OnDrop() method / event handler, and from there re-parented the windows accordingly by calling RemoveChild() and AddChild() as required.
Best regards,
Carsten
User avatar
Haimi
Posts:85
Joined:2011-11-23, 09:28

Re: Manually setting Z-Index in GUI?

Post by Haimi » 2012-04-05, 18:28

Ah, okay. Well, I think that will be the very best solution :)
I will try this as next step, as soon as the dynamic gui size changing works, in other words - as soon as I get rid of that linker error ^^
Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
User avatar
Haimi
Posts:85
Joined:2011-11-23, 09:28

Re: Manually setting Z-Index in GUI?

Post by Haimi » 2012-04-05, 20:07

Did it!

I changed the "AddChild" method not to throw an error if there is aleady another Parent Window but ro remove the old parent and then add the child.

Is there any reason why there should be an error thrown?
Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Manually setting Z-Index in GUI?

Post by Carsten » 2012-04-07, 10:55

Haimi wrote:Is there any reason why there should be an error thrown?
Well, not really. But properly re-parenting a window requires to remove it from its former parent first, then add it to it's new parent.

If the latter implicitly included the former, that's ok as well, but it must essentially run both pieces of code; only removing the error check is not enough.

In "Git lingo", you might consider RemoveChild() and AddChild() as the "plumbing" commands that you could use to implement a SetParent() "porcelain" command. ;-)
Best regards,
Carsten
User avatar
Haimi
Posts:85
Joined:2011-11-23, 09:28

Re: Manually setting Z-Index in GUI?

Post by Haimi » 2012-04-08, 10:58

Carsten wrote:In "Git lingo", you might consider RemoveChild() and AddChild() as the "plumbing" commands that you could use to implement a SetParent() "porcelain" command. ;-)
Well, that is maybe the best idea :) I will consider doing it this way before submitting the patch :D
Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
User avatar
Haimi
Posts:85
Joined:2011-11-23, 09:28

Re: Manually setting Z-Index in GUI?

Post by Haimi » 2012-04-08, 23:34

Okay, I did the trick other ways.
I just finished the last features I wanted to have. Now the GUI can handle:
  • Dynamic GUI Size (GUI Size == Window Size)
  • Dragging Windows - Droppable and reverting
  • Restict Dragging to one Area of the Draggable Window
  • Dropareas with multiple acceptance classes
  • Multiple Droppable intersection types (like draggable inside dorparea or simple touching)
  • Ghosting for Draggables
[/list]
I will create a ticket with patches in the trac.
Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests