Home » U++ Library support » U++ Widgets - General questions or Mixed problems » ScrollView - a question - maybe proposal..  
	
		
		
			| Re: ScrollView - a question - maybe proposal.. [message #51068 is a reply to message #51014] | 
			Thu, 17 January 2019 19:20    | 
		 
		
			
				
				
				
					
						  
						luoganda
						 Messages: 216 Registered: November 2016 
						
					 | 
					Experienced Member  | 
					 | 
		 
		 
	 | 
 
	
		ok, i wrote a small ImageDraw helper utility, 
this somehow works, but it's slowwwww.. 
Any improvements here or suggestions are welcome. 
 
Also - i recommend adding GetSize() to ImageDraw, to get Width/Height without getting image itself overhead. 
 
class SMXImageDraw{
	ImageDraw *id=NULL;
	public:
	~SMXImageDraw(){Clear();}
	void Set(int w,int h){Clear();id=new ImageDraw(w,h);}
	void Clear(){if(!id)return;delete id;id=NULL;}
	void ScrollImageX(int x); //does (quick)x sanity checks
	ImageDraw &Get(){return *id;}
	bool Empty(){return id==NULL;}
};
void SMXImageDraw::ScrollImageX(int x){
	int absx=abs(x);
	if(x==0||!id/*||absx>=id->GetSize().cx*/)return; // <== here, ImageDraw::GetSize() could come handy
	Image img=(Image)*id;//->GetStraight();
	if(absx>=img.GetWidth())return;
	int nx=x<0?0:x;
	id->DrawImage(nx,0,img,Rect((x<0?absx:0),0,nx+(img.GetWidth()-(x<0?0:absx)),img.GetHeight()));
}
 
		
		
		[Updated on: Thu, 17 January 2019 19:33] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 |  
  
 
Goto Forum:
 
 Current Time: Tue Nov 04 13:27:36 CET 2025 
 Total time taken to generate the page: 0.15622 seconds 
 |