Skip to content

Commit 9f95e57

Browse files
authored
Merge pull request #13 from tixlegeek/tixlegeek-draw-continuously
Tixlegeek draw continuously
2 parents 2a5be23 + fc5a862 commit 9f95e57

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

401lightMessengerApp/401LightMsg_bmp_editor.c

+29-6
Original file line numberDiff line numberDiff line change
@@ -212,31 +212,50 @@ static bool bmp_editor_select_size_input_callback(InputEvent* input_event, void*
212212
static bool bmp_editor_draw_input_callback(InputEvent* input_event, void* ctx) {
213213
AppContext* app = (AppContext*)ctx;
214214
AppBmpEditor* BmpEditor = app->sceneBmpEditor;
215-
215+
bmpEditorData* BmpEditorData = BmpEditor->model_data;
216216
bool consumed = false;
217217
BMP_err res = BMP_OK;
218-
if((input_event->type == InputTypePress) || (input_event->type == InputTypeRepeat)) {
218+
if((input_event->type == InputTypePress) || (input_event->type == InputTypeRepeat) ||
219+
(input_event->type == InputTypeLong)) {
219220
switch(input_event->key) {
220221
case InputKeyUp:
221222
bmp_editor_move(BmpEditor, 0, -1);
223+
if(BmpEditorData->draw_mode == BmpEditorDrawModeContinuous) {
224+
bmp_editor_toggle(BmpEditor);
225+
}
222226
consumed = true;
223227
break;
224228
case InputKeyDown:
225229
bmp_editor_move(BmpEditor, 0, 1);
230+
if(BmpEditorData->draw_mode == BmpEditorDrawModeContinuous) {
231+
bmp_editor_toggle(BmpEditor);
232+
}
226233
consumed = true;
227234
break;
228235
case InputKeyLeft:
229236
bmp_editor_move(BmpEditor, -1, 0);
230-
bmp_compute_model(BmpEditor, BmpEditor->model_data);
237+
if(BmpEditorData->draw_mode == BmpEditorDrawModeContinuous) {
238+
bmp_editor_toggle(BmpEditor);
239+
}
231240
consumed = true;
232241
break;
233242
case InputKeyRight:
234243
bmp_editor_move(BmpEditor, 1, 0);
235-
bmp_compute_model(BmpEditor, BmpEditor->model_data);
244+
if(BmpEditorData->draw_mode == BmpEditorDrawModeContinuous) {
245+
bmp_editor_toggle(BmpEditor);
246+
}
236247
consumed = true;
237248
break;
238249
case InputKeyOk:
239-
bmp_editor_toggle(BmpEditor);
250+
if(input_event->type == InputTypeLong) {
251+
BmpEditorData->draw_mode = (BmpEditorData->draw_mode == BmpEditorDrawModeOneshot) ?
252+
BmpEditorDrawModeContinuous :
253+
BmpEditorDrawModeOneshot;
254+
} else {
255+
if(BmpEditorData->draw_mode == BmpEditorDrawModeOneshot) {
256+
bmp_editor_toggle(BmpEditor);
257+
}
258+
}
240259
consumed = false;
241260
break;
242261
case InputKeyBack:
@@ -361,8 +380,12 @@ static void bmp_editor_drawBoard(Canvas* canvas, void* ctx) {
361380
canvas_draw_str(canvas, 25 + 10, 62, "Save");
362381
canvas_draw_icon(canvas, 25 + 35, 56, &I_btn_ok_7x7);
363382
canvas_draw_str(canvas, 25 + 45, 62, "Toggle");
364-
383+
// Indicates continuous mode
365384
canvas_set_font(canvas, FontPrimary);
385+
if(BmpEditorData->draw_mode == BmpEditorDrawModeContinuous) {
386+
canvas_draw_str(canvas, 0, 62, "C");
387+
;
388+
}
366389
// Bitmap
367390
for(x = 0; x < BmpEditorData->bmp_w; x++) {
368391
for(y = 0; y < BmpEditorData->bmp_h; y++) {

401lightMessengerApp/401LightMsg_bmp_editor.h

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ typedef enum {
5353
BmpEditorMainmenuIndex_Open,
5454
} BmpEditorMainmenuIndex;
5555

56+
typedef enum {
57+
BmpEditorDrawModeOneshot,
58+
BmpEditorDrawModeContinuous,
59+
} BmpEditorDrawMode;
60+
5661
typedef struct {
5762
bmpEditorCursor cursor;
5863
uint8_t bmp_pixel_size;
@@ -67,6 +72,7 @@ typedef struct {
6772
uint8_t* bmp_canvas;
6873
bitmapMatrix* bitmap;
6974
bmpEditorState state;
75+
BmpEditorDrawMode draw_mode;
7076
l401_err error;
7177
} bmpEditorData;
7278

0 commit comments

Comments
 (0)