add detached option for viewelements

This commit is contained in:
louis 2015-03-22 08:29:52 +01:00
parent 9c93fbc072
commit d1ea7bd4a4
14 changed files with 65 additions and 36 deletions

View File

@ -22,11 +22,13 @@ cSDDisplayChannel::cSDDisplayChannel(cTemplate *channelTemplate, bool WithInfo)
doOutput = false; doOutput = false;
return; return;
} }
esyslog("skindesigner: displaychannel opened");
} }
cSDDisplayChannel::~cSDDisplayChannel() { cSDDisplayChannel::~cSDDisplayChannel() {
if (channelView) if (channelView)
delete channelView; delete channelView;
esyslog("skindesigner: displaychannel closed");
} }
void cSDDisplayChannel::SetChannel(const cChannel *Channel, int Number) { void cSDDisplayChannel::SetChannel(const cChannel *Channel, int Number) {

View File

@ -86,6 +86,9 @@
<!ELEMENT devices (area|areascroll)*> <!ELEMENT devices (area|areascroll)*>
<!ATTLIST devices <!ATTLIST devices
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >

View File

@ -63,6 +63,8 @@ void cTemplateFunction::SetParameters(vector<pair<string, string> > params) {
p.first = ptHeight; p.first = ptHeight;
} else if (!name.compare("menuitemwidth")) { } else if (!name.compare("menuitemwidth")) {
p.first = ptMenuItemWidth; p.first = ptMenuItemWidth;
} else if (!name.compare("detached")) {
p.first = ptDetached;
} else if (!name.compare("fadetime")) { } else if (!name.compare("fadetime")) {
p.first = ptFadeTime; p.first = ptFadeTime;
} else if (!name.compare("imagetype")) { } else if (!name.compare("imagetype")) {
@ -266,6 +268,9 @@ bool cTemplateFunction::CalculateParameters(void) {
case ptHideRoot: case ptHideRoot:
paramValid = SetHideRoot(value); paramValid = SetHideRoot(value);
break; break;
case ptDetached:
paramValid = SetDetached(value);
break;
default: default:
paramValid = true; paramValid = true;
break; break;
@ -406,6 +411,8 @@ int cTemplateFunction::GetNumericParameter(eParamType type) {
return 0; return 0;
else if (type == ptHideRoot) else if (type == ptHideRoot)
return 0; return 0;
else if (type == ptDetached)
return 0;
return -1; return -1;
} }
return hit->second; return hit->second;
@ -1062,6 +1069,14 @@ bool cTemplateFunction::SetHideRoot(string value) {
return true; return true;
} }
bool cTemplateFunction::SetDetached(string value) {
int detached = 0;
if (!value.compare("true"))
detached = 1;
numericParameters.insert(pair<eParamType, int>(ptDetached, detached));
return true;
}
void cTemplateFunction::ParseStringParameters(void) { void cTemplateFunction::ParseStringParameters(void) {
//first replace stringtokens in Text (drawText) //first replace stringtokens in Text (drawText)
stringstream text; stringstream text;
@ -1446,7 +1461,10 @@ string cTemplateFunction::GetParamName(eParamType pt) {
break; break;
case ptMenuItemWidth: case ptMenuItemWidth:
name = "Menu Item Width"; name = "Menu Item Width";
break; break;
case ptDetached:
name = "Detached";
break;
case ptFadeTime: case ptFadeTime:
name = "Fade Time"; name = "Fade Time";
break; break;

View File

@ -45,6 +45,7 @@ enum eParamType {
ptWidth, ptWidth,
ptHeight, ptHeight,
ptMenuItemWidth, ptMenuItemWidth,
ptDetached,
ptFadeTime, ptFadeTime,
ptDelay, ptDelay,
ptImageType, ptImageType,
@ -152,6 +153,7 @@ protected:
bool SetFloating(string value); bool SetFloating(string value);
bool SetOverflow(string value); bool SetOverflow(string value);
bool SetHideRoot(string value); bool SetHideRoot(string value);
bool SetDetached(string value);
void ParseStringParameters(void); void ParseStringParameters(void);
void ParseNumericalParameters(void); void ParseNumericalParameters(void);
void CalculateAlign(int elementWidth, int elementHeight); void CalculateAlign(int elementWidth, int elementHeight);

View File

@ -221,6 +221,14 @@ bool cTemplateView::ExecuteView(eViewElement ve) {
return viewElement->Execute(); return viewElement->Execute();
} }
bool cTemplateView::DetachViewElement(eViewElement ve) {
map < eViewElement, cTemplateViewElement* >::iterator hit = viewElements.find(ve);
if (hit == viewElements.end())
return false;
cTemplateViewElement *viewElement = hit->second;
return viewElement->Detach();
}
int cTemplateView::GetNumListViewMenuItems(void) { int cTemplateView::GetNumListViewMenuItems(void) {
int numElements = 0; int numElements = 0;
cTemplateViewList *menuList = GetViewList(vlMenuItem); cTemplateViewList *menuList = GetViewList(vlMenuItem);
@ -613,6 +621,7 @@ void cTemplateView::SetFunctionDefinitions(void) {
string name = "viewelement"; string name = "viewelement";
set<string> attributes; set<string> attributes;
attributes.insert("debug"); attributes.insert("debug");
attributes.insert("detached");
attributes.insert("delay"); attributes.insert("delay");
attributes.insert("fadetime"); attributes.insert("fadetime");
attributes.insert("name"); attributes.insert("name");

View File

@ -114,6 +114,7 @@ public:
int GetNumPixmapsViewElement(eViewElement ve); int GetNumPixmapsViewElement(eViewElement ve);
bool HideView(void); bool HideView(void);
bool ExecuteView(eViewElement ve); bool ExecuteView(eViewElement ve);
bool DetachViewElement(eViewElement ve);
int GetNumListViewMenuItems(void); int GetNumListViewMenuItems(void);
bool GetScalingWindow(cRect &scalingWindow); bool GetScalingWindow(cRect &scalingWindow);
map<string,string> GetCustomStringTokens(void) { return globals->GetCustomStringTokens(); }; map<string,string> GetCustomStringTokens(void) { return globals->GetCustomStringTokens(); };

View File

@ -124,6 +124,14 @@ bool cTemplateViewElement::Execute(void) {
return parameters->DoExecute(); return parameters->DoExecute();
} }
bool cTemplateViewElement::Detach(void) {
if (!parameters)
return false;
int detached = parameters->GetNumericParameter(ptDetached);
if (detached == 1)
return true;
return false;
}
bool cTemplateViewElement::DebugTokens(void) { bool cTemplateViewElement::DebugTokens(void) {
if (!parameters) if (!parameters)
@ -136,6 +144,7 @@ void cTemplateViewElement::Debug(void) {
esyslog("skindesigner: viewelement container size x: %d, y: %d, width: %d, height %d", containerX, containerY, containerWidth, containerHeight); esyslog("skindesigner: viewelement container size x: %d, y: %d, width: %d, height %d", containerX, containerY, containerWidth, containerHeight);
if (parameters) if (parameters)
parameters->Debug(); parameters->Debug();
return;
for (vector<cTemplatePixmap*>::iterator it = viewPixmaps.begin(); it != viewPixmaps.end(); it++) { for (vector<cTemplatePixmap*>::iterator it = viewPixmaps.begin(); it != viewPixmaps.end(); it++) {
(*it)->Debug(); (*it)->Debug();
} }

View File

@ -107,6 +107,7 @@ public:
cTemplatePixmap *GetNextPixmap(void); cTemplatePixmap *GetNextPixmap(void);
cTemplateFunction *GetFunction(string name); cTemplateFunction *GetFunction(string name);
bool Execute(void); bool Execute(void);
bool Detach(void);
bool DebugTokens(void); bool DebugTokens(void);
virtual void Debug(void); virtual void Debug(void);
}; };

View File

@ -196,7 +196,7 @@
{devices[channelid]} ID of the currently tuned channel {devices[channelid]} ID of the currently tuned channel
{devices[source]} source of the currently tuned channel {devices[source]} source of the currently tuned channel
--> -->
<devices> <devices detached="true" delay="100" fadetime="300">
<area condition="{showdevices}" x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1"> <area condition="{showdevices}" x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1">
<fill color="{clrTransBlack}"/> <fill color="{clrTransBlack}"/>
</area> </area>

View File

@ -393,20 +393,11 @@ void cDisplayChannelView::DrawSignal(void) {
if (!ExecuteViewElement(veSignalQuality)) { if (!ExecuteViewElement(veSignalQuality)) {
return; return;
} }
time_t Now = time(NULL); time_t Now = time(NULL);
if (Now != lastSignalDisplay) { if (Now != lastSignalDisplay) {
#ifdef DOPROFILE
cStopWatch watch("DrawSignal");
#endif
int SignalStrength = cDevice::ActualDevice()->SignalStrength(); int SignalStrength = cDevice::ActualDevice()->SignalStrength();
#ifdef DOPROFILE
watch.Report("SignalStrength");
#endif
int SignalQuality = cDevice::ActualDevice()->SignalQuality(); int SignalQuality = cDevice::ActualDevice()->SignalQuality();
#ifdef DOPROFILE
watch.Report("SignalQuality");
watch.Stop("DrawSignal");
#endif
if (SignalStrength < 0) SignalStrength = 0; if (SignalStrength < 0) SignalStrength = 0;
if (SignalQuality < 0) SignalQuality = 0; if (SignalQuality < 0) SignalQuality = 0;
if ((SignalStrength == 0)&&(SignalQuality==0)) if ((SignalStrength == 0)&&(SignalQuality==0))
@ -445,6 +436,11 @@ void cDisplayChannelView::DrawDevices(bool initial) {
if (!ExecuteViewElement(veDevices)) { if (!ExecuteViewElement(veDevices)) {
return; return;
} }
if (DetachViewElement(veDevices)) {
esyslog("skindesigner: start new thread for devices");
}
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
map < string, vector< map< string, string > > > deviceLoopTokens; map < string, vector< map< string, string > > > deviceLoopTokens;

View File

@ -206,12 +206,20 @@ void cView::ActivateScrolling(void) {
} }
bool cView::ExecuteViewElement(eViewElement ve) { bool cView::ExecuteViewElement(eViewElement ve) {
if (!tmplView)
return false;
bool doExecute = tmplView->ExecuteView(ve); bool doExecute = tmplView->ExecuteView(ve);
if (!doExecute) if (!doExecute)
return false; return false;
return tmplView->GetNumPixmapsViewElement(ve); return tmplView->GetNumPixmapsViewElement(ve);
} }
bool cView::DetachViewElement(eViewElement ve) {
if (!tmplView)
return false;
return tmplView->DetachViewElement(ve);
}
bool cView::ViewElementScrolls(eViewElement ve) { bool cView::ViewElementScrolls(eViewElement ve) {
if (scrollingPix < 0) if (scrollingPix < 0)
return false; return false;

View File

@ -43,6 +43,7 @@ protected:
void ClearViewElement(eViewElement ve); void ClearViewElement(eViewElement ve);
void DestroyViewElement(eViewElement ve); void DestroyViewElement(eViewElement ve);
bool ExecuteViewElement(eViewElement ve); bool ExecuteViewElement(eViewElement ve);
bool DetachViewElement(eViewElement ve);
bool ViewElementScrolls(eViewElement ve); bool ViewElementScrolls(eViewElement ve);
void CreateViewPixmap(int num, cTemplatePixmap *pix, cRect *size = NULL); void CreateViewPixmap(int num, cTemplatePixmap *pix, cRect *size = NULL);
void CreateScrollingPixmap(int num, cTemplatePixmap *pix, cSize &drawportSize); void CreateScrollingPixmap(int num, cTemplatePixmap *pix, cSize &drawportSize);

View File

@ -6,6 +6,7 @@
#include "viewhelpers.h" #include "viewhelpers.h"
cViewHelpers::cViewHelpers(void) { cViewHelpers::cViewHelpers(void) {
numDevices = 0;
devicesInit = false; devicesInit = false;
lastSecond = -1; lastSecond = -1;
lastMinute = -1; lastMinute = -1;
@ -20,7 +21,7 @@ cViewHelpers::~cViewHelpers() {
} }
void cViewHelpers::InitDevices(void) { void cViewHelpers::InitDevices(void) {
int numDevices = cDevice::NumDevices(); numDevices = cDevice::NumDevices();
lastSignalStrength = new int[numDevices]; lastSignalStrength = new int[numDevices];
lastSignalQuality = new int[numDevices]; lastSignalQuality = new int[numDevices];
recDevices = new bool[numDevices]; recDevices = new bool[numDevices];
@ -33,10 +34,6 @@ void cViewHelpers::InitDevices(void) {
} }
bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices) { bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices) {
#ifdef DOPROFILE
cStopWatch watch("SetDevices");
#endif
int numDevices = cDevice::NumDevices();
if (!initial) { if (!initial) {
//check if drawing is necessary //check if drawing is necessary
bool changed = false; bool changed = false;
@ -46,23 +43,13 @@ bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<m
continue; continue;
} }
int signalStrength = device->SignalStrength(); int signalStrength = device->SignalStrength();
#ifdef DOPROFILE
watch.Report(*cString::sprintf("SignalStrength() device %d", i));
#endif
int signalQuality = device->SignalQuality(); int signalQuality = device->SignalQuality();
#ifdef DOPROFILE
watch.Report(*cString::sprintf("SignalQuality() device %d", i));
#endif
if ((signalStrength != lastSignalStrength[i]) || (signalQuality != lastSignalQuality[i])) { if ((signalStrength != lastSignalStrength[i]) || (signalQuality != lastSignalQuality[i])) {
changed = true; changed = true;
break; break;
} }
} }
if (!changed) { if (!changed) {
#ifdef DOPROFILE
watch.Stop("SetDevices End");
#endif
return false; return false;
} }
} }
@ -109,13 +96,7 @@ bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<m
deviceVals.insert(pair< string, string >("devices[hascam]", "0")); deviceVals.insert(pair< string, string >("devices[hascam]", "0"));
} }
int signalStrength = device->SignalStrength(); int signalStrength = device->SignalStrength();
#ifdef DOPROFILE
watch.Report(*cString::sprintf("SignalStrength() device %d", i));
#endif
int signalQuality = device->SignalQuality(); int signalQuality = device->SignalQuality();
#ifdef DOPROFILE
watch.Report(*cString::sprintf("SignalQuality() device %d", i));
#endif
stringstream strCamNumber; stringstream strCamNumber;
strCamNumber << camNumber; strCamNumber << camNumber;
deviceVals.insert(pair< string, string >("devices[cam]", strCamNumber.str())); deviceVals.insert(pair< string, string >("devices[cam]", strCamNumber.str()));
@ -157,9 +138,6 @@ bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<m
} }
intTokens->insert(pair<string, int>("numdevices", actualNumDevices)); intTokens->insert(pair<string, int>("numdevices", actualNumDevices));
#ifdef DOPROFILE
watch.Stop("SetDevices End");
#endif
return true; return true;
} }

View File

@ -3,6 +3,7 @@
class cViewHelpers { class cViewHelpers {
private: private:
int numDevices;
bool devicesInit; bool devicesInit;
int* lastSignalStrength; int* lastSignalStrength;
int* lastSignalQuality; int* lastSignalQuality;