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