From 3252ff90785458e093e464814abbf2b92e608c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 27 Feb 2017 12:59:12 +0100 Subject: [PATCH] [apps/shared] Create an OK view Change-Id: I516e4df9ef6f37a356ee42c2c9d34582905ab4cb --- apps/shared/Makefile | 1 + apps/shared/ok_view.cpp | 42 +++++++++++++++++++++++++++++++++++++++++ apps/shared/ok_view.h | 19 +++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 apps/shared/ok_view.cpp create mode 100644 apps/shared/ok_view.h diff --git a/apps/shared/Makefile b/apps/shared/Makefile index 8d78c295b..69ff00d24 100644 --- a/apps/shared/Makefile +++ b/apps/shared/Makefile @@ -24,6 +24,7 @@ app_objs += $(addprefix apps/shared/,\ list_parameter_controller.o\ memoized_curve_view_range.o\ new_function_cell.o\ + ok_view.o\ range_parameter_controller.o\ store_controller.o\ store_parameter_controller.o\ diff --git a/apps/shared/ok_view.cpp b/apps/shared/ok_view.cpp new file mode 100644 index 000000000..4773a2389 --- /dev/null +++ b/apps/shared/ok_view.cpp @@ -0,0 +1,42 @@ +#include "ok_view.h" + +namespace Shared { + +const uint8_t okMask[OkView::k_okSize][OkView::k_okSize] = { + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, + {0xFF, 0xFF, 0xFF, 0xFF, 0x0C, 0x45, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x45, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF}, + {0xFF, 0xFF, 0xE1, 0x0C, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, 0x0C, 0xE1, 0xFF, 0xFF}, + {0xFF, 0xFF, 0x0C, 0xFF,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View::k_okSize*OkView::k_okSize]; + +void OkView::drawRect(KDContext * ctx, KDRect rect) const { + KDCoordinate width = bounds().width(); + KDCoordinate height = bounds().height(); + KDRect frame((width-k_okSize)/2, (height-k_okSize)/2, k_okSize, k_okSize); + ctx->blendRectWithMask(frame, KDColorBlack, (const uint8_t *)okMask, s_okWorkingBuffer); +} + +KDSize OkView::minimalSizeForOptimalDisplay() { + return KDSize(k_okSize, k_okSize); +} + +} + diff --git a/apps/shared/ok_view.h b/apps/shared/ok_view.h new file mode 100644 index 000000000..e3d354394 --- /dev/null +++ b/apps/shared/ok_view.h @@ -0,0 +1,19 @@ +#ifndef SHARED_OK_VIEW_H +#define SHARED_OK_VIEW_H + +#include + +namespace Shared { + +class OkView : public View { +public: + using View::View; + void drawRect(KDContext * ctx, KDRect rect) const override; + KDSize minimalSizeForOptimalDisplay() override; + constexpr static KDCoordinate k_okSize = 20; +}; + +} + +#endif +