mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-07 19:01:54 -07:00
JS: Widget icons without path, just name
This commit is contained in:
@@ -34,8 +34,8 @@ widget.addDot(102, 44);
|
||||
widget.addDot(104, 43);
|
||||
|
||||
// add an icon (x, y, icon)
|
||||
widget.addIcon(100, 55, "Common/ButtonUp_7x4");
|
||||
widget.addIcon(100, 60, "Common/ButtonDown_7x4");
|
||||
widget.addIcon(100, 50, "ButtonUp_7x4");
|
||||
widget.addIcon(100, 55, "ButtonDown_7x4");
|
||||
|
||||
// add a glyph (x, y, glyph)
|
||||
widget.addGlyph(120, 50, 0x23);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <gui/view.h>
|
||||
#include <m-array.h>
|
||||
#include <m-list.h>
|
||||
#include <string.h>
|
||||
#include "../js_modules.h"
|
||||
|
||||
typedef struct WidgetComponent WidgetComponent;
|
||||
@@ -505,8 +506,11 @@ static void js_widget_add_icon(struct mjs* mjs) {
|
||||
|
||||
const Icon* icon = NULL;
|
||||
for(size_t i = 0; i < ICON_PATHS_COUNT; i++) {
|
||||
if(ICON_PATHS[i].path != NULL && strnlen(ICON_PATHS[i].path, icon_len + 2) == icon_len &&
|
||||
strncmp(icon_name, ICON_PATHS[i].path, icon_len) == 0) {
|
||||
if(ICON_PATHS[i].path == NULL) continue;
|
||||
const char* iter_name = strrchr(ICON_PATHS[i].path, '/');
|
||||
if(iter_name++ == NULL) continue;
|
||||
if(strnlen(iter_name, icon_len + 1) == icon_len &&
|
||||
strncmp(iter_name, icon_name, icon_len) == 0) {
|
||||
icon = ICON_PATHS[i].icon;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user