mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 17:58:31 +02:00
implemented cSDDisplayMenu::GetTextAreaFont()
This commit is contained in:
parent
2e4a9b86ed
commit
8b8389d975
2
HISTORY
2
HISTORY
@ -21,3 +21,5 @@ Version 0.0.2
|
||||
- changed display of menu lists, do flush first after complete rendering
|
||||
- added support for custom tokens in dislaychannel
|
||||
- added vps token in menudetailepg
|
||||
- implemented cSDDisplayMenu::GetTextAreaFont()
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "libcore/helpers.h"
|
||||
|
||||
cSDDisplayMenu::cSDDisplayMenu(cTemplate *menuTemplate) {
|
||||
textAreaFont = NULL;
|
||||
doOutput = true;
|
||||
state = vsInit;
|
||||
if (!menuTemplate) {
|
||||
@ -20,6 +21,8 @@ cSDDisplayMenu::~cSDDisplayMenu() {
|
||||
if (!doOutput)
|
||||
return;
|
||||
delete rootView;
|
||||
if (textAreaFont)
|
||||
delete textAreaFont;
|
||||
}
|
||||
|
||||
void cSDDisplayMenu::Scroll(bool Up, bool Page) {
|
||||
@ -180,7 +183,10 @@ int cSDDisplayMenu::GetTextAreaWidth(void) const {
|
||||
}
|
||||
|
||||
const cFont *cSDDisplayMenu::GetTextAreaFont(bool FixedFont) const {
|
||||
return NULL;
|
||||
if (textAreaFont)
|
||||
return textAreaFont;
|
||||
textAreaFont = rootView->GetTextAreaFont();
|
||||
return textAreaFont;
|
||||
}
|
||||
|
||||
void cSDDisplayMenu::SetScrollbar(int Total, int Offset) {
|
||||
|
@ -18,6 +18,7 @@ private:
|
||||
cDisplayMenuRootView *rootView;
|
||||
eViewState state;
|
||||
bool doOutput;
|
||||
mutable cFont *textAreaFont;
|
||||
protected:
|
||||
int Tab(int n);
|
||||
public:
|
||||
|
@ -108,6 +108,12 @@ cFont *cFontManager::Font(string fontName, int fontSize) {
|
||||
return font;
|
||||
}
|
||||
|
||||
cFont *cFontManager::FontUncached(string fontName, int fontSize) {
|
||||
cMutexLock MutexLock(&mutex);
|
||||
cFont *font = CreateFont(fontName, fontSize);
|
||||
return font;
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* Private Functions
|
||||
********************************************************************************/
|
||||
|
@ -28,6 +28,7 @@ class cFontManager {
|
||||
int Width(string fontName, int fontSize, const char *text);
|
||||
int Height(string fontName, int fontSize);
|
||||
cFont *Font(string fontName, int fontSize);
|
||||
cFont *FontUncached(string fontName, int fontSize);
|
||||
void Debug(void);
|
||||
void ListAvailableFonts(void);
|
||||
};
|
||||
|
@ -115,6 +115,54 @@ int cTemplateViewList::GetAverageFontWidth(void) {
|
||||
return averageFontWidth;
|
||||
}
|
||||
|
||||
cFont *cTemplateViewList::GetTextAreaFont(void) {
|
||||
if (!listElement)
|
||||
return NULL;
|
||||
|
||||
int fontWidth = 0;
|
||||
int numItems = GetNumericParameter(ptNumElements);
|
||||
int listHeight = GetNumericParameter(ptHeight);
|
||||
if (listHeight <= 0)
|
||||
return NULL;
|
||||
int itemHeight = (double)listHeight / (double)numItems;
|
||||
string fontFuncName = parameters->GetParameter(ptDeterminateFont);
|
||||
|
||||
cTemplateFunction *fontFunc = listElement->GetFunction(fontFuncName);
|
||||
if (!fontFunc)
|
||||
return NULL;
|
||||
|
||||
string fontNameToken = fontFunc->GetParameter(ptFont);
|
||||
string paramFontSize = fontFunc->GetParameter(ptFontSize);
|
||||
|
||||
string fontName = "";
|
||||
if ((fontNameToken.find("{") == 0) && (fontNameToken.find("}") == (fontNameToken.size()-1))) {
|
||||
fontNameToken = fontNameToken.substr(1, fontNameToken.size()-2);
|
||||
map<string,string>::iterator hit = globals->fonts.find(fontNameToken);
|
||||
if (hit != globals->fonts.end()) {
|
||||
fontName = hit->second;
|
||||
} else {
|
||||
map<string,string>::iterator def = globals->fonts.find("vdrOsd");
|
||||
if (def == globals->fonts.end())
|
||||
return NULL;
|
||||
fontName = def->second;
|
||||
}
|
||||
} else {
|
||||
//if no token, directly use input
|
||||
fontName = fontNameToken;
|
||||
}
|
||||
|
||||
cNumericParameter pFontSize(paramFontSize);
|
||||
pFontSize.SetGlobals(globals);
|
||||
pFontSize.SetAreaSize(1000, itemHeight);
|
||||
pFontSize.SetVertical();
|
||||
int fontSize = pFontSize.Parse(paramFontSize);
|
||||
if (!pFontSize.Valid())
|
||||
return NULL;
|
||||
|
||||
return fontManager->FontUncached(fontName, fontSize);
|
||||
}
|
||||
|
||||
|
||||
int cTemplateViewList::GetMenuItemWidth(void) {
|
||||
return GetNumericParameter(ptMenuItemWidth);
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
cTemplateViewElement *GetListElement(void) { return listElement; };
|
||||
cTemplateViewElement *GetListElementCurrent(void) { return currentElement; };
|
||||
int GetAverageFontWidth(void);
|
||||
cFont *GetTextAreaFont(void);
|
||||
int GetMenuItemWidth(void);
|
||||
int GetNumPixmaps(void);
|
||||
void Debug(void);
|
||||
|
@ -288,15 +288,29 @@ int cDisplayMenuRootView::GetListViewWidth(void) {
|
||||
int cDisplayMenuRootView::GetTextAreaWidth(void) {
|
||||
if (!tmplView)
|
||||
return 1900;
|
||||
cTemplateView *tempSubView = tmplView->GetSubView(svMenuDefault);
|
||||
if (!tempSubView)
|
||||
cTemplateView *tmplSubView = tmplView->GetSubView(svMenuDefault);
|
||||
if (!tmplSubView)
|
||||
return 1900;
|
||||
int areaWidth = tempSubView->GetNumericParameter(ptWidth);
|
||||
int areaWidth = tmplSubView->GetNumericParameter(ptWidth);
|
||||
if (areaWidth > 0)
|
||||
return areaWidth;
|
||||
return 1900;
|
||||
}
|
||||
|
||||
cFont *cDisplayMenuRootView::GetTextAreaFont(void) {
|
||||
if (!tmplView)
|
||||
return NULL;
|
||||
cTemplateView *tmplSubViewDefault = tmplView->GetSubView(svMenuDefault);
|
||||
if (!tmplSubViewDefault)
|
||||
return NULL;
|
||||
|
||||
cTemplateViewList *tmplViewList = tmplSubViewDefault->GetViewList(vlMenuItem);
|
||||
if (!tmplViewList)
|
||||
return NULL;
|
||||
|
||||
return tmplViewList->GetTextAreaFont();
|
||||
}
|
||||
|
||||
|
||||
void cDisplayMenuRootView::Render(void) {
|
||||
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
int GetMaxItems(void);
|
||||
int GetListViewWidth(void);
|
||||
int GetTextAreaWidth(void);
|
||||
cFont *GetTextAreaFont(void);
|
||||
bool SubViewAvailable(void) { return subViewAvailable; };
|
||||
cDisplayMenuListView *GetListView(void) { return listView; };
|
||||
void Render(void);
|
||||
|
Loading…
Reference in New Issue
Block a user