This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
DisplayElement.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include <Helpers/LinkedList.hpp>
5 
7 
11 class DisplayElement : public DoublyLinkable<DisplayElement> {
12  protected:
20  // The elements are sorted by the address of their displays.
21  // This way, all display elements that draw to the same display are next
22  // to each other. This means that the display buffer can be reused.
24  this, [](const DisplayElement &lhs, const DisplayElement &rhs) {
25  return &lhs.getDisplay() < &rhs.getDisplay();
26  });
27  }
28 
29  public:
30  virtual ~DisplayElement() { elements.remove(this); }
31 
33  virtual void draw() = 0;
34 
38  const DisplayInterface &getDisplay() const { return display; }
39 
42 
43  protected:
45 
47 };
48 
DisplayElement
An interface for elements that draw to a display.
Definition: DisplayElement.hpp:11
DisplayElement::getAll
static DoublyLinkedList< DisplayElement > & getAll()
Get the list of all DisplayElement instances.
Definition: DisplayElement.hpp:41
DisplayInterface
An interface for displays.
Definition: DisplayInterface.hpp:14
DoublyLinkedList::insertSorted
void insertSorted(Node *node, Compare cmp)
Insert a new node at the correct location into a sorted list.
Definition: LinkedList.hpp:166
LinkedList.hpp
DoublyLinkedList::remove
void remove(Node *node)
Remove a node from the linked list.
Definition: LinkedList.hpp:196
DisplayInterface.hpp
DisplayElement::~DisplayElement
virtual ~DisplayElement()
Definition: DisplayElement.hpp:30
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
DisplayElement::getDisplay
DisplayInterface & getDisplay()
Get a reference to the display that this element draws to.
Definition: DisplayElement.hpp:36
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
DisplayElement::draw
virtual void draw()=0
Draw this DisplayElement to the display buffer.
DisplayElement::display
DisplayInterface & display
Definition: DisplayElement.hpp:44
DisplayElement::DisplayElement
DisplayElement(DisplayInterface &display)
Create a new DisplayElement.
Definition: DisplayElement.hpp:19
DoublyLinkedList< DisplayElement >
DoublyLinkable
A class that can be inherited from to allow inserting into a DoublyLinkedList.
Definition: LinkedList.hpp:298
DisplayElement::elements
static DoublyLinkedList< DisplayElement > elements
Definition: DisplayElement.hpp:46
DisplayElement::getDisplay
const DisplayInterface & getDisplay() const
Get a const reference to the display that this element draws to.
Definition: DisplayElement.hpp:38