33 switch (vp->getScrollOnDragMode())
47 private ViewportDragPosition::Listener
51 viewport.contentHolder.addMouseListener (
this,
true);
54 offsetX.behaviour.setMinimumVelocity (60);
55 offsetY.behaviour.setMinimumVelocity (60);
60 viewport.contentHolder.removeMouseListener (
this);
85 viewport.contentHolder.removeMouseListener (
this);
99 auto totalOffset =
e.getEventRelativeTo (&
viewport).getOffsetFromDragStart().toFloat();
128 if (std::exchange (
isDragging,
false) ==
true)
134 viewport.contentHolder.addMouseListener (
this,
true);
142 for (
auto c = eventComp;
c !=
nullptr &&
c != &
viewport;
c =
c->getParentComponent())
143 if (
c->getViewportIgnoreDragFlag())
196 std::unique_ptr<Component> oldCompDeleter (
contentComp.get());
261 return p.transformedBy (
contentComp->getTransform().inverted());
282bool Viewport::autoScroll (
const int mouseX,
const int mouseY,
const int activeBorderThickness,
const int maximumSpeed)
290 if (mouseX < activeBorderThickness)
291 dx = activeBorderThickness - mouseX;
292 else if (mouseX >=
contentHolder.getWidth() - activeBorderThickness)
293 dx = (
contentHolder.getWidth() - activeBorderThickness) - mouseX;
303 if (mouseY < activeBorderThickness)
304 dy = activeBorderThickness - mouseY;
305 else if (mouseY >=
contentHolder.getHeight() - activeBorderThickness)
314 if (dx != 0 ||
dy != 0)
361 const bool canShowAnyBars =
getWidth() > scrollbarWidth &&
getHeight() > scrollbarWidth;
365 bool hBarVisible =
false, vBarVisible =
false;
368 for (
int i = 3; --
i >= 0;)
387 hBarVisible = canShowHBar && (hBarVisible ||
contentComp->getRight() > contentArea.
getWidth());
388 vBarVisible = canShowVBar && (vBarVisible ||
contentComp->getBottom() > contentArea.
getHeight());
396 contentArea.
setX (scrollbarWidth);
399 contentArea.
setY (scrollbarWidth);
418 contentBounds =
contentHolder.getLocalArea (cc, cc->getLocalBounds());
426 hbar.setRangeLimits (0.0, contentBounds.
getWidth());
427 hbar.setCurrentRange (visibleOrigin.x, contentArea.
getWidth());
430 if (canShowHBar && ! hBarVisible)
431 visibleOrigin.setX (0);
434 vbar.setRangeLimits (0.0, contentBounds.
getHeight());
435 vbar.setCurrentRange (visibleOrigin.y, contentArea.
getHeight());
438 if (canShowVBar && ! vBarVisible)
439 visibleOrigin.setY (0);
442 hbar.setVisible (hBarVisible);
443 vbar.setVisible (vBarVisible);
449 if (
contentComp->getBounds().getPosition() != newContentCompPos)
451 contentComp->setTopLeftPosition (newContentCompPos);
456 const Rectangle<int> visibleArea (visibleOrigin.x, visibleOrigin.y,
466 hbar.handleUpdateNowIfNeeded();
467 vbar.handleUpdateNowIfNeeded();
482 const bool showHorizontalScrollbarIfNeeded,
483 const bool allowVerticalScrollingWithoutScrollbar,
484 const bool allowHorizontalScrollingWithoutScrollbar)
513 newThickness = thickness;
530 auto newRangeStartInt =
roundToInt (newRangeStart);
544 if (
e.eventComponent ==
this)
557 if (distance == 0.0f)
560 distance *= 14.0f * (float) singleStepSize;
563 :
jmax (distance, 1.0f));
568 if (! (
e.mods.isAltDown() ||
e.mods.isCtrlDown() ||
e.mods.isCommandDown()))
573 if (canScrollHorz || canScrollVert)
580 if (deltaX != 0 && deltaY != 0 && canScrollHorz && canScrollVert)
585 else if (canScrollHorz && (deltaX != 0 ||
e.mods.isShiftDown() || ! canScrollVert))
587 pos.x -= deltaX != 0 ? deltaX : deltaY;
589 else if (canScrollVert && deltaY != 0)
647 bool horizontalScrollbarAtBottom)
Type jmin(const Type a, const Type b)
Definition MathsFunctions.h:60
Type jmax(const Type a, const Type b)
Definition MathsFunctions.h:48
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_AnimatedPosition.h:54
void setInterceptsMouseClicks(bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
Definition juce_Component.cpp:1420
bool isVisible() const noexcept
Definition juce_Component.h:122
int getHeight() const noexcept
Definition juce_Component.h:274
void addAndMakeVisible(Component *child, int zOrder=-1)
Definition juce_Component.cpp:1554
Component() noexcept
Definition juce_Component.cpp:517
void setWantsKeyboardFocus(bool wantsFocus) noexcept
Definition juce_Component.cpp:2842
int getWidth() const noexcept
Definition juce_Component.h:271
void mouseWheelMove(const MouseEvent &event, const MouseWheelDetails &wheel) override
Definition juce_Component.cpp:2303
LookAndFeel & getLookAndFeel() const noexcept
Definition juce_Component.cpp:2173
Rectangle< int > getLocalBounds() const noexcept
Definition juce_Component.cpp:2283
void addChildComponent(Component *child, int zOrder=-1)
Definition juce_Component.cpp:1548
static Desktop &JUCE_CALLTYPE getInstance()
Definition juce_Desktop.cpp:50
Definition juce_KeyPress.h:40
static const int homeKey
Definition juce_KeyPress.h:204
static const int upKey
Definition juce_KeyPress.h:198
static const int endKey
Definition juce_KeyPress.h:205
static const int rightKey
Definition juce_KeyPress.h:201
static const int downKey
Definition juce_KeyPress.h:199
static const int leftKey
Definition juce_KeyPress.h:200
static const int pageUpKey
Definition juce_KeyPress.h:202
static const int pageDownKey
Definition juce_KeyPress.h:203
Definition juce_MouseEvent.h:39
Definition juce_MouseListener.h:39
Definition juce_Point.h:42
ValueType y
Definition juce_Point.h:247
ValueType x
Definition juce_Point.h:246
Definition juce_Rectangle.h:67
void setHeight(ValueType newHeight) noexcept
Definition juce_Rectangle.h:204
bool contains(ValueType xCoord, ValueType yCoord) const noexcept
Definition juce_Rectangle.h:622
Point< ValueType > getPosition() const noexcept
Definition juce_Rectangle.h:161
ValueType getHeight() const noexcept
Definition juce_Rectangle.h:136
void setWidth(ValueType newWidth) noexcept
Definition juce_Rectangle.h:201
ValueType getX() const noexcept
Definition juce_Rectangle.h:127
ValueType getWidth() const noexcept
Definition juce_Rectangle.h:133
void setX(ValueType newX) noexcept
Definition juce_Rectangle.h:195
void setY(ValueType newY) noexcept
Definition juce_Rectangle.h:198
ValueType getY() const noexcept
Definition juce_Rectangle.h:130
Definition juce_String.h:53
Definition juce_Viewport.h:47
void mouseDown(const MouseEvent &e) override
Definition juce_Viewport.cpp:549
void setViewPositionProportionately(double proportionX, double proportionY)
Definition juce_Viewport.cpp:275
int singleStepY
Definition juce_Viewport.h:355
std::unique_ptr< ScrollBar > horizontalScrollBar
Definition juce_Viewport.h:350
bool showHScrollbar
Definition juce_Viewport.h:357
void setScrollBarPosition(bool verticalScrollbarOnRight, bool horizontalScrollbarAtBottom)
Definition juce_Viewport.cpp:646
AccessibilityIgnoredComponent contentHolder
Definition juce_Viewport.h:351
virtual void viewedComponentChanged(Component *newComponent)
Definition juce_Viewport.cpp:183
bool allowScrollingWithoutScrollbarV
Definition juce_Viewport.h:359
bool isCurrentlyScrollingOnDrag() const noexcept
Definition juce_Viewport.cpp:337
int getViewPositionX() const noexcept
Definition juce_Viewport.h:145
int getScrollBarThickness() const
Definition juce_Viewport.cpp:523
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 canScrollVertically() const noexcept
Definition juce_Viewport.cpp:249
bool allowScrollingWithoutScrollbarH
Definition juce_Viewport.h:359
int getMaximumVisibleHeight() const
Definition juce_Viewport.cpp:247
std::unique_ptr< ScrollBar > verticalScrollBar
Definition juce_Viewport.h:350
void componentMovedOrResized(Component &, bool wasMoved, bool wasResized) override
Definition juce_Viewport.cpp:326
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
bool useMouseWheelMoveIfNeeded(const MouseEvent &, const MouseWheelDetails &)
Definition juce_Viewport.cpp:566
ScrollBar & getHorizontalScrollBar() noexcept
Definition juce_Viewport.h:259
Point< int > viewportPosToCompPos(Point< int >) const
Definition juce_Viewport.cpp:252
virtual void visibleAreaChanged(const Rectangle< int > &newVisibleArea)
Definition juce_Viewport.cpp:182
bool autoScroll(int mouseX, int mouseY, int distanceFromEdge, int maximumSpeed)
Definition juce_Viewport.cpp:282
bool canScrollHorizontally() const noexcept
Definition juce_Viewport.cpp:250
void deleteOrRemoveContentComp()
Definition juce_Viewport.cpp:186
~Viewport() override
Definition juce_Viewport.cpp:176
void scrollBarMoved(ScrollBar *, double newRangeStart) override
Definition juce_Viewport.cpp:528
bool keyPressed(const KeyPress &) override
Definition juce_Viewport.cpp:621
void resized() override
Definition juce_Viewport.cpp:352
int singleStepX
Definition juce_Viewport.h:355
void setViewPosition(int xPixelsOffset, int yPixelsOffset)
Definition juce_Viewport.cpp:264
void setScrollBarsShown(bool showVerticalScrollbarIfNeeded, bool showHorizontalScrollbarIfNeeded, bool allowVerticalScrollingWithoutScrollbar=false, bool allowHorizontalScrollingWithoutScrollbar=false)
Definition juce_Viewport.cpp:481
bool vScrollbarRight
Definition juce_Viewport.h:360
int getViewPositionY() const noexcept
Definition juce_Viewport.h:150
bool deleteContent
Definition juce_Viewport.h:357
void lookAndFeelChanged() override
Definition juce_Viewport.cpp:343
void recreateScrollbars()
Definition juce_Viewport.cpp:227
int getMaximumVisibleWidth() const
Definition juce_Viewport.cpp:246
void updateVisibleArea()
Definition juce_Viewport.cpp:358
virtual ScrollBar * createScrollBarComponent(bool isVertical)
Definition juce_Viewport.cpp:641
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
static bool respondsToKey(const KeyPress &)
Definition juce_Viewport.cpp:636
WeakReference< Component > contentComp
Definition juce_Viewport.h:352
void setSingleStepSizes(int stepX, int stepY)
Definition juce_Viewport.cpp:471
void mouseWheelMove(const MouseEvent &, const MouseWheelDetails &) override
Definition juce_Viewport.cpp:542
void setScrollBarThickness(int thickness)
Definition juce_Viewport.cpp:498
* e
Definition inflate.c:1404
int y
Definition inflate.c:1588
unsigned v[N_MAX]
Definition inflate.c:1584
register unsigned i
Definition inflate.c:1575
unsigned x[BMAX+1]
Definition inflate.c:1586
static const char * name
Definition pugl.h:1582
Definition carla_juce.cpp:31
static int rescaleMouseWheelDistance(float distance, int singleStepSize) noexcept
Definition juce_Viewport.cpp:555
constexpr Type jmin(Type a, Type b)
Definition juce_MathsFunctions.h:106
constexpr Type jmax(Type a, Type b)
Definition juce_MathsFunctions.h:94
static bool viewportWouldScrollOnEvent(const Viewport *vp, const MouseInputSource &src) noexcept
Definition juce_Viewport.cpp:29
static bool isLeftRightKeyPress(const KeyPress &key)
Definition juce_Viewport.cpp:615
AnimatedPosition< AnimatedPositionBehaviours::ContinuousWithMomentum > ViewportDragPosition
Definition juce_Viewport.cpp:44
int roundToInt(const FloatType value) noexcept
Definition juce_MathsFunctions.h:465
static bool isUpDownKeyPress(const KeyPress &key)
Definition juce_Viewport.cpp:605
Definition juce_Uuid.h:141
png_structrp int mode
Definition png.h:1139
Definition juce_MouseEvent.h:392
float deltaY
Definition juce_MouseEvent.h:410
float deltaX
Definition juce_MouseEvent.h:401
uch * p
Definition crypt.c:594
return c
Definition crypt.c:175
ZCONST char * key
Definition crypt.c:587
dy
Definition zipinfo.c:2288
#define const
Definition zconf.h:137