code_uilayout.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. // UILayout application source code
  2. 'use strict';
  3. var utils = require("Scripts/utils");
  4. exports.init = function(mylayout,mylogger,myview) {
  5. var myc = mylayout.getWidget("uilayoutcontainer"); // get the container layout
  6. //
  7. // support functions
  8. //
  9. var tf0 = new Atomic.UIButton(); // the layout-o-matic spawner
  10. tf0.text = "LAYOUT-O-MATIC";
  11. tf0.id = "go_layout_config";
  12. var lo0 = new Atomic.UILayout();
  13. lo0.id = "target_layout";
  14. lo0.setLayoutConfig ( "-----" );
  15. lo0.load("Scenes/simp_button.ui.txt");
  16. lo0.addChildBefore(tf0, lo0.getFirstChild() );
  17. myc.addChild(lo0); // drop it in
  18. var tf1 = new Atomic.UITextField();
  19. tf1.text = "layout config XACAC";
  20. var lo1 = new Atomic.UILayout();
  21. lo1.setLayoutConfig ( "XACAC" );
  22. lo1.load("Scenes/simp_button.ui.txt");
  23. lo1.addChildBefore(tf1, lo1.getFirstChild() );
  24. myc.addChild(lo1);
  25. var tf2 = new Atomic.UITextField();
  26. tf2.text = "layout config XGCAC";
  27. var lo2 = new Atomic.UILayout();
  28. lo2.setLayoutConfig ( "XGCAC" );
  29. lo2.load("Scenes/simp_button.ui.txt");
  30. lo2.addChildBefore(tf2, lo2.getFirstChild() );
  31. myc.addChild(lo2);
  32. var tf3 = new Atomic.UITextField();
  33. tf3.text = "layout config XPCAC";
  34. var lo3 = new Atomic.UILayout();
  35. lo3.setLayoutConfig ( "XPCAC" );
  36. lo3.load("Scenes/simp_button.ui.txt");
  37. lo3.addChildBefore(tf3, lo3.getFirstChild() );
  38. myc.addChild(lo3);
  39. var tf4 = new Atomic.UITextField();
  40. tf4.text = "layout config XACGC";
  41. var lo4 = new Atomic.UILayout();
  42. lo4.setLayoutConfig ( "XACGC" );
  43. lo4.load("Scenes/simp_button.ui.txt");
  44. lo4.addChildBefore(tf4, lo4.getFirstChild() );
  45. myc.addChild(lo4);
  46. var tf5 = new Atomic.UITextField();
  47. tf5.text = "layout config XGRGC";
  48. var lo5 = new Atomic.UILayout();
  49. lo5.setLayoutConfig ( "XGRGC" );
  50. lo5.load("Scenes/simp_button.ui.txt");
  51. lo5.addChildBefore(tf5, lo5.getFirstChild() );
  52. myc.addChild(lo5);
  53. var tf6 = new Atomic.UITextField();
  54. tf6.text = "layout config XPLGC";
  55. var lo6 = new Atomic.UILayout();
  56. lo6.setLayoutConfig ( "XPLGC" );
  57. lo6.load("Scenes/simp_button.ui.txt");
  58. lo6.addChildBefore(tf6, lo6.getFirstChild() );
  59. myc.addChild(lo6);
  60. var tf7 = new Atomic.UITextField();
  61. tf7.text = "layout config XACPC";
  62. var lo7 = new Atomic.UILayout();
  63. lo7.setLayoutConfig ( "XACPC" );
  64. lo7.load("Scenes/simp_button.ui.txt");
  65. lo7.addChildBefore(tf7, lo7.getFirstChild() );
  66. myc.addChild(lo7);
  67. var tf8 = new Atomic.UITextField();
  68. tf8.text = "layout config XGLPL";
  69. var lo8 = new Atomic.UILayout();
  70. lo8.setLayoutConfig ( "XGLPL" );
  71. lo8.load("Scenes/simp_button.ui.txt");
  72. lo8.addChildBefore(tf8, lo8.getFirstChild() );
  73. myc.addChild(lo8);
  74. var tf9 = new Atomic.UITextField();
  75. tf9.text = "layout config XPCPR";
  76. var lo9 = new Atomic.UILayout();
  77. lo9.setLayoutConfig ( "XPCPR" );
  78. lo9.load("Scenes/simp_button.ui.txt");
  79. lo9.addChildBefore(tf9, lo9.getFirstChild() );
  80. myc.addChild(lo9);
  81. // its LAYOUT-O-MATIC time.
  82. var buttonl = mylayout.getWidget("go_layout_config");
  83. buttonl.onClick = function () {
  84. mylogger.setText( "UILayout action : " + buttonl.id + " was pressed ");
  85. var window = new Atomic.UIWindow();
  86. window.setSettings ( Atomic.UI_WINDOW_SETTINGS_TITLEBAR + Atomic.UI_WINDOW_SETTINGS_RESIZABLE + Atomic.UI_WINDOW_SETTINGS_CLOSE_BUTTON );
  87. window.text = "LAYOUT-O-MATIC(tm)";
  88. window.load("Scenes/view_layout.ui.txt");
  89. window.resizeToFitContent();
  90. myview.addChild(window);
  91. window.center();
  92. window.getWidget("ok").onClick = function () {
  93. mylogger.setText( "UILayout action : the window `" + window.text + "` was closed with ok");
  94. window.die();
  95. window = null;
  96. };
  97. var str = "XGCPC"; // all defaults
  98. var targetl = mylayout.getWidget("target_layout"); // who to operate on.
  99. var buttonax = window.getWidget("set_ax"); // oh, strings are immutable in javascript.
  100. buttonax.onClick = function() {
  101. if ( buttonax.getValue() == 1) {
  102. str = str.split('');
  103. str[0] = 'X';
  104. str = str.join('');
  105. targetl.setLayoutConfig(str);
  106. }
  107. };
  108. var buttonay = window.getWidget("set_ay");
  109. buttonay.onClick = function() {
  110. if ( buttonay.getValue() == 1) {
  111. str = str.split('');
  112. str[0] = 'Y';
  113. str = str.join('');
  114. targetl.setLayoutConfig(str);
  115. }
  116. };
  117. var buttonsza = window.getWidget("set_sza");
  118. buttonsza.onClick = function() {
  119. if ( buttonsza.getValue() == 1) {
  120. str = str.split('');
  121. str[1] = 'A';
  122. str = str.join('');
  123. targetl.setLayoutConfig(str);
  124. }
  125. };
  126. var buttonszg = window.getWidget("set_szg");
  127. buttonszg.onClick = function() {
  128. if ( buttonszg.getValue() == 1) {
  129. str = str.split('');
  130. str[1] = 'G';
  131. str = str.join('');
  132. targetl.setLayoutConfig(str);
  133. }
  134. };
  135. var buttonszp= window.getWidget("set_szp");
  136. buttonszp.onClick = function() {
  137. if ( buttonszp.getValue() == 1) {
  138. str = str.split('');
  139. str[1] = 'P';
  140. str = str.join('');
  141. targetl.setLayoutConfig(str);
  142. }
  143. };
  144. var buttonposc = window.getWidget("set_posc");
  145. buttonposc.onClick = function() {
  146. if ( buttonposc.getValue() == 1) {
  147. str = str.split('');
  148. str[2] = 'C';
  149. str = str.join('');
  150. targetl.setLayoutConfig(str);
  151. }
  152. };
  153. var buttonposg = window.getWidget("set_posg");
  154. buttonposg.onClick = function() {
  155. if ( buttonposg.getValue() == 1) {
  156. str = str.split('');
  157. str[2] = 'G';
  158. str = str.join('');
  159. targetl.setLayoutConfig(str);
  160. }
  161. };
  162. var buttonposl = window.getWidget("set_posl");
  163. buttonposl.onClick = function() {
  164. if ( buttonposl.getValue() == 1) {
  165. str = str.split('');
  166. str[2] = 'L';
  167. str = str.join('');
  168. targetl.setLayoutConfig(str);
  169. }
  170. };
  171. var buttonposr = window.getWidget("set_posr");
  172. buttonposr.onClick = function() {
  173. if ( buttonposr.getValue() == 1) {
  174. str = str.split('');
  175. str[2] = 'R';
  176. str = str.join('');
  177. targetl.setLayoutConfig(str);
  178. }
  179. };
  180. var buttondista = window.getWidget("set_dista");
  181. buttondista.onClick = function() {
  182. if ( buttondista.getValue() == 1) {
  183. str = str.split('');
  184. str[3] = 'A';
  185. str = str.join('');
  186. targetl.setLayoutConfig(str);
  187. }
  188. };
  189. var buttondistg = window.getWidget("set_distg");
  190. buttondistg.onClick = function() {
  191. if ( buttondistg.getValue() == 1) {
  192. str = str.split('');
  193. str[3] = 'G';
  194. str = str.join('');
  195. targetl.setLayoutConfig(str);
  196. }
  197. };
  198. var buttondistp = window.getWidget("set_distp");
  199. buttondistp.onClick = function() {
  200. if ( buttondistp.getValue() == 1) {
  201. str = str.split('');
  202. str[3] = 'P';
  203. str = str.join('');
  204. targetl.setLayoutConfig(str);
  205. }
  206. };
  207. var buttondpc = window.getWidget("set_dpc");
  208. buttondpc.onClick = function() {
  209. if ( buttondpc.getValue() == 1) {
  210. str = str.split('');
  211. str[4] = 'C';
  212. str = str.join('');
  213. targetl.setLayoutConfig(str);
  214. }
  215. };
  216. var buttondpl = window.getWidget("set_dpl");
  217. buttondpl.onClick = function() {
  218. if ( buttondpl.getValue() == 1) {
  219. str = str.split('');
  220. str[4] = 'L';
  221. str = str.join('');
  222. targetl.setLayoutConfig(str);
  223. }
  224. };
  225. var buttondpr = window.getWidget("set_dpr");
  226. buttondpr.onClick = function() {
  227. if ( buttondpr.getValue() == 1) {
  228. str = str.split('');
  229. str[4] = 'R';
  230. str = str.join('');
  231. targetl.setLayoutConfig(str);
  232. }
  233. };
  234. };
  235. };