[FL-1234] Keyboards redesign (#501)

* text input: keyboard redesign,; input: tune repeat keypress timing; archive: fix max string width when scrollbar is shown

* byte input: redesign

* byte/text input: long press back to activate backspace added

* archive: pass absolute path to app

* format sources

* better keyboard timings

Co-authored-by: SG <who.just.the.doctor@gmail.com>
This commit is contained in:
its your bedtime
2021-06-02 15:51:05 +03:00
committed by GitHub
parent 7f16c9fe5a
commit d5df0483a3
5 changed files with 96 additions and 38 deletions

View File

@@ -150,10 +150,13 @@ static char byte_input_get_nibble_text(uint8_t byte, bool high_nibble) {
* @param model
*/
static void byte_input_draw_input(Canvas* canvas, ByteInputModel* model) {
const uint8_t text_x = 3;
const uint8_t text_x = 8;
const uint8_t text_y = 25;
elements_slightly_rounded_frame(canvas, 1, 14, 126, 15);
elements_slightly_rounded_frame(canvas, 6, 14, 116, 15);
canvas_draw_icon_name(canvas, 2, 19, I_ButtonLeftSmall_3x5);
canvas_draw_icon_name(canvas, 123, 19, I_ButtonRightSmall_3x5);
for(uint8_t i = model->first_visible_byte;
i < model->first_visible_byte + MIN(model->bytes_count, max_drawable_bytes);
@@ -234,12 +237,15 @@ static void byte_input_draw_input(Canvas* canvas, ByteInputModel* model) {
* @param model
*/
static void byte_input_draw_input_selected(Canvas* canvas, ByteInputModel* model) {
const uint8_t text_x = 3;
const uint8_t text_x = 7;
const uint8_t text_y = 25;
canvas_draw_box(canvas, 0, 12, 128, 19);
canvas_draw_box(canvas, 0, 12, 127, 19);
canvas_invert_color(canvas);
elements_slightly_rounded_frame(canvas, 1, 14, 126, 15);
elements_slightly_rounded_frame(canvas, 6, 14, 115, 15);
canvas_draw_icon_name(canvas, 2, 19, I_ButtonLeftSmall_3x5);
canvas_draw_icon_name(canvas, 122, 19, I_ButtonRightSmall_3x5);
for(uint8_t i = model->first_visible_byte;
i < model->first_visible_byte + MIN(model->bytes_count, max_drawable_bytes);
@@ -247,7 +253,7 @@ static void byte_input_draw_input_selected(Canvas* canvas, ByteInputModel* model
uint8_t byte_position = i - model->first_visible_byte;
if(i == model->selected_byte) {
canvas_draw_box(canvas, text_x + byte_position * 14, text_y - 9, 15, 11);
canvas_draw_box(canvas, text_x + 1 + byte_position * 14, text_y - 9, 13, 11);
canvas_invert_color(canvas);
canvas_draw_glyph(
canvas,
@@ -406,6 +412,17 @@ static void byte_input_call_changed_callback(ByteInputModel* model) {
}
}
/**
* @brief Clear selected byte
*/
static void byte_input_clear_selected_byte(ByteInputModel* model) {
model->bytes[model->selected_byte] = 0;
model->selected_high_nibble = true;
byte_input_dec_selected_byte(model);
byte_input_call_changed_callback(model);
}
/**
* @brief Handle up button
*
@@ -478,10 +495,7 @@ static void byte_input_handle_ok(ByteInputModel* model) {
if(value == enter_symbol) {
byte_input_call_input_callback(model);
} else if(value == backspace_symbol) {
model->bytes[model->selected_byte] = 0;
model->selected_high_nibble = true;
byte_input_dec_selected_byte(model);
byte_input_call_changed_callback(model);
byte_input_clear_selected_byte(model);
} else {
byte_input_set_nibble(
model->bytes, model->selected_byte, value, model->selected_high_nibble);
@@ -647,6 +661,16 @@ static bool byte_input_view_input_callback(InputEvent* event, void* context) {
}
}
if((event->type == InputTypeLong || event->type == InputTypeRepeat) &&
event->key == InputKeyBack) {
with_view_model(
byte_input->view, (ByteInputModel * model) {
byte_input_clear_selected_byte(model);
return true;
});
consumed = true;
}
return consumed;
}