Home Reference Source

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

  1. import { utils } from "cables";
  2. import { PortHtmlGenerator } from "../components/opparampanel/op_params_htmlgen.js";
  3. import ParamsListener from "../components/opparampanel/params_listener.js";
  4. import GlTimelineTab from "../components/tabs/tab_gltimeline.js";
  5. import { gui } from "../gui.js";
  6. const CABLES_CMD_TIMELINE = {};
  7. const timelineCommands =
  8. {
  9. /** @type {import("./commands.js").commandObject[]} */
  10. "commands": [],
  11. "functions": CABLES_CMD_TIMELINE
  12. };
  13. export default timelineCommands;
  14. export { CABLES_CMD_TIMELINE as CmdTimeline };
  15. CABLES_CMD_TIMELINE.TimelineSnapTimes = function ()
  16. {
  17. gui.glTimeline.snapSelectedKeyTimes();
  18. };
  19. CABLES_CMD_TIMELINE.TimelineCreateKeyAtCursor = function ()
  20. {
  21. gui.glTimeline.createKeyAtCursor();
  22. };
  23. CABLES_CMD_TIMELINE.TimelinePlay = function ()
  24. {
  25. gui.corePatch().timer.play();
  26. gui.emitEvent("timelineControl", "setPlay", true, gui.corePatch().timer.getTime());
  27. };
  28. CABLES_CMD_TIMELINE.TimelineForward = function ()
  29. {
  30. gui.corePatch().timer.setTime(gui.corePatch().timer.getTime() + 2);
  31. };
  32. CABLES_CMD_TIMELINE.TimelineRewind = function ()
  33. {
  34. gui.corePatch().timer.setTime(gui.corePatch().timer.getTime() - 2);
  35. };
  36. CABLES_CMD_TIMELINE.TimelineRewindStart = function ()
  37. {
  38. gui.corePatch().timer.setTime(0);
  39. };
  40. CABLES_CMD_TIMELINE.TimelinePause = function ()
  41. {
  42. gui.corePatch().timer.pause();
  43. gui.emitEvent("timelineControl", "setPlay", false, gui.corePatch().timer.getTime());
  44. };
  45. CABLES_CMD_TIMELINE.togglePlay = function ()
  46. {
  47. if (gui.corePatch().timer.isPlaying())gui.corePatch().timer.pause();
  48. else gui.corePatch().timer.play();
  49. };
  50. CABLES_CMD_TIMELINE.toggleGraph = function ()
  51. {
  52. gui.glTimeline?.toggleGraphLayout();
  53. };
  54. CABLES_CMD_TIMELINE.openGlTimeline = function ()
  55. {
  56. gui.glTimeLineTab = new GlTimelineTab(gui.bottomTabs);
  57. };
  58. CABLES_CMD_TIMELINE.toggleTimeline = function ()
  59. {
  60. gui.toggleTimeline();
  61. };
  62. CABLES_CMD_TIMELINE.hideTimeline = function ()
  63. {
  64. gui.hideTimeline();
  65. };
  66. CABLES_CMD_TIMELINE.showTimeline = function ()
  67. {
  68. gui.showTiming();
  69. };
  70. timelineCommands.commands.push(
  71. {
  72. "cmd": "toggle timeline",
  73. "category": "ui",
  74. "func": CABLES_CMD_TIMELINE.toggleTimeline,
  75. "icon": "timeline"
  76. },
  77. {
  78. "cmd": "show timeline",
  79. "category": "ui",
  80. "func": CABLES_CMD_TIMELINE.openGlTimeline,
  81. "icon": "timeline"
  82. },
  83. {
  84. "cmd": "hide timeline",
  85. "category": "ui",
  86. "func": CABLES_CMD_TIMELINE.hideTimeline,
  87. "icon": "timeline"
  88. },
  89. {
  90. "cmd": "timeline play",
  91. "category": "ui",
  92. "func": CABLES_CMD_TIMELINE.TimelinePlay,
  93. "icon": "play"
  94. },
  95. {
  96. "cmd": "timeline pause",
  97. "category": "ui",
  98. "func": CABLES_CMD_TIMELINE.TimelinePause,
  99. "icon": "pause"
  100. },
  101. {
  102. "cmd": "timeline rewind",
  103. "category": "ui",
  104. "func": CABLES_CMD_TIMELINE.TimelineRewind,
  105. "icon": "rewind"
  106. },
  107. {
  108. "cmd": "timeline forward",
  109. "category": "ui",
  110. "func": CABLES_CMD_TIMELINE.TimelineForward,
  111. "icon": "fast-forward"
  112. },
  113. {
  114. "cmd": "timeline rewind to 0",
  115. "category": "ui",
  116. "func": CABLES_CMD_TIMELINE.TimelineRewindStart,
  117. "icon": "skip-back"
  118. },
  119. {
  120. "cmd": "add new keyframe at cursor",
  121. "category": "timeline",
  122. "func": CABLES_CMD_TIMELINE.TimelineCreateKeyAtCursor
  123. },
  124. {
  125. "cmd": "snap selected keys times to fps",
  126. "category": "timeline",
  127. "func": CABLES_CMD_TIMELINE.TimelineSnapTimes
  128. },
  129. {
  130. "cmd": "timeline toggle line/graph layout",
  131. "category": "timeline",
  132. "icon": "chart-spline",
  133. "func": CABLES_CMD_TIMELINE.toggleGraph
  134. }
  135. );