mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] Shared: create a round cursor view
This commit is contained in:
committed by
EmilieNumworks
parent
95f0efaf9f
commit
b38fda1a1e
@@ -35,6 +35,7 @@ app_objs += $(addprefix apps/shared/,\
|
||||
parameter_text_field_delegate.o\
|
||||
range_parameter_controller.o\
|
||||
regular_table_view_data_source.o\
|
||||
round_cursor_view.o\
|
||||
simple_interactive_curve_view_controller.o\
|
||||
store_controller.o\
|
||||
store_parameter_controller.o\
|
||||
|
||||
39
apps/shared/round_cursor_view.cpp
Normal file
39
apps/shared/round_cursor_view.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "round_cursor_view.h"
|
||||
|
||||
namespace Shared {
|
||||
|
||||
RoundCursorView::RoundCursorView() :
|
||||
m_color(KDColorBlack)
|
||||
{
|
||||
}
|
||||
|
||||
static constexpr KDCoordinate cursorSize = 10;
|
||||
static const uint8_t cursorMask[cursorSize][cursorSize] = {
|
||||
{0xFF, 0xFF, 0xFF, 0xED, 0xB6, 0xB6, 0xED, 0xFF, 0xFF, 0xFF},
|
||||
{0xFF, 0xFF, 0x7C, 0x06, 0x00, 0x00, 0x06, 0x7C, 0xFF, 0xFF},
|
||||
{0xFF, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xFF},
|
||||
{0xED, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE5},
|
||||
{0xB6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB6},
|
||||
{0xB6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB6},
|
||||
{0xED, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE5},
|
||||
{0xFF, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xFF},
|
||||
{0xFF, 0xFF, 0x7C, 0x06, 0x00, 0x00, 0x06, 0x7C, 0xFF, 0xFF},
|
||||
{0xFF, 0xFF, 0xFF, 0xED, 0xB6, 0xB6, 0xED, 0xFF, 0xFF, 0xFF},
|
||||
};
|
||||
|
||||
static KDColor s_cursorWorkingBuffer[cursorSize*cursorSize];
|
||||
|
||||
void RoundCursorView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->blendRectWithMask(bounds(), m_color, (const uint8_t *)cursorMask, s_cursorWorkingBuffer);
|
||||
}
|
||||
|
||||
KDSize RoundCursorView::minimalSizeForOptimalDisplay() const {
|
||||
return KDSize(cursorSize, cursorSize);
|
||||
}
|
||||
|
||||
void RoundCursorView::setColor(KDColor color) {
|
||||
m_color = color;
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
|
||||
}
|
||||
20
apps/shared/round_cursor_view.h
Normal file
20
apps/shared/round_cursor_view.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef SHARED_ROUND_CURSOR_VIEW_H
|
||||
#define SHARED_ROUND_CURSOR_VIEW_H
|
||||
|
||||
#include <escher.h>
|
||||
|
||||
namespace Shared {
|
||||
|
||||
class RoundCursorView : public View {
|
||||
public:
|
||||
RoundCursorView();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
void setColor(KDColor color);
|
||||
private:
|
||||
KDColor m_color;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user