|
|
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » howto best Ctrl Refresh handling w/ MT & very frequent refreshes
Re: howto best Ctrl Refresh handling w/ MT & very frequent refreshes [message #26788 is a reply to message #26776] |
Fri, 28 May 2010 08:12 |
|
koldo
Messages: 3361 Registered: August 2008
|
Senior Veteran |
|
|
dolik.rce wrote on Thu, 27 May 2010 09:20 | Hi Kohait,
If you develop some kind of graphics/video/game application where framerate matters, then you should use graphic acceleration as Mindtraveller suggested. But if you just want to show some rapidly changing data in real time, you should be fine with some 5 fps max, user don't react any quicker
Here is something that might or might not help you:#include <CtrlLib/CtrlLib.h>
using namespace Upp;
template <class T>
class Cached : public T{
Value val;
bool refreshflag;
public:
void operator<<=(Callback action) {T::operator<<=(action);}
void operator<<=(Value data) {refreshflag=true; val=data;}
void SetData(Value data) {refreshflag=true; val=data;}
Value GetData() {return val;}
Value operator~() {return val;}
void Apply() {if(refreshflag) T::SetData(val);}
bool IsChanged() {return refreshflag;}
};
class guitest : public TopWindow {
public:
typedef guitest CLASSNAME;
Cached<EditIntSpin> s;
guitest(){
s.SetRect(0,0,50,24);
Add(s);
s<<=0;
s.Apply();
}
void LeftDown(Point p,dword keyflags){
s<<=int(~s)+1;
}
void RightDown(Point p,dword keyflags){
s.Apply();
}
};
GUI_APP_MAIN{
guitest().Run();
}
It is a simple wrapper template that should work on any Ctrl overloading it's SetData and GetData methods, so they don't trigger Refresh. It will help you only if:- You just change the data, not the Ctrls.
- Your app has some idea about the hierarchy of Ctrl so it can call Apply on all of them when needed.
To update I would use single function called using SetTimeCallback with reasonable interval, let's say 200ms.
Best regards,
Honza
|
I like this sample .
And you told you are not a programmer...
Best regards
IƱaki
|
|
|
Goto Forum:
Current Time: Fri May 17 01:33:38 CEST 2024
Total time taken to generate the page: 0.02517 seconds
|
|
|