Slider.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /************************************************************************
  2. * Slider.js
  3. ************************************************************************
  4. * Copyright (c) 2021 Pedro Tonini Rosenberg Schneider.
  5. *
  6. * This file is part of Pandora.
  7. *
  8. * Pandora is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * Pandora is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with Pandora. If not, see <https://www.gnu.org/licenses/>.
  20. *************************************************************************/
  21. class Slider extends UIObject
  22. {
  23. constructor(name, min = 0, max = 100, value = 0, step = 0)
  24. {
  25. super(name);
  26. this.P5Element = createSlider(min, max, value, step);
  27. this.setPosition(0, 0);
  28. this.setSize(200, 25);
  29. this.setStyle(STYLE.DEFAULT_STYLE);
  30. this.connectCallbacks();
  31. this.P5Element.changed(this.onChanged);
  32. }
  33. _onChanged()
  34. {
  35. }
  36. initSignals()
  37. {
  38. this.addSignal("mousePressed");
  39. this.addSignal("doubleClicked");
  40. this.addSignal("mouseWheel");
  41. this.addSignal("mouseReleased");
  42. this.addSignal("mouseClicked");
  43. this.addSignal("mouseMoved");
  44. this.addSignal("mouseOver");
  45. this.addSignal("mouseOut");
  46. this.addSignal("touchStarted");
  47. this.addSignal("touchMoved");
  48. this.addSignal("touchEnded");
  49. this.addSignal("dragOver");
  50. this.addSignal("dragLeave");
  51. this.addSignal("changed");
  52. this._initSignals();
  53. }
  54. onChanged()
  55. {
  56. this.pandoraObject.emitSignal("changed");
  57. this.pandoraObject._onChanged();
  58. }
  59. }