mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 22:00:28 +01:00
[apps/shared] Add toggle buttons in Graph view
Change-Id: I7548d11fb114b2605ce34d3bda0776277b79ff9d
This commit is contained in:
committed by
Émilie Feral
parent
a76e54642c
commit
2f97dab6d1
41
escher/src/toggleable_dot_view.cpp
Normal file
41
escher/src/toggleable_dot_view.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <escher/toggleable_dot_view.h>
|
||||
#include <escher/palette.h>
|
||||
|
||||
const uint8_t MediumDotMask[ToggleableDotView::k_dotSize][ToggleableDotView::k_dotSize] = {
|
||||
{0xFF, 0xDB, 0x53, 0x0F, 0x0F, 0x53, 0xDB, 0xFF},
|
||||
{0xD8, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0xD8},
|
||||
{0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53},
|
||||
{0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C},
|
||||
{0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C},
|
||||
{0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53},
|
||||
{0xD7, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0xD7},
|
||||
{0xFF, 0xD8, 0x53, 0x0C, 0x0C, 0x53, 0xD8, 0xFF},
|
||||
};
|
||||
|
||||
const uint8_t MediumShallowDotMask[ToggleableDotView::k_dotSize][ToggleableDotView::k_dotSize] = {
|
||||
{0xFF, 0xDB, 0x53, 0x0F, 0x0F, 0x53, 0xDB, 0xFF},
|
||||
{0xD8, 0x17, 0x90, 0xEC, 0xEC, 0x90, 0x17, 0xD8},
|
||||
{0x53, 0x90, 0xFF, 0xFF, 0xFF, 0xFF, 0x88, 0x53},
|
||||
{0x0F, 0xEC, 0xFF, 0xFF, 0xFF, 0xFF, 0xEC, 0x0C},
|
||||
{0x0F, 0xEC, 0xFF, 0xFF, 0xFF, 0xFF, 0xEC, 0x0C},
|
||||
{0x53, 0x90, 0xFF, 0xFF, 0xFF, 0xFF, 0x88, 0x53},
|
||||
{0xD7, 0x17, 0x90, 0xEF, 0xEF, 0x90, 0x17, 0xD7},
|
||||
{0xFF, 0xD8, 0x53, 0x0C, 0x0C, 0x53, 0xD8, 0xFF},
|
||||
};
|
||||
|
||||
void ToggleableDotView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
/* Draw the view aligned on the right of the view and vertically centered
|
||||
* The heightCenter is the coordinate of the vertical middle of the view. That
|
||||
* way, (heightCenter-halfHeight) indicates the top of the StateView. */
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate heightCenter = bounds().height() / 2;
|
||||
KDCoordinate halfHeight = k_dotSize / 2;
|
||||
KDColor workingBuffer[k_dotSize * k_dotSize];
|
||||
|
||||
KDRect frame(width - k_dotSize, heightCenter - halfHeight, k_dotSize, k_dotSize);
|
||||
ctx->blendRectWithMask(
|
||||
frame,
|
||||
m_state ? Palette::YellowDark : Palette::GrayDark,
|
||||
m_state ? reinterpret_cast<const uint8_t *>(MediumDotMask) : reinterpret_cast<const uint8_t *>(MediumShallowDotMask),
|
||||
workingBuffer);
|
||||
}
|
||||
Reference in New Issue
Block a user