[FL-1472] Infrared: long names fix (#679)
* Infrared app: fix long button names * Ble: fix missing icon on start without config. * Gui: slow but nice string fitting. * Gui: fit header string in button menu Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
420c03bb58
commit
ae08c88bd6
@ -48,11 +48,11 @@ int32_t bt_srv() {
|
|||||||
furi_record_create("bt", bt);
|
furi_record_create("bt", bt);
|
||||||
furi_hal_bt_init();
|
furi_hal_bt_init();
|
||||||
|
|
||||||
if(bt->bt_settings.enabled) {
|
|
||||||
if(!furi_hal_bt_wait_startup()) {
|
if(!furi_hal_bt_wait_startup()) {
|
||||||
FURI_LOG_E(BT_SERVICE_TAG, "Core2 startup failed");
|
FURI_LOG_E(BT_SERVICE_TAG, "Core2 startup failed");
|
||||||
} else {
|
} else {
|
||||||
view_port_enabled_set(bt->statusbar_view_port, true);
|
view_port_enabled_set(bt->statusbar_view_port, true);
|
||||||
|
if(bt->bt_settings.enabled) {
|
||||||
bool bt_app_started = furi_hal_bt_start_app();
|
bool bt_app_started = furi_hal_bt_start_app();
|
||||||
if(!bt_app_started) {
|
if(!bt_app_started) {
|
||||||
FURI_LOG_E(BT_SERVICE_TAG, "BT App start failed");
|
FURI_LOG_E(BT_SERVICE_TAG, "BT App start failed");
|
||||||
|
@ -332,12 +332,12 @@ void elements_string_fit_width(Canvas* canvas, string_t string, uint8_t width) {
|
|||||||
furi_assert(string);
|
furi_assert(string);
|
||||||
|
|
||||||
uint16_t len_px = canvas_string_width(canvas, string_get_cstr(string));
|
uint16_t len_px = canvas_string_width(canvas, string_get_cstr(string));
|
||||||
|
|
||||||
if(len_px > width) {
|
if(len_px > width) {
|
||||||
size_t s_len = string_size(string);
|
width -= canvas_string_width(canvas, "...");
|
||||||
uint8_t end_pos = s_len - ((len_px - width) / ((len_px / s_len) + 2) + 2);
|
do {
|
||||||
|
string_left(string, string_size(string) - 1);
|
||||||
string_mid(string, 0, end_pos);
|
len_px = canvas_string_width(canvas, string_get_cstr(string));
|
||||||
|
} while(len_px > width);
|
||||||
string_cat(string, "...");
|
string_cat(string, "...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,13 +78,20 @@ static void button_menu_draw_common_button(
|
|||||||
} else {
|
} else {
|
||||||
canvas_draw_rframe(canvas, item_x, item_y, ITEM_WIDTH, ITEM_HEIGHT, 5);
|
canvas_draw_rframe(canvas, item_x, item_y, ITEM_WIDTH, ITEM_HEIGHT, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string_t disp_str;
|
||||||
|
string_init_set_str(disp_str, text);
|
||||||
|
elements_string_fit_width(canvas, disp_str, ITEM_WIDTH - 6);
|
||||||
|
|
||||||
canvas_draw_str_aligned(
|
canvas_draw_str_aligned(
|
||||||
canvas,
|
canvas,
|
||||||
item_x + (ITEM_WIDTH / 2),
|
item_x + (ITEM_WIDTH / 2),
|
||||||
item_y + (ITEM_HEIGHT / 2),
|
item_y + (ITEM_HEIGHT / 2),
|
||||||
AlignCenter,
|
AlignCenter,
|
||||||
AlignCenter,
|
AlignCenter,
|
||||||
text);
|
string_get_cstr(disp_str));
|
||||||
|
|
||||||
|
string_clear(disp_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void button_menu_view_draw_callback(Canvas* canvas, void* _model) {
|
static void button_menu_view_draw_callback(Canvas* canvas, void* _model) {
|
||||||
@ -110,7 +117,11 @@ static void button_menu_view_draw_callback(Canvas* canvas, void* _model) {
|
|||||||
canvas_draw_icon(canvas, 28, 123, &I_IrdaArrowDown_4x8);
|
canvas_draw_icon(canvas, 28, 123, &I_IrdaArrowDown_4x8);
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas_draw_str_aligned(canvas, 32, 10, AlignCenter, AlignCenter, model->header);
|
string_t disp_str;
|
||||||
|
string_init_set_str(disp_str, model->header);
|
||||||
|
elements_string_fit_width(canvas, disp_str, ITEM_WIDTH - 6);
|
||||||
|
canvas_draw_str_aligned(canvas, 32, 10, AlignCenter, AlignCenter, string_get_cstr(disp_str));
|
||||||
|
string_clear(disp_str);
|
||||||
|
|
||||||
for(ButtonMenuItemArray_it(it, model->items); !ButtonMenuItemArray_end_p(it);
|
for(ButtonMenuItemArray_it(it, model->items); !ButtonMenuItemArray_end_p(it);
|
||||||
ButtonMenuItemArray_next(it), ++item_position) {
|
ButtonMenuItemArray_next(it), ++item_position) {
|
||||||
|
@ -65,11 +65,18 @@ static void submenu_view_draw_callback(Canvas* canvas, void* _model) {
|
|||||||
} else {
|
} else {
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string_t disp_str;
|
||||||
|
string_init_set_str(disp_str, SubmenuItemArray_cref(it)->label);
|
||||||
|
elements_string_fit_width(canvas, disp_str, item_width - 20);
|
||||||
|
|
||||||
canvas_draw_str(
|
canvas_draw_str(
|
||||||
canvas,
|
canvas,
|
||||||
6,
|
6,
|
||||||
y_offset + (item_position * item_height) + item_height - 4,
|
y_offset + (item_position * item_height) + item_height - 4,
|
||||||
SubmenuItemArray_cref(it)->label);
|
string_get_cstr(disp_str));
|
||||||
|
|
||||||
|
string_clear(disp_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
position++;
|
position++;
|
||||||
|
@ -47,8 +47,8 @@ class IrdaAppRemoteManager {
|
|||||||
std::string make_remote_name(const std::string& full_name) const;
|
std::string make_remote_name(const std::string& full_name) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static inline const uint32_t max_button_name_length = 31;
|
static inline const uint32_t max_button_name_length = 22;
|
||||||
static inline const uint32_t max_remote_name_length = 31;
|
static inline const uint32_t max_remote_name_length = 22;
|
||||||
bool add_remote_with_button(const char* button_name, const IrdaAppSignal& signal);
|
bool add_remote_with_button(const char* button_name, const IrdaAppSignal& signal);
|
||||||
bool add_button(const char* button_name, const IrdaAppSignal& signal);
|
bool add_button(const char* button_name, const IrdaAppSignal& signal);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user