The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.2KB

  1. /*
  2. ==============================================================================
  3. This file was auto-generated!
  4. ==============================================================================
  5. */
  6. #ifndef MAINCOMPONENT_H_INCLUDED
  7. #define MAINCOMPONENT_H_INCLUDED
  8. #include "../JuceLibraryCode/JuceHeader.h"
  9. //==============================================================================
  10. /*
  11. This component lives inside our window, and this is where you should put all
  12. your controls and content.
  13. */
  14. class MainContentComponent : public Component, private Slider::Listener
  15. {
  16. public:
  17. //==============================================================================
  18. MainContentComponent()
  19. {
  20. setSize (200, 200);
  21. rotaryKnob.setRange (0.0, 1.0);
  22. rotaryKnob.setSliderStyle (Slider::RotaryVerticalDrag);
  23. rotaryKnob.setTextBoxStyle (Slider::TextBoxBelow, true, 150, 25);
  24. rotaryKnob.setBounds (10, 10, 180, 180);
  25. addAndMakeVisible (rotaryKnob);
  26. rotaryKnob.addListener (this);
  27. // specify here where to send OSC messages to: host URL and UDP port number
  28. if (! sender.connect ("127.0.0.1", 9001))
  29. showConnectionErrorMessage ("Error: could not connect to UDP port 9001.");
  30. }
  31. private:
  32. //==============================================================================
  33. void sliderValueChanged (Slider* slider) override
  34. {
  35. if (slider == &rotaryKnob)
  36. {
  37. // create and send an OSC message with an address and a float value:
  38. if (! sender.send ("/juce/rotaryknob", (float) rotaryKnob.getValue()))
  39. showConnectionErrorMessage ("Error: could not send OSC message.");
  40. }
  41. }
  42. void showConnectionErrorMessage (const String& messageText)
  43. {
  44. AlertWindow::showMessageBoxAsync (
  45. AlertWindow::WarningIcon,
  46. "Connection error",
  47. messageText,
  48. "OK");
  49. }
  50. //==============================================================================
  51. Slider rotaryKnob;
  52. OSCSender sender;
  53. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
  54. };
  55. #endif // MAINCOMPONENT_H_INCLUDED