Touch.h
Go to the documentation of this file.
1 /****
2  * Touch.h
3  *
4  * Copyright 2021 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the Sming-Graphics Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  * @author: May 2021 - mikee47 <mike@sillyhouse.net>
19  *
20  ****/
21 
22 #pragma once
23 
24 #include "Types.h"
25 
26 namespace Graphics
27 {
28 class Device;
29 
30 class Touch
31 {
32 public:
33  struct State {
36  };
37 
42 
43  Touch(Device* device = nullptr) : device(device)
44  {
45  }
46 
51 
56  virtual Size getNativeSize() const = 0;
57 
61  virtual State getState() const = 0;
62 
67  {
68  this->callback = callback;
69  }
70 
74  Size getSize() const
75  {
76  auto size = getNativeSize();
77  if(orientation == Orientation::deg90 || orientation == Orientation::deg270) {
78  std::swap(size.w, size.h);
79  }
80  return size;
81  }
82 
87  {
88  return orientation;
89  }
90 
91 protected:
93  Orientation orientation{};
95 };
96 
97 } // namespace Graphics
98 
Orientation orientation
Definition: Touch.h:93
Definition: Touch.h:30
uint16_t pressure
Definition: Touch.h:35
A physical display device.
Definition: Libraries/Graphics/src/include/Graphics/Device.h:32
The String class.
Definition: WString.h:136
String toString(Graphics::Touch::State state)
Definition: Touch.h:33
Device * device
Definition: Touch.h:92
Point pos
Definition: Touch.h:34
Size of rectangular area (width x height)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:105
Orientation getOrientation()
Get current display orientation.
Definition: Touch.h:86
virtual void setCallback(Callback callback)
Register callback to be invoked when state changes.
Definition: Touch.h:66
Callback callback
Definition: Touch.h:94
virtual Size getNativeSize() const =0
Get physical size of display.
virtual bool setOrientation(Orientation orientation)
Set display orientation.
Size getSize() const
Get native dimensions for current orientation.
Definition: Touch.h:74
Definition: Virtual.h:30
virtual State getState() const =0
Get current state.
Orientation
Defines orientation of display.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:47
Touch(Device *device=nullptr)
Definition: Touch.h:43