LMMS
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//==============================================================================
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,
107
120 void setRangeLimits (double minimum, double maximum,
122
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,
158
174 void setCurrentRange (double newStart, double newSize,
176
188 void setCurrentRangeStart (double newStart,
190
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
218
233 bool moveScrollbarInSteps (int howManySteps,
235
250 bool moveScrollbarInPages (int howManyPages,
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 //==============================================================================
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 //==============================================================================
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;
417
418private:
419 //==============================================================================
420 Range<double> totalRange { 0.0, 1.0 }, visibleRange { 0.0, 1.0 };
425 bool vertical, isDraggingThumb = false, autohides = true, userVisibilityFlag = false;
426 class ScrollbarButton;
427 std::unique_ptr<ScrollbarButton> upButton, downButton;
429
430 std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override;
431 void handleAsyncUpdate() override;
432 void updateThumbPosition();
433 void timerCallback() override;
435
437};
438
439
440} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
AsyncUpdater()
Definition juce_AsyncUpdater.cpp:44
Component() noexcept
Definition juce_Component.cpp:517
bool isMouseOver(bool includeChildren=false) const
Definition juce_Component.cpp:3159
Definition juce_GraphicsContext.h:45
Definition juce_ImageEffectFilter.h:43
Definition juce_KeyPress.h:40
Definition juce_ListenerList.h:70
Definition juce_MouseEvent.h:39
Definition juce_Range.h:40
Definition juce_ScrollBar.h:309
virtual void scrollBarMoved(ScrollBar *scrollBarThatHasMoved, double newRangeStart)=0
virtual ~Listener()=default
Definition juce_ScrollBar.cpp:30
Range< double > visibleRange
Definition juce_ScrollBar.h:420
int lastMousePos
Definition juce_ScrollBar.h:423
void removeListener(Listener *listener)
Definition juce_ScrollBar.cpp:168
int thumbSize
Definition juce_ScrollBar.h:422
double getSingleStepSize() const noexcept
Definition juce_ScrollBar.h:217
void parentHierarchyChanged() override
Definition juce_ScrollBar.cpp:329
Range< double > getRangeLimit() const noexcept
Definition juce_ScrollBar.h:126
void addListener(Listener *listener)
Definition juce_ScrollBar.cpp:163
void updateThumbPosition()
Definition juce_ScrollBar.cpp:180
ScrollBar(bool isVertical)
Definition juce_ScrollBar.cpp:61
void handleAsyncUpdate() override
Definition juce_ScrollBar.cpp:173
bool userVisibilityFlag
Definition juce_ScrollBar.h:425
bool autohides
Definition juce_ScrollBar.h:425
void mouseDown(const MouseEvent &) override
Definition juce_ScrollBar.cpp:334
bool isDraggingThumb
Definition juce_ScrollBar.h:425
double getCurrentRangeStart() const noexcept
Definition juce_ScrollBar.h:199
int dragStartMousePos
Definition juce_ScrollBar.h:423
void mouseUp(const MouseEvent &) override
Definition juce_ScrollBar.cpp:374
ListenerList< Listener > listeners
Definition juce_ScrollBar.h:428
int thumbAreaStart
Definition juce_ScrollBar.h:422
bool isVertical() const noexcept
Definition juce_ScrollBar.h:67
ColourIds
Definition juce_ScrollBar.h:293
@ thumbColourId
Definition juce_ScrollBar.h:295
@ trackColourId
Definition juce_ScrollBar.h:296
@ backgroundColourId
Definition juce_ScrollBar.h:294
std::unique_ptr< ScrollbarButton > downButton
Definition juce_ScrollBar.h:427
double singleStepSize
Definition juce_ScrollBar.h:421
bool keyPressed(const KeyPress &) override
Definition juce_ScrollBar.cpp:410
double getCurrentRangeSize() const noexcept
Definition juce_ScrollBar.h:204
int thumbAreaSize
Definition juce_ScrollBar.h:422
std::unique_ptr< AccessibilityHandler > createAccessibilityHandler() override
Definition juce_ScrollBar.cpp:444
bool getVisibility() const noexcept
Definition juce_ScrollBar.cpp:434
int minimumDelayInMillisecs
Definition juce_ScrollBar.h:424
void setVisible(bool) override
Definition juce_ScrollBar.cpp:425
int initialDelayInMillisecs
Definition juce_ScrollBar.h:424
Range< double > totalRange
Definition juce_ScrollBar.h:420
void lookAndFeelChanged() override
Definition juce_ScrollBar.cpp:262
bool vertical
Definition juce_ScrollBar.h:425
Range< double > getCurrentRange() const noexcept
Definition juce_ScrollBar.h:194
void resized() override
Definition juce_ScrollBar.cpp:270
double getMaximumRangeLimit() const noexcept
Definition juce_ScrollBar.h:138
double dragStartRange
Definition juce_ScrollBar.h:421
void mouseWheelMove(const MouseEvent &, const MouseWheelDetails &) override
Definition juce_ScrollBar.cpp:381
void paint(Graphics &) override
Definition juce_ScrollBar.cpp:244
void mouseDrag(const MouseEvent &) override
Definition juce_ScrollBar.cpp:358
void timerCallback() override
Definition juce_ScrollBar.cpp:393
std::unique_ptr< ScrollbarButton > upButton
Definition juce_ScrollBar.h:427
int thumbStart
Definition juce_ScrollBar.h:422
int repeatDelayInMillisecs
Definition juce_ScrollBar.h:424
double getMinimumRangeLimit() const noexcept
Definition juce_ScrollBar.h:132
Timer() noexcept
Definition juce_Timer.cpp:316
int y
Definition inflate.c:1588
int g
Definition inflate.c:1573
unsigned x[BMAX+1]
Definition inflate.c:1586
static int int height
Definition pugl.h:1594
static int width
Definition pugl.h:1593
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
NotificationType
Definition juce_NotificationType.h:32
@ sendNotificationAsync
Definition juce_NotificationType.h:36
Definition juce_MouseEvent.h:392
Definition juce_ScrollBar.h:334
virtual void drawScrollbarButton(Graphics &g, ScrollBar &scrollbar, int width, int height, int buttonDirection, bool isScrollbarVertical, bool isMouseOverButton, bool isButtonDown)=0
virtual int getScrollbarButtonSize(ScrollBar &)=0
virtual int getMinimumScrollbarThumbSize(ScrollBar &)=0
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
virtual ImageEffectFilter * getScrollbarEffect()=0
virtual bool areScrollbarButtonsVisible()=0
#define const
Definition zconf.h:137