LMMS
Loading...
Searching...
No Matches
juce_Viewport.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//==============================================================================
45 private ComponentListener,
47{
48public:
49 //==============================================================================
55 explicit Viewport (const String& componentName = String());
56
58 ~Viewport() override;
59
60 //==============================================================================
76 void setViewedComponent (Component* newViewedComponent,
77 bool deleteComponentWhenNoLongerNeeded = true);
78
84
85 //==============================================================================
96 void setViewPosition (int xPixelsOffset, int yPixelsOffset);
97
108 void setViewPosition (Point<int> newPosition);
109
117 void setViewPositionProportionately (double proportionX, double proportionY);
118
134 bool autoScroll (int mouseX, int mouseY, int distanceFromEdge, int maximumSpeed);
135
138
141
146
151
157 int getViewWidth() const noexcept { return lastVisibleArea.getWidth(); }
158
164 int getViewHeight() const noexcept { return lastVisibleArea.getHeight(); }
165
171 int getMaximumVisibleWidth() const;
172
178 int getMaximumVisibleHeight() const;
179
180 //==============================================================================
186 virtual void visibleAreaChanged (const Rectangle<int>& newVisibleArea);
187
189 virtual void viewedComponentChanged (Component* newComponent);
190
191 //==============================================================================
201 void setScrollBarsShown (bool showVerticalScrollbarIfNeeded,
202 bool showHorizontalScrollbarIfNeeded,
203 bool allowVerticalScrollingWithoutScrollbar = false,
204 bool allowHorizontalScrollingWithoutScrollbar = false);
205
216 void setScrollBarPosition (bool verticalScrollbarOnRight,
217 bool horizontalScrollbarAtBottom);
218
221
224
229
234
239 void setScrollBarThickness (int thickness);
240
244 int getScrollBarThickness() const;
245
249 void setSingleStepSizes (int stepX, int stepY);
250
255
260
262 void recreateScrollbars();
263
267 bool canScrollVertically() const noexcept;
268
272 bool canScrollHorizontally() const noexcept;
273
280 [[deprecated ("Use setScrollOnDragMode instead.")]]
281 void setScrollOnDragEnabled (bool shouldScrollOnDrag)
282 {
284 }
285
287 [[deprecated ("Use getScrollOnDragMode instead.")]]
289
291 {
293 nonHover,
294 all
295 };
296
303 void setScrollOnDragMode (ScrollOnDragMode scrollOnDragMode);
304
307
311 bool isCurrentlyScrollingOnDrag() const noexcept;
312
313 //==============================================================================
315 void resized() override;
317 void scrollBarMoved (ScrollBar*, double newRangeStart) override;
319 void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) override;
321 void mouseDown (const MouseEvent& e) override;
323 bool keyPressed (const KeyPress&) override;
325 void componentMovedOrResized (Component&, bool wasMoved, bool wasResized) override;
327 void lookAndFeelChanged() override;
329 bool useMouseWheelMoveIfNeeded (const MouseEvent&, const MouseWheelDetails&);
331 static bool respondsToKey (const KeyPress&);
332
333protected:
334 //==============================================================================
338 virtual ScrollBar* createScrollBarComponent (bool isVertical);
339
340private:
341 //==============================================================================
343 {
344 std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override
345 {
347 }
348 };
349
350 std::unique_ptr<ScrollBar> verticalScrollBar, horizontalScrollBar;
355 int singleStepX = 16, singleStepY = 16;
357 bool showHScrollbar = true, showVScrollbar = true, deleteContent = true;
361
363 std::unique_ptr<DragToScrollListener> dragToScrollListener;
364
366
367 void updateVisibleArea();
369
371};
372
373} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
#define override
Definition DistrhoDefines.h:73
Definition juce_Component.h:36
String componentName
Definition juce_Component.h:2534
Component() noexcept
Definition juce_Component.cpp:517
static std::unique_ptr< AccessibilityHandler > createIgnoredAccessibilityHandler(Component &)
Definition juce_Component.cpp:3292
Definition juce_ComponentListener.h:43
Definition juce_KeyPress.h:40
Definition juce_MouseEvent.h:39
Definition juce_Point.h:42
Definition juce_Rectangle.h:67
Definition juce_ScrollBar.h:309
Definition juce_ScrollBar.h:54
Definition juce_String.h:53
Definition juce_Viewport.h:343
std::unique_ptr< AccessibilityHandler > createAccessibilityHandler() override
Definition juce_Viewport.h:344
int singleStepY
Definition juce_Viewport.h:355
bool isHorizontalScrollbarAtBottom() const noexcept
Definition juce_Viewport.h:223
void setScrollOnDragEnabled(bool shouldScrollOnDrag)
Definition juce_Viewport.h:281
std::unique_ptr< ScrollBar > horizontalScrollBar
Definition juce_Viewport.h:350
bool showHScrollbar
Definition juce_Viewport.h:357
int getViewWidth() const noexcept
Definition juce_Viewport.h:157
AccessibilityIgnoredComponent contentHolder
Definition juce_Viewport.h:351
Component * getViewedComponent() const noexcept
Definition juce_Viewport.h:83
bool allowScrollingWithoutScrollbarV
Definition juce_Viewport.h:359
bool isVerticalScrollbarOnTheRight() const noexcept
Definition juce_Viewport.h:220
int getViewPositionX() const noexcept
Definition juce_Viewport.h:145
ScrollBar & getVerticalScrollBar() noexcept
Definition juce_Viewport.h:254
ScrollOnDragMode
Definition juce_Viewport.h:291
@ nonHover
Definition juce_Viewport.h:293
@ all
Definition juce_Viewport.h:294
@ never
Definition juce_Viewport.h:292
void setScrollOnDragMode(ScrollOnDragMode scrollOnDragMode)
Definition juce_Viewport.cpp:332
bool allowScrollingWithoutScrollbarH
Definition juce_Viewport.h:359
ScrollOnDragMode getScrollOnDragMode() const
Definition juce_Viewport.h:306
std::unique_ptr< ScrollBar > verticalScrollBar
Definition juce_Viewport.h:350
bool showVScrollbar
Definition juce_Viewport.h:357
Point< int > getViewPosition() const noexcept
Definition juce_Viewport.h:137
bool hScrollbarBottom
Definition juce_Viewport.h:360
int scrollBarThickness
Definition juce_Viewport.h:354
ScrollOnDragMode scrollOnDragMode
Definition juce_Viewport.h:356
int getViewHeight() const noexcept
Definition juce_Viewport.h:164
ScrollBar & getHorizontalScrollBar() noexcept
Definition juce_Viewport.h:259
Point< int > viewportPosToCompPos(Point< int >) const
Definition juce_Viewport.cpp:252
void deleteOrRemoveContentComp()
Definition juce_Viewport.cpp:186
bool isHorizontalScrollBarShown() const noexcept
Definition juce_Viewport.h:233
int singleStepX
Definition juce_Viewport.h:355
Rectangle< int > getViewArea() const noexcept
Definition juce_Viewport.h:140
bool vScrollbarRight
Definition juce_Viewport.h:360
int getViewPositionY() const noexcept
Definition juce_Viewport.h:150
bool deleteContent
Definition juce_Viewport.h:357
void updateVisibleArea()
Definition juce_Viewport.cpp:358
Rectangle< int > lastVisibleArea
Definition juce_Viewport.h:353
std::unique_ptr< DragToScrollListener > dragToScrollListener
Definition juce_Viewport.h:363
Viewport(const String &componentName=String())
Definition juce_Viewport.cpp:160
void setViewedComponent(Component *newViewedComponent, bool deleteComponentWhenNoLongerNeeded=true)
Definition juce_Viewport.cpp:207
bool customScrollBarThickness
Definition juce_Viewport.h:358
WeakReference< Component > contentComp
Definition juce_Viewport.h:352
bool isVerticalScrollBarShown() const noexcept
Definition juce_Viewport.h:228
bool isScrollOnDragEnabled() const noexcept
Definition juce_Viewport.h:288
Definition juce_WeakReference.h:78
* e
Definition inflate.c:1404
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
#define never
Definition seq2midi.cpp:41
Definition juce_MouseEvent.h:392
Definition juce_Viewport.cpp:48
#define const
Definition zconf.h:137