Home Reference Source

cables_dev/cables_ui/src/ui/commands/cmd_timeline.js

  1. import { PortHtmlGenerator } from "../components/opparampanel/op_params_htmlgen.js";
  2. import ParamsListener from "../components/opparampanel/params_listener.js";
  3.  
  4. const CABLES_CMD_TIMELINE = {};
  5.  
  6. const timelineCommands =
  7. {
  8. "commands": [],
  9. "functions": CABLES_CMD_TIMELINE
  10. };
  11.  
  12. export default timelineCommands;
  13.  
  14. CABLES_CMD_TIMELINE.ListAnimatedPorts = function ()
  15. {
  16. const panelid = CABLES.uuid();
  17. const ops = gui.corePatch().ops;
  18. const ports = [];
  19.  
  20. for (let i = 0; i < ops.length; i++)
  21. {
  22. const inputs = ops[i].portsIn;
  23. for (let j = 0; j < inputs.length; j++)
  24. if (inputs[j].isAnimated())
  25. ports.push(inputs[j]);
  26. }
  27.  
  28.  
  29. const htmlgen = new PortHtmlGenerator(panelid);
  30.  
  31. let html = "<div class=\"panel params\" ><table>";
  32.  
  33. html += htmlgen.getHtmlInputPorts(ports);
  34. html += "</table></div>";
  35. const tab = new CABLES.UI.Tab("Animated Ports", { "icon": "clock", "infotext": "tab_timeline", "padding": true, "singleton": true });
  36. gui.mainTabs.addTab(tab, true);
  37. tab.html(html);
  38. gui.maintabPanel.show(true);
  39.  
  40. const paramsListener = new ParamsListener(panelid);
  41. paramsListener.init({ "portsIn": ports });
  42. };
  43.  
  44.  
  45. CABLES_CMD_TIMELINE.TimelinePlay = function ()
  46. {
  47. gui.corePatch().timer.play();
  48. gui.emitEvent("timelineControl", "setPlay", true, gui.scene().timer.getTime());
  49. };
  50.  
  51. CABLES_CMD_TIMELINE.setLength = function ()
  52. {
  53. gui.timeLine().setProjectLength();
  54. };
  55.  
  56. CABLES_CMD_TIMELINE.TimelineForward = function ()
  57. {
  58. gui.timeLine().gotoOffset(2);
  59. gui.emitEvent("timelineControl", "setTime", gui.scene().timer.getTime());
  60. };
  61.  
  62. CABLES_CMD_TIMELINE.TimelineRewind = function ()
  63. {
  64. gui.timeLine().gotoOffset(-2);
  65. gui.emitEvent("timelineControl", "setTime", gui.scene().timer.getTime());
  66. };
  67.  
  68. CABLES_CMD_TIMELINE.TimelineRewindStart = function ()
  69. {
  70. gui.timeLine().gotoZero();
  71. gui.emitEvent("timelineControl", "setTime", 0);
  72. };
  73.  
  74. CABLES_CMD_TIMELINE.TimelinePause = function ()
  75. {
  76. gui.corePatch().timer.pause();
  77. gui.emitEvent("timelineControl", "setPlay", false, gui.scene().timer.getTime());
  78. };
  79.  
  80. CABLES_CMD_TIMELINE.togglePlay = function ()
  81. {
  82. gui.timeLine().togglePlay();
  83. gui.emitEvent("timelineControl", "setPlay", gui.scene().timer.isPlaying(), gui.scene().timer.getTime());
  84. };
  85.  
  86. CABLES_CMD_TIMELINE.toggleTimeline = function ()
  87. {
  88. gui.toggleTiming();
  89. };
  90.  
  91. CABLES_CMD_TIMELINE.hideTimeline = function ()
  92. {
  93. gui.hideTiming();
  94. };
  95.  
  96. CABLES_CMD_TIMELINE.showTimeline = function ()
  97. {
  98. gui.showTiming();
  99. };
  100.  
  101. timelineCommands.commands.push(
  102. {
  103. "cmd": "toggle timeline",
  104. "category": "ui",
  105. "func": CABLES_CMD_TIMELINE.toggleTimeline,
  106. "icon": "timeline"
  107. },
  108. {
  109. "cmd": "show timeline",
  110. "category": "ui",
  111. "func": CABLES_CMD_TIMELINE.showTimeline,
  112. "icon": "timeline"
  113. },
  114. {
  115. "cmd": "hide timeline",
  116. "category": "ui",
  117. "func": CABLES_CMD_TIMELINE.hideTimeline,
  118. "icon": "timeline"
  119. },
  120. {
  121. "cmd": "timeline play",
  122. "category": "ui",
  123. "func": CABLES_CMD_TIMELINE.TimelinePlay,
  124. "icon": "play"
  125. },
  126. {
  127. "cmd": "timeline pause",
  128. "category": "ui",
  129. "func": CABLES_CMD_TIMELINE.TimelinePause,
  130. "icon": "pause"
  131. },
  132. {
  133. "cmd": "timeline rewind",
  134. "category": "ui",
  135. "func": CABLES_CMD_TIMELINE.TimelineRewind,
  136. "icon": "rewind"
  137. },
  138. {
  139. "cmd": "timeline forward",
  140. "category": "ui",
  141. "func": CABLES_CMD_TIMELINE.TimelineForward,
  142. "icon": "fast-forward"
  143. },
  144. {
  145. "cmd": "timeline rewind to 0",
  146. "category": "ui",
  147. "func": CABLES_CMD_TIMELINE.TimelineRewindStart,
  148. "icon": "skip-back"
  149. },
  150. {
  151. "cmd": "set timeline length",
  152. "category": "timeline",
  153. "func": CABLES_CMD_TIMELINE.setLength
  154. },
  155. {
  156. "cmd": "show all animated ports",
  157. "category": "timeline",
  158. "func": CABLES_CMD_TIMELINE.ListAnimatedPorts
  159. },
  160.  
  161.  
  162. );