sequence.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include "precomp.h"
  2. #include "sequence.h"
  3. #define CBCLASS ItemSequencerI
  4. START_DISPATCH;
  5. CB(GETDEPENDENCYPTR, getDependencyPtr);
  6. CB(GETNEXTPLAYITEM, getNextPlayItem);
  7. CB(GETCURRENTPLAYBACKNUMBER, getCurrentPlaybackNumber);
  8. CB(GETNUMITEMS, getNumItems);
  9. CB(REWIND, rewind);
  10. CB(FORWARD, forward);
  11. CB(ONNOTIFY, onNotify);
  12. END_DISPATCH;
  13. #undef CBCLASS
  14. int ItemSequencerI::onNotify(int msg, int param1, int param2) {
  15. switch (msg) {
  16. case SEQNOTIFY_ONREGISTER: return onRegister();
  17. case SEQNOTIFY_ONDEREGISTER: return onDeregister();
  18. case SEQNOTIFY_ONNEXTFILE: return onNextFile();
  19. case SEQNOTIFY_ONTITLECHANGE: return onTitleChange();
  20. case SEQNOTIFY_ONSTARTED: return onStarted();
  21. case SEQNOTIFY_ONSTOPPED: return onStopped();
  22. case SEQNOTIFY_ONPAUSED: return onPaused();
  23. case SEQNOTIFY_ONUNPAUSED: return onUnpaused();
  24. }
  25. return 0;
  26. }
  27. const char *ListSequencer::getNextPlayItem() {
  28. int pos;
  29. const char *ret;
  30. pos = getCurrent();
  31. if (pos < 0) return NULL;
  32. ret = enumItem(pos);
  33. setCurrent(pos);
  34. return ret;
  35. }
  36. int ListSequencer::rewind() {
  37. int pos;
  38. pos = getCurrent();
  39. if (pos < 0) return 0;
  40. pos--;
  41. if (pos < 0) {
  42. if (loop()) {
  43. pos = getNumEntries()-1;
  44. } else {
  45. pos++;
  46. }
  47. }
  48. setCurrent(pos);
  49. return 1;
  50. }
  51. int ListSequencer::forward() {
  52. int pos;
  53. pos = getCurrent();
  54. if (pos < 0) return 0;
  55. pos++;
  56. if (pos >= getNumEntries()) {
  57. if (loop()) {
  58. pos = 0;
  59. } else {
  60. return 0;
  61. }
  62. }
  63. setCurrent(pos);
  64. return 1;
  65. }
  66. int ListSequencer::getNumItems() {
  67. return getNumEntries();
  68. }