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.

66 lines
2.2KB

  1. /*
  2. ==============================================================================
  3. This file was auto-generated!
  4. ==============================================================================
  5. */
  6. #pragma once
  7. #include "../JuceLibraryCode/JuceHeader.h"
  8. //==============================================================================
  9. /*
  10. This component lives inside our window, and this is where you should put all
  11. your controls and content.
  12. */
  13. class MainContentComponent : public Component,
  14. private OSCReceiver,
  15. private OSCReceiver::ListenerWithOSCAddress<OSCReceiver::MessageLoopCallback>
  16. {
  17. public:
  18. //==============================================================================
  19. MainContentComponent()
  20. {
  21. setSize (200, 200);
  22. rotaryKnob.setRange (0.0, 1.0);
  23. rotaryKnob.setSliderStyle (Slider::RotaryVerticalDrag);
  24. rotaryKnob.setTextBoxStyle (Slider::TextBoxBelow, true, 150, 25);
  25. rotaryKnob.setBounds (10, 10, 180, 180);
  26. rotaryKnob.setInterceptsMouseClicks (false, false);
  27. addAndMakeVisible (rotaryKnob);
  28. // specify here on which UDP port number to receive incoming OSC messages
  29. if (! connect (9001))
  30. showConnectionErrorMessage ("Error: could not connect to UDP port 9001.");
  31. // tell the component to listen for OSC messages matching this address:
  32. addListener (this, "/juce/rotaryknob");
  33. }
  34. private:
  35. //==============================================================================
  36. void oscMessageReceived (const OSCMessage& message) override
  37. {
  38. if (message.size() == 1 && message[0].isFloat32())
  39. rotaryKnob.setValue (jlimit (0.0f, 10.0f, message[0].getFloat32()));
  40. }
  41. void showConnectionErrorMessage (const String& messageText)
  42. {
  43. AlertWindow::showMessageBoxAsync (
  44. AlertWindow::WarningIcon,
  45. "Connection error",
  46. messageText,
  47. "OK");
  48. }
  49. //==============================================================================
  50. Slider rotaryKnob;
  51. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
  52. };