customToolboxGui.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. Sandbox.customLabelHeight = "15";
  23. Sandbox.customLabelWidth = "220";
  24. Sandbox.customLabelSpacing = "18";
  25. Sandbox.customOptionSpacing = "15";
  26. Sandbox.customContainerExtent = "250 3";
  27. Sandbox.containerXPosition = "20";
  28. Sandbox.flagOptionExtent = "240 35";
  29. Sandbox.buttonOptionExtent = "240 35";
  30. Sandbox.spinnerExtent = "22 25";
  31. Sandbox.intOptionExtent = "196 25";
  32. Sandbox.listOptionExtent = "240 0";
  33. Sandbox.customControlCount = "0";
  34. Sandbox.lastControlBottom = "0";
  35. //-----------------------------------------------------------------------------
  36. function resetCustomControls()
  37. {
  38. Sandbox.lastControlBottom = "0";
  39. Sandbox.customControlCount = 0;
  40. %customControlExtent = ToyCustomControls.Extent;
  41. %newExtent = getWord(ToyCustomControls.Extent, 0) SPC 705;
  42. ToyCustomControls.Extent = %newExtent;
  43. CustomControlsScroller.computeSizes();
  44. }
  45. //-----------------------------------------------------------------------------
  46. function createCustomLabel(%text)
  47. {
  48. %labelWidth = Sandbox.customLabelWidth + (%characterCount * 5);
  49. %labelExtent = %labelWidth SPC Sandbox.customLabelHeight;
  50. %labelControl = new GuiTextCtrl()
  51. {
  52. text = %text;
  53. Extent = %labelExtent;
  54. HorizSizing = "relative";
  55. VertSizing = "relative";
  56. Profile = "GuiTextProfile";
  57. canSaveDynamicFields = "0";
  58. isContainer = "0";
  59. Position = "3 0";
  60. MinExtent = "8 2";
  61. canSave = "0";
  62. Visible = "1";
  63. Active = "0";
  64. tooltipprofile = "GuiToolTipProfile";
  65. tooltipWidth = "0";
  66. maxLength = "255";
  67. truncate = "0";
  68. };
  69. return %labelControl;
  70. }
  71. //-----------------------------------------------------------------------------
  72. function nextCustomControlPosition(%index)
  73. {
  74. %verticalOffset = (Sandbox.customOptionSpacing + %index) + Sandbox.lastControlBottom;
  75. %position = Sandbox.containerXPosition SPC %verticalOffset;
  76. return %position;
  77. }
  78. //-----------------------------------------------------------------------------
  79. function addFlagOption( %label, %callback, %startingValue, %shouldReset, %tooltipText)
  80. {
  81. %containerPosition = nextCustomControlPosition(Sandbox.customControlCount);
  82. %customX = getWord(Sandbox.customContainerExtent, 0);
  83. %customY = getWord(Sandbox.customContainerExtent, 1) + getWord(Sandbox.flagOptionExtent, 1);
  84. %container = new GuiControl()
  85. {
  86. isContainer = 1;
  87. position = %containerPosition;
  88. extent = %customX SPC %customY;
  89. Profile = GuiTransparentProfile;
  90. HorizSizing = "relative";
  91. VertSizing = "relative";
  92. };
  93. %button = new GuiButtonCtrl()
  94. {
  95. canSaveDynamicFields = "0";
  96. HorizSizing = "relative";
  97. VertSizing = "relative";
  98. isContainer = "0";
  99. Profile = "BlueButtonProfile";
  100. Position = "0 0";
  101. Extent = Sandbox.flagOptionExtent;
  102. Visible = "1";
  103. toy = Sandbox.ActiveToy.ScopeSet;
  104. shouldResetToy = %shouldReset;
  105. callback = %callback;
  106. class = "FlagController";
  107. isContainer = "0";
  108. Active = "1";
  109. hovertime = "1000";
  110. toolTipProfile = "GuiToolTipProfile";
  111. toolTip = %tooltipText;
  112. text = %label;
  113. groupNum = "-1";
  114. buttonType = "ToggleButton";
  115. useMouseEvents = "0";
  116. };
  117. %button.setStateOn(%startingValue);
  118. %button.command = %button @ ".updateToy();";
  119. %container.add(%button);
  120. ToyCustomControls.add(%container);
  121. Sandbox.lastControlBottom = getWord(%container.position, 1) + getWord(%container.extent, 1);
  122. if (Sandbox.lastControlBottom > getWord(ToyCustomControls.Extent, 1))
  123. {
  124. %rootContainerExtent = getWord(ToyCustomControls.Extent, 0) SPC Sandbox.lastControlBottom + 20;
  125. ToyCustomControls.Extent = %rootContainerExtent;
  126. CustomControlsScroller.computeSizes();
  127. }
  128. Sandbox.customControlCount++;
  129. }
  130. //-----------------------------------------------------------------------------
  131. function FlagController::updateToy(%this)
  132. {
  133. if (%this.toy $= "")
  134. return;
  135. if (%this.callback !$= "")
  136. {
  137. %setter = "%this.toy." @ %this.callback @ "(" @ %this.getStateOn() @ ");";
  138. eval(%setter);
  139. }
  140. if (%this.shouldResetToy && %this.toy.isMethod("reset"))
  141. %this.toy.reset();
  142. }
  143. //-----------------------------------------------------------------------------
  144. function addButtonOption( %label, %callback, %shouldReset, %tooltipText)
  145. {
  146. %containerPosition = nextCustomControlPosition(Sandbox.customControlCount);
  147. %customX = getWord(Sandbox.customContainerExtent, 0);
  148. %customY = getWord(Sandbox.customContainerExtent, 1) + getWord(Sandbox.buttonOptionExtent, 1);
  149. %container = new GuiControl()
  150. {
  151. isContainer = 1;
  152. HorizSizing = "relative";
  153. VertSizing = "relative";
  154. position = %containerPosition;
  155. extent = %customX SPC %customY;
  156. Profile = GuiTransparentProfile;
  157. };
  158. %button = new GuiButtonCtrl()
  159. {
  160. canSaveDynamicFields = "0";
  161. HorizSizing = "relative";
  162. VertSizing = "relative";
  163. isContainer = "0";
  164. Profile = "BlueButtonProfile";
  165. Position = "0 0";
  166. Extent = Sandbox.buttonOptionExtent;
  167. Visible = "1";
  168. toy = Sandbox.ActiveToy.ScopeSet;
  169. shouldResetToy = %shouldReset;
  170. callback = %callback;
  171. class = "ButtonController";
  172. isContainer = "0";
  173. Active = "1";
  174. hovertime = "1000";
  175. toolTipProfile = "GuiToolTipProfile";
  176. toolTip = %tooltipText;
  177. text = %label;
  178. groupNum = "-1";
  179. buttonType = "PushButton";
  180. useMouseEvents = "0";
  181. };
  182. %button.command = %button @ ".updateToy();";
  183. %container.add(%button);
  184. ToyCustomControls.add(%container);
  185. Sandbox.lastControlBottom = getWord(%container.position, 1) + getWord(%container.extent, 1);
  186. if (Sandbox.lastControlBottom > getWord(ToyCustomControls.Extent, 1))
  187. {
  188. %rootContainerExtent = getWord(ToyCustomControls.Extent, 0) SPC Sandbox.lastControlBottom + 20;
  189. ToyCustomControls.Extent = %rootContainerExtent;
  190. CustomControlsScroller.computeSizes();
  191. }
  192. Sandbox.customControlCount++;
  193. }
  194. //-----------------------------------------------------------------------------
  195. function ButtonController::updateToy(%this)
  196. {
  197. if (%this.toy $= "")
  198. return;
  199. if (%this.callback !$= "")
  200. {
  201. %setter = "%this.toy." @ %this.callback @ "();";
  202. eval(%setter);
  203. }
  204. if (%this.shouldResetToy && %this.toy.isMethod("reset"))
  205. %this.toy.reset();
  206. }
  207. //-----------------------------------------------------------------------------
  208. function addNumericOption( %label, %min, %max, %step, %callback, %startingValue, %shouldReset, %tooltipText)
  209. {
  210. %customLabel = createCustomLabel(%label);
  211. %containerPosition = nextCustomControlPosition(Sandbox.customControlCount);
  212. %customX = getWord(Sandbox.customContainerExtent, 0);
  213. %customY = getWord(Sandbox.customContainerExtent, 1) + getWord(Sandbox.intOptionExtent, 1) + Sandbox.customLabelHeight;
  214. %container = new GuiControl()
  215. {
  216. isContainer = 1;
  217. position = %containerPosition;
  218. HorizSizing = "relative";
  219. VertSizing = "relative";
  220. extent = %customX SPC %customY;
  221. Profile = GuiTransparentProfile;
  222. };
  223. %container.add(%customLabel);
  224. %spinnerPosition = "1" SPC Sandbox.customLabelSpacing;
  225. %spinnerDown = new GuiImageButtonCtrl()
  226. {
  227. Action = "decrease";
  228. Class = "SpinnerController";
  229. Step = %step;
  230. HorizSizing = "relative";
  231. VertSizing = "relative";
  232. canSaveDynamicFields = "0";
  233. isContainer = "0";
  234. Profile = "GuiDefaultProfile";
  235. Position = %spinnerPosition;
  236. Extent = Sandbox.spinnerExtent;
  237. MinExtent = "8 2";
  238. canSave = "1";
  239. Visible = "1";
  240. Active = "1";
  241. hovertime = "1000";
  242. toolTipProfile = "GuiToolTipProfile";
  243. toolTip = %tooltipText;
  244. groupNum = "-1";
  245. buttonType = "PushButton";
  246. useMouseEvents = "0";
  247. NormalImage = "Sandbox:minusButtonNormal";
  248. HoverImage = "Sandbox:minusButtonHover";
  249. DownImage = "Sandbox:minusButtonDown";
  250. InactiveImage = "Sandbox:minusButtonInactive";
  251. };
  252. %controlPosition = (getWord(Sandbox.spinnerExtent, 0) + 1) SPC Sandbox.customLabelSpacing;
  253. %textEdit = new GuiTextEditCtrl()
  254. {
  255. Position = %controlPosition;
  256. HorizSizing = "relative";
  257. VertSizing = "relative";
  258. min = %min;
  259. max = %max;
  260. Text = %startingValue;
  261. Extent = Sandbox.intOptionExtent;
  262. toy = Sandbox.ActiveToy.ScopeSet;
  263. shouldResetToy = %shouldReset;
  264. callback = %callback;
  265. class = "TextEditController";
  266. isContainer = "0";
  267. Profile = "GuiSpinnerProfile";
  268. toolTipProfile = "GuiToolTipProfile";
  269. toolTip = %tooltipText;
  270. hovertime = "1000";
  271. };
  272. %spinnerPosition = (getWord(%textEdit.Extent, 0) + getWord(%textEdit.position, 0)) SPC Sandbox.customLabelSpacing;
  273. %spinnerUp = new GuiImageButtonCtrl()
  274. {
  275. Action = "increase";
  276. HorizSizing = "relative";
  277. VertSizing = "relative";
  278. Class = "SpinnerController";
  279. Step = %step;
  280. canSaveDynamicFields = "0";
  281. isContainer = "0";
  282. Profile = "GuiDefaultProfile";
  283. Position = %spinnerPosition;
  284. Extent = Sandbox.spinnerExtent;
  285. MinExtent = "8 2";
  286. canSave = "1";
  287. Visible = "1";
  288. Active = "1";
  289. hovertime = "1000";
  290. toolTipProfile = "GuiToolTipProfile";
  291. toolTip = %tooltipText;
  292. groupNum = "-1";
  293. buttonType = "PushButton";
  294. useMouseEvents = "0";
  295. NormalImage = "Sandbox:plusButtonNormal";
  296. HoverImage = "Sandbox:plusButtonHover";
  297. DownImage = "Sandbox:plusButtonDown";
  298. InactiveImage = "Sandbox:plusButtonInactive";
  299. };
  300. %textEdit.validate = %textEdit @ ".updateToy();";
  301. %spinnerDown.target = %textEdit;
  302. %spinnerUp.target = %textEdit;
  303. %spinnerDown.command = %spinnerDown @ ".updateTarget();";
  304. %spinnerUp.command = %spinnerUp @ ".updateTarget();";
  305. %container.add(%spinnerDown);
  306. %container.add(%textEdit);
  307. %container.add(%spinnerUp);
  308. ToyCustomControls.add(%container);
  309. Sandbox.lastControlBottom = getWord(%container.position, 1) + getWord(%container.extent, 1);
  310. if (Sandbox.lastControlBottom > getWord(ToyCustomControls.Extent, 1))
  311. {
  312. %rootContainerExtent = getWord(ToyCustomControls.Extent, 0) SPC Sandbox.lastControlBottom + 20;
  313. ToyCustomControls.Extent = %rootContainerExtent;
  314. CustomControlsScroller.computeSizes();
  315. }
  316. Sandbox.customControlCount++;
  317. }
  318. //-----------------------------------------------------------------------------
  319. function SpinnerController::updateTarget(%this)
  320. {
  321. %target = %this.target;
  322. if (%this.action $= "increase")
  323. {
  324. %value = %target.getText();
  325. %value += %this.step;
  326. if (%value > %target.max)
  327. %value = %target.max;
  328. %target.setText(%value);
  329. }
  330. else if (%this.action $= "decrease")
  331. {
  332. %value = %target.getText();
  333. %value -= %this.step;
  334. if (%value < %target.min)
  335. %value = %target.min;
  336. %target.setText(%value);
  337. }
  338. %target.updateToy();
  339. }
  340. //-----------------------------------------------------------------------------
  341. function TextEditController::updateToy(%this)
  342. {
  343. if (%this.toy $= "")
  344. return;
  345. if (%this.getText() > %this.max)
  346. %this.setText(%this.max);
  347. else if (%this.getText() < %this.min)
  348. %this.setText(%this.min);
  349. if (%this.callback !$= "" && %this.getValue() !$= "")
  350. {
  351. %setter = "%this.toy." @ %this.callback @ "(" @ %this.getValue() @ ");";
  352. eval(%setter);
  353. }
  354. if (%this.shouldResetToy && %this.toy.isMethod("reset"))
  355. %this.toy.reset();
  356. }
  357. //-----------------------------------------------------------------------------
  358. function addSelectionOption( %entries, %label, %maxDisplay, %callback, %shouldReset, %tooltipText)
  359. {
  360. // Combined Y extent of the up/down buttons
  361. %buttonExtentAddition = 46;
  362. // Extra padding
  363. %buffer = 15;
  364. // Size of each button added to the list
  365. %buttonSize = 50;
  366. %buttonSpacing = %maxDisplay;// * 8;
  367. // Starting location of the main container
  368. %containerPosition = nextCustomControlPosition(Sandbox.customControlCount);
  369. // Main container base width
  370. %containerWidth = getWord(Sandbox.customContainerExtent, 0);
  371. // Main container base height
  372. %containerHeight = getWord(Sandbox.customContainerExtent, 1) + getWord(Sandbox.listOptionExtent, 1) + Sandbox.customLabelHeight;
  373. // Main container buffer (accounts for size of list, up/down buttons, and buffer)
  374. %containerHeight += ((%maxDisplay+1) * %buttonSize) + %buttonExtentAddition + %buffer;
  375. // X position of buttons
  376. %buttonX = "90";
  377. // Y position for up button
  378. %upButtonY = Sandbox.customLabelSpacing;
  379. // List container
  380. %listContainerPosition = "0" SPC %upButtonY + 22;
  381. %listContainerWidth = %containerWidth;
  382. %listContainerHeight = ((%maxDisplay+1) * %buttonSize) + %buttonSpacing;
  383. %scrollContainerWidth = %listContainerWidth - 5;
  384. %scrollContainerHeight = %listContainerHeight;
  385. // Array control
  386. %arrayListWidth = %scrollContainerWidth - 25;
  387. %arrayListHeight = 0;
  388. // Y position for the down button
  389. %downButtonY = getWord(%listContainerPosition, 1) + %listContainerHeight;
  390. // Create the base container
  391. %container = new GuiControl()
  392. {
  393. isContainer = 1;
  394. HorizSizing = "relative";
  395. VertSizing = "relative";
  396. position = %containerPosition;
  397. extent = %containerWidth SPC %containerHeight;
  398. Profile = GuiTransparentProfile;
  399. };
  400. // Create and add the text label
  401. %customLabel = createCustomLabel(%label);
  402. %container.add(%customLabel);
  403. %listContainer = new GuiControl()
  404. {
  405. isContainer = 1;
  406. HorizSizing = "relative";
  407. VertSizing = "relative";
  408. position = %listContainerPosition;
  409. extent = %listContainerWidth SPC %listContainerHeight;
  410. Profile = GuiSunkenContainerProfile;
  411. };
  412. %scrollControl = new GuiScrollCtrl()
  413. {
  414. canSaveDynamicFields = "1";
  415. isContainer = "1";
  416. class = "CustomScrollControl";
  417. Profile = "GuiLightScrollProfile";
  418. HorizSizing = "relative";
  419. VertSizing = "relative";
  420. Position = "3 3";
  421. Extent = %scrollContainerWidth SPC %scrollContainerHeight;
  422. MinExtent = %scrollContainerWidth SPC %scrollContainerHeight;
  423. canSave = "1";
  424. Visible = "1";
  425. Active = "1";
  426. hovertime = "1000";
  427. willFirstRespond = "1";
  428. hScrollBar = "alwaysOn";
  429. vScrollBar = "alwaysOn";
  430. constantThumbHeight = "0";
  431. childMargin = "2 3";
  432. toolTipProfile = "GuiToolTipProfile";
  433. toolTip = %tooltipText;
  434. };
  435. %arrayList = new GuiDynamicCtrlArrayControl()
  436. {
  437. canSaveDynamicFields = "0";
  438. isContainer = "1";
  439. class = "CustomOptionArrayClass";
  440. Profile = "GuiTransparentProfile";
  441. HorizSizing = "relative";
  442. VertSizing = "relative";
  443. Position = "25 1";
  444. Extent = %arrayListWidth SPC %arrayListHeight;
  445. MinExtent = "1 2";
  446. canSave = "1";
  447. Visible = "1";
  448. Active = "1";
  449. tooltipprofile = "GuiToolTipProfile";
  450. hovertime = "1000";
  451. colCount = "1";
  452. colSize = %arrayListWidth-10;
  453. rowSize = "50";
  454. rowSpacing = "8";
  455. colSpacing = "8";
  456. toolTipProfile = "GuiToolTipProfile";
  457. toolTip = %tooltipText;
  458. };
  459. %scrollControl.add(%arrayList);
  460. %listContainer.add(%scrollControl);
  461. %container.add(%listContainer);
  462. // Populate the list
  463. for (%i = 0; %i < getUnitCount(%entries, ","); %i++)
  464. {
  465. %button = new GuiButtonCtrl()
  466. {
  467. canSaveDynamicFields = "0";
  468. class = "SelectionController";
  469. toy = Sandbox.ActiveToy.ScopeSet;
  470. shouldResetToy = %shouldReset;
  471. callback = %callback;
  472. HorizSizing = "relative";
  473. VertSizing = "relative";
  474. isContainer = "0";
  475. Profile = "BlueButtonProfile";
  476. Position = "0 0";
  477. Extent = "160 80";
  478. Visible = "1";
  479. isContainer = "0";
  480. Active = "1";
  481. text = getUnit(%entries, %i, ",");
  482. groupNum = "1";
  483. buttonType = "ToggleButton";
  484. useMouseEvents = "0";
  485. toolTipProfile = "GuiToolTipProfile";
  486. toolTip = %tooltipText;
  487. };
  488. %button.command = %arrayList @ ".clearSelections();" @ %button @ ".updateToy();";
  489. %arrayList.add(%button);
  490. }
  491. // Create and add the up button
  492. %upButton = new GuiImageButtonCtrl()
  493. {
  494. canSaveDynamicFields = "0";
  495. isContainer = "0";
  496. Profile = "GuiDefaultProfile";
  497. HorizSizing = "relative";
  498. VertSizing = "relative";
  499. Position = %buttonX SPC %upButtonY;
  500. Extent = "69 23";
  501. MinExtent = "8 2";
  502. canSave = "1";
  503. Visible = "1";
  504. Active = "1";
  505. groupNum = "-1";
  506. buttonType = "PushButton";
  507. useMouseEvents = "0";
  508. NormalImage = "Sandbox:northArrowNormal";
  509. HoverImage = "Sandbox:northArrowHover";
  510. DownImage = "Sandbox:northArrowDown";
  511. toolTipProfile = "GuiToolTipProfile";
  512. toolTip = %tooltipText;
  513. };
  514. %upButton.command = %scrollControl @ ".scrollToPrevious();";
  515. // Create and add the down button
  516. %downButton = new GuiImageButtonCtrl()
  517. {
  518. canSaveDynamicFields = "0";
  519. isContainer = "0";
  520. Profile = "GuiDefaultProfile";
  521. HorizSizing = "relative";
  522. VertSizing = "relative";
  523. Position = %buttonX SPC %downButtonY;
  524. Extent = "69 23";
  525. MinExtent = "8 2";
  526. canSave = "1";
  527. Visible = "1";
  528. Active = "1";
  529. groupNum = "-1";
  530. buttonType = "PushButton";
  531. useMouseEvents = "0";
  532. NormalImage = "Sandbox:southArrowNormal";
  533. HoverImage = "Sandbox:southArrowHover";
  534. DownImage = "Sandbox:southArrowDown";
  535. toolTipProfile = "GuiToolTipProfile";
  536. toolTip = %tooltipText;
  537. };
  538. %downButton.command = %scrollControl @ ".scrollToNext();";
  539. %container.add(%upButton);
  540. %container.add(%downButton);
  541. ToyCustomControls.add(%container);
  542. Sandbox.lastControlBottom = getWord(%container.position, 1) + getWord(%container.extent, 1);
  543. if (Sandbox.lastControlBottom > getWord(ToyCustomControls.Extent, 1))
  544. {
  545. %rootContainerExtent = getWord(ToyCustomControls.Extent, 0) SPC Sandbox.lastControlBottom + 20;
  546. ToyCustomControls.Extent = %rootContainerExtent;
  547. CustomControlsScroller.computeSizes();
  548. }
  549. Sandbox.customControlCount++;
  550. }
  551. function CustomOptionArrayClass::clearSelections(%this)
  552. {
  553. %count = %this.getCount();
  554. for (%i = 0; %i < %count; %i++)
  555. {
  556. %button = %this.getObject(%i);
  557. %button.setStateOn(false);
  558. }
  559. }
  560. //-----------------------------------------------------------------------------
  561. function CustomScrollControl::scrollToNext(%this)
  562. {
  563. %currentScroll = %this.getScrollPositionY();
  564. %currentScroll += 55;
  565. %this.setScrollPosition(0, %currentScroll);
  566. }
  567. //-----------------------------------------------------------------------------
  568. function CustomScrollControl::scrollToPrevious(%this)
  569. {
  570. %currentScroll = %this.getScrollPositionY();
  571. %currentScroll -= 55;
  572. %this.setScrollPosition(0, %currentScroll);
  573. }
  574. //-----------------------------------------------------------------------------
  575. function SelectionController::updateToy(%this)
  576. {
  577. if (%this.toy $= "")
  578. return;
  579. %this.setStateOn(true);
  580. if (%this.callback !$= "")
  581. {
  582. %value = %this.getText();
  583. %setter = "%this.toy." @ %this.callback @ "(\"" @ %value @ "\");";
  584. eval(%setter);
  585. }
  586. if (%this.shouldResetToy && %this.toy.isMethod("reset"))
  587. %this.toy.reset();
  588. }