This commit is contained in:
Nishi 2025-11-24 22:57:16 +09:00
commit 1e2eed03de
Signed by: nishi
GPG key ID: 27EF69B208EB9343
3 changed files with 24 additions and 11 deletions

View file

@ -15,6 +15,7 @@ MwWidget mainsep;
MwWidget eltime, seekbar, rmtime; MwWidget eltime, seekbar, rmtime;
MwWidget tree, list; MwWidget tree, list;
MwLLPixmap pxalbum, pxskipback, pxplay, pxpause, pxstop, pxskipfwd, pxrepeat, pxshuffle; MwLLPixmap pxalbum, pxskipback, pxplay, pxpause, pxstop, pxskipfwd, pxrepeat, pxshuffle;
MwLLPixmap pxoptical;
unsigned char* pxalbumdata; unsigned char* pxalbumdata;
static void resize(MwWidget handle, void* user, void* client) { static void resize(MwWidget handle, void* user, void* client) {
@ -116,21 +117,21 @@ static void resize(MwWidget handle, void* user, void* client) {
MwVaApply(eltime, MwVaApply(eltime,
MwNx, 5, MwNx, 5,
MwNy, y + 5 + 32 + 10, MwNy, y + 5 + 32 + 10,
MwNwidth, MwTextWidth(window, "00:00"), /* please, never put 1 hour music */ MwNwidth, MwTextWidth(window, "000:00"),
MwNheight, 16, MwNheight, 16,
NULL); NULL);
MwVaApply(seekbar, MwVaApply(seekbar,
MwNx, 5 + MwTextWidth(window, "00:00") + 5, MwNx, 5 + MwTextWidth(window, "000:00") + 5,
MwNy, y + 5 + 32 + 10, MwNy, y + 5 + 32 + 10,
MwNwidth, ww - (5 + MwTextWidth(window, "00:00") + 5) * 2, MwNwidth, ww - (5 + MwTextWidth(window, "000:00") + 5) * 2,
MwNheight, 16, MwNheight, 16,
NULL); NULL);
MwVaApply(rmtime, MwVaApply(rmtime,
MwNx, ww - 5 - MwTextWidth(window, "00:00"), MwNx, ww - 5 - MwTextWidth(window, "000:00"),
MwNy, y + 5 + 32 + 10, MwNy, y + 5 + 32 + 10,
MwNwidth, MwTextWidth(window, "00:00"), MwNwidth, MwTextWidth(window, "000:00"),
MwNheight, 16, MwNheight, 16,
NULL); NULL);
@ -156,7 +157,7 @@ int main() {
MwLibraryInit(); MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 400, window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 600, 400,
MwNtitle, "mauplay", MwNtitle, "mauplay",
NULL); NULL);
menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0); menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0);
@ -202,7 +203,7 @@ int main() {
NULL); NULL);
eltime = MwVaCreateWidget(MwLabelClass, "eltime", window, 0, 0, 0, 0, eltime = MwVaCreateWidget(MwLabelClass, "eltime", window, 0, 0, 0, 0,
MwNalignment, MwALIGNMENT_END, MwNalignment, MwALIGNMENT_END,
MwNtext, "0:00", MwNtext, "000:00",
NULL); NULL);
seekbar = MwVaCreateWidget(MwScrollBarClass, "seekbar", window, 0, 0, 0, 0, seekbar = MwVaCreateWidget(MwScrollBarClass, "seekbar", window, 0, 0, 0, 0,
MwNorientation, MwHORIZONTAL, MwNorientation, MwHORIZONTAL,
@ -211,7 +212,7 @@ int main() {
NULL); NULL);
rmtime = MwVaCreateWidget(MwLabelClass, "rmtime", window, 0, 0, 0, 0, rmtime = MwVaCreateWidget(MwLabelClass, "rmtime", window, 0, 0, 0, 0,
MwNalignment, MwALIGNMENT_END, MwNalignment, MwALIGNMENT_END,
MwNtext, "0:00", MwNtext, "000:00",
NULL); NULL);
tree = MwCreateWidget(MwTreeViewClass, "tree", window, 0, 0, 0, 0); tree = MwCreateWidget(MwTreeViewClass, "tree", window, 0, 0, 0, 0);
list = MwVaCreateWidget(MwListBoxClass, "list", window, 0, 0, 0, 0, list = MwVaCreateWidget(MwListBoxClass, "list", window, 0, 0, 0, 0,
@ -234,6 +235,8 @@ int main() {
pxrepeat = MwLoadXPM(window, repeat_xpm); pxrepeat = MwLoadXPM(window, repeat_xpm);
pxshuffle = MwLoadXPM(window, shuffle_xpm); pxshuffle = MwLoadXPM(window, shuffle_xpm);
pxoptical = MwLoadImage(window, ICON128DIR "/optical.png");
MwSetVoid(album, MwNpixmap, pxalbum); MwSetVoid(album, MwNpixmap, pxalbum);
MwSetVoid(bskipback, MwNpixmap, pxskipback); MwSetVoid(bskipback, MwNpixmap, pxskipback);
@ -251,7 +254,6 @@ int main() {
ui_init(); ui_init();
db_add("test2.mp3");
db_scan(); db_scan();
audio_init(); audio_init();

View file

@ -44,6 +44,7 @@ extern MwWidget eltime, seekbar, rmtime;
extern MwWidget tree, list; extern MwWidget tree, list;
extern unsigned char* pxalbumdata; extern unsigned char* pxalbumdata;
extern MwLLPixmap pxalbum; extern MwLLPixmap pxalbum;
extern MwLLPixmap pxoptical;
/* db.c */ /* db.c */
extern numkv_t* db_musics; extern numkv_t* db_musics;

View file

@ -102,6 +102,7 @@ static void tree_activate(MwWidget handle, void* user, void* client) {
int index = MwListBoxPacketInsert(p, -1); int index = MwListBoxPacketInsert(p, -1);
sprintf(buf, "%d", i + 1); sprintf(buf, "%d", i + 1);
MwListBoxPacketSetIcon(p, index, pxoptical);
MwListBoxPacketSet(p, index, 0, buf); MwListBoxPacketSet(p, index, 0, buf);
MwListBoxPacketSet(p, index, 1, db_musics[ind].title); MwListBoxPacketSet(p, index, 1, db_musics[ind].title);
MwListBoxPacketSet(p, index, 2, db_musics[ind].artist); MwListBoxPacketSet(p, index, 2, db_musics[ind].artist);
@ -118,6 +119,7 @@ static void tree_activate(MwWidget handle, void* user, void* client) {
int index = MwListBoxPacketInsert(p, -1); int index = MwListBoxPacketInsert(p, -1);
sprintf(buf, "%d", i + 1); sprintf(buf, "%d", i + 1);
MwListBoxPacketSetIcon(p, index, pxoptical);
MwListBoxPacketSet(p, index, 0, buf); MwListBoxPacketSet(p, index, 0, buf);
MwListBoxPacketSet(p, index, 1, db_musics[i].title); MwListBoxPacketSet(p, index, 1, db_musics[i].title);
MwListBoxPacketSet(p, index, 2, db_musics[i].artist); MwListBoxPacketSet(p, index, 2, db_musics[i].artist);
@ -189,6 +191,10 @@ static void tree_activate(MwWidget handle, void* user, void* client) {
static void list_activate(MwWidget handle, void* user, void* client) { static void list_activate(MwWidget handle, void* user, void* client) {
if(ui_last == play_queue) { if(ui_last == play_queue) {
pthread_mutex_lock(&audio_mutex); pthread_mutex_lock(&audio_mutex);
if(queue_seek != -1) {
queue[queue_seek].frames = 0;
MDESoundSeek(queue[queue_seek].sound, 0);
}
queue_seek = (*(int*)client) - 1; queue_seek = (*(int*)client) - 1;
queue[queue_seek].frames = 0; queue[queue_seek].frames = 0;
MDESoundSeek(queue[queue_seek].sound, 0); MDESoundSeek(queue[queue_seek].sound, 0);
@ -225,12 +231,16 @@ static void window_tick(MwWidget handle, void* user, void* client) {
} }
} }
free(data); free(data);
} else {
memset(((MwLLCommonPixmap)pxalbum)->raw, 0, ALBUMWIDTH * ALBUMWIDTH * 4);
} }
MwLLPixmapUpdate(pxalbum);
MwForceRender(album);
free(img); free(img);
} else {
memset(((MwLLCommonPixmap)pxalbum)->raw, 0, ALBUMWIDTH * ALBUMWIDTH * 4);
} }
MwLLPixmapUpdate(pxalbum);
MwForceRender(album);
if(ui_last == play_queue) { if(ui_last == play_queue) {
pthread_mutex_unlock(&audio_mutex); pthread_mutex_unlock(&audio_mutex);