code_uilayout.js 8.5 KB

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