Warning, file /graphics/washipad/src/sketchview.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // This file is part of Washi Pad
0002 // SPDX-FileCopyrightText: 2018 Kevin Ottens <ervin@kde.org>
0003 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 
0005 #ifndef SKETCHVIEW_H
0006 #define SKETCHVIEW_H
0007 
0008 #include <QQuickView>
0009 
0010 #include "event.h"
0011 
0012 class SketchViewHandler : public QObject
0013 {
0014     Q_OBJECT
0015     Q_PROPERTY(Event point READ point NOTIFY pointChanged)
0016     Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged)
0017 public:
0018     explicit SketchViewHandler(QObject *parent = nullptr);
0019 
0020     Q_INVOKABLE Stroke createStroke(Stroke::Type type, const QColor &color) const;
0021     Q_INVOKABLE StrokeSample createSample(const QVector2D &position, float width) const;
0022     Q_INVOKABLE void setPressed(const bool pressed);
0023     Q_INVOKABLE void mouseMoved(const float x, const float y, const int button);
0024 
0025     Event point() const;
0026     bool isPressed() const;
0027 
0028 signals:
0029     void pointChanged(const Event &point);
0030     void pressedChanged(bool pressed);
0031 
0032 private slots:
0033     void onTabletEventReceived(QTabletEvent *event);
0034 
0035 private:
0036     Event m_point;
0037     bool m_active = false;
0038     bool m_pressed = false;
0039 };
0040 
0041 class SketchView : public QQuickView
0042 {
0043     Q_OBJECT
0044 public:
0045     static SketchView *instance();
0046 
0047     explicit SketchView(QWindow *parent = nullptr);
0048 
0049     void tabletEvent(QTabletEvent *event) override;
0050 
0051 signals:
0052     void tabletEventReceived(QTabletEvent *event);
0053 
0054 private:
0055     QPoint m_lastGlobalPos;
0056     QEvent::Type m_lastType = QEvent::None;
0057 };
0058 
0059 #endif // SKETCHVIEW_H