TouchCPLib  1.0.0
A touch-enabled GUI interface based on SDL and libTS. It provides a simple desktop-free UI for your embedded Raspberry projects.
TouchEnabledObject.h
Go to the documentation of this file.
1 #pragma once
2 
13 #include <functional>
14 
15 #include "GraphicsObject.h"
16 
20 using TouchCallback = std::function<void(void)>;
21 
27 {
28 public:
29  virtual int getX() const = 0;
30  virtual int getY() const = 0;
31  virtual int getWidth() const = 0;
32  virtual int getHeight() const = 0;
34  {
35  return touchEvCallback;
36  }
42  {
43  touchEvCallback = cb;
44  }
49  bool isTouchEnabled() const
50  {
51  return touchEnabled;
52  }
57  void setTouchEnabled(bool enabled)
58  {
59  touchEnabled = enabled;
60  }
66  {
67  return propagateInteraction;
68  }
73  void setPropagateInteraction(bool propagate)
74  {
75  propagateInteraction = propagate;
76  }
77 
78 private:
79  TouchCallback touchEvCallback = nullptr;
80  bool touchEnabled = true, propagateInteraction = false;
81 };
void setPropagateInteraction(bool propagate)
Set wheter the object has to call the handlers of objects placed below, when touched.
Definition: TouchEnabledObject.h:73
std::function< void(void)> TouchCallback
The callback that will be called when the touch interaction happens.
Definition: TouchEnabledObject.h:20
virtual int getX() const =0
TouchCallback getTouchCallback() const
Definition: TouchEnabledObject.h:33
bool isPropagateInteraction() const
True if the object will call the handlers of object placed below when touched.
Definition: TouchEnabledObject.h:65
A base class that provides the methods needed for the object to react to touch input.
Definition: TouchEnabledObject.h:26
The GraphicsObject base class.
virtual int getHeight() const =0
void setTouchCallback(TouchCallback cb)
Set the touch interaction callback.
Definition: TouchEnabledObject.h:41
virtual int getY() const =0
virtual int getWidth() const =0
void setTouchEnabled(bool enabled)
Set if the object has to react to touch events.
Definition: TouchEnabledObject.h:57
bool isTouchEnabled() const
True if the object reacts to touch events.
Definition: TouchEnabledObject.h:49