Control Surface  1.1.1
MIDI Control Surface library for Arduino
DisplayElement.hpp
Go to the documentation of this file.
1 #pragma once
2 
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
DisplayInterface
An interface for displays.
Definition: DisplayInterface.hpp:14
DisplayElement::~DisplayElement
virtual ~DisplayElement()
Definition: DisplayElement.hpp:30
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
DisplayElement::elements
static DoublyLinkedList< DisplayElement > elements
Definition: DisplayElement.hpp:46
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
LinkedList.hpp
DisplayInterface.hpp
DisplayElement::getDisplay
DisplayInterface & getDisplay()
Get a reference to the display that this element draws to.
Definition: DisplayElement.hpp:36
DisplayElement::draw
virtual void draw()=0
Draw this DisplayElement to the display buffer.
DoublyLinkedList::remove
void remove(Node *node)
Remove a node from the linked list.
Definition: LinkedList.hpp:200
DisplayElement::DisplayElement
DisplayElement(DisplayInterface &display)
Create a new DisplayElement.
Definition: DisplayElement.hpp:19
DisplayElement::display
DisplayInterface & display
Definition: DisplayElement.hpp:44
DoublyLinkedList< DisplayElement >
DoublyLinkable
A class that can be inherited from to allow inserting into a DoublyLinkedList.
Definition: LinkedList.hpp:302
DisplayElement::getAll
static DoublyLinkedList< DisplayElement > & getAll()
Get the list of all DisplayElement instances.
Definition: DisplayElement.hpp:41
DoublyLinkedList::insertSorted
void insertSorted(Node *node, Compare cmp)
Insert a new node at the correct location into a sorted list.
Definition: LinkedList.hpp:170
DisplayElement::getDisplay
const DisplayInterface & getDisplay() const
Get a const reference to the display that this element draws to.
Definition: DisplayElement.hpp:38