Board index FlightGear Development Canvas

Canvas Widget use  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.

Canvas Widget use

Postby Necolatis » Thu Jul 10, 2014 9:30 am

Hi,

I have started making a failure dialog.

I have some questions.

- Has anybody started making a input field widget, or shall I make that?
- Can I change text color in the label widget, if so how?

Progress so far: (Just a fast mockup to test out canvas procedual gui)
Image
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Canvas Widget use  

Postby TheTom » Thu Jul 10, 2014 12:19 pm

Necolatis wrote in Thu Jul 10, 2014 9:30 am:- Has anybody started making a input field widget, or shall I make that?

I want to work on this after 3.2. I'll need to create keyboard events for this and handle input focus for the different windows and widgets. Once this is working an input widget should be quite easy to implement...

Necolatis wrote in Thu Jul 10, 2014 9:30 am:- Can I change text color in the label widget, if so how?

It is currently no really exposed. Though you should be able to use 'label._view._text.set("fill", <color>)'. Additionally you should disable the update function which changes the color according to the focus state: 'label._view.update = func;'. I'd call it a hack, but it should work. I'll need to do a better styling system eventually^^
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Canvas Widget use

Postby Necolatis » Thu Jul 10, 2014 1:18 pm

Thanks.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Canvas Widget use

Postby Hooray » Thu Jul 10, 2014 7:51 pm

That's looking good!
Like I mentioned previously to you, for the time being, it will be easier to work around keyboard handling by providing +/- buttons to change values in increments, or some other non-keyboard widgets, like a slider or a dropdown menu.
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: Canvas Widget use

Postby Necolatis » Thu Jul 10, 2014 9:11 pm

Ah, right. Should be doable with buttons. I'll will see what I can work out.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Canvas Widget use

Postby Philosopher » Thu Jul 10, 2014 11:10 pm

If it's okay with you guys, I was actually thinking of making widgets like Slider, DropDown, and ButtonList (either Check buttons or Radios), so I could learn and make a tutorial and help with development. I would try to make this available as soon as I could, but I don't know how soon that will be.
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: Canvas Widget use

Postby Hooray » Thu Jul 10, 2014 11:22 pm

I was also thinking of doing 2-3 widgets - mainly to create a MCP widget procedurally by iterating over the ND hash and creating a button/checkbox for each option.
This should also help for the MapStructure "widget", because we're adding widgets there to easily toggle layers on/off, so that we don't have to use PUI:
Image


So, I'll help with the tutorial, and I think Necolatis also said a few days ago that he was going to help improve the wiki article (which is currently just a stub). So I am sure it will grow quickly - ultimately, we may ask Tom have another look and establish some "best practices" though :mrgreen:

However, if in doubt, please update the wiki accordingly, and add your nicknames there so that people know what widgets are being worked on, and by whom: http://wiki.flightgear.org/Canvas_Widge ... n_Progress
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: Canvas Widget use

Postby Necolatis » Sat Jul 12, 2014 4:37 am

If I set text on a button or label, the fixed size previously set will be disregarded and I have to set it anew.
Not sure if its intended, just wanted you to know.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Canvas Widget use

Postby TheTom » Sat Jul 12, 2014 5:28 pm

Custom size hints (min/max/hint) should now be preserved and preferred to automatically calculated hints. So now fixed sized widgets should stay fixed size^^
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Canvas Widget use

Postby Necolatis » Sat Jul 12, 2014 5:30 pm

Great.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Canvas Widget use

Postby Necolatis » Mon Jul 14, 2014 12:35 am

When I use removeItem(hbox) it does not get removed, its clearly removed in the layout engine though, cause it no longer considers its size.

The hbox has a label and a vbox and a button. When I later addItem() the new item will be drawn on top of the old item that should be removed, but is still drawn.

me._dialog.getCanvas().update(); also does not help, neither does resizing the dialog.

Any way I can workaround that?
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Canvas Widget use

Postby Philosopher » Mon Jul 14, 2014 12:52 am

element.del() ?
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: Canvas Widget use

Postby Necolatis » Mon Jul 14, 2014 1:16 am

Okay, is there any way to get a list of the elements of a HBoxLayout?
I can probably find that myself, but I cannot find in which nasal file HBoxLayout is defined.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Canvas Widget use

Postby Hooray » Mon Jul 14, 2014 1:22 am

IIRC, see: $SG_SRC/canvas/layout (it's implemented in C++ using cppbind)
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: Canvas Widget use

Postby Philosopher » Mon Jul 14, 2014 1:23 am

For Canvas.Elements use .del(), for Layouts use .clear() (AFAICT – haven't tested). They're not Nasal-defined, they're cppbind classes, c.f. https://gitorious.org/fg/flightgear/sou ... s.cxx#L476
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Next

Return to Canvas

Who is online

Users browsing this forum: No registered users and 3 guests