📄 photobrowserapi.c
字号:
//********************************************************************
// Name: PhotoBrowserAPI.c
//
// Copyright (C) Sitronix TECHNOLOGY INC.
// All rights reserved by Sitronix TECHNOLOGY INC.
//
// Project: ST3110
// Author: Terry Wu
// Begin Date: 2008/05/19
// Last update:
// $Header: $
// Description:
// PhotoBrowser
//
//
//********************************************************************
#pragma codeseg(APP)
#include "sys.h"
#include "img_position.h"
#include "ST3110_img_define.h"
#include "multilanguage.h"
#include "PhotoBrowser.h"
#include "PhotoShow.h"
#include <string.h>
void _photo_browser_init(void);
void _photo_browser_thu(void); // show thumbnail
void _photo_paint_sel_frame(uint8 pos_x, uint8 pos_y);
void _photo_clear_sel_frame(uint8 pos_x, uint8 pos_y);
void _photo_show_name(uint8 result);
void _photo_show_item_icon(uint8 type, uint8 index, uint16 file_curr_paint_item);
uint8 _load_base_path(uint8 *base_folder_ptr);
uint16 file_curr_sel_item;
uint16 Folders,Files;
uint8 page,file_curr_sel_icon,file_pre_sel_icon;
uint8 root_order,file_repaint_flag,nand_sd_flag,language;
uint8 sfnPtr[13],lfnPtr[256];
uint16 total_page,total_item;
//***************************************************************************
// Func: void _photo_browser_init(void)
// Input: none
// Output: none
//
// Description: init photo broswer variable and show background image
//
//***************************************************************************
void _photo_browser_init(void)
{
root_order = API_SysReadValue(RAM_SHARING_ADR,ROOT_ORDER);
file_repaint_flag = API_SysReadValue(RAM_SHARING_ADR,PHO_PAINT_FLAG);
nand_sd_flag = API_SysReadValue(RAM_SHARING_ADR,IS_NAND_SD);
API_FATGetItemAmountInFolder(&Folders,&Files,FF_PHOTO_FORM);
language = API_SysReadValue(RAM_SETTING_ADR,SET_LANGUAGE);
// show mode by file_repaint_flag
// file_repaint_flag : 0 from PhotoEvent--no change page
// file_repaint_flag : 1 from Opening
// file_repaint_flag : 2 from PhotoEvent--change page
// file_repaint_flag : 3 from PhotoShow or ClockAClock ClockDClock ClockAlarm ClockCalendar
// get file_curr_sel_icon, file_pre_sel_icon ,page
//output : file_curr_sel_icon, file_pre_sel_icon ,page
#if RECORD_PATH == 0
if(file_repaint_flag == 1)
{
//return to base floder
_load_base_path(PHO_FOLDER_NAME);
root_order = API_SysReadValue(RAM_SHARING_ADR,ROOT_ORDER);
API_FATGetItemAmountInFolder(&Folders,&Files,FF_PHOTO_FORM);
//reset
file_curr_sel_icon = 0;
file_pre_sel_icon = 0;
page = 0;
}
else if(file_repaint_flag == 3)
#else
if(file_repaint_flag == 3 || file_repaint_flag == 1) //form photo show
#endif
{
uint16 cur_item_amount; //including return_icon, folder icon and file icon
file_curr_sel_item = API_SysReadValue2B(RAM_PHO_PATH_ADR,root_order*2)+Folders;
cur_item_amount = file_curr_sel_item;
if(root_order) // add return last layer icon
cur_item_amount++;
if(API_SysReadValue2B(RAM_PHO_PATH_ADR,root_order*2))
file_curr_sel_icon = (cur_item_amount-1)%PHOBRO_ITEM;
else
file_curr_sel_icon = 0;
file_pre_sel_icon = 0;
if((cur_item_amount%PHOBRO_ITEM)!=0 )
page = (cur_item_amount/PHOBRO_ITEM);
else
page = (cur_item_amount/PHOBRO_ITEM)-1;
}
else //show mode 0 or 2
{
file_curr_sel_icon = API_SysReadValue(RAM_SHARING_ADR,PHO_CUR_SEL);
file_pre_sel_icon = API_SysReadValue(RAM_SHARING_ADR,PHO_PRE_SEL);
page = API_SysReadValue(RAM_SHARING_ADR,PHO_PAGE);
}
// save output photo browser parameter
API_SysWriteValue(RAM_SHARING_ADR,PHO_PAGE,page);
API_SysWriteValue(RAM_SHARING_ADR,PHO_CUR_SEL,file_curr_sel_icon);
API_SysWriteValue(RAM_SHARING_ADR,PHO_PRE_SEL,0);
API_SysWriteValue(RAM_SHARING_ADR,PHO_PAINT_FLAG,file_repaint_flag);
//calculate total_item,total_page
if(root_order)
total_item = Folders+Files+1;
else
total_item = Folders+Files;
if( (total_item)%PHOBRO_ITEM != 0)
total_page = (total_item/PHOBRO_ITEM) + 1;
else
total_page = (total_item/PHOBRO_ITEM);
// init setting
if(language == 2)
API_LcmSetLanguage(CS_GBK);
else
API_LcmSetLanguage(CS_BIG5);
API_LcmSetCharForm(CHFS_16x16);
API_LcmSetCharColor(COLOR_WHITE,COLOR_DPF_BG);
API_LcmEnableKeepBackGround();
// show BG
if(API_SysReadValue(RAM_SHARING_ADR,LAST_TASK) != TASKID_PHOTOBROWSER)
{
API_LcmPutSysImage(IMG_BACKGD,POS_PHOMENU_BG_X,POS_PHOMENU_BG_Y);
API_LcmPutSysImage(IMG_INFO_BAR,POS_PHOBRO_INFOBAR_X,POS_PHOBRO_INFOBAR_Y);
}
}
//***************************************************************************
// Func: void _photo_browser_thu(void)
// Input: none
// Output: none
//
// Description: show image thumbnail and image info
//
//***************************************************************************
void _photo_browser_thu(void)
{
uint8 index;
uint8 move_h;
uint16 file_curr_paint_item;
uint8 sel_pos_x[] = {POS_PHOBRO_SEL0_X,POS_PHOBRO_SEL1_X,POS_PHOBRO_SEL2_X,
POS_PHOBRO_SEL3_X,POS_PHOBRO_SEL4_X,POS_PHOBRO_SEL5_X,
POS_PHOBRO_SEL6_X,POS_PHOBRO_SEL7_X,POS_PHOBRO_SEL8_X};
uint8 sel_pos_y[] = {POS_PHOBRO_SEL0_Y,POS_PHOBRO_SEL1_Y,POS_PHOBRO_SEL2_Y,
POS_PHOBRO_SEL3_Y,POS_PHOBRO_SEL4_Y,POS_PHOBRO_SEL5_Y,
POS_PHOBRO_SEL6_Y,POS_PHOBRO_SEL7_Y,POS_PHOBRO_SEL8_Y};
//clear sel bar first
_photo_clear_sel_frame(sel_pos_x[file_pre_sel_icon],sel_pos_y[file_pre_sel_icon]);
for(index = 0;index<PHOBRO_ITEM;index++)
{
if(root_order) //after second layer
file_curr_paint_item = (page*PHOBRO_ITEM) + index; //item number is from 0
else //root
file_curr_paint_item = (page*PHOBRO_ITEM) + index+1; //item number is from 1
if((file_repaint_flag) || (index == file_curr_sel_icon) ||(index == file_pre_sel_icon) )
{
if(file_curr_paint_item == 0)
{
_photo_show_item_icon(ICON_RETURN,index,file_curr_paint_item);
}
//show folder icon and name
else if( (file_curr_paint_item >=1) && (file_curr_paint_item <=Folders))
{
_photo_show_item_icon(ICON_FOLDER,index,file_curr_paint_item);
}
else if( (file_curr_paint_item >= Folders+1) && (file_curr_paint_item <= Folders+Files) )
{
// show file icon and name
_photo_show_item_icon(ICON_FILE,index,file_curr_paint_item);
}
else //clean sel and thu
{
API_LcmPutSysImage(IMG_PHOTO_SEL_BG,sel_pos_x[index],sel_pos_y[index]);
//API_LcmPutSysImage(IMG_PHOTO_SEL_BG,POS_PHOBRO_SEL_X+((index%3)*POS_PHOBRO_SEL_GAP_X),POS_PHOBRO_SEL_Y+((index/3)*POS_PHOBRO_SEL_GAP_Y));
}
}
}
//if there is no folder and file, show amount
if( total_item == 0)
_photo_show_item_icon(ICON_NOFILE,0,0);
// show page bar
if(file_repaint_flag)
{
API_LcmPutSysImage(IMG_MOVE_BAR_LONG,POS_PHOBRO_MOVEBAR_X,POS_PHOBRO_MOVEBAR_Y);
if( (page == total_page -1) && (page!=0))
{
API_LcmPutSysImage(IMG_MOVE,POS_PHOBRO_EMOVE_X,POS_PHOBRO_EMOVE_Y);
}
else
{
move_h = (POS_PHOBRO_MOVEBARLEN/(total_page-1));
API_LcmPutSysImage(IMG_MOVE,POS_PHOBRO_SMOVE_X,POS_PHOBRO_SMOVE_Y+(move_h*page));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -