mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
Text Box: fix displaying text with end text focus (#3658)
* text box: fix reset text offset state after initial text iteration * debug: add tests for text box view debug app * hal: flash: removed redundant #else Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
@@ -18,6 +18,33 @@ static const TextBoxViewTestContent text_box_view_test_content_arr[] = {
|
||||
.focus = TextBoxFocusStart,
|
||||
.text = "Hello, let's test text box. Press Right and Left to switch content",
|
||||
},
|
||||
{
|
||||
.font = TextBoxFontText,
|
||||
.focus = TextBoxFocusEnd,
|
||||
.text = "First test to add dynamically lines with EndFocus set\nLine 0",
|
||||
},
|
||||
{
|
||||
.font = TextBoxFontText,
|
||||
.focus = TextBoxFocusEnd,
|
||||
.text = "First test to add dynamically lines with EndFocus set\nLine 0\nLine 1",
|
||||
},
|
||||
{
|
||||
.font = TextBoxFontText,
|
||||
.focus = TextBoxFocusEnd,
|
||||
.text = "First test to add dynamically lines with EndFocus set\nLine 0\nLine 1\nLine 2",
|
||||
},
|
||||
{
|
||||
.font = TextBoxFontText,
|
||||
.focus = TextBoxFocusEnd,
|
||||
.text =
|
||||
"First test to add dynamically lines with EndFocus set\nLine 0\nLine 1\nLine 2\nLine 3",
|
||||
},
|
||||
{
|
||||
.font = TextBoxFontText,
|
||||
.focus = TextBoxFocusEnd,
|
||||
.text =
|
||||
"First test to add dynamically lines with EndFocus set\nLine 0\nLine 1\nLine 2\nLine 3\nLine 4",
|
||||
},
|
||||
{
|
||||
.font = TextBoxFontText,
|
||||
.focus = TextBoxFocusStart,
|
||||
@@ -57,7 +84,8 @@ typedef struct {
|
||||
} TextBoxViewTest;
|
||||
|
||||
static void text_box_update_view(TextBoxViewTest* instance) {
|
||||
text_box_reset(instance->text_box);
|
||||
// Intentional incorrect way to reset text box to verify that state resets if text changes
|
||||
text_box_set_text(instance->text_box, "");
|
||||
|
||||
const TextBoxViewTestContent* content =
|
||||
&text_box_view_test_content_arr[instance->current_content_i];
|
||||
|
||||
@@ -227,14 +227,13 @@ static void text_box_prepare_model(Canvas* canvas, TextBoxModel* model) {
|
||||
text_box_seek_next_line(canvas, model);
|
||||
lines_num++;
|
||||
} while(!text_box_end_of_text_reached(model));
|
||||
model->text_offset = 0;
|
||||
lines_num++;
|
||||
|
||||
if(model->focus == TextBoxFocusEnd) {
|
||||
if(lines_num > model->lines_on_screen) {
|
||||
model->text_offset = window_offset[(lines_num - 1) % model->lines_on_screen];
|
||||
}
|
||||
} else {
|
||||
model->text_offset = 0;
|
||||
}
|
||||
|
||||
if(lines_num > model->lines_on_screen) {
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#ifdef FLASH_OP_DEBUG
|
||||
#undef FURI_LOG_T
|
||||
#define FURI_LOG_T(...)
|
||||
#else
|
||||
#endif
|
||||
|
||||
#define FURI_HAL_CRITICAL_MSG "Critical flash operation fail"
|
||||
|
||||
Reference in New Issue
Block a user