📄 thumb.c
字号:
// Arguments : none.
// Return : TRUE ==> exceed left item.
// : FALSE ==> not exceed left item.
// Side Effect : none.
// Notes :
//***************************************************************************
BYTE _THUMBNAIL_CheckLeftBoundary(void)
{
#ifndef NO_PICTURECD
_bTHUMBNAILTemp = _wThumbnailIndex / COLUMN_NUM;
if (_wThumbnailIndex > (_bTHUMBNAILTemp * COLUMN_NUM))
return FALSE;
#endif
return TRUE;
}
//***************************************************************************
// Function : _THUMBNAIL_DisplayPageInfo
// Abstract : This function will display the page number.
// Arguments : none.
// Return : none.
// Side Effect : none.
// Notes : use __wFMTotalFiles to calculate the total pages.
// : use _bTHUMBNAILTemp and __bPageNO.
//***************************************************************************
void _THUMBNAIL_DisplayPageInfo(void)
{
#ifndef NO_PICTURECD
//clear the page info.
_THUMBNAIL_ClearRegion(THUMBNAIL_CLEAR_PAGE_INFO_REGION);
if (_wThumbTotalFiles != 0)
{
GDI_SetTextColor(TEXT_BG_COLOR, PAL_ENTRY_COLOR_TRANSPARENT);
GDI_SetTextColor(TEXT_FG_COLOR, THUMBNAIL_PALETTE_ENTRY_PAGE_ITEM);
#ifdef SUPPORT_FM_BUTTONS
//calculate the total page.
_bTHUMBNAILTemp = _wThumbTotalFiles / _bThumbnailTotalNum[_bThumbnailSubMode];
if (_wThumbTotalFiles % _bThumbnailTotalNum[_bThumbnailSubMode])
_bTHUMBNAILTemp++;
#else
_bTHUMBNAILTemp = _wThumbTotalFiles / TOTAL_NUM_IN_PAGE;
if (_wThumbTotalFiles % TOTAL_NUM_IN_PAGE)
_bTHUMBNAILTemp++;
#endif //SUPPORT_FM_BUTTONS
_THUMBNAIL_OutputNum(_bTHUMBNAILTemp, THUMBNAIL_PAGE_INFO_NUM_INDEX);
_wHPos = THUMBNAIL_DISPLAY_PAGE_END_H-GDI_GetStringWidth();
GDI_DRAW_STRING(_wHPos, (THUMBNAIL_DISPLAY_PAGE_START_V-_THUMBNAIL_TuneForTVType(THUMBNAIL_TUNE_POS_TYPE_TITLE)));
GDI_CopyCodeString(aThumbSlash);
_wHPos -= GDI_GetStringWidth();
GDI_DRAW_STRING(_wHPos, (THUMBNAIL_DISPLAY_PAGE_START_V-_THUMBNAIL_TuneForTVType(THUMBNAIL_TUNE_POS_TYPE_TITLE)));
#ifdef SUPPORT_FM_BUTTONS
if (_bThumbnailSubMode == THUMBNAIL_SUBMODE_PROGRAM_LIST)
{
_THUMBNAIL_OutputNum((BYTE)(_bProgramPageNo+1), THUMBNAIL_PAGE_INFO_NUM_INDEX);
}
else //general mode
#endif //SUPPORT_FM_BUTTONS
{
_THUMBNAIL_OutputNum((BYTE)(__bPageNO+1), THUMBNAIL_PAGE_INFO_NUM_INDEX);
}
_wHPos -= GDI_GetStringWidth();
GDI_DRAW_STRING(_wHPos, (THUMBNAIL_DISPLAY_PAGE_START_V-_THUMBNAIL_TuneForTVType(THUMBNAIL_TUNE_POS_TYPE_TITLE)));
GDI_CopyCodeString(aThumbPage[_bOSDLang]);
_wHPos -= GDI_GetStringWidth();
GDI_DRAW_STRING(_wHPos, (THUMBNAIL_DISPLAY_PAGE_START_V-_THUMBNAIL_TuneForTVType(THUMBNAIL_TUNE_POS_TYPE_TITLE)));
}
#endif //NO_PICTURECD
}
//***************************************************************************
// Function : THUMBNAIL_Exit
// Abstract : This function will prepare all things to exit thumbnail mode.
// Arguments : none.
// Return : none.
// Side Effect : none.
// Notes : Set __bThumbnailMode to FALSE.
// : Set __bDisplay to 0 before return to slide show.
//***************************************************************************
void THUMBNAIL_Exit(void)
{
#ifndef NO_PICTURECD
HAL_JPEGDecode(HAL_JPEG_STOP_DECODE);
__bThumbnailMode = FALSE;
//CoCo1.03, assign other frame to prevent to see the garbage.
//RISC will use the other frame to do some operation like "rotate" or "flip".
//Therefore, we can't keep the previous image to do the effect because it will be destroyed by RISC.
#ifndef SUPPORT_JPEG_3_FRAMES
__btActiveFrame = !__btActiveFrame;
#endif
_THUMBNAIL_JPEG_PSFB(TRUE); //clear all frame buffer.
__bFMStage=STAGE_NONE;
__btPlaying = FALSE;
__bCountStop = 2; //For FManager UI reference.
//clear all OSD
GDI_ClearRegion(0); //clear region 0
OSD_Output(MSG_GUI, OSD_UI_THUMBNAIL, 0); //tell OSD exit thumbnail mode
//CoCo1.00, to support > 200 files in a folder.
//When existing thumbnail, need to prepare it. Otherwise, the content in File Manager may be failed.
__bDumpPage = (__wPlayItem / FM_MAX_FILE_NO_ONCE_TIME);
FM_PreparePage(FM_PREPARE_FILEPAGE, 0);
#endif
}
//***************************************************************************
// Function : _THUMBNAIL_ChangeToNextPic
// Abstract : Prepare to change to next picture.
// Arguments : none.
// Return : none.
// Side Effect : none.
// Notes :
//***************************************************************************
void _THUMBNAIL_ChangeToNextPic(void)
{
#ifndef NO_PICTURECD
_bTHUMBNAILStage = THUMBNAIL_STAGE_START;
_THUMBNAIL_CheckPlayPageBoundary();
_wThumbnailPlayIndex++;
#endif
}
//***************************************************************************
// Function : _THUMBNAIL_Start
// Abstract : Start to play a thumbnail.
// Arguments : none.
// Return : none.
// Side Effect : none.
// Notes :
//***************************************************************************
void _THUMBNAIL_Start(void)
{
#ifdef SUPPORT_FM_BUTTONS
if (_bThumbnailSubMode == THUMBNAIL_SUBMODE_PROGRAM_LIST)
{
//CoCo0.90a, clear the OSD in the frame to prevent remenent "MP3".
_THUMBNAIL_ClearFileExtInProgramList((BYTE)(_wThumbnailPlayIndex%PROGRAM_LIST_TOTAL_NUM_IN_PAGE));
if (__pProgContent[_wThumbnailPlayIndex].bExtID != EXTNAME_JPG)
//if(FM_GetFileType(__ProgIdxList[_wThumbnailPlayIndex].wSubIndex) != EXTNAME_JPG)
{
_THUMBNAIL_ShowFileExtInProgramList((BYTE)(_wThumbnailPlayIndex%PROGRAM_LIST_TOTAL_NUM_IN_PAGE), THUMBNAIL_UPDATE_HIGHLIGHT_CLEAR);
//draw frame
_THUMBNAIL_DrawThumbnailFrame((BYTE)(_wThumbnailPlayIndex%PROGRAM_LIST_TOTAL_NUM_IN_PAGE), THUMBNAIL_FRAME_NORMAL);
_THUMBNAIL_ChangeToNextPic();
return;
}
else
{
//get the programmed file from __ProgIdxList[];
//update the playing dir for executing the playing dir.
__bFMPlayingDir = __ProgIdxList[_wThumbnailPlayIndex].bMainIndex;
UTL_PlayItem((WORD)(__ProgIdxList[_wThumbnailPlayIndex].wSubIndex), 0);
//Access the file status to set correct operation
FM_AccessJPGStatus(FM_GET_JPG_STATUS, (WORD)(__ProgIdxList[_wThumbnailPlayIndex].wSubIndex));
}
}
else //general mode, just play the files in __bFMActiveDir
#endif //SUPPORT_FM_BUTTONS
{
//update the playing dir for executing the playing dir. In general case, it is equal to __bFMActiveDir.
__bFMPlayingDir = __bFMActiveDir;
UTL_PlayItem((WORD)(_wThumbStartPlayItem+_wThumbnailPlayIndex+1), 0);
//Access the file status to set correct operation
FM_AccessJPGStatus(FM_GET_JPG_STATUS, (WORD)(_wThumbStartPlayItem+_wThumbnailPlayIndex+1));
}
#ifdef SUPPORT_JPEG_3_FRAMES
__bJPEGOperation = HAL_JPEG_OPERATION_I;
#else
__bJPEGOperation = __bFMJPGStatus; //CoCo1.25, for new structure of FManager.
#endif
dwPreTime = __dwCountSystem;
__wCheckDecodeHang = 0xFFFF; //Initialize the value to check hang
_bTHUMBNAILStage = THUMBNAIL_STAGE_PARSEHEADER;
_bCheckHangTimes = 0;
__btPlayEnd= FALSE;
}
//***************************************************************************
// Function : _THUMBNAIL_ProcessError
// Abstract : Process the error about parsing header or decoding.
// Arguments : none.
// Return : none.
// Side Effect : none.
// Notes :
//***************************************************************************
void _THUMBNAIL_ProcessError(void)
{
HAL_ControlCDIF(HAL_CDIF_CLOSE);
HAL_JPEGDecode(HAL_JPEG_STOP_DECODE);
if (_bRetryTimes)
{
_bRetryTimes--;
_THUMBNAIL_Start();
}
else
{
#ifdef SUPPORT_FM_BUTTONS
if (_bThumbnailDecodeMode == THUMBNAIL_DECODE_PAGE)
{
_THUMBNAIL_DrawThumbnailFrame((BYTE)(_wThumbnailPlayIndex%_bThumbnailTotalNum[_bThumbnailSubMode]), THUMBNAIL_FRAME_NORMAL);
_THUMBNAIL_ChangeToNextPic();
}
else if (_bThumbnailDecodeMode == THUMBNAIL_DECODE_UNDETERMINED)
{
_wThumbnailPlayIndex++;
_THUMBNAIL_SearchNextValidPic();
}
else //decode only one thumbnail
_bStop = TRUE;
#else
_THUMBNAIL_DrawThumbnailFrame((BYTE)(_wThumbnailPlayIndex%TOTAL_NUM_IN_PAGE), THUMBNAIL_FRAME_NORMAL);
_THUMBNAIL_ChangeToNextPic();
#endif //SUPPORT_FM_BUTTONS
}
}
//***************************************************************************
// Function : _THUMBNAIL_ProcessError
// Abstract : This function will process the "ENTER" key for all mode.
// Arguments : none.
// Return : KEY_NO_KEY: The key is processced.
// : INVALID_KEY: It is an invalid key.
// Side Effect : none.
// Notes :
//***************************************************************************
BYTE _THUMBNAIL_ProcessEnterKey(void)
{
#ifdef SUPPORT_FM_BUTTONS
if (_bCursorType == THUMBNAIL_CURSOR_PICTURE) //play it directly.
{
switch (_bThumbnailSubMode)
{
case THUMBNAIL_SUBMODE_GENERAL:
//play the thumbnail directly.
//leave the thumbnail mode.
return _THUMBNAIL_ToSlideShow(THUMBNAIL_PLAY_CURRENT);
case THUMBNAIL_SUBMODE_ROTATE:
//rotate the thumbnail right 90 degree.
if (_bStop) //Don't allow user to press KEY_ENTER to rotate image before a page is decoded OK.
_THUMBNAIL_Rotate();
else
return INVALID_KEY;
break;
case THUMBNAIL_SUBMODE_PROGRAM:
//If it's not in the program list, add the thumbnail to the program list.
if (LINEAR_ProgramEntryOperation(LINEAR_QUERY_INDEX, 0, __bFMActiveDir, (WORD)(_wThumbStartPlayItem+_wThumbnailIndex+1)) == 0xFF) //not found
{
if (__bProgramMaxEntry == MAX_PROG_ITEM) //current program items has been the max program item.
{
//show error message.
return INVALID_KEY;
}
LINEAR_ProgramEntryOperation(LINEAR_ADD_ENTRY_BY_INDEX, __bProgramMaxEntry, __bFMActiveDir, (WORD)(_wThumbStartPlayItem+_wThumbnailIndex+1));
__bProgramMaxEntry++;
_THUMBNAIL_DrawThumbnailFrame((BYTE)(_wThumbnailIndex % TOTAL_NUM_IN_PAGE), THUMBNAIL_FRAME_SELECT);
}
else //it's in program list and delete it from the program list
{
LINEAR_ProgramEntryOperation(LINEAR_DELETE_ENTRY_BY_INDEX_W_REARRANGE,
LINEAR_ProgramEntryOperation(LINEAR_QUERY_INDEX, 0, __bFMActiveDir, (WORD)(_wThumbStartPlayItem+_wThumbnailIndex+1)), 0, 0);
__bProgramMaxEntry--;
_THUMBNAIL_DrawThumbnailFrame((BYTE)(_wThumbnailIndex % TOTAL_NUM_IN_PAGE), THUMBNAIL_FRAME_NORMAL);
}
_bTHUMBNAILTemp = _THUMBNAIL_GetButtonPosIndex(THUMBNAIL_BUTTON_PLAY);
//change the state of "PLAY" button.
if (__bProgramMaxEntry == 0) //disable the "play" button because we can't let user play it.
{
if (_bTHUMBNAILTemp != THUMBNAIL_BUTTON_END)
{
if (__ThumbCtlBTNList[_bTHUMBNAILTemp].bStatus == THUMBNAIL_BUTTON_STATE_ENABLE)
_THUMBNAIL_UpdateButtonState(THUMBNAIL_BUTTON_PLAY, THUMBNAIL_BUTTON_STATE_DISABLE, TRUE);
}
}
else
{
if (_bTHUMBNAILTemp != THUMBNAIL_BUTTON_END)
{
if (__ThumbCtlBTNList[_bTHUMBNAILTemp].bStatus == THUMBNAIL_BUTTON_STATE_DISABLE)
_THUMBNAIL_UpdateButtonState(THUMBNAIL_BUTTON_PLAY, THUMBNAIL_BUTTON_STATE_ENABLE, TRUE);
}
}
break;
case THUMBNAIL_SUBMODE_PROGRAM_LIST:
for (_bTHUMBNAILTemp = (_wThumbnailIndex % PROGRAM_LIST_TOTAL_NUM_IN_PAGE); _bTHUMBNAILTemp < PROGRAM_LIST_TOTAL_NUM_IN_PAGE; _bTHUMBNAILTemp++)
{
//clear the region in the display buffer
_THUMBNAIL_GetPosition(_bTHUMBNAILTemp);
_THUMBNAIL_ClearFileExtInProgramList((BYTE)(_bTHUMBNAILTemp%PROGRAM_LIST_TOTAL_NUM_IN_PAGE));
_THUMBNAIL_JPEG_PSFB(FALSE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -