From 613191e9e603fe8d1472016c34802156bf308f9f Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Wed, 12 Jun 2019 22:54:25 +0200 Subject: Sort-of working --- src/colorpicker.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/colorpicker.cpp') diff --git a/src/colorpicker.cpp b/src/colorpicker.cpp index f0eb2ea..0a2ac77 100644 --- a/src/colorpicker.cpp +++ b/src/colorpicker.cpp @@ -4,6 +4,9 @@ colorpicker::colorpicker() { setSize(32,17); + + currentFG = _COL_WHITE; + currentBG = _COL_BLACK; update(); } colorpicker::~colorpicker() @@ -13,7 +16,14 @@ colorpicker::~colorpicker() void colorpicker::onClick(sPos _pos, unsigned int _button) { + uint8_t color = (16*_pos.y + _pos.x/2); + if ((_button & 0x03) == 0) + currentFG = color; + else if ((_button & 0x03) == 2) + currentBG = color; + + update(); } uint16_t colorpicker::getColor() @@ -30,7 +40,10 @@ void colorpicker::update() } } - char text[17]; - snprintf(text, 16,"asdf"); + char text[33]; + snprintf(text, 32, "FG/BG"); drawText(text, {0,16}, _COL_WHITE_BG | _COL_BLACK); + + drawText(" ", {7,16}, _COL_WHITE | currentFG << 8 ); + drawText(" ", {10,16}, _COL_WHITE | currentBG << 8 ); } -- cgit v1.2.3