mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-20 04:54:45 -07:00
GUI: Add marquee 'Text Scroll' option (#363)
* GUI: Add marquee 'Text Scroll' option - Adds the tiny `Text Scroll` option under `MNTM > Interface > General` to either use the standard scroll, or a new marquee style back and forth on any scrollable text. - `elements_scrollable_text_line_centered` renamed to `elements_scrollable_text_line_ex` to be more general. Has `bool marquee`. * Unnecessary switch here * Apply setting internally * Revert a few usages * Update changelog * Last thing --------- Co-authored-by: Willy-JL <49810075+Willy-JL@users.noreply.github.com>
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
- OFW: NFC: Disney Infinity KDF plugin (by @bettse)
|
- OFW: NFC: Disney Infinity KDF plugin (by @bettse)
|
||||||
- Archive: Add item count to directory info scene (#378 by @956MB)
|
- Archive: Add item count to directory info scene (#378 by @956MB)
|
||||||
- Clock: 12 hour "midnight format" in Momentum Settings (#341 by @956MB)
|
- Clock: 12 hour "midnight format" in Momentum Settings (#341 by @956MB)
|
||||||
|
- GUI: Add marquee 'Text Scroll' option in Momentum Settings (#363 by @956MB)
|
||||||
- UL: Input: Vibro on Button press option (by @Dmitry422)
|
- UL: Input: Vibro on Button press option (by @Dmitry422)
|
||||||
- Desktop:
|
- Desktop:
|
||||||
- UL: Option to prevent Auto Lock when connected to USB/RPC (by @Dmitry422)
|
- UL: Option to prevent Auto Lock when connected to USB/RPC (by @Dmitry422)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "../momentum_app.h"
|
#include "../momentum_app.h"
|
||||||
|
|
||||||
enum VarItemListIndex {
|
enum VarItemListIndex {
|
||||||
|
VarItemListIndexScrollType,
|
||||||
VarItemListIndexMidnightFormat,
|
VarItemListIndexMidnightFormat,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -9,6 +10,14 @@ void momentum_app_scene_interface_general_var_item_list_callback(void* context,
|
|||||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void momentum_app_scene_interface_general_scroll_marquee_changed(VariableItem* item) {
|
||||||
|
MomentumApp* app = variable_item_get_context(item);
|
||||||
|
bool value = variable_item_get_current_value_index(item);
|
||||||
|
variable_item_set_current_value_text(item, value ? "Marquee" : "Standard");
|
||||||
|
momentum_settings.scroll_marquee = value;
|
||||||
|
app->save_settings = true;
|
||||||
|
}
|
||||||
|
|
||||||
static void momentum_app_scene_interface_general_midnight_format_changed(VariableItem* item) {
|
static void momentum_app_scene_interface_general_midnight_format_changed(VariableItem* item) {
|
||||||
MomentumApp* app = variable_item_get_context(item);
|
MomentumApp* app = variable_item_get_context(item);
|
||||||
bool value = variable_item_get_current_value_index(item);
|
bool value = variable_item_get_current_value_index(item);
|
||||||
@@ -22,6 +31,16 @@ void momentum_app_scene_interface_general_on_enter(void* context) {
|
|||||||
VariableItemList* var_item_list = app->var_item_list;
|
VariableItemList* var_item_list = app->var_item_list;
|
||||||
VariableItem* item;
|
VariableItem* item;
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
var_item_list,
|
||||||
|
"Text Scroll",
|
||||||
|
2,
|
||||||
|
momentum_app_scene_interface_general_scroll_marquee_changed,
|
||||||
|
app);
|
||||||
|
variable_item_set_current_value_index(item, momentum_settings.scroll_marquee);
|
||||||
|
variable_item_set_current_value_text(
|
||||||
|
item, momentum_settings.scroll_marquee ? "Marquee" : "Standard");
|
||||||
|
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
var_item_list,
|
var_item_list,
|
||||||
"Clock Midnight Format",
|
"Clock Midnight Format",
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <momentum/settings.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t x;
|
int32_t x;
|
||||||
int32_t y;
|
int32_t y;
|
||||||
@@ -698,8 +700,9 @@ void elements_scrollable_text_line_centered(
|
|||||||
FuriString* line = furi_string_alloc_set(string);
|
FuriString* line = furi_string_alloc_set(string);
|
||||||
|
|
||||||
size_t len_px = canvas_string_width(canvas, furi_string_get_cstr(line));
|
size_t len_px = canvas_string_width(canvas, furi_string_get_cstr(line));
|
||||||
|
bool marquee = momentum_settings.scroll_marquee;
|
||||||
if(len_px > width) {
|
if(len_px > width) {
|
||||||
if(centered) {
|
if(centered && !marquee) {
|
||||||
centered = false;
|
centered = false;
|
||||||
x -= width / 2;
|
x -= width / 2;
|
||||||
}
|
}
|
||||||
@@ -717,12 +720,32 @@ void elements_scrollable_text_line_centered(
|
|||||||
scroll_size--;
|
scroll_size--;
|
||||||
if(!scroll_size) break;
|
if(!scroll_size) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that we have something to scroll
|
// Ensure that we have something to scroll
|
||||||
if(scroll_size) {
|
if(scroll_size) {
|
||||||
|
if(marquee) {
|
||||||
|
const size_t delay = 3; // positions before/after scroll to delay
|
||||||
|
size_t total_scroll = (scroll_size * 2) + (delay * 2);
|
||||||
|
size_t use_scroll = scroll % total_scroll;
|
||||||
|
|
||||||
|
if(use_scroll < scroll_size) {
|
||||||
|
furi_string_right(line, use_scroll);
|
||||||
|
} else if(use_scroll < (scroll_size + delay)) {
|
||||||
|
// Delay right
|
||||||
|
furi_string_right(line, scroll_size);
|
||||||
|
} else if(use_scroll < (scroll_size * 2 + delay)) {
|
||||||
|
size_t reverse_pos = scroll_size - (use_scroll - (scroll_size + delay));
|
||||||
|
furi_string_right(line, reverse_pos);
|
||||||
|
} else {
|
||||||
|
// Delay left
|
||||||
|
furi_string_right(line, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
scroll_size += 3;
|
scroll_size += 3;
|
||||||
scroll = scroll % scroll_size;
|
scroll = scroll % scroll_size;
|
||||||
furi_string_right(line, scroll);
|
furi_string_right(line, scroll);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
len_px = canvas_string_width(canvas, furi_string_get_cstr(line));
|
len_px = canvas_string_width(canvas, furi_string_get_cstr(line));
|
||||||
while(len_px > width) {
|
while(len_px > width) {
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
|
|||||||
canvas,
|
canvas,
|
||||||
pos_x,
|
pos_x,
|
||||||
pos_y - height / 2 - 8,
|
pos_y - height / 2 - 8,
|
||||||
126,
|
124,
|
||||||
name,
|
name,
|
||||||
scroll_counter,
|
scroll_counter,
|
||||||
false,
|
false,
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ MomentumSettings momentum_settings = {
|
|||||||
.show_internal_tab = false, // OFF
|
.show_internal_tab = false, // OFF
|
||||||
.browser_path_mode = BrowserPathOff, // OFF
|
.browser_path_mode = BrowserPathOff, // OFF
|
||||||
.favorite_timeout = 0, // OFF
|
.favorite_timeout = 0, // OFF
|
||||||
|
.scroll_marquee = false, // OFF
|
||||||
.dark_mode = false, // OFF
|
.dark_mode = false, // OFF
|
||||||
.rgb_backlight = false, // OFF
|
.rgb_backlight = false, // OFF
|
||||||
.butthurt_timer = 21600, // 6 H
|
.butthurt_timer = 21600, // 6 H
|
||||||
@@ -103,6 +104,7 @@ static const struct {
|
|||||||
{setting_bool(show_internal_tab)},
|
{setting_bool(show_internal_tab)},
|
||||||
{setting_enum(browser_path_mode, BrowserPathModeCount)},
|
{setting_enum(browser_path_mode, BrowserPathModeCount)},
|
||||||
{setting_uint(favorite_timeout, 0, 60)},
|
{setting_uint(favorite_timeout, 0, 60)},
|
||||||
|
{setting_bool(scroll_marquee)},
|
||||||
{setting_bool(dark_mode)},
|
{setting_bool(dark_mode)},
|
||||||
{setting_bool(rgb_backlight)},
|
{setting_bool(rgb_backlight)},
|
||||||
{setting_uint(butthurt_timer, 0, 172800)},
|
{setting_uint(butthurt_timer, 0, 172800)},
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ typedef struct {
|
|||||||
bool show_internal_tab;
|
bool show_internal_tab;
|
||||||
BrowserPathMode browser_path_mode;
|
BrowserPathMode browser_path_mode;
|
||||||
uint32_t favorite_timeout;
|
uint32_t favorite_timeout;
|
||||||
|
bool scroll_marquee;
|
||||||
bool dark_mode;
|
bool dark_mode;
|
||||||
bool rgb_backlight;
|
bool rgb_backlight;
|
||||||
uint32_t butthurt_timer;
|
uint32_t butthurt_timer;
|
||||||
|
|||||||
Reference in New Issue
Block a user