Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Images not showing and callback not taking lambda
Re: Images not showing and callback not taking lambda [message #50753 is a reply to message #50736] Tue, 11 December 2018 22:03 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1094
Registered: August 2007
Senior Contributor
Hello slashupp,

I can see two things:

1) Callback is depreceated. You should be able to use Event<> instead, which is basically an alias for Upp::Function<void()>.
2) Try using Size() instead of Rect() (This means Rect(0, 0, cx, cy), as you're erroneously offseting both the Ctrls AND the images in your code. That's why the images are invisible: x and y values of the images should be 0.

E.g.

struct Thumbnail : public Ctrl //clickable rect with a picture in it
{
	using CLASSNAME=Thumbnail;
	Image pic;
	bool bldn;
	
	//Callback WhenClick; //doesn't want to play nice with lambda ?!?!
	Event<> WhenClick;
	
	
	virtual~Thumbnail(){ }
	Thumbnail() { bldn=false; }
	
	Thumbnail(Image img, Event<> cb, const std::string &desc="") { bldn=false; pic = img; Tip(desc.c_str()); WhenClick=cb; }
	
	virtual void Paint(Draw &drw)
	{
		drw.DrawRect(GetSize(), SColorFace());
		drw.DrawImage((Rect) GetSize(), pic); // means Rect(0, 0, cx, cy);
	}
	virtual void LeftDown(Point p, dword kf) { bldn=true; }
	virtual void LostFocus() { bldn=false; }
	virtual void LeftUp(Point p, dword kf) { if (bldn) if (WhenClick) WhenClick(); }
	
};



Best regards,
Oblivion


[Updated on: Tue, 11 December 2018 22:11]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic: Problem with DHCTRL on Windows
Next Topic: Framebuffer backend compilation errors
Goto Forum:
  


Current Time: Sun May 12 07:42:05 CEST 2024

Total time taken to generate the page: 0.01456 seconds