JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
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) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
51class JUCE_API ScrollBar : public Component,
52 public AsyncUpdater,
53 private Timer
54{
55public:
56 //==============================================================================
60 ScrollBar (bool isVertical);
61
63 ~ScrollBar() override;
64
65 //==============================================================================
67 bool isVertical() const noexcept { return vertical; }
68
76 void setOrientation (bool shouldBeVertical);
77
85 void setAutoHide (bool shouldHideWhenFullRange);
86
91 bool autoHides() const noexcept;
92
93 //==============================================================================
105 void setRangeLimits (Range<double> newRangeLimit,
106 NotificationType notification = sendNotificationAsync);
107
120 void setRangeLimits (double minimum, double maximum,
121 NotificationType notification = sendNotificationAsync);
122
126 Range<double> getRangeLimit() const noexcept { return totalRange; }
127
132 double getMinimumRangeLimit() const noexcept { return totalRange.getStart(); }
133
138 double getMaximumRangeLimit() const noexcept { return totalRange.getEnd(); }
139
140 //==============================================================================
156 bool setCurrentRange (Range<double> newRange,
157 NotificationType notification = sendNotificationAsync);
158
174 void setCurrentRange (double newStart, double newSize,
175 NotificationType notification = sendNotificationAsync);
176
188 void setCurrentRangeStart (double newStart,
189 NotificationType notification = sendNotificationAsync);
190
194 Range<double> getCurrentRange() const noexcept { return visibleRange; }
195
199 double getCurrentRangeStart() const noexcept { return visibleRange.getStart(); }
200
204 double getCurrentRangeSize() const noexcept { return visibleRange.getLength(); }
205
206 //==============================================================================
212 void setSingleStepSize (double newSingleStepSize) noexcept;
213
217 double getSingleStepSize() const noexcept { return singleStepSize; }
218
233 bool moveScrollbarInSteps (int howManySteps,
234 NotificationType notification = sendNotificationAsync);
235
250 bool moveScrollbarInPages (int howManyPages,
251 NotificationType notification = sendNotificationAsync);
252
261 bool scrollToTop (NotificationType notification = sendNotificationAsync);
262
271 bool scrollToBottom (NotificationType notification = sendNotificationAsync);
272
280 void setButtonRepeatSpeed (int initialDelayInMillisecs,
281 int repeatDelayInMillisecs,
282 int minimumDelayInMillisecs = -1);
283
284 //==============================================================================
293 {
294 backgroundColourId = 0x1000300,
295 thumbColourId = 0x1000400,
296 trackColourId = 0x1000401
297 };
298
299 //==============================================================================
308 class JUCE_API Listener
309 {
310 public:
312 virtual ~Listener() = default;
313
319 virtual void scrollBarMoved (ScrollBar* scrollBarThatHasMoved,
320 double newRangeStart) = 0;
321 };
322
324 void addListener (Listener* listener);
325
327 void removeListener (Listener* listener);
328
329 //==============================================================================
333 struct JUCE_API LookAndFeelMethods
334 {
335 virtual ~LookAndFeelMethods() = default;
336
337 virtual bool areScrollbarButtonsVisible() = 0;
338
351 ScrollBar& scrollbar,
352 int width, int height,
353 int buttonDirection,
354 bool isScrollbarVertical,
355 bool isMouseOverButton,
356 bool isButtonDown) = 0;
357
375 virtual void drawScrollbar (Graphics& g, ScrollBar& scrollbar,
376 int x, int y, int width, int height,
377 bool isScrollbarVertical,
378 int thumbStartPosition,
379 int thumbSize,
380 bool isMouseOver,
381 bool isMouseDown) = 0;
382
385
388
390 virtual int getDefaultScrollbarWidth() = 0;
391
394 };
395
396 //==============================================================================
398 bool keyPressed (const KeyPress&) override;
400 void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) override;
402 void lookAndFeelChanged() override;
404 void mouseDown (const MouseEvent&) override;
406 void mouseDrag (const MouseEvent&) override;
408 void mouseUp (const MouseEvent&) override;
410 void paint (Graphics&) override;
412 void resized() override;
414 void parentHierarchyChanged() override;
416 void setVisible (bool) override;
418 std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override;
419
420private:
421 //==============================================================================
422 Range<double> totalRange { 0.0, 1.0 }, visibleRange { 0.0, 1.0 };
423 double singleStepSize = 0.1, dragStartRange = 0;
424 int thumbAreaStart = 0, thumbAreaSize = 0, thumbStart = 0, thumbSize = 0;
425 int dragStartMousePos = 0, lastMousePos = 0;
426 int initialDelayInMillisecs = 100, repeatDelayInMillisecs = 50, minimumDelayInMillisecs = 10;
427 bool vertical, isDraggingThumb = false, autohides = true, userVisibilityFlag = false;
428 class ScrollbarButton;
429 std::unique_ptr<ScrollbarButton> upButton, downButton;
430 ListenerList<Listener> listeners;
431
432 void handleAsyncUpdate() override;
433 void updateThumbPosition();
434 void timerCallback() override;
435 bool getVisibility() const noexcept;
436
438};
439
440
441} // namespace juce
Has a callback method that is triggered asynchronously.
The base class for all JUCE user-interface objects.
A graphics context, used for drawing a component or image.
A graphical effect filter that can be applied to components.
Represents a key press, including any modifier keys that are needed.
Contains position and status information about a mouse event.
A general-purpose range object, that simply represents any linear range with a start and end point.
Definition juce_Range.h:40
A class for receiving events from a ScrollBar.
virtual void scrollBarMoved(ScrollBar *scrollBarThatHasMoved, double newRangeStart)=0
Called when a ScrollBar is moved.
virtual ~Listener()=default
Destructor.
A scrollbar component.
double getSingleStepSize() const noexcept
Returns the current step size.
double getCurrentRangeStart() const noexcept
Returns the position of the top of the thumb.
bool isVertical() const noexcept
Returns true if the scrollbar is vertical, false if it's horizontal.
ColourIds
A set of colour IDs to use to change the colour of various aspects of the component.
double getCurrentRangeSize() const noexcept
Returns the current size of the thumb.
Range< double > getCurrentRange() const noexcept
Returns the current thumb range.
double getMaximumRangeLimit() const noexcept
Returns the upper value that the thumb can be set to.
double getMinimumRangeLimit() const noexcept
Returns the lower value that the thumb can be set to.
Makes repeated callbacks to a virtual method at a specified time interval.
Definition juce_Timer.h:52
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
JUCE Namespace.
NotificationType
These enums are used in various classes to indicate whether a notification event should be sent out.
Contains status information about a mouse wheel event.
This abstract base class is implemented by LookAndFeel classes to provide scrollbar-drawing functiona...
virtual void drawScrollbarButton(Graphics &g, ScrollBar &scrollbar, int width, int height, int buttonDirection, bool isScrollbarVertical, bool isMouseOverButton, bool isButtonDown)=0
Draws one of the buttons on a scrollbar.
virtual int getScrollbarButtonSize(ScrollBar &)=0
Returns the length in pixels to use for a scrollbar button.
virtual int getMinimumScrollbarThumbSize(ScrollBar &)=0
Returns the minimum length in pixels to use for a scrollbar thumb.
virtual void drawScrollbar(Graphics &g, ScrollBar &scrollbar, int x, int y, int width, int height, bool isScrollbarVertical, int thumbStartPosition, int thumbSize, bool isMouseOver, bool isMouseDown)=0
Draws the thumb area of a scrollbar.
virtual ImageEffectFilter * getScrollbarEffect()=0
Returns the component effect to use for a scrollbar.
virtual int getDefaultScrollbarWidth()=0
Returns the default thickness to use for a scrollbar.