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.

720 lines
33KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-7 by Raw Material Software ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the
  7. GNU General Public License, as published by the Free Software Foundation;
  8. either version 2 of the License, or (at your option) any later version.
  9. JUCE is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with JUCE; if not, visit www.gnu.org/licenses or write to the
  15. Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  16. Boston, MA 02111-1307 USA
  17. ------------------------------------------------------------------------------
  18. If you'd like to release a closed-source product which uses JUCE, commercial
  19. licenses are also available: visit www.rawmaterialsoftware.com/juce for
  20. more information.
  21. ==============================================================================
  22. */
  23. #ifndef __JUCE_SLIDER_JUCEHEADER__
  24. #define __JUCE_SLIDER_JUCEHEADER__
  25. #include "juce_SliderListener.h"
  26. #include "juce_Label.h"
  27. #include "../buttons/juce_Button.h"
  28. #include "../../../events/juce_AsyncUpdater.h"
  29. #include "../../../../juce_core/containers/juce_SortedSet.h"
  30. //==============================================================================
  31. /**
  32. A slider control for changing a value.
  33. The slider can be horizontal, vertical, or rotary, and can optionally have
  34. a text-box inside it to show an editable display of the current value.
  35. To use it, create a Slider object and use the setSliderStyle() method
  36. to set up the type you want. To set up the text-entry box, use setTextBoxStyle().
  37. To define the values that it can be set to, see the setRange() and setValue() methods.
  38. There are also lots of custom tweaks you can do by subclassing and overriding
  39. some of the virtual methods, such as changing the scaling, changing the format of
  40. the text display, custom ways of limiting the values, etc.
  41. You can register SliderListeners with a slider, which will be informed when the value
  42. changes, or a subclass can override valueChanged() to be informed synchronously.
  43. @see SliderListener
  44. */
  45. class JUCE_API Slider : public Component,
  46. public SettableTooltipClient,
  47. private AsyncUpdater,
  48. private ButtonListener,
  49. private LabelListener
  50. {
  51. public:
  52. //==============================================================================
  53. /** Creates a slider.
  54. When created, you'll need to set up the slider's style and range with setSliderStyle(),
  55. setRange(), etc.
  56. */
  57. Slider (const String& componentName);
  58. /** Destructor. */
  59. ~Slider();
  60. //==============================================================================
  61. /** The types of slider available.
  62. @see setSliderStyle, setRotaryParameters
  63. */
  64. enum SliderStyle
  65. {
  66. LinearHorizontal, /**< A traditional horizontal slider. */
  67. LinearVertical, /**< A traditional vertical slider. */
  68. LinearBar, /**< A horizontal bar slider with the text label drawn on top of it. */
  69. Rotary, /**< A rotary control that you move by dragging the mouse in a circular motion, like a knob.
  70. @see setRotaryParameters */
  71. RotaryHorizontalDrag, /**< A rotary control that you move by dragging the mouse left-to-right.
  72. @see setRotaryParameters */
  73. RotaryVerticalDrag, /**< A rotary control that you move by dragging the mouse up-and-down.
  74. @see setRotaryParameters */
  75. IncDecButtons, /**< A pair of buttons that increment or decrement the slider's value by the increment set in setRange(). */
  76. TwoValueHorizontal, /**< A horizontal slider that has two thumbs instead of one, so it can show a minimum and maximum value.
  77. @see setMinValue, setMaxValue */
  78. TwoValueVertical, /**< A vertical slider that has two thumbs instead of one, so it can show a minimum and maximum value.
  79. @see setMinValue, setMaxValue */
  80. ThreeValueHorizontal, /**< A horizontal slider that has three thumbs instead of one, so it can show a minimum and maximum
  81. value, with the current value being somewhere between them.
  82. @see setMinValue, setMaxValue */
  83. ThreeValueVertical, /**< A vertical slider that has three thumbs instead of one, so it can show a minimum and maximum
  84. value, with the current value being somewhere between them.
  85. @see setMinValue, setMaxValue */
  86. };
  87. /** Changes the type of slider interface being used.
  88. @param newStyle the type of interface
  89. @see setRotaryParameters, setVelocityBasedMode,
  90. */
  91. void setSliderStyle (const SliderStyle newStyle);
  92. /** Returns the slider's current style.
  93. @see setSliderStyle
  94. */
  95. SliderStyle getSliderStyle() const throw() { return style; }
  96. //==============================================================================
  97. /** Changes the properties of a rotary slider.
  98. @param startAngleRadians the angle (in radians, clockwise from the top) at which
  99. the slider's minimum value is represented
  100. @param endAngleRadians the angle (in radians, clockwise from the top) at which
  101. the slider's maximum value is represented. This must be
  102. greater than startAngleRadians
  103. @param stopAtEnd if true, then when the slider is dragged around past the
  104. minimum or maximum, it'll stop there; if false, it'll wrap
  105. back to the opposite value
  106. */
  107. void setRotaryParameters (const float startAngleRadians,
  108. const float endAngleRadians,
  109. const bool stopAtEnd);
  110. /** Sets the distance the mouse has to move to drag the slider across
  111. the full extent of its range.
  112. This only applies when in modes like RotaryHorizontalDrag, where it's using
  113. relative mouse movements to adjust the slider.
  114. */
  115. void setMouseDragSensitivity (const int distanceForFullScaleDrag);
  116. //==============================================================================
  117. /** Changes the way the the mouse is used when dragging the slider.
  118. If true, this will turn on velocity-sensitive dragging, so that
  119. the faster the mouse moves, the bigger the movement to the slider. This
  120. helps when making accurate adjustments if the slider's range is quite large.
  121. If false, the slider will just try to snap to wherever the mouse is.
  122. */
  123. void setVelocityBasedMode (const bool isVelocityBased) throw();
  124. /** Changes aspects of the scaling used when in velocity-sensitive mode.
  125. These apply when you've used setVelocityBasedMode() to turn on velocity mode,
  126. or if you're holding down ctrl.
  127. @param sensitivity higher values than 1.0 increase the range of acceleration used
  128. @param threshold the minimum number of pixels that the mouse needs to move for it
  129. to be treated as a movement
  130. @param offset values greater than 0.0 increase the minimum speed that will be used when
  131. the threshold is reached
  132. */
  133. void setVelocityModeParameters (const double sensitivity = 1.0,
  134. const int threshold = 1.0,
  135. const double offset = 0.0) throw();
  136. //==============================================================================
  137. /** Sets up a skew factor to alter the way values are distributed.
  138. You may want to use a range of values on the slider where more accuracy
  139. is required towards one end of the range, so this will logarithmically
  140. spread the values across the length of the slider.
  141. If the factor is < 1.0, the lower end of the range will fill more of the
  142. slider's length; if the factor is > 1.0, the upper end of the range
  143. will be expanded instead. A factor of 1.0 doesn't skew it at all.
  144. To set the skew position by using a mid-point, use the setSkewFactorFromMidPoint()
  145. method instead.
  146. @see getSkewFactor, setSkewFactorFromMidPoint
  147. */
  148. void setSkewFactor (const double factor) throw();
  149. /** Sets up a skew factor to alter the way values are distributed.
  150. This allows you to specify the slider value that should appear in the
  151. centre of the slider's visible range.
  152. @see setSkewFactor, getSkewFactor
  153. */
  154. void setSkewFactorFromMidPoint (const double sliderValueToShowAtMidPoint) throw();
  155. /** Returns the current skew factor.
  156. See setSkewFactor for more info.
  157. @see setSkewFactor, setSkewFactorFromMidPoint
  158. */
  159. double getSkewFactor() const throw() { return skewFactor; }
  160. //==============================================================================
  161. /** Used by setIncDecButtonsMode().
  162. */
  163. enum IncDecButtonMode
  164. {
  165. incDecButtonsNotDraggable,
  166. incDecButtonsDraggable_AutoDirection,
  167. incDecButtonsDraggable_Horizontal,
  168. incDecButtonsDraggable_Vertical
  169. };
  170. /** When the style is IncDecButtons, this lets you turn on a mode where the mouse
  171. can be dragged on the buttons to drag the values.
  172. By default this is turned off. When enabled, clicking on the buttons still works
  173. them as normal, but by holding down the mouse on a button and dragging it a little
  174. distance, it flips into a mode where the value can be dragged. The drag direction can
  175. either be set explicitly to be vertical or horizontal, or can be set to
  176. incDecButtonsDraggable_AutoDirection so that it depends on whether the buttons
  177. are side-by-side or above each other.
  178. */
  179. void setIncDecButtonsMode (const IncDecButtonMode mode);
  180. //==============================================================================
  181. /** The position of the slider's text-entry box.
  182. @see setTextBoxStyle
  183. */
  184. enum TextEntryBoxPosition
  185. {
  186. NoTextBox, /**< Doesn't display a text box. */
  187. TextBoxLeft, /**< Puts the text box to the left of the slider, vertically centred. */
  188. TextBoxRight, /**< Puts the text box to the right of the slider, vertically centred. */
  189. TextBoxAbove, /**< Puts the text box above the slider, horizontally centred. */
  190. TextBoxBelow /**< Puts the text box below the slider, horizontally centred. */
  191. };
  192. /** Changes the location and properties of the text-entry box.
  193. @param newPosition where it should go (or NoTextBox to not have one at all)
  194. @param isReadOnly if true, it's a read-only display
  195. @param textEntryBoxWidth the width of the text-box in pixels. Make sure this leaves enough
  196. room for the slider as well!
  197. @param textEntryBoxHeight the height of the text-box in pixels. Make sure this leaves enough
  198. room for the slider as well!
  199. @see setTextBoxIsEditable, getValueFromText, getTextFromValue
  200. */
  201. void setTextBoxStyle (const TextEntryBoxPosition newPosition,
  202. const bool isReadOnly,
  203. const int textEntryBoxWidth,
  204. const int textEntryBoxHeight);
  205. /** Returns the status of the text-box.
  206. @see setTextBoxStyle
  207. */
  208. const TextEntryBoxPosition getTextBoxPosition() const throw() { return textBoxPos; }
  209. /** Returns the width used for the text-box.
  210. @see setTextBoxStyle
  211. */
  212. int getTextBoxWidth() const throw() { return textBoxWidth; }
  213. /** Returns the height used for the text-box.
  214. @see setTextBoxStyle
  215. */
  216. int getTextBoxHeight() const throw() { return textBoxHeight; }
  217. /** Makes the text-box editable.
  218. By default this is true, and the user can enter values into the textbox,
  219. but it can be turned off if that's not suitable.
  220. @see setTextBoxStyle, getValueFromText, getTextFromValue
  221. */
  222. void setTextBoxIsEditable (const bool shouldBeEditable) throw();
  223. /** Returns true if the text-box is read-only.
  224. @see setTextBoxStyle
  225. */
  226. bool isTextBoxEditable() const throw() { return editableText; }
  227. /** If the text-box is editable, this will give it the focus so that the user can
  228. type directly into it.
  229. This is basically the effect as the user clicking on it.
  230. */
  231. void showTextBox();
  232. /** If the text-box currently has focus and is being edited, this resets it and takes keyboard
  233. focus away from it.
  234. @param discardCurrentEditorContents if true, the slider's value will be left
  235. unchanged; if false, the current contents of the
  236. text editor will be used to set the slider position
  237. before it is hidden.
  238. */
  239. void hideTextBox (const bool discardCurrentEditorContents);
  240. //==============================================================================
  241. /** Changes the slider's current value.
  242. This will trigger a callback to SliderListener::sliderValueChanged() for any listeners
  243. that are registered, and will synchronously call the valueChanged() method in case subclasses
  244. want to handle it.
  245. @param newValue the new value to set - this will be restricted by the
  246. minimum and maximum range, and will be snapped to the
  247. nearest interval if one has been set
  248. @param sendUpdateMessage if false, a change to the value will not trigger a call to
  249. any SliderListeners or the valueChanged() method
  250. @param sendMessageSynchronously if true, then a call to the SliderListeners will be made
  251. synchronously; if false, it will be asynchronous
  252. */
  253. void setValue (double newValue,
  254. const bool sendUpdateMessage = true,
  255. const bool sendMessageSynchronously = false);
  256. /** Returns the slider's current value. */
  257. double getValue() const throw();
  258. //==============================================================================
  259. /** Sets the limits that the slider's value can take.
  260. @param newMinimum the lowest value allowed
  261. @param newMaximum the highest value allowed
  262. @param newInterval the steps in which the value is allowed to increase - if this
  263. is not zero, the value will always be (newMinimum + (newInterval * an integer)).
  264. */
  265. void setRange (const double newMinimum,
  266. const double newMaximum,
  267. const double newInterval = 0);
  268. /** Returns the current maximum value.
  269. @see setRange
  270. */
  271. double getMaximum() const throw() { return maximum; }
  272. /** Returns the current minimum value.
  273. @see setRange
  274. */
  275. double getMinimum() const throw() { return minimum; }
  276. /** Returns the current step-size for values.
  277. @see setRange
  278. */
  279. double getInterval() const throw() { return interval; }
  280. //==============================================================================
  281. /** For a slider with two or three thumbs, this returns the lower of its values.
  282. For a two-value slider, the values are controlled with getMinValue() and getMaxValue().
  283. A slider with three values also uses the normal getValue() and setValue() methods to
  284. control the middle value.
  285. @see setMinValue, getMaxValue, TwoValueHorizontal, TwoValueVertical, ThreeValueHorizontal, ThreeValueVertical
  286. */
  287. double getMinValue() const throw();
  288. /** For a slider with two or three thumbs, this sets the lower of its values.
  289. This will trigger a callback to SliderListener::sliderValueChanged() for any listeners
  290. that are registered, and will synchronously call the valueChanged() method in case subclasses
  291. want to handle it.
  292. @param newValue the new value to set - this will be restricted by the
  293. minimum and maximum range, and the max value (in a two-value
  294. slider) or the mid value (in a three-value slider), and
  295. will be snapped to the nearest interval if one has been set.
  296. @param sendUpdateMessage if false, a change to the value will not trigger a call to
  297. any SliderListeners or the valueChanged() method
  298. @param sendMessageSynchronously if true, then a call to the SliderListeners will be made
  299. synchronously; if false, it will be asynchronous
  300. @see getMinValue, setMaxValue, setValue
  301. */
  302. void setMinValue (double newValue,
  303. const bool sendUpdateMessage = true,
  304. const bool sendMessageSynchronously = false);
  305. /** For a slider with two or three thumbs, this returns the higher of its values.
  306. For a two-value slider, the values are controlled with getMinValue() and getMaxValue().
  307. A slider with three values also uses the normal getValue() and setValue() methods to
  308. control the middle value.
  309. @see getMinValue, TwoValueHorizontal, TwoValueVertical, ThreeValueHorizontal, ThreeValueVertical
  310. */
  311. double getMaxValue() const throw();
  312. /** For a slider with two or three thumbs, this sets the lower of its values.
  313. This will trigger a callback to SliderListener::sliderValueChanged() for any listeners
  314. that are registered, and will synchronously call the valueChanged() method in case subclasses
  315. want to handle it.
  316. @param newValue the new value to set - this will be restricted by the
  317. minimum and maximum range, and the max value (in a two-value
  318. slider) or the mid value (in a three-value slider), and
  319. will be snapped to the nearest interval if one has been set.
  320. @param sendUpdateMessage if false, a change to the value will not trigger a call to
  321. any SliderListeners or the valueChanged() method
  322. @param sendMessageSynchronously if true, then a call to the SliderListeners will be made
  323. synchronously; if false, it will be asynchronous
  324. @see getMaxValue, setMinValue, setValue
  325. */
  326. void setMaxValue (double newValue,
  327. const bool sendUpdateMessage = true,
  328. const bool sendMessageSynchronously = false);
  329. //==============================================================================
  330. /** Adds a listener to be called when this slider's value changes. */
  331. void addListener (SliderListener* const listener) throw();
  332. /** Removes a previously-registered listener. */
  333. void removeListener (SliderListener* const listener) throw();
  334. //==============================================================================
  335. /** This lets you choose whether double-clicking moves the slider to a given position.
  336. By default this is turned off, but it's handy if you want a double-click to act
  337. as a quick way of resetting a slider. Just pass in the value you want it to
  338. go to when double-clicked.
  339. @see getDoubleClickReturnValue
  340. */
  341. void setDoubleClickReturnValue (const bool isDoubleClickEnabled,
  342. const double valueToSetOnDoubleClick) throw();
  343. /** Returns the values last set by setDoubleClickReturnValue() method.
  344. Sets isEnabled to true if double-click is enabled, and returns the value
  345. that was set.
  346. @see setDoubleClickReturnValue
  347. */
  348. double getDoubleClickReturnValue (bool& isEnabled) const throw();
  349. //==============================================================================
  350. /** Tells the slider whether to keep sending change messages while the user
  351. is dragging the slider.
  352. If set to true, a change message will only be sent when the user has
  353. dragged the slider and let go. If set to false (the default), then messages
  354. will be continuously sent as they drag it while the mouse button is still
  355. held down.
  356. */
  357. void setChangeNotificationOnlyOnRelease (const bool onlyNotifyOnRelease) throw();
  358. /** If enabled, this gives the slider a pop-up bubble which appears while the
  359. slider is being dragged.
  360. This can be handy if your slider doesn't have a text-box, so that users can
  361. see the value just when they're changing it.
  362. If you pass a component as the parentComponentToUse parameter, the pop-up
  363. bubble will be added as a child of that component when it's needed. If you
  364. pass 0, the pop-up will be placed on the desktop instead (note that it's a
  365. transparent window, so if you're using an OS that can't do transparent windows
  366. you'll have to add it to a parent component instead).
  367. */
  368. void setPopupDisplayEnabled (const bool isEnabled,
  369. Component* const parentComponentToUse) throw();
  370. /** If this is set to true, then right-clicking on the slider will pop-up
  371. a menu to let the user change the way it works.
  372. By default this is turned off, but when turned on, the menu will include
  373. things like velocity sensitivity, and for rotary sliders, whether they
  374. use a linear or rotary mouse-drag to move them.
  375. */
  376. void setPopupMenuEnabled (const bool menuEnabled) throw();
  377. /** This can be used to stop the mouse scroll-wheel from moving the slider.
  378. By default it's enabled.
  379. */
  380. void setScrollWheelEnabled (const bool enabled) throw();
  381. //==============================================================================
  382. /** Callback to indicate that the user is about to start dragging the slider.
  383. @see SliderListener::sliderDragStarted
  384. */
  385. virtual void startedDragging();
  386. /** Callback to indicate that the user has just stopped dragging the slider.
  387. @see SliderListener::sliderDragEnded
  388. */
  389. virtual void stoppedDragging();
  390. /** Callback to indicate that the user has just moved the slider.
  391. @see SliderListener::sliderValueChanged
  392. */
  393. virtual void valueChanged();
  394. /** Callback to indicate that the user has just moved the slider.
  395. Note - the valueChanged() method has changed its format and now no longer has
  396. any parameters. Update your code to use the new version.
  397. This version has been left here with an int as its return value to cause
  398. a syntax error if you've got existing code that uses the old version.
  399. */
  400. virtual int valueChanged (double) { jassertfalse; return 0; }
  401. //==============================================================================
  402. /** Subclasses can override this to convert a text string to a value.
  403. When the user enters something into the text-entry box, this method is
  404. called to convert it to a value.
  405. The default routine just tries to convert it to a double.
  406. @see getTextFromValue
  407. */
  408. virtual double getValueFromText (const String& text);
  409. /** Turns the slider's current value into a text string.
  410. Subclasses can override this to customise the formatting of the text-entry box.
  411. The default implementation just turns the value into a string, using
  412. a number of decimal places based on the range interval. If a suffix string
  413. has been set using setTextValueSuffix(), this will be appended to the text.
  414. @see getValueFromText
  415. */
  416. virtual const String getTextFromValue (double value);
  417. /** Sets a suffix to append to the end of the numeric value when it's displayed as
  418. a string.
  419. This is used by the default implementation of getTextFromValue(), and is just
  420. appended to the numeric value. For more advanced formatting, you can override
  421. getTextFromValue() and do something else.
  422. */
  423. void setTextValueSuffix (const String& suffix);
  424. //==============================================================================
  425. /** Allows a user-defined mapping of distance along the slider to its value.
  426. The default implementation for this performs the skewing operation that
  427. can be set up in the setSkewFactor() method. Override it if you need
  428. some kind of custom mapping instead, but make sure you also implement the
  429. inverse function in valueToProportionOfLength().
  430. @param proportion a value 0 to 1.0, indicating a distance along the slider
  431. @returns the slider value that is represented by this position
  432. @see valueToProportionOfLength
  433. */
  434. virtual double proportionOfLengthToValue (double proportion);
  435. /** Allows a user-defined mapping of value to the position of the slider along its length.
  436. The default implementation for this performs the skewing operation that
  437. can be set up in the setSkewFactor() method. Override it if you need
  438. some kind of custom mapping instead, but make sure you also implement the
  439. inverse function in proportionOfLengthToValue().
  440. @param value a valid slider value, between the range of values specified in
  441. setRange()
  442. @returns a value 0 to 1.0 indicating the distance along the slider that
  443. represents this value
  444. @see proportionOfLengthToValue
  445. */
  446. virtual double valueToProportionOfLength (double value);
  447. /** Returns the X or Y coordinate of a value along the slider's length.
  448. If the slider is horizontal, this will be the X coordinate of the given
  449. value, relative to the left of the slider. If it's vertical, then this will
  450. be the Y coordinate, relative to the top of the slider.
  451. If the slider is rotary, this will throw an assertion and return 0. If the
  452. value is out-of-range, it will be constrained to the length of the slider.
  453. */
  454. float getPositionOfValue (const double value);
  455. //==============================================================================
  456. /** This can be overridden to allow the slider to snap to user-definable values.
  457. If overridden, it will be called when the user tries to move the slider to
  458. a given position, and allows a subclass to sanity-check this value, possibly
  459. returning a different value to use instead.
  460. @param attemptedValue the value the user is trying to enter
  461. @param userIsDragging true if the user is dragging with the mouse; false if
  462. they are entering the value using the text box
  463. @returns the value to use instead
  464. */
  465. virtual double snapValue (double attemptedValue, const bool userIsDragging);
  466. //==============================================================================
  467. /** This can be called to force the text box to update its contents.
  468. (Not normally needed, as this is done automatically).
  469. */
  470. void updateText();
  471. /** True if the slider moves horizontally. */
  472. bool isHorizontal() const throw();
  473. /** True if the slider moves vertically. */
  474. bool isVertical() const throw();
  475. //==============================================================================
  476. /** A set of colour IDs to use to change the colour of various aspects of the slider.
  477. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  478. methods.
  479. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  480. */
  481. enum ColourIds
  482. {
  483. backgroundColourId = 0x1001200, /**< A colour to use to fill the slider's background. */
  484. thumbColourId = 0x1001300, /**< The colour to draw the thumb with. It's up to the look
  485. and feel class how this is used. */
  486. trackColourId = 0x1001310, /**< The colour to draw the groove that the thumb moves along. */
  487. rotarySliderFillColourId = 0x1001311, /**< For rotary sliders, this colour fills the outer curve. */
  488. rotarySliderOutlineColourId = 0x1001312, /**< For rotary sliders, this colour is used to draw the outer curve's outline. */
  489. textBoxTextColourId = 0x1001400, /**< The colour for the text in the text-editor box used for editing the value. */
  490. textBoxBackgroundColourId = 0x1001500, /**< The background colour for the text-editor box. */
  491. textBoxHighlightColourId = 0x1001600, /**< The text highlight colour for the text-editor box. */
  492. textBoxOutlineColourId = 0x1001700 /**< The colour to use for a border around the text-editor box. */
  493. };
  494. //==============================================================================
  495. juce_UseDebuggingNewOperator
  496. protected:
  497. /** @internal */
  498. void labelTextChanged (Label*);
  499. /** @internal */
  500. void paint (Graphics& g);
  501. /** @internal */
  502. void resized();
  503. /** @internal */
  504. void mouseDown (const MouseEvent& e);
  505. /** @internal */
  506. void mouseUp (const MouseEvent& e);
  507. /** @internal */
  508. void mouseDrag (const MouseEvent& e);
  509. /** @internal */
  510. void mouseDoubleClick (const MouseEvent& e);
  511. /** @internal */
  512. void mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY);
  513. /** @internal */
  514. void modifierKeysChanged (const ModifierKeys& modifiers);
  515. /** @internal */
  516. void buttonClicked (Button* button);
  517. /** @internal */
  518. void lookAndFeelChanged();
  519. /** @internal */
  520. void enablementChanged();
  521. /** @internal */
  522. void focusOfChildComponentChanged (FocusChangeType cause);
  523. /** @internal */
  524. void handleAsyncUpdate();
  525. /** @internal */
  526. void colourChanged();
  527. private:
  528. SortedSet <void*> listeners;
  529. double currentValue, valueMin, valueMax;
  530. double minimum, maximum, interval, doubleClickReturnValue;
  531. double valueWhenLastDragged, valueOnMouseDown, skewFactor, lastAngle;
  532. double velocityModeSensitivity, velocityModeOffset, minMaxDiff;
  533. int velocityModeThreshold;
  534. float rotaryStart, rotaryEnd;
  535. int numDecimalPlaces, mouseXWhenLastDragged, mouseYWhenLastDragged;
  536. int sliderRegionStart, sliderRegionSize;
  537. int sliderBeingDragged;
  538. int pixelsForFullDragExtent;
  539. Rectangle sliderRect;
  540. String textSuffix;
  541. SliderStyle style;
  542. TextEntryBoxPosition textBoxPos;
  543. int textBoxWidth, textBoxHeight;
  544. IncDecButtonMode incDecButtonMode;
  545. bool editableText : 1, doubleClickToValue : 1;
  546. bool isVelocityBased : 1, rotaryStop : 1, incDecButtonsSideBySide : 1;
  547. bool sendChangeOnlyOnRelease : 1, popupDisplayEnabled : 1;
  548. bool menuEnabled : 1, menuShown : 1, mouseWasHidden : 1, incDecDragged : 1, scrollWheelEnabled : 1;
  549. Font font;
  550. Label* valueBox;
  551. Button* incButton;
  552. Button* decButton;
  553. Component* popupDisplay;
  554. Component* parentForPopupDisplay;
  555. float getLinearSliderPos (const double value);
  556. void restoreMouseIfHidden();
  557. void sendDragStart();
  558. void sendDragEnd();
  559. double constrainedValue (double value) const throw();
  560. void triggerChangeMessage (const bool synchronous);
  561. bool incDecDragDirectionIsHorizontal() const throw();
  562. Slider (const Slider&);
  563. const Slider& operator= (const Slider&);
  564. };
  565. #endif // __JUCE_SLIDER_JUCEHEADER__