seqband.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #include <precomp.h>
  2. #include "seqband.h"
  3. #include <api/core/api_core.h>
  4. #define NOTIFYMSG_EQ_HELLO 0x3003
  5. const wchar_t eqBandXuiStr[] = L"EqBand"; // This is the xml tag
  6. char eqBandXuiSvcName[] = "EqBand xui object"; // this is the name of the xuiservice
  7. XMLParamPair SEQBand::params[] = {
  8. {SEQBAND_SETPARAM, L"BAND"},
  9. {SEQBAND_SETPARAM, L"PARAM"},
  10. };
  11. SEQBand::SEQBand() {
  12. band = 0;
  13. setDrawOnBorders(TRUE);
  14. setEnable(TRUE);
  15. setHotPosition(0);
  16. isactive=0;
  17. discard_next_event = 0;
  18. xuihandle = newXuiHandle();
  19. CreateXMLParameters(xuihandle);
  20. setLimits(-127,127);
  21. }
  22. void SEQBand::CreateXMLParameters(int master_handle)
  23. {
  24. //SEQBAND_PARENT::CreateXMLParameters(master_handle);
  25. int numParams = sizeof(params) / sizeof(params[0]);
  26. hintNumberOfParams(xuihandle, numParams);
  27. for (int i = 0;i < numParams;i++)
  28. addParam(xuihandle, params[i], XUI_ATTRIBUTE_IMPLIED);
  29. }
  30. SEQBand::~SEQBand() {
  31. WASABI_API_MEDIACORE->core_delCallback(0, this);
  32. }
  33. int SEQBand::setXuiParam(int _xuihandle, int attrid, const wchar_t *name, const wchar_t *strval) {
  34. if (_xuihandle != xuihandle) return SEQBAND_PARENT::setXuiParam(_xuihandle, attrid, name, strval);
  35. switch (attrid) {
  36. case SEQBAND_SETPARAM:
  37. case SEQBAND_SETBAND:
  38. setBand(WTOI(strval)-1);
  39. break;
  40. default:
  41. return 0;
  42. }
  43. return 1;
  44. }
  45. void SEQBand::setBand(int b) {
  46. band = b;
  47. }
  48. int SEQBand::onInit() {
  49. SEQBAND_PARENT::onInit();
  50. corecb_onEQBandChange(band, WASABI_API_MEDIACORE->core_getEqBand(0, band));
  51. WASABI_API_MEDIACORE->core_addCallback(0, this);
  52. return 1;
  53. }
  54. int SEQBand::onSetPosition() {
  55. setHotPosition((Std::keyDown(VK_SHIFT) ? -1 : 0));
  56. SEQBAND_PARENT::onSetPosition();
  57. int pos = getSliderPosition(); // get slider pos
  58. discard_next_event = 1;
  59. WASABI_API_MEDIACORE->core_setEqBand(0,band,pos);
  60. return 1;
  61. }
  62. int SEQBand::onResize() {
  63. SEQBAND_PARENT::onResize();
  64. invalidate();
  65. return 1;
  66. }
  67. int SEQBand::corecb_onEQBandChange(int b, int newval) {
  68. if(b!=band) return 0;
  69. if (discard_next_event) {
  70. discard_next_event = 0;
  71. return 0;
  72. }
  73. setPosition(newval,0);
  74. return 0;
  75. }
  76. int SEQBand::onLeftButtonDown(int x, int y) {
  77. isactive=1;
  78. return SEQBAND_PARENT::onLeftButtonDown(x,y);
  79. }
  80. int SEQBand::onMouseMove(int x, int y) {
  81. if(isactive) {
  82. ifc_window *parent=getParent();
  83. if(parent) {
  84. ifc_window *wnd=parent->findRootWndChild(x,y);
  85. if(wnd && wnd!=this) {
  86. if(wnd->childNotify(this,NOTIFYMSG_EQ_HELLO,0,0)) { // will return 1 if it's another EQBand
  87. onLeftButtonUp(x,y);
  88. wnd->onLeftButtonDown(x,y);
  89. }
  90. }
  91. }
  92. }
  93. return SEQBAND_PARENT::onMouseMove(x,y);
  94. }
  95. int SEQBand::onLeftButtonUp(int x, int y) {
  96. isactive=0;
  97. return SEQBAND_PARENT::onLeftButtonUp(x,y);
  98. }
  99. int SEQBand::childNotify(ifc_window *child, int msg, intptr_t param1, intptr_t param2) {
  100. if(msg==NOTIFYMSG_EQ_HELLO) return 1;
  101. return SEQBAND_PARENT::childNotify(child,msg,param1,param2);
  102. }