2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2017 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
2017-01-20 12:53:35 +00:00
|
|
|
|
|
|
|
#ifndef QQUICKSCROLLBAR_P_P_H
|
|
|
|
#define QQUICKSCROLLBAR_P_P_H
|
|
|
|
|
|
|
|
//
|
|
|
|
// W A R N I N G
|
|
|
|
// -------------
|
|
|
|
//
|
|
|
|
// This file is not part of the Qt API. It exists purely as an
|
|
|
|
// implementation detail. This header file may change from version to
|
|
|
|
// version without notice, or even be removed.
|
|
|
|
//
|
|
|
|
// We mean it.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <QtQuickTemplates2/private/qquickscrollbar_p.h>
|
|
|
|
#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
|
|
|
|
#include <QtQuick/private/qquickitemchangelistener_p.h>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
class QQuickFlickable;
|
2020-10-29 16:01:27 +00:00
|
|
|
class QQuickIndicatorButton;
|
2017-01-20 12:53:35 +00:00
|
|
|
|
|
|
|
class QQuickScrollBarPrivate : public QQuickControlPrivate
|
|
|
|
{
|
|
|
|
Q_DECLARE_PUBLIC(QQuickScrollBar)
|
|
|
|
|
|
|
|
public:
|
|
|
|
static QQuickScrollBarPrivate *get(QQuickScrollBar *bar)
|
|
|
|
{
|
|
|
|
return bar->d_func();
|
|
|
|
}
|
|
|
|
|
2017-11-01 14:25:38 +00:00
|
|
|
struct VisualArea
|
|
|
|
{
|
|
|
|
VisualArea(qreal pos, qreal sz)
|
|
|
|
: position(pos), size(sz) { }
|
2018-05-03 09:23:56 +00:00
|
|
|
qreal position = 0;
|
|
|
|
qreal size = 0;
|
2017-11-01 14:25:38 +00:00
|
|
|
};
|
|
|
|
VisualArea visualArea() const;
|
|
|
|
|
|
|
|
qreal logicalPosition(qreal position) const;
|
|
|
|
|
2017-01-20 12:53:35 +00:00
|
|
|
qreal snapPosition(qreal position) const;
|
|
|
|
qreal positionAt(const QPointF &point) const;
|
2017-01-25 09:22:47 +00:00
|
|
|
void setInteractive(bool interactive);
|
2017-01-20 12:53:35 +00:00
|
|
|
void updateActive();
|
|
|
|
void resizeContent() override;
|
2020-10-29 16:01:27 +00:00
|
|
|
void itemImplicitWidthChanged(QQuickItem *item) override;
|
|
|
|
void itemImplicitHeightChanged(QQuickItem *item) override;
|
2017-01-20 12:53:35 +00:00
|
|
|
|
Controls: ignore mouse events unless handling is implemented
In Qt, input events are accepted by default, and item event handlers
ignore the event. Overrides of the event handlers don't have to do
anything explicit to mark events as handled, but can explicitly ignore
events (i.e. such events that hit transparent areas or are from devices
or buttons the item doesn't care about).
Controls, as of d88d9d63422c086417e8cc1935f8d3376043f845, always
accepted events, even if they didn't do anything with it. This is
fundamentally breaking event delivery semantics, preventing control
implementations from selectively accepting or ignoring events depending
on event attributes.
Revert that behavior, and ignore events unless the handler override
returns true. Change all existing handlers to return true so that we
don't break existing controls. Controls that don't override handlers
will ignore the event, which will then propagate as per Qt's event
handling semantics.
The odd control out is Pane, which doesn't do anything with events, but
nevertheless returns true to stop propagation to controls covered by it.
In QWidget world we have special attributes for this kind of UI element,
WA_NoMousePropagation and WA_TransparentForMouseEvents. We might need
something similar in Quick to fix the bug that Drawer eats events in the
(invisible) drag margin, preventing controls underneath to receive them
with priority.
Task-number: QTBUG-59141
Change-Id: Ic1a347ce293c8e11dab958c076ee488834060839
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-05-05 14:05:55 +00:00
|
|
|
bool handlePress(const QPointF &point, ulong timestamp) override;
|
|
|
|
bool handleMove(const QPointF &point, ulong timestamp) override;
|
|
|
|
bool handleRelease(const QPointF &point, ulong timestamp) override;
|
2017-04-19 15:30:08 +00:00
|
|
|
void handleUngrab() override;
|
2017-01-20 12:53:35 +00:00
|
|
|
|
2017-11-01 14:25:38 +00:00
|
|
|
void visualAreaChange(const VisualArea &newVisualArea, const VisualArea &oldVisualArea);
|
|
|
|
|
2020-10-29 16:01:27 +00:00
|
|
|
void updateHover(const QPointF &pos, std::optional<bool> newHoverState = {});
|
|
|
|
|
|
|
|
QQuickIndicatorButton *decreaseVisual = nullptr;
|
|
|
|
QQuickIndicatorButton *increaseVisual = nullptr;
|
2018-05-03 09:23:56 +00:00
|
|
|
qreal size = 0;
|
|
|
|
qreal position = 0;
|
|
|
|
qreal stepSize = 0;
|
|
|
|
qreal offset = 0;
|
|
|
|
qreal minimumSize = 0;
|
|
|
|
bool active = false;
|
|
|
|
bool pressed = false;
|
|
|
|
bool moving = false;
|
|
|
|
bool interactive = true;
|
|
|
|
bool explicitInteractive = false;
|
|
|
|
Qt::Orientation orientation = Qt::Vertical;
|
|
|
|
QQuickScrollBar::SnapMode snapMode = QQuickScrollBar::NoSnap;
|
|
|
|
QQuickScrollBar::Policy policy = QQuickScrollBar::AsNeeded;
|
2017-01-20 12:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class QQuickScrollBarAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static QQuickScrollBarAttachedPrivate *get(QQuickScrollBarAttached *attached)
|
|
|
|
{
|
|
|
|
return attached->d_func();
|
|
|
|
}
|
|
|
|
|
2017-01-23 08:50:01 +00:00
|
|
|
void setFlickable(QQuickFlickable *flickable);
|
|
|
|
|
|
|
|
void initHorizontal();
|
|
|
|
void initVertical();
|
|
|
|
void cleanupHorizontal();
|
|
|
|
void cleanupVertical();
|
2017-01-20 12:53:35 +00:00
|
|
|
void activateHorizontal();
|
|
|
|
void activateVertical();
|
|
|
|
void scrollHorizontal();
|
|
|
|
void scrollVertical();
|
|
|
|
void mirrorVertical();
|
|
|
|
|
|
|
|
void layoutHorizontal(bool move = true);
|
|
|
|
void layoutVertical(bool move = true);
|
|
|
|
|
|
|
|
void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
|
|
|
|
void itemImplicitWidthChanged(QQuickItem *item) override;
|
|
|
|
void itemImplicitHeightChanged(QQuickItem *item) override;
|
|
|
|
void itemDestroyed(QQuickItem *item) override;
|
|
|
|
|
2018-05-03 09:23:56 +00:00
|
|
|
QQuickFlickable *flickable = nullptr;
|
|
|
|
QQuickScrollBar *horizontal = nullptr;
|
|
|
|
QQuickScrollBar *vertical = nullptr;
|
2017-01-20 12:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
#endif // QQUICKSCROLLBAR_P_P_H
|