File indexing completed on 2024-04-21 15:24:03

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 PRESSUREEQUATION_H
0006 #define PRESSUREEQUATION_H
0007 
0008 #include <QObject>
0009 
0010 #include "stroke.h"
0011 
0012 class PressureEquation : public QObject
0013 {
0014     Q_OBJECT
0015     Q_PROPERTY(float minWidth READ minWidth WRITE setMinWidth NOTIFY minWidthChanged)
0016     Q_PROPERTY(float maxWidth READ maxWidth WRITE setMaxWidth NOTIFY maxWidthChanged)
0017 
0018     Q_PROPERTY(float pressure READ pressure WRITE setPressure NOTIFY pressureChanged)
0019     Q_PROPERTY(float width READ width NOTIFY widthChanged)
0020 public:
0021     using QObject::QObject;
0022 
0023     float minWidth() const;
0024     float maxWidth() const;
0025 
0026     float pressure() const;
0027     float width() const;
0028 
0029 public slots:
0030     void setMinWidth(float minWidth);
0031     void setMaxWidth(float maxWidth);
0032 
0033     void setPressure(float pressure);
0034 
0035 signals:
0036     void minWidthChanged(float minWidth);
0037     void maxWidthChanged(float maxWidth);
0038 
0039     void pressureChanged(float pressure);
0040     void widthChanged(float width);
0041 
0042 private:
0043     void updateWidth();
0044 
0045     float m_minWidth = 1.0f;
0046     float m_maxWidth = 1.0f;
0047 
0048     float m_pressure = 0.0f;
0049     float m_width = m_maxWidth;
0050 };
0051 
0052 #endif // PRESSUREEQUATION_H