From d1ea7bd4a467463b939029aa76c43bae4e58b73f Mon Sep 17 00:00:00 2001 From: louis Date: Sun, 22 Mar 2015 08:29:52 +0100 Subject: [PATCH] add detached option for viewelements --- displaychannel.c | 2 ++ dtd/displaychannel.dtd | 3 +++ libtemplate/templatefunction.c | 20 ++++++++++++++++- libtemplate/templatefunction.h | 2 ++ libtemplate/templateview.c | 9 ++++++++ libtemplate/templateview.h | 1 + libtemplate/templateviewelement.c | 9 ++++++++ libtemplate/templateviewelement.h | 1 + skins/metrixhd/xmlfiles/displaychannel.xml | 2 +- views/displaychannelview.c | 16 +++++-------- views/view.c | 8 +++++++ views/view.h | 1 + views/viewhelpers.c | 26 ++-------------------- views/viewhelpers.h | 1 + 14 files changed, 65 insertions(+), 36 deletions(-) diff --git a/displaychannel.c b/displaychannel.c index 711f05a..bb447d3 100644 --- a/displaychannel.c +++ b/displaychannel.c @@ -22,11 +22,13 @@ cSDDisplayChannel::cSDDisplayChannel(cTemplate *channelTemplate, bool WithInfo) doOutput = false; return; } + esyslog("skindesigner: displaychannel opened"); } cSDDisplayChannel::~cSDDisplayChannel() { if (channelView) delete channelView; + esyslog("skindesigner: displaychannel closed"); } void cSDDisplayChannel::SetChannel(const cChannel *Channel, int Number) { diff --git a/dtd/displaychannel.dtd b/dtd/displaychannel.dtd index fcae25d..cb86725 100644 --- a/dtd/displaychannel.dtd +++ b/dtd/displaychannel.dtd @@ -86,6 +86,9 @@ diff --git a/libtemplate/templatefunction.c b/libtemplate/templatefunction.c index fa0b958..8ea8917 100644 --- a/libtemplate/templatefunction.c +++ b/libtemplate/templatefunction.c @@ -63,6 +63,8 @@ void cTemplateFunction::SetParameters(vector > params) { p.first = ptHeight; } else if (!name.compare("menuitemwidth")) { p.first = ptMenuItemWidth; + } else if (!name.compare("detached")) { + p.first = ptDetached; } else if (!name.compare("fadetime")) { p.first = ptFadeTime; } else if (!name.compare("imagetype")) { @@ -266,6 +268,9 @@ bool cTemplateFunction::CalculateParameters(void) { case ptHideRoot: paramValid = SetHideRoot(value); break; + case ptDetached: + paramValid = SetDetached(value); + break; default: paramValid = true; break; @@ -406,6 +411,8 @@ int cTemplateFunction::GetNumericParameter(eParamType type) { return 0; else if (type == ptHideRoot) return 0; + else if (type == ptDetached) + return 0; return -1; } return hit->second; @@ -1062,6 +1069,14 @@ bool cTemplateFunction::SetHideRoot(string value) { return true; } +bool cTemplateFunction::SetDetached(string value) { + int detached = 0; + if (!value.compare("true")) + detached = 1; + numericParameters.insert(pair(ptDetached, detached)); + return true; +} + void cTemplateFunction::ParseStringParameters(void) { //first replace stringtokens in Text (drawText) stringstream text; @@ -1446,7 +1461,10 @@ string cTemplateFunction::GetParamName(eParamType pt) { break; case ptMenuItemWidth: name = "Menu Item Width"; - break; + break; + case ptDetached: + name = "Detached"; + break; case ptFadeTime: name = "Fade Time"; break; diff --git a/libtemplate/templatefunction.h b/libtemplate/templatefunction.h index 66678a6..e53dbda 100644 --- a/libtemplate/templatefunction.h +++ b/libtemplate/templatefunction.h @@ -45,6 +45,7 @@ enum eParamType { ptWidth, ptHeight, ptMenuItemWidth, + ptDetached, ptFadeTime, ptDelay, ptImageType, @@ -152,6 +153,7 @@ protected: bool SetFloating(string value); bool SetOverflow(string value); bool SetHideRoot(string value); + bool SetDetached(string value); void ParseStringParameters(void); void ParseNumericalParameters(void); void CalculateAlign(int elementWidth, int elementHeight); diff --git a/libtemplate/templateview.c b/libtemplate/templateview.c index e0cd079..5677a31 100644 --- a/libtemplate/templateview.c +++ b/libtemplate/templateview.c @@ -221,6 +221,14 @@ bool cTemplateView::ExecuteView(eViewElement ve) { 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 numElements = 0; cTemplateViewList *menuList = GetViewList(vlMenuItem); @@ -613,6 +621,7 @@ void cTemplateView::SetFunctionDefinitions(void) { string name = "viewelement"; set attributes; attributes.insert("debug"); + attributes.insert("detached"); attributes.insert("delay"); attributes.insert("fadetime"); attributes.insert("name"); diff --git a/libtemplate/templateview.h b/libtemplate/templateview.h index fa55ba2..51bb4bf 100644 --- a/libtemplate/templateview.h +++ b/libtemplate/templateview.h @@ -114,6 +114,7 @@ public: int GetNumPixmapsViewElement(eViewElement ve); bool HideView(void); bool ExecuteView(eViewElement ve); + bool DetachViewElement(eViewElement ve); int GetNumListViewMenuItems(void); bool GetScalingWindow(cRect &scalingWindow); map GetCustomStringTokens(void) { return globals->GetCustomStringTokens(); }; diff --git a/libtemplate/templateviewelement.c b/libtemplate/templateviewelement.c index 8c9541a..aae68a8 100644 --- a/libtemplate/templateviewelement.c +++ b/libtemplate/templateviewelement.c @@ -124,6 +124,14 @@ bool cTemplateViewElement::Execute(void) { 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) { 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); if (parameters) parameters->Debug(); + return; for (vector::iterator it = viewPixmaps.begin(); it != viewPixmaps.end(); it++) { (*it)->Debug(); } diff --git a/libtemplate/templateviewelement.h b/libtemplate/templateviewelement.h index 5c7be48..4e4ea00 100644 --- a/libtemplate/templateviewelement.h +++ b/libtemplate/templateviewelement.h @@ -107,6 +107,7 @@ public: cTemplatePixmap *GetNextPixmap(void); cTemplateFunction *GetFunction(string name); bool Execute(void); + bool Detach(void); bool DebugTokens(void); virtual void Debug(void); }; diff --git a/skins/metrixhd/xmlfiles/displaychannel.xml b/skins/metrixhd/xmlfiles/displaychannel.xml index 3c63a18..7e39236 100644 --- a/skins/metrixhd/xmlfiles/displaychannel.xml +++ b/skins/metrixhd/xmlfiles/displaychannel.xml @@ -196,7 +196,7 @@ {devices[channelid]} ID of the currently tuned channel {devices[source]} source of the currently tuned channel --> - + diff --git a/views/displaychannelview.c b/views/displaychannelview.c index 384ae67..fe127e7 100644 --- a/views/displaychannelview.c +++ b/views/displaychannelview.c @@ -393,20 +393,11 @@ void cDisplayChannelView::DrawSignal(void) { if (!ExecuteViewElement(veSignalQuality)) { return; } + time_t Now = time(NULL); if (Now != lastSignalDisplay) { -#ifdef DOPROFILE - cStopWatch watch("DrawSignal"); -#endif int SignalStrength = cDevice::ActualDevice()->SignalStrength(); -#ifdef DOPROFILE - watch.Report("SignalStrength"); -#endif int SignalQuality = cDevice::ActualDevice()->SignalQuality(); -#ifdef DOPROFILE - watch.Report("SignalQuality"); - watch.Stop("DrawSignal"); -#endif if (SignalStrength < 0) SignalStrength = 0; if (SignalQuality < 0) SignalQuality = 0; if ((SignalStrength == 0)&&(SignalQuality==0)) @@ -445,6 +436,11 @@ void cDisplayChannelView::DrawDevices(bool initial) { if (!ExecuteViewElement(veDevices)) { return; } + + if (DetachViewElement(veDevices)) { + esyslog("skindesigner: start new thread for devices"); + } + map < string, string > stringTokens; map < string, int > intTokens; map < string, vector< map< string, string > > > deviceLoopTokens; diff --git a/views/view.c b/views/view.c index 6c4cb26..0c8c584 100644 --- a/views/view.c +++ b/views/view.c @@ -206,12 +206,20 @@ void cView::ActivateScrolling(void) { } bool cView::ExecuteViewElement(eViewElement ve) { + if (!tmplView) + return false; bool doExecute = tmplView->ExecuteView(ve); if (!doExecute) return false; return tmplView->GetNumPixmapsViewElement(ve); } +bool cView::DetachViewElement(eViewElement ve) { + if (!tmplView) + return false; + return tmplView->DetachViewElement(ve); +} + bool cView::ViewElementScrolls(eViewElement ve) { if (scrollingPix < 0) return false; diff --git a/views/view.h b/views/view.h index 3c19b83..3d9c501 100644 --- a/views/view.h +++ b/views/view.h @@ -43,6 +43,7 @@ protected: void ClearViewElement(eViewElement ve); void DestroyViewElement(eViewElement ve); bool ExecuteViewElement(eViewElement ve); + bool DetachViewElement(eViewElement ve); bool ViewElementScrolls(eViewElement ve); void CreateViewPixmap(int num, cTemplatePixmap *pix, cRect *size = NULL); void CreateScrollingPixmap(int num, cTemplatePixmap *pix, cSize &drawportSize); diff --git a/views/viewhelpers.c b/views/viewhelpers.c index e10798f..3ec8847 100644 --- a/views/viewhelpers.c +++ b/views/viewhelpers.c @@ -6,6 +6,7 @@ #include "viewhelpers.h" cViewHelpers::cViewHelpers(void) { + numDevices = 0; devicesInit = false; lastSecond = -1; lastMinute = -1; @@ -20,7 +21,7 @@ cViewHelpers::~cViewHelpers() { } void cViewHelpers::InitDevices(void) { - int numDevices = cDevice::NumDevices(); + numDevices = cDevice::NumDevices(); lastSignalStrength = new int[numDevices]; lastSignalQuality = new int[numDevices]; recDevices = new bool[numDevices]; @@ -33,10 +34,6 @@ void cViewHelpers::InitDevices(void) { } bool cViewHelpers::SetDevices(bool initial, map *intTokens, vector > *devices) { -#ifdef DOPROFILE - cStopWatch watch("SetDevices"); -#endif - int numDevices = cDevice::NumDevices(); if (!initial) { //check if drawing is necessary bool changed = false; @@ -46,23 +43,13 @@ bool cViewHelpers::SetDevices(bool initial, map *intTokens, vectorSignalStrength(); -#ifdef DOPROFILE - watch.Report(*cString::sprintf("SignalStrength() device %d", i)); -#endif int signalQuality = device->SignalQuality(); -#ifdef DOPROFILE - watch.Report(*cString::sprintf("SignalQuality() device %d", i)); -#endif - if ((signalStrength != lastSignalStrength[i]) || (signalQuality != lastSignalQuality[i])) { changed = true; break; } } if (!changed) { -#ifdef DOPROFILE - watch.Stop("SetDevices End"); -#endif return false; } } @@ -109,13 +96,7 @@ bool cViewHelpers::SetDevices(bool initial, map *intTokens, vector("devices[hascam]", "0")); } int signalStrength = device->SignalStrength(); -#ifdef DOPROFILE - watch.Report(*cString::sprintf("SignalStrength() device %d", i)); -#endif int signalQuality = device->SignalQuality(); -#ifdef DOPROFILE - watch.Report(*cString::sprintf("SignalQuality() device %d", i)); -#endif stringstream strCamNumber; strCamNumber << camNumber; deviceVals.insert(pair< string, string >("devices[cam]", strCamNumber.str())); @@ -157,9 +138,6 @@ bool cViewHelpers::SetDevices(bool initial, map *intTokens, vectorinsert(pair("numdevices", actualNumDevices)); -#ifdef DOPROFILE - watch.Stop("SetDevices End"); -#endif return true; } diff --git a/views/viewhelpers.h b/views/viewhelpers.h index 8e49554..53209b4 100644 --- a/views/viewhelpers.h +++ b/views/viewhelpers.h @@ -3,6 +3,7 @@ class cViewHelpers { private: + int numDevices; bool devicesInit; int* lastSignalStrength; int* lastSignalQuality;