File indexing completed on 2024-05-19 04:07:48

0001 /*
0002     SPDX-FileCopyrightText: 2010 Stefan Majewsky <majewsky@gmx.net>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef PALAPELI_CONSTRAINTINTERACTOR_H
0008 #define PALAPELI_CONSTRAINTINTERACTOR_H
0009 
0010 #include "interactor.h"
0011 
0012 namespace Palapeli
0013 {
0014     class ConstraintInteractor : public Palapeli::Interactor
0015     {
0016         public:
0017             explicit ConstraintInteractor(QGraphicsView* view);
0018         protected:
0019             bool startInteraction(const Palapeli::MouseEvent& event) override;
0020             void continueInteraction(const Palapeli::MouseEvent& event) override;
0021             void stopInteraction(const Palapeli::MouseEvent& event) override;
0022         private:
0023             enum Side { LeftSide = 0, RightSide, TopSide, BottomSide };
0024             QList<Side> touchingSides(const QPointF& scenePos) const;
0025 
0026             QList<Side> m_draggingSides;
0027             QPointF m_baseSceneRectOffset;
0028     };
0029 }
0030 
0031 #endif // PALAPELI_CONSTRAINTINTERACTOR_H