tcMenu
Loading...
Searching...
No Matches
MenuTouchScreenEncoder.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 https://www.thecoderscorner.com (Dave Cherry).
3 * This product is licensed under an Apache license, see the LICENSE file in the top-level directory.
4 */
5
11#ifndef TCMENU_MENUTOUCHSCREENENCODER_H
12#define TCMENU_MENUTOUCHSCREENENCODER_H
13
14#include "PlatformDetermination.h"
15#include <IoAbstraction.h>
17#include <AnalogDeviceAbstraction.h>
18#include <ResistiveTouchScreen.h>
19
20namespace tcgfx {
21
28 private:
30 Coord cursorPosition;
31 Coord itemSize;
32 bool withinItem;
33 iotouch::TouchState touchState;
34 public:
35 TouchNotification(const Coord& rawCoords, iotouch::TouchState touchState)
36 : pEntry(nullptr), cursorPosition(rawCoords), itemSize(0, 0), withinItem(false), touchState(touchState) {}
37
38 TouchNotification(GridPositionRowCacheEntry* ent, const Coord& local, const Coord& localStart, const Coord& localSize, iotouch::TouchState touchState)
39 : pEntry(ent), cursorPosition(local), itemSize(localSize), withinItem(true), touchState(touchState) {}
40
41 GridPositionRowCacheEntry* getEntry() const {
42 return pEntry;
43 }
44
45 const Coord &getCursorPosition() const {
46 return cursorPosition;
47 }
48
49 const Coord &getItemSize() const {
50 return itemSize;
51 }
52
53 bool isWithinItem() const {
54 return withinItem;
55 }
56
57 iotouch::TouchState getTouchState() const {
58 return touchState;
59 }
60 };
61
63 public:
64 virtual void touched(const TouchNotification& notification)=0;
65 };
66
68 private:
69 BaseGraphicalRenderer *renderer;
70 public:
72 renderer = rend;
73 }
74
75 void touched(const TouchNotification& notification) override;
76 };
77
84 class MenuTouchScreenManager : public iotouch::TouchScreenManager {
85 private:
86 GridPositionRowCacheEntry* currentlySelected;
87 Coord localStart;
88 Coord localSize;
90 BaseGraphicalRenderer* renderer;
91 TouchObserver* observer;
92 TouchObserver* secondaryObserver;
93 float lastX, lastY;
94 Coord lastCoord;
95 iotouch::TouchState currentState;
96 public:
109 MenuTouchScreenManager(iotouch::TouchInterrogator* interrogator, BaseGraphicalRenderer* renderer,
110 const iotouch::TouchOrientationSettings& rotation);
111
112 void sendEvent(float locationX, float locationY, float touchPressure, iotouch::TouchState touched) override;
113 iotouch::TouchState getLastTouchState() const { return currentState; }
114 float getLastX() const { return lastX; }
115 float getLastY() const { return lastY; }
116 Coord getLastScreenCoord() { return lastCoord; }
117
124
129 void clearSecondaryObserver() { secondaryObserver = nullptr; }
130
131 void sendToObservers(TouchNotification notification);
132 };
133
134} // namespace tcgfx
135
136#endif //TCMENU_MENUTOUCHSCREENENCODER_H
Contains the base functionality for all graphical renderers.
Definition BaseGraphicalRenderer.h:131
Definition BaseGraphicalRenderer.h:60
Definition MenuTouchScreenEncoder.h:67
Definition MenuTouchScreenEncoder.h:84
void clearSecondaryObserver()
Definition MenuTouchScreenEncoder.h:129
void setSecondaryObserver(TouchObserver *secondaryObs)
Definition MenuTouchScreenEncoder.h:123
Definition MenuTouchScreenEncoder.h:27
Definition MenuTouchScreenEncoder.h:62
Definition GfxMenuConfig.h:32
Definition DrawingPrimitives.h:123