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.3KB

  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,
  15. private OSCReceiver,
  16. private OSCReceiver::ListenerWithOSCAddress<OSCReceiver::MessageLoopCallback>
  17. {
  18. public:
  19. //==============================================================================
  20. MainContentComponent()
  21. {
  22. setSize (200, 200);
  23. rotaryKnob.setRange (0.0, 1.0);
  24. rotaryKnob.setSliderStyle (Slider::RotaryVerticalDrag);
  25. rotaryKnob.setTextBoxStyle (Slider::TextBoxBelow, true, 150, 25);
  26. rotaryKnob.setBounds (10, 10, 180, 180);
  27. rotaryKnob.setInterceptsMouseClicks (false, false);
  28. addAndMakeVisible (rotaryKnob);
  29. // specify here on which UDP port number to receive incoming OSC messages
  30. if (! connect (9001))
  31. showConnectionErrorMessage ("Error: could not connect to UDP port 9001.");
  32. // tell the component to listen for OSC messages matching this address:
  33. addListener (this, "/juce/rotaryknob");
  34. }
  35. private:
  36. //==============================================================================
  37. void oscMessageReceived (const OSCMessage& message) override
  38. {
  39. if (message.size() == 1 && message[0].isFloat32())
  40. rotaryKnob.setValue (jlimit (0.0f, 10.0f, message[0].getFloat32()));
  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. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
  53. };
  54. #endif // MAINCOMPONENT_H_INCLUDED