Numworks Epsilon  1.4.1
Graphing Calculator Operating System
key_view.cpp
Go to the documentation of this file.
1 #include <escher/key_view.h>
2 
4  {0xFF, 0xFF, 0xFF, 0x45, 0x45, 0xFF, 0xFF, 0xFF},
5  {0xFF, 0xFF, 0xE1, 0x00, 0x00, 0xE1, 0xFF, 0xFF},
6  {0xFF, 0xFF, 0x45, 0x0C, 0x0C, 0x45, 0xFF, 0xFF},
7  {0xFF, 0xE1, 0x00, 0xE1, 0xE1, 0x00, 0xE1, 0xFF},
8  {0xFF, 0x45, 0x0C, 0xFF, 0xFF, 0x0C, 0x45, 0xFF},
9  {0xE1, 0x00, 0xE1, 0xFF, 0xFF, 0xE1, 0x00, 0xE1},
10  {0x45, 0x0C, 0xE1, 0xE1, 0xE1, 0xE1, 0x0C, 0x45},
11  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
12 };
13 
15  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
16  {0x45, 0x0C, 0xE1, 0xE1, 0xE1, 0xE1, 0x0C, 0x45},
17  {0xE1, 0x00, 0xE1, 0xFF, 0xFF, 0xE1, 0x00, 0xE1},
18  {0xFF, 0x45, 0x0C, 0xFF, 0xFF, 0x0C, 0x45, 0xFF},
19  {0xFF, 0xE1, 0x00, 0xE1, 0xE1, 0x00, 0xE1, 0xFF},
20  {0xFF, 0xFF, 0x45, 0x0C, 0x0C, 0x45, 0xFF, 0xFF},
21  {0xFF, 0xFF, 0xE1, 0x00, 0x00, 0xE1, 0xFF, 0xFF},
22  {0xFF, 0xFF, 0xFF, 0x45, 0x45, 0xFF, 0xFF, 0xFF},
23 };
24 
26  {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, 0x45, 0x00},
27  {0xFF, 0xFF, 0xFF, 0xE1, 0x45, 0x00, 0x0C, 0x00},
28  {0xFF, 0xE1, 0x45, 0x00, 0x0C, 0xE1, 0xE1, 0x00},
29  {0x45, 0x00, 0x0C, 0xE1, 0xFF, 0xFF, 0xE1, 0x00},
30  {0x45, 0x00, 0x0C, 0xE1, 0xFF, 0xFF, 0xE1, 0x00},
31  {0xFF, 0xE1, 0x45, 0x00, 0x0C, 0xE1, 0xE1, 0x00},
32  {0xFF, 0xFF, 0xFF, 0xE1, 0x45, 0x00, 0x0C, 0x00},
33  {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, 0x45, 0x00},
34 };
35 
37  {0x00, 0x45, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
38  {0x00, 0x0C, 0x00, 0x45, 0xE1, 0xFF, 0xFF, 0xFF},
39  {0x00, 0xE1, 0xE1, 0x0C, 0x00, 0x45, 0xE1, 0xFF},
40  {0x00, 0xE1, 0xFF, 0xFF, 0xE1, 0x0C, 0x00, 0x45},
41  {0x00, 0xE1, 0xFF, 0xFF, 0xE1, 0x0C, 0x00, 0x45},
42  {0x00, 0xE1, 0xE1, 0x0C, 0x00, 0x45, 0xE1, 0xE1},
43  {0x00, 0x0C, 0x00, 0x45, 0xE1, 0xFF, 0xFF, 0xFF},
44  {0x00, 0x45, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
45 };
46 
48  {0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF},
49  {0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF},
50  {0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF},
51  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
52  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
53  {0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF},
54  {0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF},
55  {0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF},
56 };
57 
59  {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
60  {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
61  {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
62  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
63  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
64  {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
65  {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
66  {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
67 };
68 
70  View(),
71  m_type(type)
72 {
73 }
74 
75 void KeyView::setType(Type type) {
76  m_type = type;
78 }
79 
81 
82 void KeyView::drawRect(KDContext * ctx, KDRect rect) const {
83  /* Draw the key centered on the view. */
84  KDCoordinate width = bounds().width();
85  KDCoordinate height = bounds().height();
86  KDRect frame((width - k_keySize)/2, (height - k_keySize)/2, k_keySize, k_keySize);
88 }
89 
91  return KDSize(k_keySize, k_keySize);
92 }
93 
94 const uint8_t * KeyView::mask() const {
95  switch (m_type) {
96  case Type::Up:
97  return (const uint8_t *)upMask;
98  case Type::Down:
99  return (const uint8_t *)downMask;
100  case Type::Left:
101  return (const uint8_t *)leftMask;
102  case Type::Right:
103  return (const uint8_t *)rightMask;
104  case Type::Plus:
105  return (const uint8_t *)plusMask;
106  case Type::Minus:
107  return (const uint8_t *)minusMask;
108  default:
109  return nullptr;
110  }
111 }
112 
KDSize minimalSizeForOptimalDisplay() const override
Definition: key_view.cpp:90
const uint8_t plusMask[KeyView::k_keySize][KeyView::k_keySize]
Definition: key_view.cpp:47
const uint8_t upMask[KeyView::k_keySize][KeyView::k_keySize]
Definition: key_view.cpp:3
const uint8_t minusMask[KeyView::k_keySize][KeyView::k_keySize]
Definition: key_view.cpp:58
int16_t KDCoordinate
Definition: coordinate.h:6
void markRectAsDirty(KDRect rect)
Definition: view.cpp:39
void blendRectWithMask(KDRect rect, KDColor color, const uint8_t *mask, KDColor *workingBuffer)
const uint8_t leftMask[KeyView::k_keySize][KeyView::k_keySize]
Definition: key_view.cpp:25
unsigned char uint8_t
Definition: stdint.h:4
const uint8_t downMask[KeyView::k_keySize][KeyView::k_keySize]
Definition: key_view.cpp:14
Definition: size.h:6
KDColor s_keyWorkingBuffer[KeyView::k_keySize *KeyView::k_keySize]
Definition: key_view.cpp:80
KeyView(Type type=Type::Up)
Definition: key_view.cpp:69
void drawRect(KDContext *ctx, KDRect rect) const override
Definition: key_view.cpp:82
constexpr KDColor KDColorBlack
Definition: color.h:41
const uint8_t rightMask[KeyView::k_keySize][KeyView::k_keySize]
Definition: key_view.cpp:36
Definition: rect.h:26
Definition: color.h:6
static constexpr KDCoordinate k_keySize
Definition: key_view.h:20
Definition: view.h:23
KDCoordinate width() const
Definition: rect.h:39
KDCoordinate height() const
Definition: rect.h:40
KDRect bounds() const
Definition: view.cpp:157
void setType(Type type)
Definition: key_view.cpp:75