📄 guistyle.c
字号:
/*****************************************************************************
** TEXAS INSTRUMENTS PROPRIETARY INFORMATION
**
** (c) Copyright, Texas Instruments Incorporated, 2006.
** All Rights Reserved.
**
** Property of Texas Instruments Incorporated. Restricted Rights -
** Use, duplication, or disclosure is subject to restrictions set
** forth in TI's program license agreement and associated documentation.
******************************************************************************/
#include "common.h"
#include "osd.h"
#include "guiStyle.h"
#include "guiStyle_sub.h"
#include "dbmessage.h"
#include "eeprom.h"
#include "ddp2230_rtos_include.h"
#include "tmr.h"
/* link list of open menus. The top menu in this
* list has the user focus */
GUI_OPEN_MENU *guiTopMenu = NULL;
/* callback functions for the application */
void (*gui_AppTask_OsdOnStart)( void ) = NULL;
void (*gui_AppTask_OsdOnClose)( void ) = NULL;
int08 (*gui_AppAction_OnStart)( int16 menuId, GUIMSG *msg ) = NULL;
int08 (*gui_AppAction_OnClose)( int16 menuId ) = NULL;
int08 (*gui_AppAction_GuiMsg)( int16 menuId, int16 itemId, GUIMSG *msg ) = NULL;
int08 (*gui_AppAction_Redraw)( int16 menuId, GUIMSG *msg ) = NULL;
int08 (*gui_AppAction_GetHighlightWindow)( int16 menuId, uint08 *window ) = NULL;
/* memory pool for dynamically allocated memory */
uint32 ID_StyleMemPool;
/* Iint status */
BOOL initDone = FALSE;
BOOL fadeEnabled = FALSE;
/*******************************************************
* Interface to gui_msgPump
******************************************************/
BOOL guiStyle_IsOsdDisplayed()
{
if( guiTopMenu != NULL )
return TRUE;
else
return FALSE;
}
BOOL guiStyle_IsMenuDisplayed( int16 menuId )
{
GUI_OPEN_MENU *temp;
temp = guiTopMenu;
while( temp != NULL )
{
if( temp->menuId == menuId )
return TRUE;
temp = temp->previousMenu;
}
return FALSE;
}
/* load and initialize a new menu.
* The newMenuId argument corresponds to the ID assigned
* by DLP Composer(tm). The msg arugment allows the
* gui_msgPump module to pass messages needed during
* initialization */
int08 guiStyle_StartMenu( int16 newMenuId, GUIMSG *msg )
{
BOOL useFade = FALSE;
if( guiTopMenu == NULL )
{
OSD_Enable( TRUE );
gui_AppTask_OsdOnStart();
if( guiStyle_IsFadeEnabled() )
{
useFade = TRUE;
OSD_SetFadeControl( 255, OSD_FADE_IN );
dbmsg_ftrace( DBM_GUI, "gui: guiStyle_StartMenu fade in\r\n");
}
}
/* allocate another node on the link list */
if( guiStyle_sub_AddTopMenuStruct( &guiTopMenu ) != PASS )
{
return FAIL;
}
guiTopMenu->menuId = newMenuId;
guiTopMenu->itemId = OSD_ERR_ID_INVALID;
guiTopMenu->hiddenItemList = NULL;
/* Loads the OSD into memory, but does not display it */
if( OSD_LoadMenu( newMenuId, FALSE ) != PASS )
{
guiStyle_sub_RemoveOpenMenuStruct( &guiTopMenu, guiTopMenu );
return FAIL;
}
/* Call the menustyle OnStart function. This takes a GUIMSG pointer as a parameter. */
guiStyle_menu_OnStart( guiTopMenu, msg );
OSD_DisplayMenu( newMenuId, TRUE );
/* kick off fade operation if this is the first menu to be displayed */
if( useFade )
{
if( OSD_StartFade() != PASS )
{
dbmsg_ftrace( DBM_GUI, "gui: FADE ERROR\r\n");
return FAIL;
}
}
return PASS;
}
int08 guiStyle_Exit()
{
int08 retval = PASS;
/* Check if initialization has been done */
if(initDone == FALSE )
return FAIL;
if( guiStyle_IsFadeEnabled() && guiStyle_IsOsdDisplayed() )
{
OSD_SetFadeControl( 255, OSD_FADE_OUT );
if( OSD_StartFade() != PASS )
{
dbmsg_ftrace( DBM_GUI, "gui: FADE ERROR\r\n");
return FAIL;
}
/* fade starts on OSD_StartFade() for fade out. Delay to allow menu to close */
RTA_TaskDelay( TMR_ConvertMSToTicks( 300 ));
}
/* close all menus, deallocate memory */
while( guiTopMenu != NULL )
{
guiStyle_menu_OnClose( guiTopMenu );
if( OSD_DisplayMenu( guiTopMenu->menuId, FALSE ) != PASS )
retval = FAIL;
if( guiStyle_sub_RemoveOpenMenuStruct( &guiTopMenu, guiTopMenu ) != PASS )
retval = FAIL;
}
OSD_Enable( FALSE );
gui_AppTask_OsdOnClose();
return retval;
}
/* This function is used primarily for passing keypresses */
int08 guiStyle_SendTopMenuMsg( GUIMSG *msg )
{
if( msg != NULL )
{
return guiStyle_menu_GuiMsg( guiTopMenu, msg );
}
return FAIL;
}
/* This function is used primarily for passing menu specific messages */
int08 guiStyle_SendMenuMsg( int16 menuId, GUIMSG *msg )
{
GUI_OPEN_MENU *temp;
temp = guiTopMenu;
while( temp != NULL )
{
if( temp->menuId == menuId )
{
return guiStyle_menu_GuiMsg( temp, msg );
}
temp = temp->previousMenu;
}
return FAIL;
}
int08 guiStyle_CloseMenu( int16 menuId )
{
GUI_OPEN_MENU *temp;
int08 retval = PASS;
temp = guiTopMenu;
while( temp != NULL )
{
if( temp->menuId == menuId )
{
guiStyle_menu_OnClose( temp );
if( OSD_DisplayMenu( temp->menuId, FALSE ) != PASS )
retval = FAIL;
if( guiStyle_sub_RemoveOpenMenuStruct( &guiTopMenu, temp ) != PASS )
retval = FAIL;
if( guiTopMenu == NULL )
{
OSD_Enable( FALSE );
gui_AppTask_OsdOnClose();
}
return retval;
}
temp = temp->previousMenu;
}
return FAIL;
}
int08 guiStyle_Redraw()
{
GUI_OPEN_MENU *temp;
temp = guiTopMenu;
/* tell all menus to redraw */
while( temp != NULL )
{
guiStyle_menu_Redraw( temp );
temp = temp->previousMenu;
}
return PASS;
}
int08 guiStyle_Reload()
{
GUI_OPEN_MENU *temp, *temp2;
int08 retval = PASS;
temp = guiTopMenu;
/* close all menus, but do not deallocate memory from link list */
while( temp != NULL )
{
guiStyle_menu_OnClose( temp );
if( OSD_DisplayMenu( temp->menuId, FALSE ) != PASS )
retval = FAIL;
/* deallocate the hiddenItemList so that gui_AppAction_OnStart can hide the appropriate items */
if( guiStyle_sub_RemoveHiddenItemList( temp ) != PASS )
retval = FAIL;
if( temp->previousMenu == NULL )
break;
temp = temp->previousMenu;
}
OSD_Enable( FALSE );
/* bring them all back up */
OSD_Enable( TRUE );
while( temp != NULL )
{
if( OSD_LoadMenu( temp->menuId, FALSE ) != PASS )
{
retval = FAIL;
}
else
{
guiStyle_menu_OnStart( temp, NULL );
if( OSD_DisplayMenu( temp->menuId, TRUE ) != PASS )
retval = FAIL;
}
if( temp == guiTopMenu )
break;
/* traverse the list from the bottom up */
temp2 = guiTopMenu;
while( temp2->previousMenu != temp && temp2->previousMenu != NULL )
{
temp2 = temp2->previousMenu;
}
temp = temp2;
}
return retval;
}
int08 guiStyle_Init( uint32 memPoolID,
void (*onOsdStartCallback)(void),
void (*onOsdCloseCallback)(void),
int08 (*actionOnStartCallback)( int16 menuId, GUIMSG *msg ),
int08 (*actionOnCloseCallback)( int16 menuId ),
int08 (*actionGuiMsgCallback)( int16 menuId, int16 itemId, GUIMSG *msg ),
int08 (*actionRedrawCallback)( int16 menuId, GUIMSG *msg ),
int08 (*actionGetHighlightWindowCallback)( int16 menuId, uint08 *window )
)
{
BOOL fadeValue;
uint08 language;
OSD_SIZE_PARAMS OSD_Size;
ID_StyleMemPool = memPoolID;
gui_AppTask_OsdOnStart = onOsdStartCallback;
gui_AppTask_OsdOnClose = onOsdCloseCallback;
gui_AppAction_OnStart = actionOnStartCallback;
gui_AppAction_OnClose = actionOnCloseCallback;
gui_AppAction_GuiMsg = actionGuiMsgCallback;
gui_AppAction_Redraw = actionRedrawCallback;
gui_AppAction_GetHighlightWindow = actionGetHighlightWindowCallback;
OSD_Size.MaxNumWindows = OSD_MAX_DISPLAYED_WINDOWS;
OSD_Size.MaxNumLines = OSD_MAX_DISPLAYED_LINES;
OSD_Size.MaxLineContent = OSD_MAX_LINE_CONTENT;
/* Initialize the OSD system, but don't load a menu. OSD_Init takes the size from the application */
OSD_Init( -1, 0, ID_StyleMemPool, &OSD_Size );
/* Disable OSD output during updates */
// OSD_SetUpdateMode(OSD_UPDATE_BLANKING);
OSD_SetUpdateMode(OSD_UPDATE_DISABLE);
/* set language based on value in EEPROM */
EE_GETVAR( UserMachine.Projector.Language, language );
OSD_SetLanguage( language );
/* set fade enabled based on value in EEPROM */
EE_GETVAR( UserMachine.Projector.Fade, fadeValue );
guiStyle_SetFadeEnabled( fadeValue );
initDone = TRUE;
return PASS;
}
int08 guiStyle_HideItem( int16 menuId, int16 itemId, BOOL hide )
{
GUI_OPEN_MENU *temp;
temp = guiTopMenu;
while( temp != NULL )
{
if( temp->menuId == menuId )
{
return guiStyle_menu_HideItem( temp, itemId, hide );
}
temp = temp->previousMenu;
}
return FAIL;
}
int08 guiStyle_GrayOutItem( int16 menuId, int16 itemId, BOOL disable )
{
GUI_OPEN_MENU *temp;
temp = guiTopMenu;
while( temp != NULL )
{
if( temp->menuId == menuId )
{
return guiStyle_menu_GrayOutItem( temp, itemId, disable );
}
temp = temp->previousMenu;
}
return FAIL;
}
int08 guiStyle_SetVerticalBackPorchTimeInUS( uint32 backporch )
{
/* set the OSD mode according to how much backporch we have */
if( backporch < 200 )
{
OSD_SetUpdateMode(OSD_UPDATE_DISABLE);
}
else
{
OSD_SetUpdateMode(OSD_UPDATE_BLANKING);
}
return PASS;
}
int08 guiStyle_SetFadeEnabled( BOOL enable )
{
fadeEnabled = enable;
return PASS;
}
BOOL guiStyle_IsFadeEnabled()
{
if( fadeEnabled == TRUE )
return TRUE;
else
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -