Guest User

fgplot NG prototyping

a guest
Jul 24th, 2013
129
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0"?>
  2. <!--
  3. This file is part of FlightGear, the free flight simulator
  4. http://www.flightgear.org/
  5.  
  6. Copyright (C) 2009 Torsten Dreyer, Torsten (at) t3r _dot_ de
  7.  
  8. This program is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU General Public License as
  10. published by the Free Software Foundation; either version 2 of the
  11. License, or (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful, but
  14. WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. General Public License for more details.
  17. -->
  18.  
  19. <PropertyList>
  20.   <name>about</name>
  21.   <modal>false</modal>
  22.   <layout>vbox</layout>
  23.   <resizable>false</resizable>
  24.   <default-padding>3</default-padding>
  25.  
  26.   <group>
  27.     <layout>hbox</layout>
  28.     <default-padding>1</default-padding>
  29.  
  30.     <empty>
  31.       <stretch>true</stretch>
  32.     </empty>
  33.  
  34.     <text>
  35.       <label>About FlightGear</label>
  36.     </text>
  37.  
  38.     <empty>
  39.       <stretch>true</stretch>
  40.     </empty>
  41.  
  42.     <button>
  43.       <legend/>
  44.       <key>Esc</key>
  45.       <pref-width>16</pref-width>
  46.       <pref-height>16</pref-height>
  47.       <border>2</border>
  48.       <binding>
  49.         <command>dialog-close</command>
  50.       </binding>
  51.     </button>
  52.   </group>
  53.  
  54.   <hrule/>
  55.  
  56.   <group>
  57.     <layout>vbox</layout>
  58.     <default-padding>5</default-padding>
  59.    
  60.     <group>
  61.       <layout>hbox</layout>
  62.      
  63.       <empty>
  64.         <stretch>true</stretch>
  65.       </empty>
  66.          
  67.       <text>
  68.         <label>FlightGear Flight Simulator VX.X.X</label>
  69.       </text>
  70.  
  71.       <empty>
  72.         <stretch>true</stretch>
  73.       </empty>
  74.     </group>
  75.    
  76.     <text>
  77.       <label>(c) 1996-2013, the FlightGear Contributors</label>
  78.     </text>
  79.    
  80.     <group>
  81.       <layout>vbox</layout>
  82.       <border>10</border>
  83.       <halign>center</halign>
  84.       <default-padding>2</default-padding>
  85.  
  86.       <text>
  87.         <halign>left</halign>
  88.         <label>FlightGear is free and open source software, licensed</label>
  89.       </text>
  90.      
  91.       <text>
  92.         <halign>left</halign>
  93.         <label>under the GNU General Public License Version 2.</label>
  94.       </text>
  95.      
  96.       <text>
  97.         <halign>left</halign>
  98.         <label>Get new versions, add-ons, forum, wiki and more</label>
  99.       </text>
  100.      
  101.       <text>
  102.         <halign>left</halign>
  103.         <label>from the web-site at http://www.flightgear.org/ for free.</label>
  104.       </text>
  105.      
  106.       <text>
  107.         <halign>left</halign>
  108.         <label>Have a nice flight!</label>
  109.       </text>
  110.      
  111.     </group>
  112.      
  113.     <empty>
  114.       <stretch>true</stretch>
  115.     </empty>
  116.    
  117.     <hrule/>
  118.    
  119.  
  120.     <text>
  121.       <halign>center</halign>
  122.       <label>Version Information</label>
  123.     </text>
  124.    
  125.     <group>
  126.       <layout>vbox</layout>
  127.       <border>10</border>
  128.       <halign>center</halign>
  129.       <default-padding>2</default-padding>
  130.      
  131.       <text>
  132.         <halign>left</halign>
  133.         <label>MMMMMMMMMM</label>
  134.         <format>FlightGear Version: %s</format>
  135.         <property>/sim/version/flightgear</property>
  136.       </text>
  137.      
  138.       <text>
  139.         <halign>left</halign>
  140.         <label>MMMMMMMMMM</label>
  141.         <format>SimGear Version: %s</format>
  142.         <property>/sim/version/simgear</property>
  143.       </text>
  144.  
  145.       <text>
  146.         <halign>left</halign>
  147.         <label>MMMMMMMMMMMMMMMMMM</label>
  148.         <format>OpenSceneGraph Version: %s</format>
  149.         <property>/sim/version/openscenegraph</property>
  150.       </text>
  151.  
  152.       <text>
  153.         <halign>left</halign>
  154.         <label>MMMMMMMMMMMMMMMMMM</label>
  155.         <format>Build Id: %s</format>
  156.         <property>/sim/version/build-id</property>
  157.       </text>
  158.      
  159.       <text>
  160.         <halign>left</halign>
  161.         <label>MMMMMM</label>
  162.         <format>Build Number: %d</format>
  163.         <property>/sim/version/build-number</property>
  164.       </text>
  165.      
  166.       <text>
  167.         <halign>left</halign>
  168.         <label>MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</label>
  169.         <format>Revision: %s</format>
  170.         <property>/sim/version/revision</property>
  171.       </text>
  172.     </group>
  173.      
  174.     <empty>
  175.       <stretch>true</stretch>
  176.     </empty>
  177.  
  178.     <hrule/>
  179.      
  180.     <text>
  181.       <halign>center</halign>
  182.       <label>Graphics/OpenGL Information</label>
  183.     </text>
  184.    
  185.     <group>
  186.       <layout>vbox</layout>
  187.       <border>10</border>
  188.       <halign>center</halign>
  189.       <default-padding>2</default-padding>
  190.    
  191.  
  192.       <text>
  193.         <halign>left</halign>
  194.         <label>MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</label>
  195.         <format>OpenGL Vendor: %s</format>
  196.         <property>/sim/rendering/gl-vendor</property>
  197.       </text>
  198.  
  199.       <text>
  200.         <halign>left</halign>
  201.         <label>MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</label>
  202.         <format>OpenGL Renderer: %s</format>
  203.         <property>/sim/rendering/gl-renderer</property>
  204.       </text>
  205.  
  206.       <text>
  207.         <halign>left</halign>
  208.         <label>MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</label>
  209.         <format>OpenGL Version: %s</format>
  210.         <property>/sim/rendering/gl-version</property>
  211.       </text>
  212.    
  213.       <text>
  214.         <halign>left</halign>
  215.         <label>MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</label>
  216.         <format>GLSL Version: %s</format>
  217.         <property>/sim/rendering/gl-shading-language-version</property>
  218.       </text>
  219.  
  220.       <text>
  221.         <halign>left</halign>
  222.         <label>MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</label>
  223.         <format>Max Texture Size: %s</format>
  224.         <property>/sim/rendering/max-texture-size</property>
  225.       </text>
  226.  
  227.       <text>
  228.         <halign>left</halign>
  229.         <label>MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</label>
  230.         <format>Depth Buffer Bits: %s</format>
  231.         <property>/sim/rendering/depth-buffer-bits</property>
  232.       </text>
  233.     </group>
  234.   </group>
  235.  
  236.   <hrule/>
  237.  
  238.   <group>
  239.     <layout>hbox</layout>
  240.     <halign>fill</halign>
  241.    
  242.     <empty><stretch>true</stretch></empty>
  243.    
  244.     <button>
  245.       <legend>ChgBg</legend>
  246.       <equal>true</equal>
  247.       <default>true</default>
  248.       <key>Esc</key>
  249.       <binding>
  250.         <command>nasal</command>
  251.            <script>MyApp.chgbg('#0000FF00');</script>
  252.       </binding>
  253.     </button>
  254.  
  255.     <button>
  256.       <legend>Test</legend>
  257.       <equal>true</equal>
  258.       <default>false</default>
  259.       <binding>
  260.         <command>nasal</command>
  261.            <script>MyApp.create();</script>
  262.       </binding>
  263.     </button>
  264.  
  265.     <button>
  266.       <legend>MyApp.del</legend>
  267.       <equal>true</equal>
  268.       <default>false</default>
  269.       <binding>
  270.         <command>nasal</command>
  271.    <script>MyApp.delete();</script>
  272.       </binding>
  273.     </button>
  274.  
  275.     <button>
  276.       <legend>Copy to Clipboard</legend>
  277.       <equal>true</equal>
  278.       <default>false</default>
  279.       <binding>
  280.         <command>nasal</command>
  281.         <script><![CDATA[
  282.   var properties = ["gl-vendor","gl-version","gl-renderer", "gl-shading-language-version"];
  283.   var data = "";
  284.   var path = "/sim/rendering/";
  285.   foreach(var p; properties)
  286.      data ~= p ~":"~getprop(path~p) ~"\n";
  287.   clipboard.setText(data);
  288.   gui.popupTip("Copied version information to clipboard!");
  289.   ]]></script>
  290.       </binding>
  291.     </button>
  292.  
  293.  
  294.     <empty><stretch>true</stretch></empty>
  295.    
  296.   </group>
  297.  
  298.   <nasal>
  299.     <open><![CDATA[
  300.      # Replace version in Nasal, as using the <format> code upsets layout
  301.      var ver = cmdarg().getNode("group[1]/group/text/label");
  302.      ver.setValue("FlightGear Flight Simulator V" ~ getprop("/sim/version/flightgear"));
  303.  
  304. # below is a piece of test code.
  305.  
  306. var dum = {} ;
  307. var menubar = {};
  308. var sidebar = {};
  309. var plot = {};
  310.  
  311. var Button = {
  312.   Me: 0,
  313.   B1: 0,
  314.   new: func {
  315.      me.Me = { parents: [Button] };
  316.        return me.Me;
  317.   },
  318.   create: func (bar,x,y,w,h) {
  319.      me.B1 = bar.createChild("path")
  320.         .moveTo(x, y)
  321.         .vertTo(y + h)
  322.         .horizTo(x + w)
  323.         .vertTo(y)
  324.         .horizTo(x)
  325.         .close()
  326.         .setColor(0,0,0)
  327.         .setColorFill(0.8,0.8,0.8)
  328.         .setStrokeLineWidth(1);
  329.      print("Button created.");
  330.      return me.Me;
  331.   },
  332.   color: func (cl) {
  333.      me.B1.setColorFill(cl);
  334.      print("ButtonColor set");
  335.      return me.Me;
  336.   },
  337.   addhandler: func (Ev,Act) {
  338.      me.B1.addEventListener(Ev, Act );
  339.      return me.Me;
  340.   },
  341. };
  342.  
  343. var Box = {
  344.   trp: 0,
  345.   Me: 0,
  346.   B1: 0,
  347.   T1: 0,
  348.   W: 0,
  349.   H: 0,
  350.   new: func {
  351.      me.Me = { parents: [Box] };
  352.      return me.Me;
  353.   },
  354.   create: func(root,bar,x,y,w,h) {
  355.      me.H = h;
  356.      me.W = w;
  357.      me.B1 = bar.createChild("path")
  358.         .moveTo(x, y)
  359.         .vertTo(y + h)
  360.         .horizTo(x + w)
  361.         .vertTo(y)
  362.         .horizTo(x)
  363.         .close()
  364.         .setColorFill(0.5,0.5,0.5,1)
  365.         .setStrokeLineWidth(1);
  366. # This is going to be the resizer.
  367. # Maby much more code is needed.
  368. # Resizing the graph area , but not thicken the menubars.
  369. #      me.B1.addEventListener("drag", func(e) {
  370. #            root.set(size[0],me.W+e.deltaX);  # size[] x, y , w , h ?
  371. #            root.set(size[1],me.H+e.deltaX);
  372. #         });
  373.      print("Box created.");
  374.      return me.Me;
  375.   },
  376.   color: func (t) {
  377.      me.B1.setColorFill(t);
  378.      print("SetColor done.");
  379.      return me.Me;
  380.   },
  381.   settitle: func (bar,t) {
  382.      me.T1 = bar.createChild("text", "box-caption")
  383.         .setText( t )
  384.         .setTranslation(4,24)
  385.         .setAlignment("left-top")
  386.         .setFontSize(14)
  387.         .setFont("LiberationFonts/LiberationSans-Bold.ttf")
  388.         .setColor(0,1,0);
  389.      print("Settitle done.");
  390.      return me.Me;
  391.   },
  392.   settext: func (t) {
  393.      me.T1.setText(t);
  394.      print("Settext done.");
  395.      return me.Me;
  396.   },
  397.   transparency: func () {
  398.      if(me.trp) {
  399.         me.B1.setColorFill(0.5,0.5,0.5,1);
  400.         me.trp = 0;
  401.      }else{
  402.         me.B1.setColorFill(0.5,0.5,0.5,0.5);
  403.         me.trp = 1;
  404.      }
  405.      print("Transparency done.");
  406.      return me.Me;
  407.   },
  408.   addhandler: func (Ev,Act) {
  409.      me.B1.addEventListener(Ev, Act );
  410.      return me.Me;
  411.   },
  412. };
  413.  
  414. var Menubar = {
  415.   B: 0,
  416.   T: 0,
  417.   Me: 0,
  418.   new: func {
  419.      me.Me = { parents: [Menubar] };
  420.      return me.Me;
  421.   },
  422.   create: func(root,bar,x,y,w,h) {
  423.      var rx = 8;
  424.      var ry = 8;
  425.      me.B = bar.createChild("path")
  426.         .moveTo(x + w - rx, y)
  427.         .arcSmallCWTo(rx, ry, 0, x + w, y + ry)
  428.         .vertTo(y + h)
  429.         .horizTo(x)
  430.         .vertTo(y + ry)
  431.         .arcSmallCWTo(rx, ry, 0, x + rx, y)
  432.         .close()
  433.         .setColorFill(0.8,0.8,0.8)
  434.         .setStrokeLineWidth(1);
  435.      me.B.addEventListener("drag", func(e) {
  436.           root.move(e.deltaX, e.deltaY);
  437.      });
  438.      print("Menubar created.");
  439.      return me.Me;
  440.   },
  441.   createtitle: func (bar,t) {
  442.      me.T = bar.createChild("text", "dialog-caption")
  443.         .setText(t)
  444.         .setTranslation(4,4)
  445.         .setAlignment("left-top")
  446.         .setFontSize(14)
  447.         .setFont("LiberationFonts/LiberationSans-Bold.ttf")
  448.         .setColor(0,0,0);
  449.      print("Createtitle done.");
  450.      return me.Me;
  451.   },
  452.   settitle: func (t) {
  453.      me.T.setText(t);
  454.      print("Settitle done.");
  455.      return me.Me;
  456.   },
  457.   addbutton: func (bar,graph,x,y,w,h) {
  458.      var Child = Button.new();
  459.      Child.create(bar,graph,x,y,w,h);
  460.      print("AddButton done.");
  461.      return Child;
  462.   },
  463. };
  464.  
  465. var Xline = {
  466.   Me: 0,
  467.   new: func () {
  468.      me.Me = { parents: [Xline] };
  469.      return me.Me;
  470.   },
  471.   start: func (bar,x,w,h,Th) {
  472.      bar.createChild("path")
  473.         .moveTo(0,0)
  474.         .lineTo(w,0)
  475.         .setColor(0,0,0)
  476.         .setTranslation(x,Th-h/2);
  477.      return me.Me;
  478.   },
  479. };
  480.  
  481. var _plot = {
  482.   Me: 0,
  483.   lines: 0,
  484.   running: 0,
  485.   new: func () {
  486.      me.Me = { parents: [_plot] };
  487.      return me.Me;
  488.   },
  489.   do_plot: func () {
  490.      return me.Me;
  491.   },
  492.   add: func () {
  493.      print("adding property to plot.");
  494.      return me.Me;
  495.   },
  496.   run: func () {
  497.      me.do_Plot();
  498.      return me.Me;
  499.   },
  500.   start: func () {
  501.      me.running=1;
  502.      print("graph running.");
  503.      return me.Me;
  504.   },
  505.   stop: func () {
  506.      me.running=0;
  507.      print("graph paused.");
  508.      return me.Me;
  509.   },
  510. };
  511.  
  512. var _App = {
  513.   x: 200,
  514.   y: 200,
  515.   width:400,
  516.   height:300,
  517.   mbwidth:400,
  518.   mbheight: 20,
  519.   sbwidth: 20,
  520.   sbheight:280,
  521.   pwidth: 380,
  522.   pheight: 280,
  523.   bg: '#00000000',
  524.   hello: func {print("Hello world"); },
  525.   info: func {
  526.         print("x:",me.x, " y:", me.y, " width:", me.width, " height:", me.height);
  527.   },
  528.   create: func {
  529.     var x = me.x;
  530.     var y = me.y;
  531.     var dlg = canvas.Window.new([me.width, me.height+me.mbheight]);
  532.     var cnv = dlg.createCanvas()
  533.         .setColorBackground(me.bg);
  534.     cnv.addEventListener('wheel', func () { dlg.del();} );
  535.  
  536.     var root = cnv.createGroup();
  537.     var mbr = root.createChild("group");   # All about menubar
  538.     var grphB = root.createChild("group"); # The background of All,maby unneeded.
  539.     var grph = root.createChild("group");  # All about plot
  540.  
  541.     plot["canvas"] = Box.new();
  542.     plot["canvas"].create(dlg,grphB,
  543.                   me.sbwidth,me.mbheight,me.pwidth,me.pheight);
  544.  
  545.     plot["xline"] = Xline.new();
  546.     plot["xline"].start(grph,me.sbwidth,me.pwidth,me.pheight,me.height);
  547.  
  548.     plot["line"] = _plot.new();
  549.  
  550.     print ( "type plot[0] : "~typeof(plot[0]));
  551.  
  552.     sidebar["side"] = Menubar.new();
  553.     sidebar["side"].create(dlg,mbr,0,me.mbheight,me.sbwidth,me.sbheight);
  554.  
  555.     sidebar["start"] = Button.new();
  556.     sidebar["start"].create(mbr,0,20,20,25);
  557.     sidebar["start"].color("#0000FF");
  558.     sidebar["start"].addhandler('click', dum[0] = func plot["line"].start());
  559.  
  560.     sidebar["stop"] = Button.new();
  561.     sidebar["stop"].create(mbr,0,45,20,25);
  562.     sidebar["stop"].color("#00FFFF");
  563.     sidebar["stop"].addhandler('click', dum[0] = func plot["line"].stop());
  564.  
  565.     menubar["bar"] = Menubar.new();
  566.     menubar["bar"].create(dlg,mbr,0,0,me.mbwidth,me.mbheight);
  567.     menubar["title"] = menubar["bar"].createtitle(mbr,"Dyn.FgPlot");
  568.     menubar["title"].settitle("My.FgPlot");
  569.  
  570.     menubar["chgtxt"] = Button.new();
  571.     menubar["chgtxt"].create(mbr,80,0,25,me.mbheight);
  572.     menubar["chgtxt"].addhandler('click', dum[0] = func menubar["title"].settitle("My.Oh.My"));
  573.     menubar["chgtxt"].color('#00FF00');
  574.  
  575.     menubar["trnsp"] = Button.new();
  576.     menubar["trnsp"].create(mbr,105,0,25,me.mbheight);
  577.     print("after create : "~typeof(menubar["trnsp"]));
  578.     menubar["trnsp"].addhandler('click', dum[0] = func plot["canvas"].transparency());
  579.     menubar["trnsp"].color('#0000FF');
  580.  
  581.     menubar["addline"] = Button.new();
  582.     menubar["addline"].create(mbr,130,0,25,me.mbheight);
  583.     print("after create : "~typeof(menubar["addline"]));
  584.     menubar["addline"].addhandler('click', dum[0] = func plot["line"].add());
  585.     menubar["addline"].color('#880088');
  586.  
  587.     menubar["quit"] = Button.new();
  588.     menubar["quit"].create(mbr,155,0,25,me.mbheight);
  589.     print("after create : "~typeof(menubar["quit"]));
  590.     menubar["quit"].addhandler('click', dum[0] = func dlg.del());
  591.     menubar["quit"].color('#880000');
  592.  
  593.     print(typeof(menubar["quit"]));
  594.  
  595.   },
  596.   chgbg: func (e) {
  597.     me.bg = e ; cnv.setColorBackground(me.bg);
  598.   },
  599.   delete: func () {
  600.      MyApp.del();
  601.   },
  602. };
  603.  
  604. var MyApp = { parents:[_App] };
  605.  
  606. MyApp.hello();
  607. MyApp.info();
  608.  
  609. #var listener_id = _setlistener("/sim/test/start", MyApp.hello(); );
  610.    ]]></open>
  611.  
  612.     <close><![CDATA[
  613.    ]]></close>
  614.   </nasal>
  615. </PropertyList>
RAW Paste Data