CommonParameterInterface.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef PARAM_INTERFACE_H
  2. #define PARAM_INTERFACE_H
  3. #pragma once
  4. typedef void (*SliderParamChangedCallback) (float newVal);
  5. #include "LinearMath/btScalar.h"
  6. struct SliderParams
  7. {
  8. const char* m_name;
  9. float m_minVal;
  10. float m_maxVal;
  11. SliderParamChangedCallback m_callback;
  12. btScalar* m_paramValuePointer;
  13. void* m_userPointer;
  14. bool m_clampToNotches;
  15. bool m_showValues;
  16. SliderParams(const char* name, btScalar* targetValuePointer)
  17. :m_name(name),
  18. m_minVal(-100),
  19. m_maxVal(100),
  20. m_callback(0),
  21. m_paramValuePointer(targetValuePointer),
  22. m_userPointer(0),
  23. m_clampToNotches(true),
  24. m_showValues(true)
  25. {
  26. }
  27. };
  28. typedef void (*ButtonParamChangedCallback) (int buttonId, bool buttonState, void* userPointer);
  29. typedef void (*ComboBoxCallback) (int combobox, const char* item, void* userPointer);
  30. struct ButtonParams
  31. {
  32. const char* m_name;
  33. int m_buttonId;
  34. void* m_userPointer;
  35. bool m_isTrigger;
  36. ButtonParamChangedCallback m_callback;
  37. ButtonParams(const char* name, int buttonId, bool isTrigger)
  38. :m_name(name),
  39. m_buttonId(buttonId),
  40. m_userPointer(0),
  41. m_isTrigger(isTrigger),
  42. m_callback(0)
  43. {
  44. }
  45. };
  46. struct ComboBoxParams
  47. {
  48. int m_comboboxId;
  49. int m_numItems;
  50. const char** m_items;
  51. int m_startItem;
  52. ComboBoxCallback m_callback;
  53. void* m_userPointer;
  54. ComboBoxParams()
  55. :m_comboboxId(-1),
  56. m_numItems(0),
  57. m_items(0),
  58. m_startItem(0),
  59. m_callback(0),
  60. m_userPointer(0)
  61. {
  62. }
  63. };
  64. struct CommonParameterInterface
  65. {
  66. virtual ~CommonParameterInterface() {}
  67. virtual void registerSliderFloatParameter(SliderParams& params)=0;
  68. virtual void registerButtonParameter(ButtonParams& params)=0;
  69. virtual void registerComboBox(ComboBoxParams& params)=0;
  70. virtual void syncParameters()=0;
  71. virtual void removeAllParameters()=0;
  72. virtual void setSliderValue(int sliderIndex, double sliderValue)=0;
  73. };
  74. #endif //PARAM_INTERFACE_H