qtdeclarative/src/quicktemplates2/qquickscrollbar_p_p.h

118 lines
3.5 KiB
C
Raw Normal View History

// 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
#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;
class QQuickIndicatorButton;
class QQuickScrollBarPrivate : public QQuickControlPrivate
{
Q_DECLARE_PUBLIC(QQuickScrollBar)
public:
static QQuickScrollBarPrivate *get(QQuickScrollBar *bar)
{
return bar->d_func();
}
struct VisualArea
{
VisualArea(qreal pos, qreal sz)
: position(pos), size(sz) { }
qreal position = 0;
qreal size = 0;
};
VisualArea visualArea() const;
qreal logicalPosition(qreal position) const;
qreal snapPosition(qreal position) const;
qreal positionAt(const QPointF &point) const;
void setInteractive(bool interactive);
void updateActive();
void resizeContent() override;
void itemImplicitWidthChanged(QQuickItem *item) override;
void itemImplicitHeightChanged(QQuickItem *item) override;
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;
void handleUngrab() override;
void visualAreaChange(const VisualArea &newVisualArea, const VisualArea &oldVisualArea);
void updateHover(const QPointF &pos, std::optional<bool> newHoverState = {});
QQuickIndicatorButton *decreaseVisual = nullptr;
QQuickIndicatorButton *increaseVisual = nullptr;
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;
};
class QQuickScrollBarAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener
{
public:
static QQuickScrollBarAttachedPrivate *get(QQuickScrollBarAttached *attached)
{
return attached->d_func();
}
void setFlickable(QQuickFlickable *flickable);
void initHorizontal();
void initVertical();
void cleanupHorizontal();
void cleanupVertical();
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;
QQuickFlickable *flickable = nullptr;
QQuickScrollBar *horizontal = nullptr;
QQuickScrollBar *vertical = nullptr;
};
QT_END_NAMESPACE
#endif // QQUICKSCROLLBAR_P_P_H