Board index FlightGear Development Canvas

Aircraft Center | pui2canvas parser (devel-list follow-up)

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.

Re: Aircraft Center | pui2canvas parser (devel-list follow-u

Postby bugman » Tue Jun 21, 2016 8:53 pm

I would suggest having side-by-side screenshots of the PUI and CUI dialogs on the wiki article. It would be useful for tracking progress, graphic design, aesthetic layout, and how close to functional this is ;)

Regards,
Edward
bugman
Moderator
 
Posts: 1808
Joined: Thu Mar 19, 2015 10:01 am
Version: next

Re: Aircraft Center | pui2canvas parser (devel-list follow-u

Postby Hooray » Tue Jun 21, 2016 9:12 pm

yeah, that's a good idea - and one recently suggested to me in private - however, none of the screenshots is intended to claim that the UI is fully functional, a screenshot would be insufficient to "prove" that - it's really just demonstrating the completeness of the parser, not of any functionality mappings.

And I specifically stated that certain tags (widgets, and layouts) are ignored altogether - and the "n/a" label actually tells you so, too.

Referring to the "mammooth task" you mentioned, it is meanwhile pretty safe to say that it's less than a handful of widgets that are now missing to be able to approximate most PUI widgets/dialogs - it goes without saying that this won't look as good as a Qt5 UI, but it also won't have the costs associated with it - i.e. you could say, the pui2canvas approach is merely a simple fasttrack concept to get rid of PUI completely, without having to manually port any of the existing resources necessarily.

However, based on these experiments, I am actually in agreement with James' and Torsten's comments regarding the state of affairs in PUI/XML land: custom Nasal blobs should be actively discouraged, and probably discontinued/phased out sooner or later.
Well, I could make it show a big red rectangle whenever an unsupported widget is ignored ...

What is needed is an extensible file format to get rid of these constructs, so that they can be replaced with the corresponding layout/widget tags (think for tabs), as well as custom fgcommand implementations, which could then be shared among all front-ends. Sooner or later, this would end up being fully-declarative, and could be easily processed by all UIs - at which point a 1:1 Qt migration would be much less work, no matter if that involves procedural UI generation or semi-automated translation using some scripted approach.

What is currently taking place in PUI/XML space is hugely problematic for anything that does not run within the FlightGear process space and that does not have access to the Nasal subsystem, and that needs to change - for features like Phi/Qt etc to work, Nasal use must be encapsulated, i.e. delegated through some kind of "service layer" that is isolated from internals.

Anyway, Thorsten was right - it would be possible for a dedicated team of experienced Nasal/Canvas "hackers" to phase out PUI entirely, without causing tons of work - while I have been collecting a few ideas for improving the C++ interface of the Canvas code, I don't see many additions that are really required - it is one widget that James once added which is using data that is not currently accessible, i.e. the loglist widget - and we specifically talked about that a while ago, he ended up not quite sharing my view, so he moved on with its implementation - but otherwise, everything else can be approximated using a handful of additional widgets.

Besides, given that you are obviously interested in this, and given your wiki experience, you are obviously invited to help and come up with a corresponding table for those pui screenshots (or even the corresponding shots).

For example:
Image

(It would take 5 LOC to actually show the initial state of each checkbox, it just hasn't been a priority so far)
But this dialog does contain embedded nasal code which procedurally modifies its own dialog tree to add/customize widgets, which is working correctly here.

However, I wasn't planning on regularly updating those shots - I was merely documenting some progress - let's keep in mind that the parser was laying dormant for the past 6+ months, so -in total- I still haven't spent more than a week's time of spare time hacking on it so far, i.e. have really only been motivated to resurrect it due to the recent events and debates, we've been having.

I have begun documenting some of the work that lies ahead: http://wiki.flightgear.org/Howto:Proces ... as#Roadmap
And I am also hoping to document useful C++ changes: http://wiki.flightgear.org/Howto:Proces ... C.2B.2B.29

As far as I can see the original proposal that James and Tom came up with is very solid, and the kind of work that I am doing is sufficiently straightforward that it would be possible for 1-2 dedicated contributors to bring the parser up to par with the PUI engine, but even the new Qt5 UI, without too much work.

But regardless of the outcome of this, this work is fairly self-contained and instructional for other reasons, i.e. helping unify the 2D rendering back-end (2D panels, HUD, splash screen, osgText animation) for better OpenGL compatibility, as per James' original proposal: http://wiki.flightgear.org/Unifying_the ... via_canvas

In other words, the whole approach could be adapted to also parse legacy 2D panels and HUD XML files to use modern OSG-aware OpenGL code, and any improvements to the lower-level C++ code would obviously not be specific to just the UI use-case.
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Aircraft Center | pui2canvas parser (devel-list follow-u

Postby Hooray » Sat Jul 08, 2017 9:40 am

bugman wrote in Tue Jun 14, 2016 2:10 pm:As for Qt being optional, over the last two years on the mailing list, that position has obviously evolved. I'm only stating what I see. And that is that it will be only optional for a tiny subset of people. The majority will use it, probably without knowing, as it will be the default GUI shipped with FG.


Just a little update, roughly ~12 months later, it seems indeed that bugman was right: the position on using Qt5 for the in-sim UI seems to have evolved (though, not exactly in line with bugman's original assertion a year ago):

https://sourceforge.net/p/flightgear/ma ... /35863607/
James Turner wrote:I would say do the PUI fix for now, I am still very much undecided about which technology to use for in-sim GUI. I am somewhat inclined towards using the Canvas, because it avoids some rendering issues (but exposes a few more, + some performance ones) but the problem is I am fairly unhappy with the GUI / widget API in the Canvas right now - it does not satisfy my ideas about how simple + robust such an API should be. I need to evaluate if the current API can be improved or needs to be drastically changed.

The other issue is to use QtQuick rendered into OpenGL, which has a very nice robust and well-designed API, but adds some dependencies and complicates the rendering architecture, which makes me nervous about multi-window setups and other more esoteric OSG configs.

So, yes, I’d say do PUI for now, since this is worth a fairly quick fix as it’s the default airport.

Kind regards,
James

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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

survival of the fittest

Postby Hooray » Fri Sep 02, 2022 2:52 pm

https://wiki.flightgear.org/PUI#2022
James wrote:https://sourceforge.net/p/flightgear/ma ... /37701750/
It was going to be Qt but it started to get very complicated with changes in Qt 5.15 + Qt 6, so I’m going with a more light-weight approach now.

Qt added support for Vulkan / Metal / D3D starting in 5.15, but FlightGear / OpenSceneGraph can’t support those, so integrating the two renderers went from being ‘complicated but ok’ to ‘very very complicated’. (If for some reason anyone wants the code to render Qt Quick in OpenGL mode into OpenSceneGraph, I have it working nicely on a branch, from about two years ago...)

So now i’m going with something much lightweight using some C++ compatibility code, some Nasal for styling and the existing widget rendering from Thomas with some extensions and additions: some pieces are in FlightGear & FGData already. I have basic dialogs working okay but not the more complex ones and everything looks kind of ugly, I need to improve the visual look before I share screenshots to avoid everyone freaking out :) The disadvantage of this approach is I’m far from expert at creating visual appearances this way, so it’s kind on unrewarding and slow for me.
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: survival of the fittest

Postby TheEagle » Fri Sep 02, 2022 3:31 pm

Hooray wrote in Fri Sep 02, 2022 2:52 pm:https://wiki.flightgear.org/PUI#2022
James wrote:So now i’m going with something much lightweight using some C++ compatibility code, some Nasal for styling and the existing widget rendering from Thomas with some extensions and additions: some pieces are in FlightGear & FGData already. I have basic dialogs working okay but not the more complex ones and everything looks kind of ugly, I need to improve the visual look before I share screenshots to avoid everyone freaking out :) The disadvantage of this approach is I’m far from expert at creating visual appearances this way, so it’s kind on unrewarding and slow for me.

May we know what that "something" actually is ? ;)
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Aircraft Center | pui2canvas parser (devel-list follow-u

Postby Hooray » Sun Sep 04, 2022 2:42 pm

Apparently, a new parser written in Nasal to parse PUI/XML and translate that into Canvas widgets, some of which are currently in the process of being created, to display these dialogs using the Canvas GUI system implemented back in 2012 (aka a decade ago) ...

To learn more about creating your own Canvas widgets, see: https://wiki.flightgear.org/Howto:Creat ... GUI_Widget


https://wiki.flightgear.org/PUI#Replacement_status




Also note, that the original parser prototyped 6 years ago, was already able to handle complex dialogs, i.e. those created procedurally or those using a ton of embedded Nasal blobs, including even sub-canvas areas:

Image
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Aircraft Center | pui2canvas parser (devel-list follow-u

Postby TheEagle » Sun Sep 04, 2022 3:04 pm

In fact, I started working on a slider widget some time ago, for the ground towing dialog of my C210, which I wanted to implement in Nasal - but then, my focus shifted onto the new 3D model (and I did some work on two other aircraft as well) so it was never finished. I could finish that in the near future - so, maybe implement the other widgets first ! ;)
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Aircraft Center | pui2canvas parser (devel-list follow-u

Postby Hooray » Sun Sep 04, 2022 3:11 pm

A slider is basically nothing more than a button responding to a drag/drop event, which in turn changes its position horizontally or vertically - so, we already have that, too - using event handling and updating the position of the widget :D

Besides, keep in mind that the ScrollArea/LineArea widgets already have its own slider implementation, which you could borrow from (see the right hand side of the text area):

https://wiki.flightgear.org/Canvas_widget_matrix
https://sourceforge.net/p/flightgear/fg ... llArea.nas


What people are missing, we have more stuff than you might think, because any Nasal/Canvas code used by aircraft (MFDs) could be adapted to be used for that upcoming UI - and as a matter of fact, the artwork currently used by the Canvas GUI system was borrowed from Ubuntu, too. In other words, we can reuse a ton of stuff - people only need to look at some of the more sophisticated airliners.
For instance, there was recently talk about implementing sub-menu functionality - and that, too, is already existing - we can trivially render a menubar using the Canvas system, and we can also trivially support sub-menus, nothing is missing here - it's all supported out of the box, and has been working for the last 10 years, regardless of platform specifics like Mac OS/Ẁindows etc ....

Image

What's currently missing are hooks to support i18n support to scripting space, so that we can access all the different languages in scripting space - which is why early menubar prototypes were simply using the name/title of each menu, rather than the localized text:

https://wiki.flightgear.org/Howto:Makin ... as_Menubar
Image

Obviously, the real menubar would rather work without the window decoration being enabled, and it would rather be using nested popups with buttons for each entry - but all the stuff is there already, and has been there for 10+ years meanwhile - none of it is specific to a single platform/build, it will work on all systems, just like the Canvas system as a whole.

Under the hood, the Canvas GUI system is nothing more than a special canvas placement, with event handling support.
Last edited by Hooray on Sun Sep 04, 2022 3:21 pm, edited 1 time in total.
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Aircraft Center | pui2canvas parser (devel-list follow-u

Postby TheEagle » Sun Sep 04, 2022 3:15 pm

Hooray wrote in Sun Sep 04, 2022 3:11 pm:I slider is basically nothing more than a button responding to a drag/drop event, which in turn changes its position horizontally or vertically - so, we already have that, too - using event handling and updating the position of the widget :D

Is there really a class canvas.Slider in next which I can just create an object of and add it to my layout ?
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Aircraft Center | pui2canvas parser (devel-list follow-u

Postby Hooray » Sun Sep 04, 2022 3:21 pm

It's currently part of the LineEdit/ScrollArea implementations, but you could borrow code from it - and as I said, you'd only need to sub-class a Button and create a ScrollableButton for vertical/horizontal scrolling, i.e. with event handlers that respond to drag/drop and click events - that way, you could also add buttons with arrows for the beginning/end of the slider, e.g.:


<< .............. [slider] ...........>>

To implement a slider from scratch, just create a new Canvas widget, sub-class it from Button.nas, and then make it respond to events:

- click: retrieve new x/y position and set the position of the widget
- drag/drop retrieve new x/y position and set position of the widget

That way, you can fairly easily prototype new widgets, including an airport list widget or a basic (but functional) property browser, using roughly 30 lines of code per widget:

Image
Image

Like I said, once you're using Nasal and Canvas, there already is a ton of code that people can use - you just need to open the corresponding Nasal files to see for yourself:

The extra500 has a working implementation of tabbed dialogs:
Image

And the FG1000 features a bunch of more sophisticated UI widgets:
Image
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Aircraft Center | pui2canvas parser (devel-list follow-u

Postby merspieler » Sun Sep 04, 2022 5:14 pm

if everything's there for ages, why wasn't it widely used?
Nia (you&, she/her)

Please use gender neutral terms when referring to a group of people!

Be the change you wish to see in the world, be an ally to all!

Join the official matrix space
merspieler
 
Posts: 2241
Joined: Thu Oct 26, 2017 11:43 am
Location: Wish to be in YBCS
Pronouns: you&, she/her
Callsign: you&, she/her
IRC name: merspieler
Version: next
OS: NixOS

Re: Aircraft Center | pui2canvas parser (devel-list follow-u

Postby Hooray » Sun Sep 04, 2022 5:37 pm

It was initially being developed by one core developer, and subsequently used by some early adopters to prototype UIs.

Shortly afterwards, there was a consensus discussed on the devel list to use this approach to unify the 2D rendering backend in FG, brought up by a handful of core devs.

However, that overlapped with the introduction of the new integrated Qt based launcher, which looked so promising that a number of folks were hoping, Qt could also be used for the internal UI.

Because of those talks, all people involved in revamping the integrated UI using the canvas system took a step back, hoping that the Qt effort would materialize soon'ish

A number of folks who were still tinkering with a canvas UI were explicitly told not to pursue this option, out of fear that such an effort could materialize much sooner in comparison to the Qt effort, and that the Qt option would thus be stillborn by default.

All of the nitty-gritty details can be looked up in the archives - the pui2canvas and qtquick articles on the wiki provide a rough summary, including links to the original discussions:

https://wiki.flightgear.org/Howto:Proce ... ing_Canvas
https://wiki.flightgear.org/QtQuick_use_in_FlightGear

Unrelated to all of this, aircraft devs kept using the canvas UI system - because they could not afford to create UIs that would only work in Qt enabled builds, which was another consensus reached by core devs: Qt must never be required to build or use FG.
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Aircraft Center | pui2canvas parser (devel-list follow-u

Postby Thorsten » Mon Sep 05, 2022 8:01 am

Unrelated to all of this, aircraft devs kept using the canvas UI system - because they could not afford to create UIs that would only work in Qt enabled builds,


... and because you get a seamless integration with in-aircraft displays - which are, after all, driven by the same technology. I found it for instance very neat that in-sim I have a display that is controlled by buttons underneath while if you expand that display into a GUI dialog, it becomes a touchscreen.

At hardly any effort, since I also have a lib of (a bit more specialized) canvas GUI widgets.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Aircraft Center | pui2canvas parser (devel-list follow-u

Postby Hooray » Mon Sep 05, 2022 3:21 pm

The original idea/discussion can be looked up in the devel-archives, but the meat of it can also be found here (a collection of quotes from the devel list, of statements made by core devs at the time): https://wiki.flightgear.org/Howto:Proce ... Discussion

The background here being, that the Canvas system was in the process of being used for a built-in launcher (called the "aircraft center", pre-dating the current Qt launcher):

https://wiki.flightgear.org/Aircraft_Center
Image


This built-in launcher is entirely coded in Nasal/Canvas space, and still exists in FG today - however, it's been disabled in favor of the new Qt launcher - but also in builds not having Qt support.
The background can be looked up here, which is a copy of the announcement of the new Qt launcher: https://wiki.flightgear.org/QtQuick_use ... Background

All that being said, writing a parser to dynamically translate PUI/XML into Canvas properties really is the only sane option, and also has been the only option - simply because of the lack of manpower, but also because of technical constraints (see James's comments).

Back in 2012 (yikes, 10 yrs ago!!), the Canvas GUI system was specifically designed to help us get rid of PUI/XML, and the core developers involved in that discussion, laid out the plans for this step: https://wiki.flightgear.org/Howto:Proce ... Discussion

As can be seen in various screen shots, writing a parser to render PUI/XML dialogs in much less work than porting a single dialog - what's obviously missing is a handful of widgets, but even those can be created relatively easily, because it's a set of skills that most aircraft developers are already familiar with, namely: Nasal + Canvas + timers and listeners

6 years ago, we used a simple dialog to pre-view different dialogs for testing purposes, and that should also work for the new parser:
Image

Also note, any new widget/layouting directive that is supported by the parser, will automatically benefit all GUI dialogs, including those kept outside $FGDATA, i.e. aircraft specific dialogs living in other hangars.

Going through the fgcommand based dialog handling layer, also means that all existing uses of dynamically created/modified dialogs will "just work", including those doing fancy meta-programming, e.g. the joystick handling dialog and other stuff making use of fancy PUI/Nasal hacks.

Image
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Aircraft Center | pui2canvas parser (devel-list follow-u

Postby TheEagle » Mon Sep 05, 2022 3:28 pm

Hooray wrote:Also note, any new widget/layouting directive that is supported by the parser, will automatically benefit all GUI dialogs, including those kept outside $FGDATA, i.e. aircraft specific dialogs living in other hangars

Ah, so basically dialog-show will be rewritten in Nasal using the PUI2Canvas parser, so that dialogs will be created in the same way as always (PUI XML format) but shown as their Canvas equivalent ? That's an excellent concept ! :)
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

PreviousNext

Return to Canvas

Who is online

Users browsing this forum: No registered users and 2 guests