Skip to content

File PlotDragRect.hpp

File List > QAccelPlot > src > QAccelPlot > PlotDragRect.hpp

Go to the documentation of this file

//
// SPDX-FileCopyrightText: 2026 Michal Grabarczyk
// SPDX-License-Identifier: GPL-3.0-only WITH Universal-FOSS-exception-1.0
//
// This file is also available under a separate commercial license.
// See COMMERCIAL-LICENSING.md for contact information.
//
#pragma once

#include <QPointF>
#include <QRectF>

namespace QAccelPlot {

class PlotDragRect {
public:
    void begin(const QPointF& position);
    void moveTo(const QPointF& position, const QRectF& bounds);
    void end();
    [[nodiscard]] bool active() const;
    [[nodiscard]] QRectF rect() const;

    [[nodiscard]] static bool modifiersMatch(Qt::KeyboardModifiers pressed, Qt::KeyboardModifiers required);
    [[nodiscard]] static bool meetsMinimum(const QRectF& rect, qreal minimumSize, bool checkWidth = true, bool checkHeight = true);

private:
    bool active_{false};
    QPointF start_;
    QPointF end_;
};

} // namespace QAccelPlot