2020-03-12 10:47:59 +01:00
# if !defined(__XTHEME_H__)
2020-03-13 14:34:36 +01:00
# define __XTHEME_H__
2023-11-06 22:46:13 +01:00
# include "nanosvg.h"
2020-03-12 10:47:59 +01:00
# include "../cpp_foundation/XObjArray.h"
2020-03-16 12:15:25 +01:00
# include "../cpp_foundation/XString.h"
2021-04-28 20:30:34 +02:00
# include "../Settings/Self.h"
2020-03-13 14:34:36 +01:00
# include "libeg.h"
2020-03-26 18:00:53 +01:00
# include "XImage.h"
2020-08-11 14:43:53 +02:00
# include "XIcon.h"
2020-04-13 21:01:40 +02:00
# include "XCinema.h"
2020-03-26 18:00:53 +01:00
2020-08-25 17:35:19 +02:00
2021-02-06 18:16:46 +01:00
class TagDict ;
2020-08-19 14:50:26 +02:00
class TagStruct ;
2020-03-18 07:39:11 +01:00
# define INDICATOR_SIZE (52)
2021-02-06 18:16:46 +01:00
# define CONFIG_THEME_FILENAME L"theme.plist"
# define CONFIG_THEME_SVG L"theme.svg"
# define HEIGHT_2K 1100
EFI_STATUS InitTheme ( const CHAR8 * ChosenTheme ) ;
2023-11-08 14:35:22 +01:00
extern textFaces nullTextFaces ;
2020-03-18 07:39:11 +01:00
2020-03-13 14:34:36 +01:00
class XTheme
{
public :
2020-05-16 21:30:29 +02:00
XObjArray < XIcon > Icons ;
2020-10-20 09:55:46 +02:00
XStringW m_ThemePath = NullXStringW ;
2023-11-08 14:35:22 +01:00
EFI_FILE * ThemeDir = 0 ;
2020-10-03 19:02:31 +02:00
2020-03-27 17:50:17 +01:00
// UINTN DisableFlags;
2020-03-12 10:47:59 +01:00
UINTN HideBadges ;
UINTN HideUIFlags ;
2021-09-28 15:54:31 +02:00
// XBool TextOnly;
2020-03-12 10:47:59 +01:00
FONT_TYPE Font ;
INTN CharWidth ;
UINTN SelectionColor ;
XStringW FontFileName ;
XStringW Theme ;
XStringW BannerFileName ;
XStringW SelectionSmallFileName ;
XStringW SelectionBigFileName ;
XStringW SelectionIndicatorName ;
XStringW DefaultSelection ;
XStringW BackgroundName ;
SCALING BackgroundScale ;
2020-03-26 15:24:20 +01:00
INTN BackgroundSharp ;
2021-09-28 15:54:31 +02:00
XBool BackgroundDark ;
// XBool CustomIcons;
XBool SelectionOnTop ;
XBool BootCampStyle ;
2020-03-12 10:47:59 +01:00
INTN BadgeOffsetX ;
INTN BadgeOffsetY ;
INTN BadgeScale ;
INTN ThemeDesignWidth ;
INTN ThemeDesignHeight ;
INTN BannerPosX ;
INTN BannerPosY ;
INTN BannerEdgeHorizontal ;
INTN BannerEdgeVertical ;
INTN BannerNudgeX ;
INTN BannerNudgeY ;
2021-09-28 15:54:31 +02:00
XBool VerticalLayout ;
XBool NonSelectedGrey ;
2020-03-12 10:47:59 +01:00
INTN MainEntriesSize ;
INTN TileXSpace ;
INTN TileYSpace ;
2020-03-12 15:00:36 +01:00
// INTN IconFormat;
2021-09-28 15:54:31 +02:00
XBool Proportional ;
// XBool ShowOptimus;
XBool embedded ;
XBool DarkEmbedded ;
XBool TypeSVG ;
2020-04-08 11:45:36 +02:00
// INTN Codepage; //no! it is global settings
// INTN CodepageSize;
2020-03-12 10:47:59 +01:00
float Scale ;
2020-03-13 14:34:36 +01:00
float CentreShift ;
2020-03-20 18:48:19 +01:00
INTN row0TileSize ;
INTN row1TileSize ;
2020-04-04 05:46:41 +02:00
INTN BanHeight ;
2020-03-20 18:48:19 +01:00
INTN LayoutHeight ; //it was 376 before
2020-03-26 15:24:20 +01:00
INTN LayoutBannerOffset ;
INTN LayoutButtonOffset ;
INTN LayoutTextOffset ;
INTN LayoutAnimMoveForMenuX ;
2020-04-02 16:03:58 +02:00
INTN ScrollWidth ;
INTN ScrollButtonsHeight ;
INTN ScrollBarDecorationsHeight ;
INTN ScrollScrollDecorationsHeight ;
2020-03-26 15:24:20 +01:00
2020-04-07 21:48:36 +02:00
INTN FontWidth ;
INTN FontHeight ;
INTN TextHeight ;
2021-09-28 15:54:31 +02:00
XBool Daylight ;
2020-03-13 14:34:36 +01:00
XImage Background ; //Background and Banner will not be in array as they live own life
2020-03-17 05:25:38 +01:00
XImage BigBack ; //it size is not equal to screen size will be scaled or cropped
XImage Banner ; //same as logo in the array, make a link?
2020-03-20 18:48:19 +01:00
XImage SelectionImages [ 6 ] ;
2020-03-23 15:51:20 +01:00
XImage Buttons [ 4 ] ;
2020-03-20 18:48:19 +01:00
XImage ScrollbarBackgroundImage ;
XImage BarStartImage ;
XImage BarEndImage ;
XImage ScrollbarImage ;
XImage ScrollStartImage ;
XImage ScrollEndImage ;
XImage UpButtonImage ;
XImage DownButtonImage ;
2020-03-13 14:34:36 +01:00
2020-04-07 21:48:36 +02:00
XImage FontImage ;
2020-04-04 05:46:41 +02:00
EG_RECT BannerPlace ;
2020-04-16 06:45:53 +02:00
2020-04-13 21:01:40 +02:00
XCinema Cinema ;
2020-04-16 06:45:53 +02:00
2023-11-11 07:20:58 +01:00
UINTN NumFrames = 0 ;
UINTN FrameTime = 0 ;
2023-11-11 06:50:58 +01:00
2023-11-08 14:35:22 +01:00
public :
NSVGfontChain * fontsDB = 0 ;
textFaces textFace [ 4 ] ; //0-help 1-message 2-menu 3-test, far future it will be infinite list with id // in VectorGraphics, I use sizeof(textFace)/sizeof(textFace[0]. So if you change that to a pointer, it'll break.
2020-08-11 14:43:53 +02:00
void Init ( ) ;
XTheme ( ) ; //default constructor
XTheme ( const XTheme & ) = delete ;
XTheme & operator = ( const XTheme & ) = delete ;
2023-11-08 14:35:22 +01:00
~ XTheme ( ) {
if ( ThemeDir ! = NULL ) ThemeDir - > Close ( ThemeDir ) ;
if ( fontsDB ) {
nsvg__deleteFontChain ( fontsDB ) ;
}
for ( size_t i = 0 ; i < Icons . length ( ) ; + + i ) {
Icons [ i ] . setEmpty ( ) ;
}
}
2020-08-11 14:43:53 +02:00
2023-11-08 14:35:22 +01:00
const EFI_FILE & getThemeDir ( ) const { return * ThemeDir ; }
2023-11-12 03:48:29 +01:00
XBool IsEmbeddedTheme ( void )
{
if ( embedded ) {
ThemeDir = NULL ;
}
return ThemeDir = = NULL ;
}
2023-11-08 14:35:22 +01:00
2020-03-17 05:25:38 +01:00
//fill the theme
2020-04-05 14:25:39 +02:00
// const XImage& GetIcon(const char* Name);
// const XImage& GetIcon(const CHAR16* Name);
2020-05-16 21:30:29 +02:00
const XIcon & GetIcon ( const XString8 & Name ) ; //get by name
2023-11-08 14:35:22 +01:00
XIcon * GetIconP ( const XString8 & Name ) ;
2020-05-16 21:30:29 +02:00
const XIcon & GetIcon ( INTN Id ) ; //get by id
2020-05-23 13:16:02 +02:00
XIcon & GetIconAlt ( INTN Id , INTN Alt ) ; //if id not found
2020-05-16 21:30:29 +02:00
const XIcon & LoadOSIcon ( const CHAR16 * OSIconName ) ; //TODO make XString provider
const XIcon & LoadOSIcon ( const XString8 & Full ) ;
2021-09-28 15:54:31 +02:00
XBool CheckNative ( INTN Id ) ;
2020-05-16 21:30:29 +02:00
2020-04-07 21:48:36 +02:00
//fonts
2021-09-28 10:28:45 +02:00
void LoadFontImage ( IN XBool UseEmbedded , IN INTN Rows , IN INTN Cols ) ;
2020-04-07 21:48:36 +02:00
void PrepareFont ( ) ;
2020-04-22 01:27:01 +02:00
INTN GetEmpty ( const XImage & Buffer , const EFI_GRAPHICS_OUTPUT_BLT_PIXEL & FirstPixel , INTN MaxWidth , INTN Start , INTN Step ) ;
2020-04-07 21:48:36 +02:00
INTN RenderText ( IN const XStringW & Text , OUT XImage * CompImage_ptr ,
2020-04-15 23:04:33 +02:00
IN INTN PosX , IN INTN PosY , IN UINTN Cursor , INTN textType , float textScale = 0.f ) ;
2020-04-08 11:45:36 +02:00
//overload for UTF8 text
2020-04-30 08:03:56 +02:00
INTN RenderText ( IN const XString8 & Text , OUT XImage * CompImage_ptr ,
2020-04-15 23:04:33 +02:00
IN INTN PosX , IN INTN PosY , IN UINTN Cursor , INTN textType , float textScale = 0.f ) ;
2020-10-03 19:02:31 +02:00
void MeasureText ( IN const XStringW & Text , OUT INTN * Width , OUT INTN * Height ) ;
2020-04-07 21:48:36 +02:00
2020-05-16 21:30:29 +02:00
// void AddIcon(XIcon& NewIcon); //return EFI_STATUS?
2020-03-16 12:15:25 +01:00
void FillByEmbedded ( ) ;
2020-03-21 12:43:45 +01:00
void FillByDir ( ) ;
2020-08-25 17:35:19 +02:00
EFI_STATUS GetThemeTagSettings ( const TagDict * DictPointer ) ;
2021-02-06 18:16:46 +01:00
void parseTheme ( void * p , char * * dict ) ; //in nano project
2023-11-06 22:46:13 +01:00
EFI_STATUS ParseSVGXTheme ( UINT8 * buffer , UINTN Size ) ; // in VectorTheme
2023-11-08 14:35:22 +01:00
EFI_STATUS ParseSVGXIcon ( NSVGparser * SVGParser , INTN Id , const XString8 & IconNameX , XImage * Image ) ;
2020-08-25 17:35:19 +02:00
TagDict * LoadTheme ( const XStringW & TestTheme ) ; //return TagStruct* why?
2023-11-08 14:35:22 +01:00
EFI_STATUS LoadSvgFrame ( NSVGparser * SVGParser , INTN i , OUT XImage * XFrame ) ; // for animation
const textFaces & getTextFace ( size_t idx ) {
if ( ! TypeSVG ) return nullTextFaces ;
return textFace [ idx ] ;
}
2020-03-17 05:25:38 +01:00
//screen operations
void ClearScreen ( ) ;
2020-03-17 20:43:58 +01:00
void FillRectAreaOfScreen ( IN INTN XPos , IN INTN YPos , IN INTN Width , IN INTN Height ) ;
2020-04-05 16:04:39 +02:00
// void InitSelection();
2020-03-20 18:48:19 +01:00
void InitBar ( ) ;
2020-03-16 12:15:25 +01:00
2020-03-13 14:34:36 +01:00
protected :
//internal layout variables instead of globals in menu.cpp
} ;
2021-02-06 18:16:46 +01:00
2023-11-06 21:53:57 +01:00
extern XTheme * ThemeX ;
2021-02-06 18:16:46 +01:00
2020-03-16 20:47:02 +01:00
# endif