static void uiMenuDraw( void ) { uint32_t * buf = NULL; uint32_t * drw = NULL; int x,y,tmp; if ( !guiApp.menuIsPresent ) return; if ( !uiMenuRender && !guiApp.menuWindow.Visible ) return; if ( uiMenuRender || menuItem != oldMenuItem ) { memcpy( menuDrawBuffer,guiApp.menu.Bitmap.Image,guiApp.menu.Bitmap.ImageSize ); /* --- */ if ( menuItem != -1 ) { buf=(uint32_t *)menuDrawBuffer; drw=(uint32_t *)guiApp.menuSelected.Bitmap.Image; for ( y=guiApp.menuItems[ menuItem ].y; y < guiApp.menuItems[ menuItem ].y + guiApp.menuItems[ menuItem ].height; y++ ) for ( x=guiApp.menuItems[ menuItem ].x; x < guiApp.menuItems[ menuItem ].x + guiApp.menuItems[ menuItem ].width; x++ ) { tmp=drw[ y * guiApp.menuSelected.width + x ]; if ( !IS_TRANSPARENT ( tmp ) ) buf[ y * guiApp.menu.width + x ]=tmp; } } oldMenuItem=menuItem; /* --- */ wsImageRender( &guiApp.menuWindow,menuDrawBuffer ); uiMenuRender=False; } wsImageDraw( &guiApp.menuWindow ); }
void uiVideoInit (void) { wsWindowCreate(&guiApp.videoWindow, guiApp.video.x, guiApp.video.y, guiApp.video.width, guiApp.video.height, wsShowFrame | wsHideWindow | wsAspect, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, "MPlayer - Video"); mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[video] videoWindow ID: 0x%x\n", (int) guiApp.videoWindow.WindowID); wsWindowIcon(wsDisplay, guiApp.videoWindow.WindowID, &guiIcon); if (guiApp.video.Bitmap.Image) { wsImageResize(&guiApp.videoWindow, guiApp.video.Bitmap.Width, guiApp.video.Bitmap.Height); wsImageRender(&guiApp.videoWindow, guiApp.video.Bitmap.Image); } wsXDNDMakeAwareness(&guiApp.videoWindow); guiApp.videoWindow.DrawHandler = uiVideoDraw; guiApp.videoWindow.MouseHandler = uiVideoMouse; guiApp.videoWindow.KeyHandler = guiApp.mainWindow.KeyHandler; guiApp.videoWindow.DNDHandler = guiApp.mainWindow.DNDHandler; }
/** * @brief Render all GUI items in a window, i.e. copy the respective images * into the draw buffer. * * @param window pointer to a ws window structure of the window to be rendered * @param items pointer to the array of items * @param till maximum index in use for the @a items, i.e. number of last item in array * @param drawbuf memory location of the @a window's draw buffer */ void RenderAll(wsWindow *window, guiItem *items, int till, char *drawbuf) { uint32_t *db; guiItem *item; guiImage *image = NULL; int dw, i, index, x; char *trans; unsigned int d; db = (uint32_t *)drawbuf; dw = window->Width; for (i = 0; i <= till; i++) { item = &items[i]; switch (item->pressed) { case btnPressed: index = 0; break; case btnReleased: index = 1; break; default: index = 2; break; } switch (item->type) { case itButton: PutImage(item->x, item->y, db, dw, &item->Bitmap, 3, index, True); break; case itPimage: PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, True); break; case itHPotmeter: PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, True); PutImage(item->x + (item->width - item->pbwidth) * item->value / 100.0, item->y, db, dw, &item->Mask, 3, index, True); break; case itVPotmeter: PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, False); PutImage(item->x, item->y + (item->height - item->pbheight) * (1.0 - item->value / 100.0), db, dw, &item->Mask, 3, index, True); break; case itRPotmeter: PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, True); if (item->Mask.Image) { double radius, radian; int y; // keep the button inside the potmeter outline radius = (FFMIN(item->width, item->height) - FFMAX(item->pbwidth, item->pbheight)) / 2.0; radian = item->value / 100.0 * item->arclength + item->zeropoint; // coordinates plus a correction for a non-square item // (remember: both axes are mirrored, we have a clockwise radian) x = radius * (1 + cos(radian)) + FFMAX(0, (item->width - item->height) / 2.0) + 0.5; y = radius * (1 + sin(radian)) + FFMAX(0, (item->height - item->width) / 2.0) + 0.5; PutImage(item->x + x, item->y + y, db, dw, &item->Mask, 3, index, True); } break; case itSLabel: if (item->width == -1) item->width = fntTextWidth(item->fontid, item->label); image = fntTextRender(item, 0, item->label); if (image) PutImage(item->x, item->y, db, dw, image, 1, 0, True); break; case itDLabel: trans = TranslateVariables(item->label); if (!item->text || (strcmp(item->text, trans) != 0)) { free(item->text); item->text = strdup(trans); item->textwidth = fntTextWidth(item->fontid, trans); item->starttime = GetTimerMS(); item->last_x = 0; } d = GetTimerMS() - item->starttime; if (d < DLABEL_DELAY) x = item->last_x; // don't scroll yet else { int l; char c[2]; l = (item->textwidth ? item->textwidth : item->width); x = (l ? l - ((d - DLABEL_DELAY) / 20) % l - 1 : 0); c[0] = *item->text; c[1] = 0; if (x < (fntTextWidth(item->fontid, c) + 1) >> 1) { item->starttime = GetTimerMS(); // stop again item->last_x = x; // at current x pos } } image = fntTextRender(item, x, trans); if (image) PutImage(item->x, item->y, db, dw, image, 1, 0, True); break; } } wsImageRender(window, drawbuf); }
void RenderAll(wsWindow *window, guiItem *Items, int nrItems, char *db) { guiItem *item; guiImage *image = NULL; int i, ofs; image_buffer = db; image_width = window->Width; for (i = 0; i < nrItems + 1; i++) { item = &Items[i]; switch (item->pressed) { case btnPressed: ofs = 0; break; case btnReleased: ofs = 1; break; default: ofs = 2; break; } switch (item->type) { case itButton: PutImage(&item->Bitmap, item->x, item->y, 3, ofs); break; case itPotmeter: if (item->numphases == 1) SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0); else PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0)); break; case itHPotmeter: if (item->numphases == 1) SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0); else PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0)); PutImage(&item->Mask, item->x + (item->width - item->pwidth) * (item->value / 100.0), item->y, 3, ofs); break; case itVPotmeter: PutImage(&item->Bitmap, item->x, item->y, item->numphases, item->numphases * (1.0 - item->value / 100.0)); PutImage(&item->Mask, item->x, item->y + (item->height - item->pheight) * (1.0 - item->value / 100.0), 3, ofs); break; case itSLabel: if (item->width == -1) item->width = fntTextWidth(item->fontid, item->label); image = fntTextRender(item, 0, item->label); if (image) PutImage(image, item->x, item->y, 1, 0); break; case itDLabel: { int x; unsigned int d; char *t = Translate(item->label); if (!item->text || (strcmp(item->text, t) != 0)) { free(item->text); item->text = strdup(t); item->textwidth = fntTextWidth(item->fontid, t); item->starttime = GetTimerMS(); item->last_x = 0; } d = GetTimerMS() - item->starttime; if (d < DLABEL_DELAY) x = item->last_x; // don't scroll yet else { int l; char c[2]; l = (item->textwidth ? item->textwidth : item->width); x = (l ? l - ((d - DLABEL_DELAY) / 20) % l - 1 : 0); c[0] = *item->text; c[1] = '\0'; if (x < (fntTextWidth(item->fontid, c) + 1) >> 1) { item->starttime = GetTimerMS(); // stop again item->last_x = x; // at current x pos } } image = fntTextRender(item, x, t); } if (image) PutImage(image, item->x, item->y, 1, 0); break; } } wsImageRender(window, db); }
/** * @brief Change to a different skin. * * @param name name of the skin to change to */ void uiChangeSkin(char *name) { int was_menu, was_playbar; was_menu = guiApp.menuIsPresent; was_playbar = guiApp.playbarIsPresent; mainVisible = False; if (skinRead(name) != 0) { if (skinRead(skinName) != 0) { gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_GUI_MSG_SkinCfgError, skinName); mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); } } /* reload main window (must be first!) */ uiMainDone(); uiMainInit(); wsWindowVisibility(&guiApp.mainWindow, wsShowWindow); mainVisible = True; /* adjust video window */ if (guiApp.video.Bitmap.Image) { wsImageResize(&guiApp.videoWindow, guiApp.video.Bitmap.Width, guiApp.video.Bitmap.Height); wsImageRender(&guiApp.videoWindow, guiApp.video.Bitmap.Image); } if (!guiInfo.Playing) { if (!guiApp.videoWindow.isFullScreen) { wsWindowResize(&guiApp.videoWindow, guiApp.video.width, guiApp.video.height); wsWindowMove(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y); } wsWindowRedraw(&guiApp.videoWindow); } /* reload playbar */ if (was_playbar) uiPlaybarDone(); uiPlaybarInit(); /* reload menu window */ if (was_menu) uiMenuDone(); uiMenuInit(); /* */ if (guiInfo.AudioPassthrough) btnSet(evSetVolume, btnDisabled); if (guiInfo.AudioChannels < 2 || guiInfo.AudioPassthrough) btnSet(evSetBalance, btnDisabled); btnSet(evFullScreen, guiApp.videoWindow.isFullScreen ? btnPressed : btnReleased); wsWindowLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.videoWindow.isFullScreen); wsWindowLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.videoWindow.isFullScreen); }