void GUI_Ctrl_Progress_Draw( const GUIControl_t *pCtrl ) { const GUIMenuImage_t *pBkgImg, *pLeftImg, *pRightImg, *pMidImg; GUICtrl_Progress_t *pProgress = pCtrl->pCtrl; double f; unsigned int nMidWidth, nBarWidth; if( pProgress->nTextureLeft == -1 || pProgress->nTextureMid == - 1 || pProgress->nTextureRight == - 1 ) return; if( pProgress->nTextureBg != -1 ) { pBkgImg = GUI_MenuGetImage( pCtrl->pParent, pProgress->nTextureBg ); if( pBkgImg ) { gsLib_prim_sprite_texture( pBkgImg->gsTexture, pCtrl->nPosX, pCtrl->nPosY, pProgress->nWidth, pProgress->nHeight, 0, 0, pBkgImg->gsTexture->Width, pBkgImg->gsTexture->Height, colorTex ); } } f = (double) pProgress->nPos / (pProgress->nMaxs - pProgress->nMins); if( f > 0.0 ) { pLeftImg = GUI_MenuGetImage( pCtrl->pParent, pProgress->nTextureLeft ); if( !pLeftImg ) return; gsLib_prim_sprite_texture( pLeftImg->gsTexture, pCtrl->nPosX, pCtrl->nPosY, pLeftImg->gsTexture->Width, pProgress->nHeight, 0, 0, pLeftImg->gsTexture->Width, pLeftImg->gsTexture->Height, colorTex ); pRightImg = GUI_MenuGetImage( pCtrl->pParent, pProgress->nTextureRight ); if( !pRightImg ) return; nMidWidth = pProgress->nWidth - pLeftImg->gsTexture->Width - pRightImg->gsTexture->Width; nBarWidth = nMidWidth * f; pMidImg = GUI_MenuGetImage( pCtrl->pParent, pProgress->nTextureMid ); if( !pMidImg ) return; gsLib_prim_sprite_texture( pMidImg->gsTexture, pCtrl->nPosX + pLeftImg->gsTexture->Width, pCtrl->nPosY, nBarWidth, pProgress->nHeight, 0, 0, pMidImg->gsTexture->Width * f, pMidImg->gsTexture->Height, colorTex ); if( f == 1.0 ) { gsLib_prim_sprite_texture( pRightImg->gsTexture, pCtrl->nPosX + pLeftImg->gsTexture->Width + nBarWidth, pCtrl->nPosY, pRightImg->gsTexture->Width, pProgress->nHeight, 0, 0, pRightImg->gsTexture->Width, pRightImg->gsTexture->Height, colorTex ); } } }
unsigned int GUI_CB_MyPictures( GUIMenu_t *lpGUIMenu, unsigned int nGUIMsg, unsigned int nCtrlParam, unsigned int nOther ) { GUIThumbItem_t *pItem; const fileInfo_t *pFile; unsigned int nRet, nOffset; char szNewPath[MAX_PATH + 1], *pStr; switch( nGUIMsg ) { case GUI_MSG_OPEN: pErrImage = GUI_MenuGetImage( lpGUIMenu, ((GUICtrl_Image_t*)GUI_ControlByID(ID_IMAGE_ERROR)->pCtrl)->nTexture ); pDirImage = GUI_MenuGetImage( lpGUIMenu, ((GUICtrl_Image_t*)GUI_ControlByID(ID_IMAGE_DIR)->pCtrl)->nTexture ); if( !szCurDir[0] ) MyPictures_Init(); break; case GUI_MSG_CLOSE: GUI_Ctrl_ThumbnailPanel_VramClean( GUI_ControlByID(ID_THUMBNAIL_PANEL) ); break; case GUI_MSG_CONTROL: switch( LOWORD(nCtrlParam) ) { case ID_CACHE_IMAGES: GUI_OpenDialog( GUI_MENU_DLGTHUMB, lpGUIMenu, 0 ); break; case ID_SORT_BY_NAME: if( nNumFiles ) { qsort( fileInfo, nNumFiles, sizeof(fileInfo_t), SortPanelByName ); RefreshPanel(); } break; case ID_SORT_BY_SIZE: if( nNumFiles ) { qsort( fileInfo, nNumFiles, sizeof(fileInfo_t), SortPanelBySize ); RefreshPanel(); } break; case ID_SORT_BY_TYPE: break; case ID_GO_BACK: GUI_OpenMenu( GUI_MENU_MAIN ); break; case ID_THUMBNAIL_PANEL: switch( HIWORD(nCtrlParam) ) { case GUI_NOT_NEED_INFO: pItem = (GUIThumbItem_t*) nOther; pFile = (fileInfo_t*) pItem->pUser; pItem->pStr = pFile->name; // device list if( !szCurDir[0] ) { if( !strncmp( pFile->name, "pfs", 3 ) ) { pItem->pStr = HDD_GetPartition(pFile->name); } else if( !strncmp( pFile->name, "smb", 3 ) ) { pItem->pStr = SMB_GetShareNameByPath(pFile->name); } } nRet = CreateThumbnail( pFile, szCurDir, &pItem->pTexture ); if( nRet == 0 ) pItem->pTexture = pErrImage->gsTexture; break; case GUI_NOT_REMOVE: pItem = (GUIThumbItem_t*) nOther; if( pItem->pTexture ) { if( pItem->pTexture && pItem->pTexture != pErrImage->gsTexture && pItem->pTexture != pDirImage->gsTexture ) gsLib_texture_free( pItem->pTexture ); } pItem->pTexture = NULL; pItem->pStr = NULL; break; case GUI_NOT_THUMB: pFile = (fileInfo_t*) ((GUIThumbItem_t*)nOther)->pUser; pItem = (GUIThumbItem_t*) nOther; if( pFile->flags & FLAG_DIRECTORY ) { if( !strcmp( pFile->name, ".." ) ) { if( BrowsingRoot(szCurDir) ) { MyPictures_Init(); GUI_Render(); return 0; } else { nOffset = strlen(szCurDir) - 1; strncpy( szNewPath, szCurDir, nOffset ); szNewPath[ nOffset ] = 0; if( !(pStr = strrchr( szNewPath, '/' )) ) break; nOffset = pStr - szNewPath + 1; strncpy( szNewPath, szCurDir, nOffset ); szNewPath[ nOffset ] = 0; } } else { snprintf( szNewPath, MAX_PATH, "%s%s", szCurDir, pFile->name ); if( szNewPath[ strlen(szNewPath) - 1 ] != '/' ) strncat( szNewPath, "/", MAX_PATH ); } SetBrowseDir( szNewPath ); } else { // clicked an image thumbnail if( pItem->pTexture != pErrImage->gsTexture && pItem->pTexture != pDirImage->gsTexture ) { snprintf( szNewPath, sizeof(szNewPath), "%s%s", szCurDir, pFile->name ); GUI_OpenViewMenu( szNewPath ); } } break; } break; } break; } return 0; }
void GUI_Ctrl_List_Draw( const GUIControl_t *pCtrl ) { unsigned int nNumItems, bHasFocus, bItemFocus; unsigned int i, nItemIdx, nItemPosY; u64 uTextColor, uTexColor; unsigned int nItemHeight, nTextPosY, nTextPosX, nStrIndex; const GUIMenuImage_t *pTexNoFocus, *pTexFocus, *pTexMarked, *pTex, *pScrollTex; const GUIMenuFont_t *pFont; char szStr[ MAX_PATH + 1 ]; GUIListItem_t *pItem; GUICtrl_List_t *pList = pCtrl->pCtrl; if( pList->nTexture == -1 || pList->nTextureFocus == -1 || pList->nTextureMarked == -1 || pList->nFontIdx == -1 ) return; pTexNoFocus = GUI_MenuGetImage( pCtrl->pParent, pList->nTexture ); if( !pTexNoFocus ) return; pTexFocus = GUI_MenuGetImage( pCtrl->pParent, pList->nTextureFocus ); if( !pTexFocus ) return; pTexMarked = GUI_MenuGetImage( pCtrl->pParent, pList->nTextureMarked ); if( !pTexMarked ) return; pFont = GUI_MenuGetFont( pCtrl->pParent, pList->nFontIdx ); if( !pFont ) return; nItemHeight = pList->nItemHeight ? pList->nItemHeight : gsLib_font_height(pFont->gsFont); nNumItems = pList->nHeight / (nItemHeight + pList->nPadding); bHasFocus = pCtrl->pParent->iSelID == pCtrl->nID; nItemPosY = pCtrl->nPosY; uTexColor = pList->nColorDiffuse ? pList->nColorDiffuse : colorTex; for( i = 0; i < nNumItems; i++ ) { nItemIdx = pList->nStartItem + i; if( nItemIdx >= pList->nNumItems ) break; pItem = &pList->pItems[nItemIdx]; bItemFocus = (bHasFocus) && (nItemIdx == pList->nSelectedItem); pTex = (pItem->nFlags & FLAG_MARKED) ? pTexMarked : pTexNoFocus; if( bItemFocus ) pTex = pTexFocus; gsLib_prim_sprite_texture( pTex->gsTexture, pCtrl->nPosX, nItemPosY, pList->nWidth, nItemHeight, 0, 0, pTex->gsTexture->Width, pTex->gsTexture->Height, uTexColor ); uTextColor = (pItem->nFlags & FLAG_MARKED) ? pList->nMarkedColor : pList->nTextColor; if( bItemFocus ) uTextColor = pList->nSelectedColor; nTextPosX = pCtrl->nPosX + pList->nTextOffset; nTextPosY = nItemPosY + (nItemHeight - gsLib_font_height(pFont->gsFont)) / 2; CharsetConvert_UTF8ToCharset( szStr, pItem->pStr, sizeof(szStr) ); nStrIndex = strlen(szStr) - 1; while( gsLib_font_width( pFont->gsFont, szStr ) > (pList->nWidth - pList->nTextOffset * 2) ) { szStr[ nStrIndex ] = 0; if( nStrIndex > 1 ) { szStr[ nStrIndex - 1 ] = '.'; szStr[ nStrIndex - 2 ] = '.'; } nStrIndex--; } gsLib_font_print( pFont->gsFont, nTextPosX, nTextPosY, uTextColor, szStr ); nItemPosY += nItemHeight + pList->nPadding; } if( pList->nNumItems > nNumItems ) { if( pList->nStartItem > 0 ) { pScrollTex = GUI_MenuGetImage( pCtrl->pParent, pList->nUpTexture ); if( pScrollTex ) { gsLib_prim_sprite_texture( pScrollTex->gsTexture, pCtrl->nPosX + pList->nUpTexPosX, pCtrl->nPosY + pList->nUpTexPosY, pScrollTex->gsTexture->Width, pScrollTex->gsTexture->Height, 0, 0, pScrollTex->gsTexture->Width, pScrollTex->gsTexture->Height, colorTex ); } } if( (pList->nStartItem + nNumItems) < pList->nNumItems ) { pScrollTex = GUI_MenuGetImage( pCtrl->pParent, pList->nDownTexture ); if( pScrollTex ) { gsLib_prim_sprite_texture( pScrollTex->gsTexture, pCtrl->nPosX + pList->nDownTexPosX, pCtrl->nPosY + pList->nDownTexPosY, pScrollTex->gsTexture->Width, pScrollTex->gsTexture->Height, 0, 0, pScrollTex->gsTexture->Width, pScrollTex->gsTexture->Height, colorTex ); } } } }