openshot-audio  0.1.7
juce_Slider.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_SLIDER_H_INCLUDED
26 #define JUCE_SLIDER_H_INCLUDED
27 
28 
29 //==============================================================================
50 class JUCE_API Slider : public Component,
52 {
53 public:
54  //==============================================================================
60  {
65  Rotary,
67  RotaryHorizontalDrag,
69  RotaryVerticalDrag,
71  RotaryHorizontalVerticalDrag,
75  TwoValueHorizontal,
77  TwoValueVertical,
80  ThreeValueHorizontal,
83  ThreeValueVertical,
86  };
87 
92  {
97  TextBoxBelow
98  };
99 
103  enum DragMode
104  {
107  velocityDrag
108  };
109 
110  //==============================================================================
114  Slider();
115 
119  explicit Slider (const String& componentName);
120 
122  Slider (SliderStyle style, TextEntryBoxPosition textBoxPosition);
123 
125  ~Slider();
126 
127  //==============================================================================
133  void setSliderStyle (SliderStyle newStyle);
134 
138  SliderStyle getSliderStyle() const noexcept;
139 
140  //==============================================================================
154  void setRotaryParameters (float startAngleRadians,
155  float endAngleRadians,
156  bool stopAtEnd);
157 
164  void setMouseDragSensitivity (int distanceForFullScaleDrag);
165 
167  int getMouseDragSensitivity() const noexcept;
168 
169  //==============================================================================
178  void setVelocityBasedMode (bool isVelocityBased);
179 
183  bool getVelocityBasedMode() const noexcept;
184 
198  void setVelocityModeParameters (double sensitivity = 1.0,
199  int threshold = 1,
200  double offset = 0.0,
201  bool userCanPressKeyToSwapMode = true);
202 
206  double getVelocitySensitivity() const noexcept;
207 
211  int getVelocityThreshold() const noexcept;
212 
216  double getVelocityOffset() const noexcept;
217 
221  bool getVelocityModeIsSwappable() const noexcept;
222 
223  //==============================================================================
239  void setSkewFactor (double factor);
240 
248  void setSkewFactorFromMidPoint (double sliderValueToShowAtMidPoint);
249 
254  double getSkewFactor() const noexcept;
255 
256  //==============================================================================
260  {
264  incDecButtonsDraggable_Vertical
265  };
266 
277  void setIncDecButtonsMode (IncDecButtonMode mode);
278 
279  //==============================================================================
291  void setTextBoxStyle (TextEntryBoxPosition newPosition,
292  bool isReadOnly,
293  int textEntryBoxWidth,
294  int textEntryBoxHeight);
295 
299  TextEntryBoxPosition getTextBoxPosition() const noexcept;
300 
304  int getTextBoxWidth() const noexcept;
305 
309  int getTextBoxHeight() const noexcept;
310 
318  void setTextBoxIsEditable (bool shouldBeEditable);
319 
323  bool isTextBoxEditable() const noexcept;
324 
329  void showTextBox();
330 
339  void hideTextBox (bool discardCurrentEditorContents);
340 
341 
342  //==============================================================================
356  void setValue (double newValue, NotificationType notification = sendNotificationAsync);
357 
359  double getValue() const;
360 
367  Value& getValueObject() noexcept;
368 
369  //==============================================================================
377  void setRange (double newMinimum,
378  double newMaximum,
379  double newInterval = 0);
380 
384  double getMaximum() const noexcept;
385 
389  double getMinimum() const noexcept;
390 
394  double getInterval() const noexcept;
395 
396  //==============================================================================
405  double getMinValue() const;
406 
413  Value& getMinValueObject() noexcept;
414 
433  void setMinValue (double newValue,
434  NotificationType notification = sendNotificationAsync,
435  bool allowNudgingOfOtherValues = false);
436 
445  double getMaxValue() const;
446 
453  Value& getMaxValueObject() noexcept;
454 
473  void setMaxValue (double newValue,
474  NotificationType notification = sendNotificationAsync,
475  bool allowNudgingOfOtherValues = false);
476 
492  void setMinAndMaxValues (double newMinValue, double newMaxValue,
493  NotificationType notification = sendNotificationAsync);
494 
495  //==============================================================================
504  {
505  public:
506  //==============================================================================
508  virtual ~Listener() {}
509 
510  //==============================================================================
520  virtual void sliderValueChanged (Slider* slider) = 0;
521 
522  //==============================================================================
531  virtual void sliderDragStarted (Slider*) {}
532 
536  virtual void sliderDragEnded (Slider*) {}
537  };
538 
540  void addListener (Listener* listener);
541 
543  void removeListener (Listener* listener);
544 
545  //==============================================================================
554  void setDoubleClickReturnValue (bool shouldDoubleClickBeEnabled,
555  double valueToSetOnDoubleClick);
556 
560  double getDoubleClickReturnValue() const noexcept;
561 
565  bool isDoubleClickReturnEnabled() const noexcept;
566 
567  //==============================================================================
576  void setChangeNotificationOnlyOnRelease (bool onlyNotifyOnRelease);
577 
587  void setSliderSnapsToMousePosition (bool shouldSnapToMouse);
588 
590  bool getSliderSnapsToMousePosition() const noexcept;
591 
604  void setPopupDisplayEnabled (bool isEnabled, Component* parentComponentToUse);
605 
610  Component* getCurrentPopupDisplay() const noexcept;
611 
619  void setPopupMenuEnabled (bool menuEnabled);
620 
624  void setScrollWheelEnabled (bool enabled);
625 
631  int getThumbBeingDragged() const noexcept;
632 
633  //==============================================================================
637  virtual void startedDragging();
638 
642  virtual void stoppedDragging();
643 
647  virtual void valueChanged();
648 
649  //==============================================================================
658  virtual double getValueFromText (const String& text);
659 
670  virtual String getTextFromValue (double value);
671 
679  void setTextValueSuffix (const String& suffix);
680 
682  String getTextValueSuffix() const;
683 
689  int getNumDecimalPlacesToDisplay() const noexcept;
690 
691  //==============================================================================
703  virtual double proportionOfLengthToValue (double proportion);
704 
718  virtual double valueToProportionOfLength (double value);
719 
729  float getPositionOfValue (double value);
730 
731  //==============================================================================
744  virtual double snapValue (double attemptedValue, DragMode dragMode);
745 
746 
747  //==============================================================================
751  void updateText();
752 
754  bool isHorizontal() const noexcept;
756  bool isVertical() const noexcept;
758  bool isRotary() const noexcept;
760  bool isBar() const noexcept;
761 
762  //==============================================================================
771  {
772  backgroundColourId = 0x1001200,
773  thumbColourId = 0x1001300,
775  trackColourId = 0x1001310,
776  rotarySliderFillColourId = 0x1001311,
777  rotarySliderOutlineColourId = 0x1001312,
779  textBoxTextColourId = 0x1001400,
780  textBoxBackgroundColourId = 0x1001500,
781  textBoxHighlightColourId = 0x1001600,
782  textBoxOutlineColourId = 0x1001700
783  };
784 
785  //==============================================================================
790  {
793  };
794 
795  //==============================================================================
800  {
801  virtual ~LookAndFeelMethods() {}
802 
803  //==============================================================================
804  virtual void drawLinearSlider (Graphics&,
805  int x, int y, int width, int height,
806  float sliderPos,
807  float minSliderPos,
808  float maxSliderPos,
809  const Slider::SliderStyle,
810  Slider&) = 0;
811 
812  virtual void drawLinearSliderBackground (Graphics&,
813  int x, int y, int width, int height,
814  float sliderPos,
815  float minSliderPos,
816  float maxSliderPos,
817  const Slider::SliderStyle style,
818  Slider&) = 0;
819 
820  virtual void drawLinearSliderThumb (Graphics&,
821  int x, int y, int width, int height,
822  float sliderPos,
823  float minSliderPos,
824  float maxSliderPos,
825  const Slider::SliderStyle,
826  Slider&) = 0;
827 
828  virtual int getSliderThumbRadius (Slider&) = 0;
829 
830  virtual void drawRotarySlider (Graphics&,
831  int x, int y, int width, int height,
832  float sliderPosProportional,
833  float rotaryStartAngle,
834  float rotaryEndAngle,
835  Slider&) = 0;
836 
837  virtual Button* createSliderButton (Slider&, bool isIncrement) = 0;
838  virtual Label* createSliderTextBox (Slider&) = 0;
839 
840  virtual ImageEffectFilter* getSliderEffect (Slider&) = 0;
841 
842  virtual Font getSliderPopupFont (Slider&) = 0;
843  virtual int getSliderPopupPlacement (Slider&) = 0;
844 
845  virtual SliderLayout getSliderLayout (Slider&) = 0;
846 
847  #if JUCE_CATCH_DEPRECATED_CODE_MISUSE
848  // These methods' parameters have changed: see the new method signatures.
849  virtual void createSliderButton (bool) {}
850  virtual void getSliderEffect() {}
851  virtual void getSliderPopupFont() {}
852  virtual void getSliderPopupPlacement() {}
853  #endif
854  };
855 
856  //==============================================================================
858  void paint (Graphics&) override;
860  void resized() override;
862  void mouseDown (const MouseEvent&) override;
864  void mouseUp (const MouseEvent&) override;
866  void mouseDrag (const MouseEvent&) override;
868  void mouseDoubleClick (const MouseEvent&) override;
870  void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) override;
872  void modifierKeysChanged (const ModifierKeys&) override;
874  void lookAndFeelChanged() override;
876  void enablementChanged() override;
878  void focusOfChildComponentChanged (FocusChangeType) override;
880  void colourChanged() override;
881 
882 private:
883  //==============================================================================
884  JUCE_PUBLIC_IN_DLL_BUILD (class Pimpl)
885  friend class Pimpl;
886  friend struct ContainerDeletePolicy<Pimpl>;
887  ScopedPointer<Pimpl> pimpl;
888 
889  void init (SliderStyle, TextEntryBoxPosition);
890 
891  #if JUCE_CATCH_DEPRECATED_CODE_MISUSE
892  // These methods' bool parameters have changed: see the new method signature.
893  JUCE_DEPRECATED (void setValue (double, bool));
894  JUCE_DEPRECATED (void setValue (double, bool, bool));
895  JUCE_DEPRECATED (void setMinValue (double, bool, bool, bool));
896  JUCE_DEPRECATED (void setMinValue (double, bool, bool));
897  JUCE_DEPRECATED (void setMinValue (double, bool));
898  JUCE_DEPRECATED (void setMaxValue (double, bool, bool, bool));
899  JUCE_DEPRECATED (void setMaxValue (double, bool, bool));
900  JUCE_DEPRECATED (void setMaxValue (double, bool));
901  JUCE_DEPRECATED (void setMinAndMaxValues (double, double, bool, bool));
902  JUCE_DEPRECATED (void setMinAndMaxValues (double, double, bool));
903  virtual void snapValue (double, bool) {}
904  #endif
905 
907 };
908 
911 
912 #endif // JUCE_SLIDER_H_INCLUDED
Definition: juce_Slider.h:62
Definition: juce_Slider.h:93
Rectangle< int > sliderBounds
Definition: juce_Slider.h:791
ColourIds
Definition: juce_Slider.h:770
Definition: juce_Slider.h:95
virtual ~LookAndFeelMethods()
Definition: juce_Slider.h:801
Definition: juce_Font.h:39
#define true
Definition: ordinals.h:82
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_Slider.h:63
Definition: juce_NotificationType.h:38
TextEntryBoxPosition
Definition: juce_Slider.h:91
Definition: juce_Button.h:39
SliderStyle
Definition: juce_Slider.h:59
Definition: juce_ModifierKeys.h:38
Definition: juce_Slider.cpp:25
DragMode
Definition: juce_Slider.h:103
#define false
Definition: ordinals.h:83
Definition: juce_String.h:43
#define JUCE_API
Definition: juce_StandardHeader.h:139
#define JUCE_PUBLIC_IN_DLL_BUILD(declaration)
Definition: juce_StandardHeader.h:145
Definition: juce_Slider.h:96
#define const
png_structrp int mode
Definition: juce_PNGLoader.cpp:1243
Definition: juce_Rectangle.h:36
Definition: juce_Label.h:34
NotificationType
Definition: juce_NotificationType.h:33
Definition: juce_TooltipClient.h:63
virtual void sliderDragEnded(Slider *)
Definition: juce_Slider.h:536
Rectangle< int > textBoxBounds
Definition: juce_Slider.h:792
Definition: juce_Slider.h:263
Definition: juce_Slider.h:106
Definition: juce_Component.h:33
Definition: juce_ScopedPointer.h:70
IncDecButtonMode
Definition: juce_Slider.h:259
Definition: juce_MouseEvent.h:329
Definition: juce_Slider.h:73
png_const_structrp png_const_inforp int png_fixed_point * width
Definition: juce_PNGLoader.cpp:2339
Slider::Listener SliderListener
Definition: juce_Slider.h:910
Definition: juce_Slider.h:503
#define JUCE_DEPRECATED(functionDef)
Definition: juce_PlatformDefs.h:319
Definition: juce_ContainerDeletePolicy.h:44
Definition: juce_Value.h:44
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_Slider.h:789
Definition: juce_GraphicsContext.h:42
virtual void sliderDragStarted(Slider *)
Definition: juce_Slider.h:531
Definition: juce_Slider.h:105
Definition: juce_Slider.h:94
Definition: juce_Slider.h:61
Definition: juce_Slider.h:50
Definition: juce_Slider.h:799
Definition: juce_MouseEvent.h:36
Definition: juce_Slider.h:64
virtual ~Listener()
Definition: juce_Slider.h:508
Definition: juce_Slider.h:261
Definition: juce_ImageEffectFilter.h:40