From f6f140b2ea0bb1de9e055e920ef9c0c43c6e2add Mon Sep 17 00:00:00 2001 From: Christian Tusche Date: Sun, 6 May 2007 17:26:51 +0200 Subject: 2007-05-06: Version 1.1-cvs_ext-0.10c (text2skin-1.1-cvs_ext-0.10c.diff) - selective update of changed objects refresh can be controlled for individual objects by the attributes "refresh" and "changed" default behaviour is to redraw everything (compatible with old skins) --- xml/display.c | 3 +- xml/display.h | 1 + xml/object.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xml/object.h | 35 ++++++++++++++++++ xml/parser.c | 23 +++++++++++- 5 files changed, 174 insertions(+), 2 deletions(-) (limited to 'xml') diff --git a/xml/display.c b/xml/display.c index a8268c4..adf500b 100644 --- a/xml/display.c +++ b/xml/display.c @@ -11,7 +11,8 @@ static const std::string DisplayNames[] = cxDisplay::cxDisplay(cxSkin *parent): mSkin(parent), mType((eType)__COUNT_DISPLAY__), - mNumWindows(0) + mNumWindows(0), + mRefreshDefault(NULL) { } diff --git a/xml/display.h b/xml/display.h index a9b2080..af1f590 100644 --- a/xml/display.h +++ b/xml/display.h @@ -35,6 +35,7 @@ private: int mNumWindows; int mNumMarquees; cxObjects mObjects; + cxRefresh mRefreshDefault; public: cxDisplay(cxSkin *Parent); diff --git a/xml/object.c b/xml/object.c index 81dc854..587eab5 100644 --- a/xml/object.c +++ b/xml/object.c @@ -30,6 +30,7 @@ cxObject::cxObject(cxDisplay *Parent): mFontWidth(0), mDelay(150), mIndex(0), + mRefresh(this), mObjects(NULL) { } @@ -59,6 +60,7 @@ cxObject::cxObject(const cxObject &Src): mFontSize(Src.mFontSize), mFontWidth(Src.mFontWidth), mDelay(Src.mDelay), + mRefresh(Src.mRefresh), mObjects(NULL) { if (Src.mCondition) @@ -223,3 +225,115 @@ cxObjects::~cxObjects() delete operator[](i); } + + + + + +cxRefresh::cxRefresh( cxObject *Object ): + mRefreshType(0xFF), + mText(NULL), + mChanged(NULL), + mObject(Object), + mForce(true), + mFull(true) +{ +} + +cxRefresh::~cxRefresh() +{ + delete mText; +} + +bool cxRefresh::Dirty(uint dirty, bool force) +{ + bool need_changed = !mForce && !force && !(mRefreshType & dirty & ~(1<Evaluate(); + + if( mEval == mLastEval && need_changed ) { + return false; + } else { + mLastEval = mEval; + } + + return true; +} + + + + + +bool cxRefresh::Parse(const std::string &Text) +{ + uint refresh=0; + bool force=false, full=false; + + if( Text.find("all") != std::string::npos ) + refresh |= (1<Parse(Text) ) { + mChanged = mText; + return true; + } + + return false; +} + +cxRefresh &cxRefresh::operator=(const cxRefresh &a) +{ + mRefreshType = a.mRefreshType; + mForce = a.mForce; + mFull = a.mFull; + return *this; +} diff --git a/xml/object.h b/xml/object.h index 603019f..7a37b5c 100644 --- a/xml/object.h +++ b/xml/object.h @@ -33,6 +33,40 @@ struct txWindow { pos1(_x1, _y2), pos2(_x2, _y2), bpp(_bpp) {} }; +class cxObject; + +class cxRefresh { + friend bool xEndElem(const std::string &name); + +public: + enum eRefreshType { + all, // complete redraw of the screen + timeout, // redraw due to a timeout + //message, // a message was set or removed + update, // update of the osd elements + scroll, // a scroll event + list, // list items or the current item have changed + }; + + cxRefresh(cxObject *Object); + ~cxRefresh(); + bool Dirty(uint dirty, bool force=false); + bool Full(void) const { return mFull; } + uint Type(void) const { return mRefreshType; } + bool Parse(const std::string &Text); + bool ParseChanged(const std::string &Text); + cxRefresh &cxRefresh::operator=(const cxRefresh &b); + +private: + uint mRefreshType; + cxType mLastEval; + cxType mEval; + cxString *mText; + cxString *mChanged; + cxObject *mObject; + bool mForce, mFull; +}; + class cxObjects; class cxObject { @@ -88,6 +122,7 @@ private: int mFontWidth; uint mDelay; uint mIndex; + cxRefresh mRefresh; cxObjects *mObjects; // used for block objects such as public: diff --git a/xml/parser.c b/xml/parser.c index 0045af1..1e3ed73 100644 --- a/xml/parser.c +++ b/xml/parser.c @@ -102,6 +102,7 @@ bool xStartElem(const std::string &name, std::map &attr if (name == "display") { display = new cxDisplay(skin); ATTRIB_MAN_FUNC ("id", display->ParseType); + ATTRIB_OPT_FUNC ("refresh", display->mRefreshDefault.Parse); } else TAG_ERR_REMAIN("skin"); @@ -129,12 +130,18 @@ bool xStartElem(const std::string &name, std::map &attr else { object = new cxObject(display); if (object->ParseType(name)) { + if(parents.size() > 0) + object->mRefresh = parents.back()->mRefresh; + else + object->mRefresh = display->mRefreshDefault; + ATTRIB_OPT_NUMBER("x1", object->mPos1.x); ATTRIB_OPT_NUMBER("y1", object->mPos1.y); ATTRIB_OPT_NUMBER("x2", object->mPos2.x); ATTRIB_OPT_NUMBER("y2", object->mPos2.y); ATTRIB_OPT_FUNC ("condition", object->ParseCondition); - + ATTRIB_OPT_FUNC ("refresh", object->mRefresh.Parse); + ATTRIB_OPT_FUNC ("changed", object->mRefresh.ParseChanged); if (name == "image") { ATTRIB_OPT_NUMBER("x", object->mPos1.x); ATTRIB_OPT_NUMBER("y", object->mPos1.y); @@ -256,6 +263,20 @@ bool xEndElem(const std::string &name) { } } + if (object->mRefresh.mChanged == NULL) { + switch (object->mType) { + case cxObject::text: + case cxObject::marquee: + case cxObject::blink: + case cxObject::scrolltext: + object->mRefresh.mChanged = &object->mText; + break; + + default: + break; + } + } + object->mIndex = oindex++; if (parents.size() > 0) { Dprintf("pushing to parent\n"); -- cgit v1.2.3