Board index FlightGear Development Canvas

Supporting rendering precedence for groups  Topic is solved

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

Supporting rendering precedence for groups  

Postby Hooray » Mon Sep 24, 2012 11:49 am

TheTom wrote:
hooray wrote:Now, without explicit design, enforcing rendering order is a little tedious, so that taxiways may get rendered on top of runways.
I'd suggest to extend the C++ code such that groups may have a pre-defined rendering order, so that hiding/showing child groups, will automatically honor the proper rendering order.


We could simply support child nodes "render-before", "render-after" - and specify the index of another group.
I have already though about this earlie and will do something like the css z-index, where the default value is 0 and with positive or negative numbers groups/elements are rendered before or after elements with a lower index. To keep it simple I'll probably won't do it completely like CSS but instead just support ordering inside each single group.


fixed in NEXT
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11437
Joined: Tue Mar 25, 2008 8:40 am

Re: Supporting rendering precedence for groups

Postby jam007 » Fri Feb 08, 2013 4:15 pm

Since I started working on a canvas radar I'm curious. How do I code so that one child is drawn "on top" of another?
jam007
 
Posts: 477
Joined: Sun Dec 16, 2012 10:04 am
Location: Uppsala, Sweden
Version: 2017.3.1
OS: Ubuntu 16.04

Re: Supporting rendering precedence for groups

Postby TheTom » Fri Feb 08, 2013 4:32 pm

Either just add the children in the correct order - Children added later are drawn on top of existing ones- or set the "z-index" property on the children as you need them. It's 0 by default and you can assign any integer value you like where higher index means later drawn.
TheTom
 
Posts: 321
Joined: Sun Oct 09, 2011 10:20 am

Re: Supporting rendering precedence for groups

Postby jam007 » Fri Feb 08, 2013 5:21 pm

Thanks!
jam007
 
Posts: 477
Joined: Sun Dec 16, 2012 10:04 am
Location: Uppsala, Sweden
Version: 2017.3.1
OS: Ubuntu 16.04

Re: Supporting rendering precedence for groups

Postby jam007 » Tue Feb 26, 2013 10:39 am

Previously I solved the ordering by puting the children in the right drawing order. But now I tested setting z-index, sine I will need to do that later, but can not get it to work.
My code:
Code: Select all
    m.scale=g.createChild("image")
             .setFile("Radar/scale.png")
             .setSourceRect(0,0,1,1)
             .setSize(1024,1024)
             .setTranslation(0,0);
    m.scale.set("z-index",1);

.... Other children with default z-index

The scale still gets drawn first with the others on top.
What am I doing wrong?
jam007
 
Posts: 477
Joined: Sun Dec 16, 2012 10:04 am
Location: Uppsala, Sweden
Version: 2017.3.1
OS: Ubuntu 16.04

Re: Supporting rendering precedence for groups

Postby TheTom » Tue Feb 26, 2013 12:09 pm

jam007 wrote in Tue Feb 26, 2013 10:39 am:What am I doing wrong?

Nothing ;) I've just pushed a fix. If you change the z-index after adding children everything worked, but adding children after setting the z-index didn't update the ordering...
TheTom
 
Posts: 321
Joined: Sun Oct 09, 2011 10:20 am

Re: Supporting rendering precedence for groups

Postby jam007 » Tue Feb 26, 2013 12:42 pm

Ah!
jam007
 
Posts: 477
Joined: Sun Dec 16, 2012 10:04 am
Location: Uppsala, Sweden
Version: 2017.3.1
OS: Ubuntu 16.04


Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest