2020-03-13 09:44:45 +01:00
/*
* a class to keep definitions for all theme settings
*/
2020-03-17 20:43:58 +01:00
extern " C " {
# include <Protocol/GraphicsOutput.h>
}
2020-03-16 12:15:25 +01:00
# include "libegint.h"
2020-03-18 07:39:11 +01:00
# include "../refit/screen.h"
2020-03-13 09:44:45 +01:00
# include "XTheme.h"
2020-03-24 05:36:39 +01:00
//temporary
extern INTN ScrollWidth ;
extern INTN ScrollButtonsHeight ;
extern INTN ScrollBarDecorationsHeight ;
extern INTN ScrollScrollDecorationsHeight ;
extern EG_RECT UpButton ;
extern EG_RECT DownButton ;
extern EG_RECT BarStart ;
extern EG_RECT BarEnd ;
extern EG_RECT ScrollbarBackground ;
extern EG_RECT Scrollbar ;
extern EG_RECT ScrollStart ;
extern EG_RECT ScrollEnd ;
extern EG_RECT ScrollTotal ;
extern BOOLEAN IsDragging ;
extern EG_RECT ScrollbarOldPointerPlace ;
extern EG_RECT ScrollbarNewPointerPlace ;
extern INTN ScrollbarYMovement ;
2020-03-16 12:15:25 +01:00
CONST CHAR8 * IconsNames [ ] = {
" func_about " ,
" func_options " ,
" func_clover " ,
" func_secureboot " ,
" func_secureboot_config " ,
" func_reset " ,
" func_shutdown " ,
" func_help " ,
" tool_shell " , //8
" tool_part " ,
" tool_rescue " ,
" pointer " , //11
" vol_internal " ,
" vol_external " ,
" vol_optical " ,
" vol_firewire " ,
" vol_clover " ,
" vol_internal_hfs " ,
" vol_internal_apfs " ,
" vol_internal_ntfs " ,
" vol_internal_ext3 " ,
" vol_recovery " , //21
// not used?
" logo " ,
" selection_small " ,
2020-03-18 15:11:56 +01:00
" selection_big " , //BUILTIN_SELECTION_BIG=24 we keep this numeration
2020-03-16 12:15:25 +01:00
//os icons
" os_mac " , //0 + 25
" os_tiger " ,
" os_leo " ,
" os_snow " ,
" os_lion " ,
" os_cougar " ,
" os_mav " ,
" os_yos " ,
" os_cap " ,
" os_sierra " ,
" os_hsierra " ,
" os_moja " , //11
" os_cata " , //12
" os_linux " ,
" os_ubuntu " ,
" os_suse " ,
" os_freebsd " , //16
" os_freedos " ,
" os_win " ,
" os_vista " ,
2020-03-19 19:35:58 +01:00
" radio_button " , //20
2020-03-16 12:15:25 +01:00
" radio_button_selected " ,
2020-03-19 19:35:58 +01:00
" checkbox " , //22
2020-03-16 12:15:25 +01:00
" checkbox_checked " ,
" scrollbar_background " , //24
" scrollbar_holder "
} ;
Icon : : Icon ( INTN Index ) : Image ( 0 ) , ImageNight ( 0 )
{
Id = Index ;
2020-03-18 07:39:11 +01:00
Name . takeValueFrom ( IconsNames [ Index ] ) ;
2020-03-16 12:15:25 +01:00
}
2020-03-13 09:44:45 +01:00
Icon : : ~ Icon ( ) { }
2020-03-16 12:15:25 +01:00
XTheme : : XTheme ( ) {
Init ( ) ;
}
XTheme : : ~ XTheme ( ) {
//nothing todo?
}
void XTheme : : Init ( )
2020-03-13 09:44:45 +01:00
{
2020-03-12 15:00:36 +01:00
DisableFlags = 0 ;
HideBadges = 0 ;
HideUIFlags = 0 ;
TextOnly = FALSE ;
Font = FONT_GRAY ; // FONT_TYPE
CharWidth = 9 ;
SelectionColor = 0xFFFFFF80 ;
FontFileName . setEmpty ( ) ;
Theme . takeValueFrom ( " embedded " ) ;
BannerFileName . setEmpty ( ) ;
SelectionSmallFileName . setEmpty ( ) ;
SelectionBigFileName . setEmpty ( ) ;
SelectionIndicatorName . setEmpty ( ) ;
DefaultSelection . setEmpty ( ) ;
BackgroundName . setEmpty ( ) ;
BackgroundScale = imNone ; // SCALING
BackgroundSharp = 0 ;
BackgroundDark = FALSE ; //TODO should be set to true if Night theme
CustomIcons = FALSE ; //TODO don't know how to handle with SVG theme
SelectionOnTop = FALSE ;
BootCampStyle = FALSE ;
BadgeOffsetX = 0 ;
BadgeOffsetY = 0 ;
BadgeScale = 4 ; // TODO now we have float scale = BadgeScale/16
ThemeDesignWidth = 0xFFFF ;
ThemeDesignHeight = 0xFFFF ;
2020-03-26 15:24:20 +01:00
BannerPosX = 0xFFFF ; // the value out of range [0,1000]
2020-03-12 15:00:36 +01:00
BannerPosY = 0xFFFF ;
BannerEdgeHorizontal = 0 ;
BannerEdgeVertical = 0 ;
BannerNudgeX = 0 ;
BannerNudgeY = 0 ;
VerticalLayout = FALSE ;
NonSelectedGrey = FALSE ; //TODO what about SVG?
MainEntriesSize = 128 ;
TileXSpace = 8 ;
TileYSpace = 24 ;
// IconFormat = ICON_FORMAT_DEF;
Proportional = FALSE ;
ShowOptimus = FALSE ;
DarkEmbedded = FALSE ; //looks like redundant, we always check Night or Daylight
TypeSVG = FALSE ;
Codepage = 0xC0 ; //this is for PNG theme
CodepageSize = 0xC0 ; // INTN CodepageSize; //extended latin
Scale = 1.0f ;
2020-03-13 09:44:45 +01:00
CentreShift = 0.0f ;
2020-03-18 10:07:34 +01:00
Daylight = true ;
2020-03-20 18:48:19 +01:00
LayoutHeight = 376 ;
2020-03-26 15:24:20 +01:00
LayoutBannerOffset = 64 ; //default value if not set
LayoutButtonOffset = 0 ; //default value if not set
LayoutTextOffset = 0 ; //default value if not set
LayoutAnimMoveForMenuX = 0 ; //default value if not set
row0TileSize = 144 ;
row1TileSize = 64 ;
2020-03-13 09:44:45 +01:00
}
2020-03-18 15:11:56 +01:00
XImage & XTheme : : GetIcon ( const char * Name )
{
2020-03-21 12:43:45 +01:00
return GetIcon ( XStringW ( ) . takeValueFrom ( Name ) ) ;
2020-03-18 15:11:56 +01:00
}
2020-03-13 09:44:45 +01:00
2020-03-21 12:43:45 +01:00
XImage & XTheme : : GetIcon ( const XStringW & Name )
2020-03-13 09:44:45 +01:00
{
XImage * TheIcon = NULL ;
for ( size_t i = 0 ; i < Icons . size ( ) ; i + + )
{
if ( Icons [ i ] . Name = = Name )
{
2020-03-18 10:07:34 +01:00
if ( ! Daylight ) {
2020-03-13 09:44:45 +01:00
TheIcon = & Icons [ i ] . ImageNight ;
}
if ( TheIcon = = NULL | | ( * TheIcon ) . isEmpty ( ) ) { //if daylight or night icon absent
TheIcon = & Icons [ i ] . Image ;
}
break ;
}
}
return * TheIcon ;
}
2020-03-18 10:07:34 +01:00
XImage & XTheme : : GetIcon ( INTN Id )
2020-03-13 09:44:45 +01:00
{
XImage * TheIcon = NULL ;
for ( size_t i = 0 ; i < Icons . size ( ) ; i + + )
{
if ( Icons [ i ] . Id = = Id )
{
2020-03-18 10:07:34 +01:00
if ( ! Daylight ) {
2020-03-13 09:44:45 +01:00
TheIcon = & Icons [ i ] . ImageNight ;
}
if ( TheIcon = = NULL | | ( * TheIcon ) . isEmpty ( ) ) { //if daylight or night icon absent
TheIcon = & Icons [ i ] . Image ;
}
break ;
}
}
return * TheIcon ;
}
void XTheme : : AddIcon ( Icon & NewIcon )
{
Icons . AddCopy ( NewIcon ) ;
2020-03-16 12:15:25 +01:00
}
//if ImageNight is not set then Image should be used
# define DEC_BUILTIN_ICON(id, ico) { \
2020-03-19 19:35:58 +01:00
Image . FromPNG ( ACCESS_EMB_DATA ( ico ) , ACCESS_EMB_SIZE ( ico ) ) ; \
2020-03-16 12:15:25 +01:00
}
# define DEC_BUILTIN_ICON2(id, ico, dark) { \
2020-03-19 19:35:58 +01:00
Image . FromPNG ( ACCESS_EMB_DATA ( ico ) , ACCESS_EMB_SIZE ( ico ) ) ; \
ImageNight . FromPNG ( ACCESS_EMB_DATA ( dark ) , ACCESS_EMB_SIZE ( dark ) ) ; \
2020-03-16 12:15:25 +01:00
}
2020-03-19 19:35:58 +01:00
Icon : : Icon ( INTN Index , BOOLEAN Embedded ) : Image ( 0 ) , ImageNight ( 0 )
{
Id = Index ;
if ( Index < BUILTIN_ICON_FUNC_ABOUT | | Index > = BUILTIN_ICON_COUNT | | ! Embedded ) {
Name . setEmpty ( ) ;
return ;
}
Name . takeValueFrom ( IconsNames [ Index ] ) ;
switch ( Id ) {
case BUILTIN_ICON_FUNC_ABOUT :
DEC_BUILTIN_ICON2 ( BUILTIN_ICON_FUNC_ABOUT , emb_func_about , emb_dark_func_about )
break ;
case BUILTIN_ICON_FUNC_OPTIONS :
DEC_BUILTIN_ICON2 ( BUILTIN_ICON_FUNC_OPTIONS , emb_func_options , emb_dark_func_options )
break ;
case BUILTIN_ICON_FUNC_CLOVER :
DEC_BUILTIN_ICON2 ( BUILTIN_ICON_FUNC_CLOVER , emb_func_clover , emb_dark_func_clover )
break ;
case BUILTIN_ICON_FUNC_SECURE_BOOT :
DEC_BUILTIN_ICON2 ( BUILTIN_ICON_FUNC_SECURE_BOOT , emb_func_secureboot , emb_dark_func_secureboot )
break ;
case BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG :
DEC_BUILTIN_ICON2 ( BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG , emb_func_secureboot_config , emb_dark_func_secureboot_config )
break ;
case BUILTIN_ICON_FUNC_RESET :
DEC_BUILTIN_ICON2 ( BUILTIN_ICON_FUNC_RESET , emb_func_reset , emb_dark_func_reset )
break ;
case BUILTIN_ICON_FUNC_EXIT :
DEC_BUILTIN_ICON2 ( BUILTIN_ICON_FUNC_EXIT , emb_func_exit , emb_dark_func_exit )
break ;
case BUILTIN_ICON_FUNC_HELP :
DEC_BUILTIN_ICON2 ( BUILTIN_ICON_FUNC_HELP , emb_func_help , emb_dark_func_help )
break ;
case BUILTIN_ICON_TOOL_SHELL :
DEC_BUILTIN_ICON2 ( BUILTIN_ICON_TOOL_SHELL , emb_func_shell , emb_dark_func_shell )
break ;
case BUILTIN_ICON_BANNER :
DEC_BUILTIN_ICON2 ( BUILTIN_ICON_BANNER , emb_logo , emb_dark_logo )
break ;
case BUILTIN_SELECTION_SMALL :
DEC_BUILTIN_ICON2 ( BUILTIN_SELECTION_SMALL , emb_selection_small , emb_dark_selection_small )
break ;
case BUILTIN_SELECTION_BIG :
DEC_BUILTIN_ICON2 ( BUILTIN_SELECTION_BIG , emb_selection_big , emb_dark_selection_big )
break ;
//next icons have no dark image
case BUILTIN_ICON_POINTER :
DEC_BUILTIN_ICON ( BUILTIN_ICON_POINTER , emb_pointer )
break ;
case BUILTIN_ICON_VOL_INTERNAL :
DEC_BUILTIN_ICON ( BUILTIN_ICON_VOL_INTERNAL , emb_vol_internal )
break ;
case BUILTIN_ICON_VOL_EXTERNAL :
DEC_BUILTIN_ICON ( BUILTIN_ICON_VOL_EXTERNAL , emb_vol_external )
break ;
case BUILTIN_ICON_VOL_OPTICAL :
DEC_BUILTIN_ICON ( BUILTIN_ICON_VOL_OPTICAL , emb_vol_optical )
break ;
case BUILTIN_ICON_VOL_BOOTER :
DEC_BUILTIN_ICON ( BUILTIN_ICON_VOL_BOOTER , emb_vol_internal_booter )
break ;
case BUILTIN_ICON_VOL_INTERNAL_HFS :
DEC_BUILTIN_ICON ( BUILTIN_ICON_VOL_INTERNAL_HFS , emb_vol_internal_hfs )
break ;
case BUILTIN_ICON_VOL_INTERNAL_APFS :
DEC_BUILTIN_ICON ( BUILTIN_ICON_VOL_INTERNAL_APFS , emb_vol_internal_apfs )
break ;
case BUILTIN_ICON_VOL_INTERNAL_NTFS :
DEC_BUILTIN_ICON ( BUILTIN_ICON_VOL_INTERNAL_NTFS , emb_vol_internal_ntfs )
break ;
case BUILTIN_ICON_VOL_INTERNAL_EXT3 :
DEC_BUILTIN_ICON ( BUILTIN_ICON_VOL_INTERNAL_EXT3 , emb_vol_internal_ext )
break ;
case BUILTIN_ICON_VOL_INTERNAL_REC :
DEC_BUILTIN_ICON ( BUILTIN_ICON_VOL_INTERNAL_REC , emb_vol_internal_recovery )
break ;
default :
Name . setEmpty ( ) ;
break ;
}
//something to do else?
}
2020-03-16 12:15:25 +01:00
void XTheme : : FillByEmbedded ( )
2020-03-17 20:43:58 +01:00
{
2020-03-19 19:35:58 +01:00
for ( INTN i = 0 ; i < BUILTIN_ICON_COUNT ; + + i ) {
Icon NewIcon ( i , true ) ;
Icons . AddCopy ( NewIcon ) ;
}
2020-03-17 20:43:58 +01:00
}
void XTheme : : ClearScreen ( ) //and restore background and banner
{
if ( BanHeight < 2 ) {
BanHeight = ( ( UGAHeight - ( int ) ( LayoutHeight * Scale ) ) > > 1 ) ;
}
if ( ! ( HideUIFlags & HIDEUI_FLAG_BANNER ) ) {
//Banner image prepared before
if ( ! Banner . isEmpty ( ) ) {
2020-03-18 07:39:11 +01:00
BannerPlace . Width = Banner . GetWidth ( ) ;
BannerPlace . Height = ( BanHeight > = Banner . GetHeight ( ) ) ? Banner . GetHeight ( ) : BanHeight ;
2020-03-17 20:43:58 +01:00
BannerPlace . XPos = BannerPosX ;
BannerPlace . YPos = BannerPosY ;
if ( ! TypeSVG ) {
// Check if new style placement value was used for banner in theme.plist
if ( ( BannerPosX > = 0 & & BannerPosX < = 1000 ) & & ( BannerPosY > = 0 & & BannerPosY < = 1000 ) ) {
// Check if screen size being used is different from theme origination size.
// If yes, then recalculate the placement % value.
// This is necessary because screen can be a different size, but banner is not scaled.
BannerPlace . XPos = HybridRepositioning ( BannerEdgeHorizontal , BannerPosX , BannerPlace . Width , UGAWidth , ThemeDesignWidth ) ;
BannerPlace . YPos = HybridRepositioning ( BannerEdgeVertical , BannerPosY , BannerPlace . Height , UGAHeight , ThemeDesignHeight ) ;
// Check if banner is required to be nudged.
2020-03-18 07:39:11 +01:00
BannerPlace . XPos = CalculateNudgePosition ( BannerPlace . XPos , BannerNudgeX , Banner . GetWidth ( ) , UGAWidth ) ;
BannerPlace . YPos = CalculateNudgePosition ( BannerPlace . YPos , BannerNudgeY , Banner . GetHeight ( ) , UGAHeight ) ;
2020-03-17 20:43:58 +01:00
// DBG("banner position new style\n");
} else {
// Use rEFIt default (no placement values speicifed)
2020-03-18 07:39:11 +01:00
BannerPlace . XPos = ( UGAWidth - Banner . GetWidth ( ) ) > > 1 ;
BannerPlace . YPos = ( BanHeight > = Banner . GetHeight ( ) ) ? ( BanHeight - Banner . GetHeight ( ) ) : 0 ;
2020-03-17 20:43:58 +01:00
// DBG("banner position old style\n");
}
}
}
}
//Then prepare Background from BigBack
2020-03-18 07:39:11 +01:00
if ( ! Background . isEmpty ( ) & & ( Background . GetWidth ( ) ! = ( UINTN ) UGAWidth | | Background . GetHeight ( ) ! = ( UINTN ) UGAHeight ) ) { // should we type UGAWidth and UGAHeight as UINTN to avoid cast ?
2020-03-17 20:43:58 +01:00
// Resolution changed
Background . setEmpty ( ) ;
}
if ( Background . isEmpty ( ) ) {
Background = XImage ( UGAWidth , UGAHeight ) ;
2020-03-18 07:39:11 +01:00
Background . Fill ( ( EFI_GRAPHICS_OUTPUT_BLT_PIXEL & ) BlueBackgroundPixel ) ;
2020-03-17 20:43:58 +01:00
}
if ( ! BigBack . isEmpty ( ) ) {
switch ( BackgroundScale ) {
case imScale :
Background . CopyScaled ( BigBack , Scale ) ;
break ;
case imCrop :
2020-03-18 07:39:11 +01:00
{
2020-03-17 20:43:58 +01:00
INTN x = UGAWidth - BigBack . GetWidth ( ) ;
INTN x1 , x2 , y1 , y2 ;
if ( x > = 0 ) {
x1 = x > > 1 ;
x2 = 0 ;
x = BigBack . GetWidth ( ) ;
} else {
x1 = 0 ;
x2 = ( - x ) > > 1 ;
x = UGAWidth ;
}
INTN y = UGAHeight - BigBack . GetHeight ( ) ;
if ( y > = 0 ) {
y1 = y > > 1 ;
y2 = 0 ;
y = BigBack . GetHeight ( ) ;
} else {
y1 = 0 ;
y2 = ( - y ) > > 1 ;
y = UGAHeight ;
}
//the function can be in XImage class
/* egRawCopy(Background.GetPixelPtr(x1, y1),
BigBack . GetPixelPtr ( x2 , y2 ) ,
x , y , Background . GetWidth ( ) , BigBack . GetWidth ( ) ) ; */
Background . Compose ( x , y , BigBack , true ) ;
break ;
2020-03-18 07:39:11 +01:00
}
2020-03-17 20:43:58 +01:00
case imTile :
2020-03-18 07:39:11 +01:00
{
INTN x = ( BigBack . GetWidth ( ) * ( ( UGAWidth - 1 ) / BigBack . GetWidth ( ) + 1 ) - UGAWidth ) > > 1 ;
INTN y = ( BigBack . GetHeight ( ) * ( ( UGAHeight - 1 ) / BigBack . GetHeight ( ) + 1 ) - UGAHeight ) > > 1 ;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL * p1 = Background . GetPixelPtr ( 0 , 0 ) ;
for ( INTN j = 0 ; j < UGAHeight ; j + + ) {
for ( INTN i = 0 ; i < UGAWidth ; i + + ) {
2020-03-17 20:43:58 +01:00
* p1 + + = BigBack . GetPixel ( ( i + x ) % BigBack . GetWidth ( ) , ( j + y ) % BigBack . GetHeight ( ) ) ;
}
}
break ;
2020-03-18 07:39:11 +01:00
}
2020-03-17 20:43:58 +01:00
case imNone :
default :
// already scaled
break ;
}
}
2020-03-25 18:49:01 +01:00
Background . Draw ( 0 , 0 ) ;
2020-03-17 20:43:58 +01:00
//then draw banner
2020-03-18 07:39:11 +01:00
if ( ! Banner . isEmpty ( ) ) {
2020-03-17 20:43:58 +01:00
Banner . Draw ( BannerPlace . XPos , BannerPlace . YPos , Scale ) ;
}
}
void XTheme : : InitSelection ( )
{
2020-03-19 19:35:58 +01:00
EFI_STATUS Status ;
2020-03-17 20:43:58 +01:00
if ( ! AllowGraphicsMode )
return ;
2020-03-19 19:35:58 +01:00
//used to fill TextBuffer if selected
2020-03-17 20:43:58 +01:00
SelectionBackgroundPixel . r = ( SelectionColor > > 24 ) & 0xFF ;
SelectionBackgroundPixel . g = ( SelectionColor > > 16 ) & 0xFF ;
SelectionBackgroundPixel . b = ( SelectionColor > > 8 ) & 0xFF ;
SelectionBackgroundPixel . a = ( SelectionColor > > 0 ) & 0xFF ;
2020-03-19 19:35:58 +01:00
if ( ! SelectionImages [ 0 ] . isEmpty ( ) ) { //already presents
2020-03-17 20:43:58 +01:00
return ;
}
// load small selection image
2020-03-18 10:07:34 +01:00
if ( SelectionSmallFileName . isEmpty ( ) ) {
2020-03-19 19:35:58 +01:00
SelectionImages [ 2 ] . LoadXImage ( ThemeDir , SelectionSmallFileName ) ;
2020-03-17 20:43:58 +01:00
}
if ( SelectionImages [ 2 ] . isEmpty ( ) ) {
// SelectionImages[2] = BuiltinIcon(BUILTIN_SELECTION_SMALL);
// SelectionImages[2]->HasAlpha = FALSE; // support transparensy for selection icons
2020-03-18 10:07:34 +01:00
if ( Daylight ) {
SelectionImages [ 2 ] . FromPNG ( ACCESS_EMB_DATA ( emb_selection_small ) , ACCESS_EMB_SIZE ( emb_selection_small ) ) ;
} else {
SelectionImages [ 2 ] . FromPNG ( ACCESS_EMB_DATA ( emb_dark_selection_small ) , ACCESS_EMB_SIZE ( emb_dark_selection_small ) ) ;
}
2020-03-17 20:43:58 +01:00
// CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EG_PIXEL)); //why???
}
//cut or extend the image by Compose
/* SelectionImages[2] = egEnsureImageSize(SelectionImages[2],
row1TileSize , row1TileSize , & MenuBackgroundPixel ) ;
if ( SelectionImages [ 2 ] = = NULL ) {
return ;
} */
2020-03-18 15:11:56 +01:00
2020-03-17 20:43:58 +01:00
// load big selection image
2020-03-18 10:07:34 +01:00
if ( ! TypeSVG & & ! SelectionBigFileName . isEmpty ( ) ) {
2020-03-19 19:35:58 +01:00
SelectionImages [ 0 ] . LoadXImage ( ThemeDir , SelectionBigFileName ) ;
2020-03-18 10:07:34 +01:00
// SelectionImages[0].EnsureImageSize(row0TileSize, row0TileSize, &MenuBackgroundPixel);
2020-03-17 20:43:58 +01:00
}
2020-03-18 07:39:11 +01:00
if ( SelectionImages [ 0 ] . isEmpty ( ) ) {
2020-03-17 20:43:58 +01:00
// calculate big selection image from small one
2020-03-18 10:07:34 +01:00
// SelectionImages[0] = BuiltinIcon(BUILTIN_SELECTION_BIG);
if ( Daylight ) {
SelectionImages [ 0 ] . FromPNG ( ACCESS_EMB_DATA ( emb_selection_big ) , ACCESS_EMB_SIZE ( emb_selection_big ) ) ;
} else {
SelectionImages [ 0 ] . FromPNG ( ACCESS_EMB_DATA ( emb_dark_selection_big ) , ACCESS_EMB_SIZE ( emb_dark_selection_big ) ) ;
}
2020-03-18 07:39:11 +01:00
// SelectionImages[0]->HasAlpha = FALSE; // support transparensy for selection icons
2020-03-17 20:43:58 +01:00
CopyMem ( & BlueBackgroundPixel , & StdBackgroundPixel , sizeof ( EG_PIXEL ) ) ;
2020-03-18 07:39:11 +01:00
if ( SelectionImages [ 0 ] . isEmpty ( ) ) {
SelectionImages [ 2 ] . setEmpty ( ) ;
2020-03-17 20:43:58 +01:00
return ;
}
2020-03-18 10:07:34 +01:00
// if (SelectionOnTop) {
2020-03-18 07:39:11 +01:00
// SelectionImages[0]->HasAlpha = TRUE; // TODO ?
// SelectionImages[2]->HasAlpha = TRUE;
2020-03-18 10:07:34 +01:00
// }
2020-03-17 20:43:58 +01:00
}
// BootCampStyle indicator image
2020-03-18 10:07:34 +01:00
if ( BootCampStyle ) {
2020-03-17 20:43:58 +01:00
// load indicator selection image
2020-03-18 10:07:34 +01:00
if ( ! SelectionIndicatorName . isEmpty ( ) ) {
2020-03-19 19:35:58 +01:00
SelectionImages [ 4 ] . LoadXImage ( ThemeDir , SelectionIndicatorName ) ;
2020-03-17 20:43:58 +01:00
}
2020-03-18 07:39:11 +01:00
if ( ! SelectionImages [ 4 ] . isEmpty ( ) ) {
2020-03-18 10:07:34 +01:00
SelectionImages [ 4 ] . FromPNG ( ACCESS_EMB_DATA ( emb_selection_indicator ) , ACCESS_EMB_SIZE ( emb_selection_indicator ) ) ;
2020-03-17 20:43:58 +01:00
}
2020-03-18 10:07:34 +01:00
INTN ScaledIndicatorSize = ( INTN ) ( INDICATOR_SIZE * Scale ) ;
// SelectionImages[4].EnsureImageSize(ScaledIndicatorSize, ScaledIndicatorSize, &MenuBackgroundPixel);
2020-03-18 07:39:11 +01:00
if ( SelectionImages [ 4 ] . isEmpty ( ) ) {
2020-03-18 10:07:34 +01:00
// SelectionImages[4] = egCreateFilledImage(ScaledIndicatorSize, ScaledIndicatorSize,
// TRUE, &StdBackgroundPixel);
SelectionImages [ 4 ] = XImage ( ScaledIndicatorSize , ScaledIndicatorSize ) ;
SelectionImages [ 4 ] . Fill ( ( EFI_GRAPHICS_OUTPUT_BLT_PIXEL & ) StdBackgroundPixel ) ;
2020-03-17 20:43:58 +01:00
}
2020-03-18 10:07:34 +01:00
// SelectionImages[5] = egCreateFilledImage(ScaledIndicatorSize, ScaledIndicatorSize,
// TRUE, &MenuBackgroundPixel);
SelectionImages [ 5 ] = XImage ( ScaledIndicatorSize , ScaledIndicatorSize ) ;
SelectionImages [ 5 ] . Fill ( ( EFI_GRAPHICS_OUTPUT_BLT_PIXEL & ) MenuBackgroundPixel ) ;
2020-03-17 20:43:58 +01:00
}
/*
Button & radio , or any other next icons with builtin icon as fallback should synced to :
- BUILTIN_ICON_ * in lib . h
- BuiltinIconTable in icns . c
- Data in egemb_icons . h / scroll_images . h
*/
// Radio buttons
//it was a nonsense egLoadImage is just inluded into egLoadIcon.
// will be corrected with XTheme support
//the procedure loadIcon should also check embedded icons
2020-03-19 19:35:58 +01:00
//DECLARE_EMB_EXTERN_WITH_SIZE(emb_radio_button_selected)
//DECLARE_EMB_EXTERN_WITH_SIZE(emb_radio_button)
//DECLARE_EMB_EXTERN_WITH_SIZE(emb_checkbox)
//DECLARE_EMB_EXTERN_WITH_SIZE(emb_checkbox_checked)
2020-03-20 18:48:19 +01:00
//DECLARE_EMB_EXTERN_WITH_SIZE(emb_dark_font_data)
2020-03-19 19:35:58 +01:00
2020-03-24 05:36:39 +01:00
Status = Buttons [ 0 ] . LoadXImage ( ThemeDir , " radio_button " ) ;
2020-03-19 19:35:58 +01:00
if ( EFI_ERROR ( Status ) ) {
2020-03-24 05:36:39 +01:00
Buttons [ 0 ] . FromPNG ( ACCESS_EMB_DATA ( emb_radio_button ) , ACCESS_EMB_SIZE ( emb_radio_button ) ) ;
2020-03-19 19:35:58 +01:00
}
2020-03-24 05:36:39 +01:00
Status = Buttons [ 1 ] . LoadXImage ( ThemeDir , " radio_button_selected " ) ;
2020-03-19 19:35:58 +01:00
if ( EFI_ERROR ( Status ) ) {
2020-03-24 05:36:39 +01:00
Buttons [ 1 ] . FromPNG ( ACCESS_EMB_DATA ( emb_radio_button_selected ) , ACCESS_EMB_SIZE ( emb_radio_button_selected ) ) ;
2020-03-19 19:35:58 +01:00
}
2020-03-24 05:36:39 +01:00
Status = Buttons [ 2 ] . LoadXImage ( ThemeDir , " checkbox " ) ;
2020-03-19 19:35:58 +01:00
if ( EFI_ERROR ( Status ) ) {
2020-03-24 05:36:39 +01:00
Buttons [ 2 ] . FromPNG ( ACCESS_EMB_DATA ( emb_checkbox ) , ACCESS_EMB_SIZE ( emb_checkbox ) ) ;
2020-03-19 19:35:58 +01:00
}
2020-03-24 05:36:39 +01:00
Status = Buttons [ 3 ] . LoadXImage ( ThemeDir , " checkbox_checked " ) ;
2020-03-19 19:35:58 +01:00
if ( EFI_ERROR ( Status ) ) {
2020-03-24 05:36:39 +01:00
Buttons [ 3 ] . FromPNG ( ACCESS_EMB_DATA ( emb_checkbox_checked ) , ACCESS_EMB_SIZE ( emb_checkbox_checked ) ) ;
2020-03-19 19:35:58 +01:00
}
2020-03-18 10:07:34 +01:00
2020-03-17 20:43:58 +01:00
// non-selected background images
2020-03-18 10:07:34 +01:00
2020-03-21 12:43:45 +01:00
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BackgroundPixel = { 0xbf , 0xbf , 0xbf , 0xff } ;
2020-03-18 10:07:34 +01:00
if ( ! SelectionBigFileName . isEmpty ( ) ) {
BackgroundPixel = { 0x00 , 0x00 , 0x00 , 0x00 } ;
} else if ( DarkEmbedded | | TypeSVG ) {
BackgroundPixel = { 0x33 , 0x33 , 0x33 , 0xff } ;
2020-03-17 20:43:58 +01:00
} else {
2020-03-18 10:07:34 +01:00
BackgroundPixel = { 0xbf , 0xbf , 0xbf , 0xff } ;
2020-03-17 20:43:58 +01:00
}
2020-03-18 10:07:34 +01:00
SelectionImages [ 1 ] = XImage ( row0TileSize , row0TileSize ) ;
2020-03-21 12:43:45 +01:00
SelectionImages [ 1 ] . Fill ( BackgroundPixel ) ;
2020-03-18 10:07:34 +01:00
SelectionImages [ 3 ] = XImage ( row1TileSize , row1TileSize ) ;
2020-03-21 12:43:45 +01:00
SelectionImages [ 3 ] . Fill ( BackgroundPixel ) ;
2020-03-18 10:07:34 +01:00
2020-03-17 20:43:58 +01:00
}
2020-03-18 15:11:56 +01:00
2020-03-19 19:35:58 +01:00
//use this only for PNG theme
2020-03-18 15:11:56 +01:00
void XTheme : : FillByDir ( ) //assume ThemeDir is defined by InitTheme() procedure
{
2020-03-19 19:35:58 +01:00
for ( INTN i = 0 ; i < BUILTIN_ICON_COUNT ; + + i ) {
Icon NewIcon ( i , true ) ; //initialize with embedded but further replace by loaded
2020-03-21 12:43:45 +01:00
NewIcon . Image . LoadXImage ( ThemeDir , IconsNames [ i ] ) ;
NewIcon . ImageNight . LoadXImage ( ThemeDir , XStringWP ( IconsNames [ i ] ) + XStringWP ( " _night " ) ) ;
2020-03-18 15:11:56 +01:00
Icons . AddCopy ( NewIcon ) ;
}
2020-03-19 19:35:58 +01:00
for ( INTN i = BUILTIN_ICON_COUNT ; i < 45 ; + + i ) {
Icon NewIcon ( i ) ; //there is no embedded
2020-03-21 12:43:45 +01:00
NewIcon . Image . LoadXImage ( ThemeDir , IconsNames [ i ] ) ; //all os_***
2020-03-19 19:35:58 +01:00
Icons . AddCopy ( NewIcon ) ;
}
InitSelection ( ) ; //initialize selections, buttons
2020-03-20 18:48:19 +01:00
//load banner and background
2020-03-19 19:35:58 +01:00
Banner . LoadXImage ( ThemeDir , BannerFileName ) ;
2020-03-24 05:36:39 +01:00
BigBack . LoadXImage ( ThemeDir , BackgroundName ) ;
2020-03-20 18:48:19 +01:00
}
void XTheme : : InitBar ( )
{
if ( ! TypeSVG ) {
ScrollbarBackgroundImage . LoadXImage ( ThemeDir , " scrollbar \\ bar_fill " ) ;
BarStartImage . LoadXImage ( ThemeDir , " scrollbar \\ bar_start " ) ;
BarEndImage . LoadXImage ( ThemeDir , " scrollbar \\ bar_end " ) ;
ScrollbarImage . LoadXImage ( ThemeDir , " scrollbar \\ scroll_fill " ) ;
ScrollStartImage . LoadXImage ( ThemeDir , " scrollbar \\ scroll_start " ) ;
ScrollEndImage . LoadXImage ( ThemeDir , " scrollbar \\ scroll_end " ) ;
UpButtonImage . LoadXImage ( ThemeDir , " scrollbar \\ up_button " ) ;
DownButtonImage . LoadXImage ( ThemeDir , " scrollbar \\ down_button " ) ;
}
2020-03-19 19:35:58 +01:00
2020-03-20 18:48:19 +01:00
//some help with embedded scroll
if ( BarStartImage . isEmpty ( ) & & ! TypeSVG ) {
BarStartImage . FromPNG ( ACCESS_EMB_DATA ( emb_scroll_bar_start ) , ACCESS_EMB_SIZE ( emb_scroll_bar_start ) ) ;
}
if ( BarEndImage . isEmpty ( ) & & ! TypeSVG ) {
BarEndImage . FromPNG ( ACCESS_EMB_DATA ( emb_scroll_bar_end ) , ACCESS_EMB_SIZE ( emb_scroll_bar_end ) ) ;
}
if ( ScrollbarBackgroundImage . isEmpty ( ) ) {
if ( TypeSVG ) {
//return OSIconsTable[i].image;
2020-03-24 05:36:39 +01:00
ScrollbarBackgroundImage = GetIcon ( " scrollbar_background " ) ;
2020-03-20 18:48:19 +01:00
}
if ( ScrollbarBackgroundImage . isEmpty ( ) ) {
ScrollbarBackgroundImage . FromPNG ( ACCESS_EMB_DATA ( emb_scroll_bar_fill ) , ACCESS_EMB_SIZE ( emb_scroll_bar_fill ) ) ;
}
}
if ( ScrollbarImage . isEmpty ( ) ) {
if ( TypeSVG ) {
2020-03-24 05:36:39 +01:00
ScrollbarImage = GetIcon ( " scrollbar_holder " ) ; //"_night" is already accounting
2020-03-20 18:48:19 +01:00
}
if ( ScrollbarImage . isEmpty ( ) ) {
ScrollbarImage . FromPNG ( ACCESS_EMB_DATA ( emb_scroll_scroll_fill ) , ACCESS_EMB_SIZE ( emb_scroll_scroll_fill ) ) ;
}
}
if ( ScrollStartImage . isEmpty ( ) ) {
if ( TypeSVG ) {
2020-03-24 05:36:39 +01:00
ScrollStartImage = GetIcon ( " scrollbar_start " ) ;
2020-03-20 18:48:19 +01:00
}
if ( ScrollStartImage . isEmpty ( ) ) {
ScrollStartImage . FromPNG ( ACCESS_EMB_DATA ( emb_scroll_scroll_start ) , ACCESS_EMB_SIZE ( emb_scroll_scroll_start ) ) ;
}
}
if ( ScrollEndImage . isEmpty ( ) ) {
if ( TypeSVG ) {
2020-03-24 05:36:39 +01:00
ScrollEndImage = GetIcon ( " scrollbar_end " ) ;
2020-03-20 18:48:19 +01:00
}
if ( ScrollEndImage . isEmpty ( ) ) {
ScrollEndImage . FromPNG ( ACCESS_EMB_DATA ( emb_scroll_scroll_end ) , ACCESS_EMB_SIZE ( emb_scroll_scroll_end ) ) ;
}
}
if ( UpButtonImage . isEmpty ( ) ) {
if ( TypeSVG ) {
2020-03-24 05:36:39 +01:00
UpButtonImage = GetIcon ( " scrollbar_up_button " ) ;
2020-03-20 18:48:19 +01:00
}
UpButtonImage . FromPNG ( ACCESS_EMB_DATA ( emb_scroll_up_button ) , ACCESS_EMB_SIZE ( emb_scroll_up_button ) ) ;
}
if ( DownButtonImage . isEmpty ( ) ) {
if ( TypeSVG ) {
2020-03-24 05:36:39 +01:00
DownButtonImage = GetIcon ( " scrollbar_down_button " ) ;
2020-03-20 18:48:19 +01:00
}
if ( DownButtonImage . isEmpty ( ) ) {
DownButtonImage . FromPNG ( ACCESS_EMB_DATA ( emb_scroll_down_button ) , ACCESS_EMB_SIZE ( emb_scroll_down_button ) ) ;
}
}
2020-03-24 05:36:39 +01:00
//TODO it must be somewhere in InitScroll - Scrfeen function
2020-03-20 18:48:19 +01:00
if ( ! TypeSVG ) {
UpButton . Width = ScrollWidth ; // 16
UpButton . Height = ScrollButtonsHeight ; // 20
DownButton . Width = UpButton . Width ;
DownButton . Height = ScrollButtonsHeight ;
BarStart . Height = ScrollBarDecorationsHeight ; // 5
BarEnd . Height = ScrollBarDecorationsHeight ;
ScrollStart . Height = ScrollScrollDecorationsHeight ; // 7
ScrollEnd . Height = ScrollScrollDecorationsHeight ;
} else {
UpButton . Width = ScrollWidth ; // 16
UpButton . Height = 0 ; // 20
DownButton . Width = UpButton . Width ;
DownButton . Height = 0 ;
BarStart . Height = ScrollBarDecorationsHeight ; // 5
BarEnd . Height = ScrollBarDecorationsHeight ;
ScrollStart . Height = 0 ; // 7
ScrollEnd . Height = 0 ;
}
2020-03-18 15:11:56 +01:00
}
2020-03-20 18:48:19 +01:00