Numworks Epsilon  1.4.1
Graphing Calculator Operating System
arrow_view.cpp
Go to the documentation of this file.
1 #include "arrow_view.h"
2 
3 namespace HardwareTest {
4 
5 const uint8_t arrowUpMask[10][9] = {
6  {0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF},
7  {0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF},
8  {0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF},
9  {0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF},
10  {0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF},
11  {0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF},
12  {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF},
13  {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF},
14  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
15  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
16 };
17 
18 const uint8_t arrowDownMask[10][9] = {
19  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
20  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
21  {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF},
22  {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF},
23  {0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF},
24  {0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF},
25  {0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF},
26  {0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF},
27  {0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF},
28  {0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF},
29 };
30 
32  m_directionIsUp(true),
33  m_color(KDColorBlack)
34 {
35 }
36 
37 void ArrowView::setDirection(bool isUp) {
38  if (m_directionIsUp!= isUp) {
39  m_directionIsUp = isUp;
41  }
42 }
43 
45  if (m_color != color) {
46  m_color = color;
48  }
49 }
50 
52 
53 void ArrowView::drawRect(KDContext * ctx, KDRect rect) const {
54  ctx->fillRect(bounds(), KDColorWhite);
55  KDCoordinate startLine = m_directionIsUp ? k_arrowHeight : 0;
56  KDCoordinate startArrow = m_directionIsUp ? 0 : bounds().height()-k_arrowHeight;
57  ctx->fillRect(KDRect((Ion::Display::Width-k_arrowThickness)/2, startLine, k_arrowThickness, bounds().height()-k_arrowHeight), m_color);
58  KDRect frame((Ion::Display::Width-k_arrowWidth)/2, startArrow, k_arrowWidth, k_arrowHeight);
59  const uint8_t * mask = m_directionIsUp ? (const uint8_t *)arrowUpMask : (const uint8_t *)arrowDownMask;
60  ctx->blendRectWithMask(frame, m_color, mask, s_arrowWorkingBuffer);
61 }
62 
63 }
64 
const uint8_t arrowDownMask[10][9]
Definition: arrow_view.cpp:18
constexpr int Width
Definition: display.h:26
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)
void drawRect(KDContext *ctx, KDRect rect) const override
Definition: arrow_view.cpp:53
void setDirection(bool up)
Definition: arrow_view.cpp:37
void setColor(KDColor color)
Definition: arrow_view.cpp:44
unsigned char uint8_t
Definition: stdint.h:4
KDColor s_arrowWorkingBuffer[10 *9]
Definition: arrow_view.cpp:51
constexpr KDColor KDColorWhite
Definition: color.h:42
constexpr KDColor KDColorBlack
Definition: color.h:41
Definition: rect.h:26
void fillRect(KDRect rect, KDColor color)
Definition: context_rect.cpp:8
Definition: color.h:6
KDCoordinate height() const
Definition: rect.h:40
KDRect bounds() const
Definition: view.cpp:157
#define true
Definition: stdbool.h:8
const uint8_t arrowUpMask[10][9]
Definition: arrow_view.cpp:5