diff options
Diffstat (limited to 'src/yuzu/configuration/configure_touch_widget.h')
| -rw-r--r-- | src/yuzu/configuration/configure_touch_widget.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/yuzu/configuration/configure_touch_widget.h b/src/yuzu/configuration/configure_touch_widget.h new file mode 100644 index 000000000..c85960f82 --- /dev/null +++ b/src/yuzu/configuration/configure_touch_widget.h | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | // Copyright 2020 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <optional> | ||
| 8 | #include <utility> | ||
| 9 | #include <vector> | ||
| 10 | #include <QFrame> | ||
| 11 | #include <QPointer> | ||
| 12 | |||
| 13 | class QLabel; | ||
| 14 | |||
| 15 | // Widget for representing touchscreen coordinates | ||
| 16 | class TouchScreenPreview : public QFrame { | ||
| 17 | Q_OBJECT | ||
| 18 | Q_PROPERTY(QColor dotHighlightColor MEMBER dot_highlight_color) | ||
| 19 | |||
| 20 | public: | ||
| 21 | explicit TouchScreenPreview(QWidget* parent); | ||
| 22 | ~TouchScreenPreview() override; | ||
| 23 | |||
| 24 | void SetCoordLabel(QLabel*); | ||
| 25 | int AddDot(int device_x, int device_y); | ||
| 26 | void RemoveDot(int id); | ||
| 27 | void HighlightDot(int id, bool active = true) const; | ||
| 28 | void MoveDot(int id, int device_x, int device_y) const; | ||
| 29 | |||
| 30 | signals: | ||
| 31 | void DotAdded(const QPoint& pos); | ||
| 32 | void DotSelected(int dot_id); | ||
| 33 | void DotMoved(int dot_id, const QPoint& pos); | ||
| 34 | |||
| 35 | protected: | ||
| 36 | virtual void resizeEvent(QResizeEvent*) override; | ||
| 37 | virtual void mouseMoveEvent(QMouseEvent*) override; | ||
| 38 | virtual void leaveEvent(QEvent*) override; | ||
| 39 | virtual void mousePressEvent(QMouseEvent*) override; | ||
| 40 | virtual bool eventFilter(QObject*, QEvent*) override; | ||
| 41 | |||
| 42 | private: | ||
| 43 | std::optional<QPoint> MapToDeviceCoords(int screen_x, int screen_y) const; | ||
| 44 | void PositionDot(QLabel* dot, int device_x = -1, int device_y = -1) const; | ||
| 45 | |||
| 46 | bool ignore_resize = false; | ||
| 47 | QPointer<QLabel> coord_label; | ||
| 48 | |||
| 49 | std::vector<std::pair<int, QLabel*>> dots; | ||
| 50 | int max_dot_id = 0; | ||
| 51 | QColor dot_highlight_color; | ||
| 52 | static constexpr char PropId[] = "dot_id"; | ||
| 53 | static constexpr char PropX[] = "device_x"; | ||
| 54 | static constexpr char PropY[] = "device_y"; | ||
| 55 | |||
| 56 | struct { | ||
| 57 | bool active = false; | ||
| 58 | QPointer<QLabel> dot; | ||
| 59 | QPoint start_pos; | ||
| 60 | } drag_state; | ||
| 61 | }; | ||