11e58ade0ab8fe5651497b8d7ee114df3c2a6035 — Gregory Mullen 1 year, 1 month ago f8b3140
clean up music ui
M Makefile => Makefile +1 -1
@@ 52,7 52,7 @@ LIBS   +=  -lffi -ldl -lrt -lpthread -lm
 
 %.o: %.c %.h
 	@# $(CC) -v -g -c $(CFLAGS) $< -o $@
-	@$(CC) -c  $(CFLAGS) $< -o $@
+	$(CC) -c  $(CFLAGS) $< -o $@
 
 
 hudtds: $(OBJ)

M audio_search.c => audio_search.c +4 -3
@@ 37,6 37,7 @@ static struct track_data *track_get(int id)
     return &m_db->track_db.data[id];
 }
 
+
 static struct directory_data *directory_get(int id)
 {
     return &m_db->dir_db.data[id];


@@ 415,9 416,9 @@ void *find_files_thread(void *p)
 
     struct timespec __ts_nanosleep = { .tv_nsec = _10_mSECS };
     const struct track_data *track;
-    uint32_t pos = 0;
-
-    while ((track = track_get(pos++))) {
+    int pos = 0;
+    while (pos < m_db->track_db.count) {
+        track = track_get(pos++);
         metadata_add((struct track_data *)track);
         nanosleep(&__ts_nanosleep, NULL);
     }

M gui/music.c => gui/music.c +16 -17
@@ 52,17 52,16 @@ static bool music_playing_kdn(struct ui_panel *p, const uint32_t key, const uint
 
 
 
-struct music_track_panel music_track_playing = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music entry playing",
-        .draw = draw_music_playing,
-        .k_dn = music_playing_kdn,
-        .pos_x = 0,
-        .pos_y = 0,
-        .height = 60,
-        .touch_focus = true,
-    },
+struct ui_panel music_track_playing = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music entry playing",
+    .draw = draw_music_playing,
+    .k_dn = music_playing_kdn,
+    .pos_x = 0,
+    .pos_y = 0,
+    .height = 60,
+    .touch_focus = true,
+    .order = 0,
 };
 
 


@@ 74,10 73,10 @@ static bool frame_key_down_main(struct ui_panel *panel, const uint32_t key, cons
     switch (key) {
         case MZD_KEYMAP_DPAD_UP: {
             LOG_T("music_frame_keydown dpad up\n");
-            if (music_track_playing.panel.focused == true) {
+            if (music_track_playing.focused == true) {
                 return false;
             } else {
-                music_track_playing.panel.focused = true;
+                music_track_playing.focused = true;
                 music_buttons_frame.focused = false;
                 music_tracks_frame.focused = false;
                 return true;


@@ 89,7 88,7 @@ static bool frame_key_down_main(struct ui_panel *panel, const uint32_t key, cons
                 return false;
             } else {
                 music_tracks_frame.focused = true;
-                music_track_playing.panel.focused = false;
+                music_track_playing.focused = false;
                 music_buttons_frame.focused = false;
                 return true;
             }


@@ 100,7 99,7 @@ static bool frame_key_down_main(struct ui_panel *panel, const uint32_t key, cons
                 return false;
             } else {
                 music_buttons_frame.focused = true;
-                music_track_playing.panel.focused = false;
+                music_track_playing.focused = false;
                 music_tracks_frame.focused = false;
                 return true;
             }


@@ 111,7 110,7 @@ static bool frame_key_down_main(struct ui_panel *panel, const uint32_t key, cons
                 return false;
             } else {
                 music_tracks_frame.focused = true;
-                music_track_playing.panel.focused = false;
+                music_track_playing.focused = false;
                 music_buttons_frame.focused = false;
                 return true;
             }


@@ 133,8 132,8 @@ struct ui_panel music_frame = {
 
     .children = (struct ui_panel*[]) {
         (struct ui_panel*)&music_track_playing,
-        (struct ui_panel*)&music_buttons_frame,
         (struct ui_panel*)&music_tracks_frame,
+        (struct ui_panel*)&music_buttons_frame,
         (struct ui_panel*)&music_artists_frame,
         (struct ui_panel*)&music_albums_frame,
         NULL

M gui/music.h => gui/music.h +0 -7
@@ 9,11 9,4 @@ extern struct ui_panel music_tracks_frame;
 extern struct ui_panel music_artists_frame;
 extern struct ui_panel music_albums_frame;
 
-struct music_track_panel {
-    struct ui_panel panel;
-
-    uint32_t position;
-};
-
-
 #endif // _HUDTDS_GUI_MUSIC_

M gui/music_albums.c => gui/music_albums.c +82 -97
@@ 30,8 30,7 @@ static void draw_music_album(struct ui_panel *p, int32_t x, int32_t y, int32_t w
     h = p->height <= 0 ? h + p->height : y + p->height; \
     draw_square_c(x, y, w, y + p->height, 0xff000000);
 
-    struct music_track *music = (struct music_track *)p;
-    const struct album_data *album = album_pos(music->position);
+    const struct album_data *album = album_pos(p->order);
 
     // LOG_E("Draw music entry (track: %s), %i %i %i %i (%i)\n", music->track_title, x, y, w, h, y + p->height);
     if (music_albums_frame.focused && p->focused) {


@@ 42,102 41,88 @@ static void draw_music_album(struct ui_panel *p, int32_t x, int32_t y, int32_t w
 }
 
 
-struct music_track album_0 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music album_0",
-        .draw = draw_music_album,
-        .pos_x = 0,
-        .pos_y = 0,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 0
+struct ui_panel album_0 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music album_0",
+    .draw = draw_music_album,
+    .pos_x = 0,
+    .pos_y = 0,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 0
 };
 
-struct music_track album_1 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music album_1",
-        .draw = draw_music_album,
-        .pos_x = 0,
-        .pos_y = 40,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 1
+struct ui_panel album_1 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music album_1",
+    .draw = draw_music_album,
+    .pos_x = 0,
+    .pos_y = 40,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 1
 };
 
-struct music_track album_2 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music album_2",
-        .draw = draw_music_album,
-        .pos_x = 0,
-        .pos_y = 80,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 2
+struct ui_panel album_2 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music album_2",
+    .draw = draw_music_album,
+    .pos_x = 0,
+    .pos_y = 80,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 2
 };
 
-struct music_track album_3 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music album_3",
-        .draw = draw_music_album,
-        .pos_x = 0,
-        .pos_y = 120,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 3
+struct ui_panel album_3 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music album_3",
+    .draw = draw_music_album,
+    .pos_x = 0,
+    .pos_y = 120,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 3
 };
 
-struct music_track album_4 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music album_4",
-        .draw = draw_music_album,
-        .pos_x = 0,
-        .pos_y = 160,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 4
+struct ui_panel album_4 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music album_4",
+    .draw = draw_music_album,
+    .pos_x = 0,
+    .pos_y = 160,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 4
 };
 
-struct music_track album_5 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music album_5",
-        .draw = draw_music_album,
-        .pos_x = 0,
-        .pos_y = 200,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 5
+struct ui_panel album_5 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music album_5",
+    .draw = draw_music_album,
+    .pos_x = 0,
+    .pos_y = 200,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 5
 };
 
-struct music_track album_6 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music album_6",
-        .draw = draw_music_album,
-        .pos_x = 0,
-        .pos_y = 240,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 6
+struct ui_panel album_6 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music album_6",
+    .draw = draw_music_album,
+    .pos_x = 0,
+    .pos_y = 240,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 6
 };
 
 


@@ 145,21 130,21 @@ struct music_track album_6 = {
 static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_t s)
 {
     (void) s;
-    struct music_track **children = (struct music_track**)p->children;
+    struct ui_panel **children = (struct ui_panel**)p->children;
 
     if (!children) {
         return false;
     }
-    struct music_track *first = *children, *entry, *prev;
+    struct ui_panel *first = *children, *entry, *prev;
 
     while ((entry = *children++)) {
-        if (entry->panel.focused) {
+        if (entry->focused) {
             switch (key) {
                 case MZD_KEYMAP_ROTATE_LEFT: {
                     if (entry != first) {
                         LOG_T("move to prev\n");
-                        prev->panel.focused = true;
-                        entry->panel.focused = false;
+                        prev->focused = true;
+                        entry->focused = false;
                     } else {
                         LOG_D("already at beginning\n");
                         if (albums_skip) {


@@ 170,9 155,9 @@ static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_
                 }
                 case MZD_KEYMAP_ROTATE_RIGHT: {
                     if (*children) {
-                        LOG_T("move to next %s\n", (*children)->panel.name);
-                        (*children)->panel.focused = true;
-                        entry->panel.focused = false;
+                        LOG_T("move to next %s\n", (*children)->name);
+                        (*children)->focused = true;
+                        entry->focused = false;
                     } else {
                         LOG_D("already at end\n");
                         albums_skip++;


@@ 180,11 165,11 @@ static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_
                     break;
                 }
                 case MZD_KEYMAP_DPAD_CENTER: {
-                    LOG_D("play this one %s\n", entry->panel.name);
+                    LOG_D("play this one %s\n", entry->name);
                     // if (track_get_pos(entry->position)) {
                     //     postmsg_audio(AMSG_PLAY, track_get_pos(entry->position));
                     // } else {
-                    //     LOG_E("No track found here %s\n", entry->panel.name);
+                    //     LOG_E("No track found here %s\n", entry->name);
                     // }
                     break;
                 }


@@ 201,7 186,7 @@ static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_
     }
 
     LOG_D("focus not found\n");
-    first->panel.focused = true;
+    first->focused = true;
     return false;
 }
 

M gui/music_artists.c => gui/music_artists.c +83 -98
@@ 31,8 31,7 @@ static void draw_music_track(struct ui_panel *p, int32_t x, int32_t y, int32_t w
     h = p->height <= 0 ? h + p->height : y + p->height; \
     draw_square_c(x, y, w, y + p->height, 0xff000000);
 
-    struct music_track *music = (struct music_track *)p;
-    const struct artist_data *artist = artist_pos(music->position);
+    const struct artist_data *artist = artist_pos(p->order);
 
     // LOG_E("Draw music entry (track: %s), %i %i %i %i (%i)\n", music->track_title, x, y, w, h, y + p->height);
     if (music_artists_frame.focused && p->focused) {


@@ 43,102 42,88 @@ static void draw_music_track(struct ui_panel *p, int32_t x, int32_t y, int32_t w
 }
 
 
-struct music_track music_artist_0 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music artist_0",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 0,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 0
+struct ui_panel music_artist_0 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music artist_0",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 0,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 0
 };
 
-struct music_track music_artist_1 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music artist_1",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 40,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 1
+struct ui_panel music_artist_1 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music artist_1",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 40,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 1
 };
 
-struct music_track music_artist_2 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music artist_2",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 80,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 2
+struct ui_panel music_artist_2 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music artist_2",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 80,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 2
 };
 
-struct music_track music_artist_3 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music artist_3",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 120,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 3
+struct ui_panel music_artist_3 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music artist_3",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 120,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 3
 };
 
-struct music_track music_artist_4 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music artist_4",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 160,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 4
+struct ui_panel music_artist_4 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music artist_4",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 160,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 4
 };
 
-struct music_track music_artist_5 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music artist_5",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 200,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 5
+struct ui_panel music_artist_5 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music artist_5",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 200,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 5
 };
 
-struct music_track music_artist_6 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music artist_6",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 240,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 6
+struct ui_panel music_artist_6 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music artist_6",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 240,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 6
 };
 
 


@@ 146,21 131,21 @@ struct music_track music_artist_6 = {
 static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_t s)
 {
     (void) s;
-    struct music_track **children = (struct music_track**)p->children;
+    struct ui_panel **children = (struct ui_panel**)p->children;
 
     if (!children) {
         return false;
     }
-    struct music_track *first = *children, *entry, *prev;
+    struct ui_panel *first = *children, *entry, *prev;
 
     while ((entry = *children++)) {
-        if (entry->panel.focused) {
+        if (entry->focused) {
             switch (key) {
                 case MZD_KEYMAP_ROTATE_LEFT: {
                     if (entry != first) {
                         LOG_T("move to prev\n");
-                        prev->panel.focused = true;
-                        entry->panel.focused = false;
+                        prev->focused = true;
+                        entry->focused = false;
                     } else {
                         LOG_D("already at beginning\n");
                         if (artist_skip) {


@@ 171,9 156,9 @@ static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_
                 }
                 case MZD_KEYMAP_ROTATE_RIGHT: {
                     if (*children) {
-                        LOG_T("move to next %s\n", (*children)->panel.name);
-                        (*children)->panel.focused = true;
-                        entry->panel.focused = false;
+                        LOG_T("move to next %s\n", (*children)->name);
+                        (*children)->focused = true;
+                        entry->focused = false;
                     } else {
                         LOG_D("already at end\n");
                         artist_skip++;


@@ 181,13 166,13 @@ static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_
                     break;
                 }
                 case MZD_KEYMAP_DPAD_CENTER: {
-                    LOG_D("play this one %s\n", entry->panel.name);
-                    if (artist_pos(entry->position)) {
+                    LOG_D("play this one %s\n", entry->name);
+                    if (artist_pos(entry->order)) {
                         // Set search value,
                         // reset focus to tracks
                         // postmsg_audio(AMSG_PLAY, artist_pos(entry->position));
                     } else {
-                        LOG_E("No track found here %s\n", entry->panel.name);
+                        LOG_E("No track found here %s\n", entry->name);
                     }
                     break;
                 }


@@ 204,7 189,7 @@ static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_
     }
 
     LOG_D("focus not found\n");
-    first->panel.focused = true;
+    first->focused = true;
     return false;
 }
 

M gui/music_buttons.c => gui/music_buttons.c +11 -13
@@ 149,23 149,21 @@ struct ui_panel music_btn_3 = {
 static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_t s)
 {
     (void) s;
-    (void) key;
-    struct music_track **children = (struct music_track**)p->children;
 
+    struct ui_panel **children = p->children;
     if (!children) {
         return false;
     }
 
-    struct music_track *first = *children, *entry, *prev;
-
+    struct ui_panel *first = *children, *entry, *prev;
     while ((entry = *children++)) {
-        if (entry->panel.focused) {
+        if (entry->focused) {
             switch (key) {
                 case MZD_KEYMAP_ROTATE_LEFT: {
                     if (entry != first) {
                         LOG_T("move to prev\n");
-                        prev->panel.focused = true;
-                        entry->panel.focused = false;
+                        prev->focused = true;
+                        entry->focused = false;
                     } else {
                         LOG_D("already at beginning\n");
                     }


@@ 173,16 171,16 @@ static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_
                 }
                 case MZD_KEYMAP_ROTATE_RIGHT: {
                     if (*children) {
-                        LOG_T("move to next %s\n", (*children)->panel.name);
-                        (*children)->panel.focused = true;
-                        entry->panel.focused = false;
+                        LOG_T("move to next %s\n", (*children)->name);
+                        (*children)->focused = true;
+                        entry->focused = false;
                     } else {
                         LOG_D("already at end\n");
                     }
                     break;
                 }
                 case MZD_KEYMAP_DPAD_CENTER: {
-                    LOG_D("play this one %s\n", entry->panel.name);
+                    LOG_D("play this one %s\n", entry->name);
                     break;
                 }
                 default: {


@@ 198,7 196,7 @@ static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_
     }
 
     LOG_D("focus not found\n");
-    first->panel.focused = true;
+    first->focused = true;
     return false;
 }
 


@@ 206,7 204,7 @@ static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_
 struct ui_panel music_buttons_frame = {
     .type = PANEL_LIST,
     .name = "music entry frame",
-    .pos_x = 0,
+    .pos_x = -80,
     .pos_y = 60,
     .height = -80,
     .k_dn = frame_key_down,

M gui/music_tracks.c => gui/music_tracks.c +91 -103
@@ 66,114 66,101 @@ static void draw_music_track(struct ui_panel *p, int32_t x, int32_t y, int32_t w
     h = p->height <= 0 ? h + p->height : y + p->height; \
     draw_square_c(x, y, w, y + p->height, 0xff000000);
 
-    struct music_track_panel *music = (struct music_track_panel *)p;
-
     // LOG_E("Draw music entry (track: %s), %i %i %i %i (%i)\n", music->track_title, x, y, w, h, y + p->height);
     if (music_tracks_frame.focused && p->focused) {
-        draw_box_c(x, y, w, y + p->height, p->color);
+        draw_box_depth_c(x, y, w, y + p->height, 8, 0xff881010);
+        draw_box_depth_c(x, y, w, y + p->height, 4, 0xff660505);
     }
 
-    const struct track_data *track = track_get_pos(music->position);
-    text_draw_string(entry_text(track), x + 3, y + 3);
+    draw_box_depth_c(x, y, w, y + p->height, 2, 0xff440000);
+
+    const struct track_data *track = track_get_pos(p->order);
+    text_draw_string_width(entry_text(track), x + 8, y + 8, w - 8);
 }
 
 
-struct music_track_panel music_track_0 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music entry_0",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 0,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 0
+struct ui_panel music_track_0 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music entry_0",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 0,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 0,
 };
 
-struct music_track_panel music_track_1 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music entry_1",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 40,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 1
+struct ui_panel music_track_1 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music entry_1",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 40,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 1,
 };
 
-struct music_track_panel music_track_2 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music entry_2",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 80,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 2
+struct ui_panel music_track_2 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music entry_2",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 80,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 2,
 };
 
-struct music_track_panel music_track_3 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music entry_3",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 120,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 3
+struct ui_panel music_track_3 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music entry_3",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 120,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 3,
 };
 
-struct music_track_panel music_track_4 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music entry_4",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 160,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 4
+struct ui_panel music_track_4 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music entry_4",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 160,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 4,
 };
 
-struct music_track_panel music_track_5 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music entry_5",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 200,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 5
+struct ui_panel music_track_5 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music entry_5",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 200,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 5,
 };
 
-struct music_track_panel music_track_6 = {
-    .panel = {
-        .type = PANEL_LIST_ENTRY,
-        .name = "music entry_6",
-        .draw = draw_music_track,
-        .pos_x = 0,
-        .pos_y = 240,
-        .height = 40,
-        .color = 0xffff0000,
-        .children = NULL,
-    },
-    .position = 6
+struct ui_panel music_track_6 = {
+    .type = PANEL_LIST_ENTRY,
+    .name = "music entry_6",
+    .draw = draw_music_track,
+    .pos_x = 0,
+    .pos_y = 240,
+    .height = 40,
+    .color = 0xffff0000,
+    .children = NULL,
+    .order = 6,
 };
 
 


@@ 181,21 168,21 @@ struct music_track_panel music_track_6 = {
 static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_t s)
 {
     (void) s;
-    struct music_track_panel **children = (struct music_track_panel**)p->children;
+    struct ui_panel **children = p->children;
 
     if (!children) {
         return false;
     }
-    struct music_track_panel *first = *children, *entry, *prev;
+    struct ui_panel *first = *children, *entry, *prev;
 
     while ((entry = *children++)) {
-        if (entry->panel.focused) {
+        if (entry->focused) {
             switch (key) {
                 case MZD_KEYMAP_ROTATE_LEFT: {
                     if (entry != first) {
                         LOG_T("move to prev\n");
-                        prev->panel.focused = true;
-                        entry->panel.focused = false;
+                        prev->focused = true;
+                        entry->focused = false;
                     } else {
                         LOG_D("already at beginning\n");
                         if (cur_db_loc) {


@@ 206,9 193,9 @@ static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_
                 }
                 case MZD_KEYMAP_ROTATE_RIGHT: {
                     if (*children) {
-                        LOG_T("move to next %s\n", (*children)->panel.name);
-                        (*children)->panel.focused = true;
-                        entry->panel.focused = false;
+                        LOG_T("move to next %s\n", (*children)->name);
+                        (*children)->focused = true;
+                        entry->focused = false;
                     } else {
                         LOG_D("already at end\n");
                         cur_db_loc++;


@@ 216,11 203,11 @@ static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_
                     break;
                 }
                 case MZD_KEYMAP_DPAD_CENTER: {
-                    LOG_D("play this one %s\n", entry->panel.name);
-                    if (track_get_pos(entry->position)) {
-                        postmsg_audio(AMSG_PLAY, (void *)track_get_pos(entry->position));
+                    LOG_D("play this one %s\n", entry->name);
+                    if (track_get_pos(entry->order)) {
+                        postmsg_audio(AMSG_PLAY, (void *)track_get_pos(entry->order));
                     } else {
-                        LOG_E("No track found here %s\n", entry->panel.name);
+                        LOG_E("No track found here %s\n", entry->name);
                     }
                     break;
                 }


@@ 237,7 224,7 @@ static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_
     }
 
     LOG_D("focus not found\n");
-    first->panel.focused = true;
+    first->focused = true;
     return false;
 }
 


@@ 245,8 232,9 @@ static bool frame_key_down(struct ui_panel *p, const uint32_t key, const uint32_
 struct ui_panel music_tracks_frame = {
     .type = PANEL_LIST,
     .name = "music entry frame",
-    .pos_x = 80,
+    .pos_x = 0,
     .pos_y = 60,
+    .width = -80,
     .height = -80,
     .k_dn = frame_key_down,
     .focused = true,

M wl/draw.c => wl/draw.c +22 -7
@@ 196,7 196,6 @@ void draw_vline_c(int32_t x, int32_t y, int32_t h, uint32_t c)
 
     for (int32_t rem = h - y; rem > 0; rem--) {
         P(x, y + rem, c);
-        P(x + 1, y + rem, c);
     }
 }
 


@@ 207,7 206,6 @@ void draw_hline_c(int32_t x, int32_t y, int32_t w, uint32_t c)
 
     for (int rem = w - x; rem > 0; rem--) {
         P(x + rem, y, c);
-        P(x + rem, y + 1, c);
     }
 }
 


@@ 228,14 226,31 @@ void draw_square(int32_t x, int32_t y, int32_t w, int32_t h)
 }
 
 
-void draw_box_c(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t c)
+void draw_box_depth_c(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t d, uint32_t c)
 {
     LOG_D("draw box %i %i %i %i \n", x, y, w, h);
-    draw_vline_c(x, y, h, c);
-    draw_vline_c(w - 1, y, h, c);
+    for (uint32_t i = 0; i < d; i++) {
+        draw_hline_c(x, y + i, w , c);
+
+        draw_vline_c(x + i, y, h, c);
+        draw_vline_c(w - i, y, h, c);
+
+        draw_hline_c(x, h - i, w, c);
+    }
+}
+
+
+void draw_box_depth(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t d)
+{
+    return draw_box_depth_c(x, y, w, h, d, 0xff000000);
+}
+
+
 
-    draw_hline_c(x, y, w, c);
-    draw_hline_c(x, h - 1, w, c);
+void draw_box_c(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t c)
+{
+    LOG_D("draw box %i %i %i %i \n", x, y, w, h);
+    draw_box_depth_c(x, y, w, h, 2, c);
 }
 
 

M wl/draw.h => wl/draw.h +10 -3
@@ 8,16 8,23 @@
 void draw_swap_buffer(uint32_t *buffer);
 
 bool draw_pixel(int32_t x, int32_t y, uint32_t c);
+
 void draw_dot_c(int32_t x, int32_t y, uint32_t c);
+void draw_dot(int32_t x, int32_t y);
 
 void draw_vline_c(int32_t x, int32_t y, int32_t h, uint32_t c);
 void draw_hline_c(int32_t x, int32_t y, int32_t w, uint32_t c);
 
 void draw_square_c(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t c);
-void draw_box_c(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t c);
-
 void draw_square(int32_t x, int32_t y, int32_t w, int32_t h);
-void draw_dot(int32_t x, int32_t y);
+
+
+// depth >= max(x - w, y - h) is undefined.
+void draw_box_depth_c(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t depth, uint32_t c);
+void draw_box_depth(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t depth);
+
+void draw_box_c(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t c);
+void draw_box(int32_t x, int32_t y, int32_t w, int32_t h);
 
 void draw_circle_c(int32_t x, int32_t y, int32_t w, uint32_t c);
 void draw_circle(int32_t x, int32_t y, int32_t w);

M wl/text.c => wl/text.c +7 -5
@@ 42,7 42,7 @@ void init_text(void)
 }
 
 
-void text_draw_string(const char *string, int32_t x, int32_t y)
+void text_draw_string(const char *string, uint32_t x, uint32_t y)
 {
     if (!string) {
         return;


@@ 63,10 63,8 @@ void text_draw_string(const char *string, int32_t x, int32_t y)
 }
 
 
-void text_draw_string_width(const char *string, int32_t x, int32_t y, int32_t w)
+void text_draw_string_width(const char *string, uint32_t x, uint32_t y, uint32_t w)
 {
-    (void) w;
-
     if (!string) {
         return;
     }


@@ 77,7 75,11 @@ void text_draw_string_width(const char *string, int32_t x, int32_t y, int32_t w)
         glyph_index = FT_Get_Char_Index(face, string[i]);
         FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
         FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
-        draw_char(&face->glyph->bitmap, x + face->glyph->bitmap_left, y - face->glyph->bitmap_top);
+
+        if (x + face->glyph->bitmap_left + face->glyph->bitmap.width < w) {
+            draw_char(&face->glyph->bitmap, x + face->glyph->bitmap_left, y - face->glyph->bitmap_top);
+        }
+
         x += face->glyph->advance.x >> 6;
     }
 }

M wl/text.h => wl/text.h +2 -2
@@ 7,8 7,8 @@ extern struct ui_panel nav_frame;
 
 void init_text(void);
 
-void text_draw_string(const char *string, int32_t x, int32_t y);
-void text_draw_string_width(const char *string, int32_t x, int32_t y, int32_t w);
+void text_draw_string(const char *string, uint32_t x, uint32_t y);
+void text_draw_string_width(const char *string, uint32_t x, uint32_t y, uint32_t w);
 
 
 #endif // _HUDTDS_WL_TEXT_

M wl/ui.h => wl/ui.h +2 -0
@@ 36,6 36,7 @@ struct ui_panel {
     PANEL_TYPE type;
 
     char *name;
+    uint8_t order;
 
     touch_dn *t_dn;
     touch_up *t_mv;


@@ 55,6 56,7 @@ struct ui_panel {
     int32_t width;
     int32_t height;
 
+    // TODO probably removed, unused
     struct ui_panel *prev;
     struct ui_panel *next;