diff options
-rw-r--r-- | src/colorpicker.cpp | 17 | ||||
-rw-r--r-- | src/editor.cpp | 11 | ||||
-rw-r--r-- | src/editor.h | 5 | ||||
-rw-r--r-- | src/main.cpp | 10 |
4 files changed, 37 insertions, 6 deletions
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 ); } diff --git a/src/editor.cpp b/src/editor.cpp index f8aafac..cde860b 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -23,6 +23,8 @@ editor::editor(sPos _size) drawPoint('+', {_size.x + 1,0} ,_COL_DEFAULT); drawPoint('+', {0,_size.y + 1} ,_COL_DEFAULT); drawPoint('+', {_size.x + 1,_size.y + 1} ,_COL_DEFAULT); + + update(); } editor::~editor() @@ -92,3 +94,12 @@ void editor::moveCursor(sPos _relMovement) setCursor({currentPosition.x + _relMovement.x, currentPosition.y + _relMovement.y}); } +void editor::accept() +{ + switch (currentMode) { + default: + storage->drawPoint(currentChar, currentPosition, currentColor); + update(); + break; + }; +} diff --git a/src/editor.h b/src/editor.h index 7c5a848..809a8c7 100644 --- a/src/editor.h +++ b/src/editor.h @@ -5,6 +5,9 @@ #include <stdint.h> +#define _MODE_STD 0 +#define _MODE_LINE 1 + class editor : public cObject { public: @@ -21,6 +24,8 @@ public: void setMode(uint8_t _mode); + void accept(); + void update(); private: sPos currentPosition; diff --git a/src/main.cpp b/src/main.cpp index b6be560..fb094c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,14 +49,14 @@ int main() { };//switch }//if else if ( ie.type == _EVENT_MOUSE ) { - if ( ie.b == 0 ) - handler.clickEvent({ie.x, ie.y}, 0); + handler.clickEvent({ie.x, ie.y}, ie.b); }// if else if ( ie.type == _EVENT_CHAR ) { switch ( ie.c ) { - case 'w': + case 0x0D: //return + edit.accept(); break; case 's': break; @@ -67,7 +67,7 @@ int main() { render.enableDebugInfo(false); break; default: - handler.charEvent( ie.c ); + edit.setChar( ie.c ); };//switch }//if else if ( ie.type == _EVENT_TERM ) { @@ -75,6 +75,8 @@ int main() { }//if }//if + edit.setColor( pick.getColor() ); + handler.write(); render.render(); } |