openshot-audio  0.1.2
juce_ScrollBar.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_SCROLLBAR_H_INCLUDED
26 #define JUCE_SCROLLBAR_H_INCLUDED
27 
28 
29 //==============================================================================
49 class JUCE_API ScrollBar : public Component,
50  public AsyncUpdater,
51  private Timer
52 {
53 public:
54  //==============================================================================
58  ScrollBar (bool isVertical);
59 
61  ~ScrollBar();
62 
63  //==============================================================================
65  bool isVertical() const noexcept { return vertical; }
66 
74  void setOrientation (bool shouldBeVertical);
75 
83  void setAutoHide (bool shouldHideWhenFullRange);
84 
89  bool autoHides() const noexcept;
90 
91  //==============================================================================
99  void setRangeLimits (Range<double> newRangeLimit,
100  NotificationType notification = sendNotificationAsync);
101 
109  void setRangeLimits (double minimum, double maximum,
110  NotificationType notification = sendNotificationAsync);
111 
115  Range<double> getRangeLimit() const noexcept { return totalRange; }
116 
121  double getMinimumRangeLimit() const noexcept { return totalRange.getStart(); }
122 
127  double getMaximumRangeLimit() const noexcept { return totalRange.getEnd(); }
128 
129  //==============================================================================
145  bool setCurrentRange (Range<double> newRange,
146  NotificationType notification = sendNotificationAsync);
147 
163  void setCurrentRange (double newStart, double newSize,
164  NotificationType notification = sendNotificationAsync);
165 
177  void setCurrentRangeStart (double newStart,
178  NotificationType notification = sendNotificationAsync);
179 
183  Range<double> getCurrentRange() const noexcept { return visibleRange; }
184 
188  double getCurrentRangeStart() const noexcept { return visibleRange.getStart(); }
189 
193  double getCurrentRangeSize() const noexcept { return visibleRange.getLength(); }
194 
195  //==============================================================================
201  void setSingleStepSize (double newSingleStepSize) noexcept;
202 
212  bool moveScrollbarInSteps (int howManySteps,
213  NotificationType notification = sendNotificationAsync);
214 
224  bool moveScrollbarInPages (int howManyPages,
225  NotificationType notification = sendNotificationAsync);
226 
231  bool scrollToTop (NotificationType notification = sendNotificationAsync);
232 
237  bool scrollToBottom (NotificationType notification = sendNotificationAsync);
238 
246  void setButtonRepeatSpeed (int initialDelayInMillisecs,
247  int repeatDelayInMillisecs,
248  int minimumDelayInMillisecs = -1);
249 
250  //==============================================================================
259  {
260  backgroundColourId = 0x1000300,
261  thumbColourId = 0x1000400,
262  trackColourId = 0x1000401
263  };
264 
265  //==============================================================================
275  {
276  public:
278  virtual ~Listener() {}
279 
285  virtual void scrollBarMoved (ScrollBar* scrollBarThatHasMoved,
286  double newRangeStart) = 0;
287  };
288 
290  void addListener (Listener* listener);
291 
293  void removeListener (Listener* listener);
294 
295  //==============================================================================
300  {
301  virtual ~LookAndFeelMethods() {}
302 
303  virtual bool areScrollbarButtonsVisible() = 0;
304 
316  virtual void drawScrollbarButton (Graphics& g,
317  ScrollBar& scrollbar,
318  int width, int height,
319  int buttonDirection,
320  bool isScrollbarVertical,
321  bool isMouseOverButton,
322  bool isButtonDown) = 0;
323 
341  virtual void drawScrollbar (Graphics& g, ScrollBar& scrollbar,
342  int x, int y, int width, int height,
343  bool isScrollbarVertical,
344  int thumbStartPosition,
345  int thumbSize,
346  bool isMouseOver,
347  bool isMouseDown) = 0;
348 
350  virtual ImageEffectFilter* getScrollbarEffect() = 0;
351 
353  virtual int getMinimumScrollbarThumbSize (ScrollBar&) = 0;
354 
356  virtual int getDefaultScrollbarWidth() = 0;
357 
359  virtual int getScrollbarButtonSize (ScrollBar&) = 0;
360  };
361 
362  //==============================================================================
364  bool keyPressed (const KeyPress&) override;
366  void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) override;
368  void lookAndFeelChanged() override;
370  void mouseDown (const MouseEvent&) override;
372  void mouseDrag (const MouseEvent&) override;
374  void mouseUp (const MouseEvent&) override;
376  void paint (Graphics&) override;
378  void resized() override;
380  void parentHierarchyChanged() override;
381 
382 private:
383  //==============================================================================
384  Range <double> totalRange, visibleRange;
385  double singleStepSize, dragStartRange;
386  int thumbAreaStart, thumbAreaSize, thumbStart, thumbSize;
387  int minimumScrollBarThumbSize;
388  int dragStartMousePos, lastMousePos;
389  int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs;
390  bool vertical, isDraggingThumb, autohides;
392  friend struct ContainerDeletePolicy<ScrollbarButton>;
393  ScopedPointer<ScrollbarButton> upButton, downButton;
394  ListenerList<Listener> listeners;
395 
396  void handleAsyncUpdate() override;
397  void updateThumbPosition();
398  void timerCallback() override;
399 
401 };
402 
405 
406 
407 #endif // JUCE_SCROLLBAR_H_INCLUDED
ColourIds
Definition: juce_ScrollBar.h:258
virtual ~LookAndFeelMethods()
Definition: juce_ScrollBar.h:301
double getMinimumRangeLimit() const noexcept
Definition: juce_ScrollBar.h:121
Definition: juce_KeyPress.h:37
double getCurrentRangeStart() const noexcept
Definition: juce_ScrollBar.h:188
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_NotificationType.h:38
Definition: juce_ScrollBar.h:49
Range< double > getRangeLimit() const noexcept
Definition: juce_ScrollBar.h:115
Definition: juce_Range.h:44
#define JUCE_API
Definition: juce_StandardHeader.h:139
#define const
Definition: juce_AsyncUpdater.h:39
NotificationType
Definition: juce_NotificationType.h:33
bool isVertical() const noexcept
Definition: juce_ScrollBar.h:65
ScrollBar::Listener ScrollBarListener
Definition: juce_ScrollBar.h:404
Definition: juce_ListenerList.h:69
Range< double > getCurrentRange() const noexcept
Definition: juce_ScrollBar.h:183
Definition: juce_Component.h:33
double getMaximumRangeLimit() const noexcept
Definition: juce_ScrollBar.h:127
Definition: juce_ScopedPointer.h:70
Definition: juce_MouseEvent.h:329
png_const_structrp png_const_inforp int png_fixed_point * width
Definition: juce_PNGLoader.cpp:2339
Definition: juce_ContainerDeletePolicy.h:44
Definition: juce_ScrollBar.h:299
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
double getCurrentRangeSize() const noexcept
Definition: juce_ScrollBar.h:193
Definition: juce_GraphicsContext.h:42
Definition: juce_ScrollBar.cpp:25
Definition: juce_ScrollBar.h:274
virtual ~Listener()
Definition: juce_ScrollBar.h:278
Definition: juce_Timer.h:52
Definition: juce_MouseEvent.h:36
Definition: juce_ImageEffectFilter.h:40