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
Images not showing and callback not taking lambda [message #50736] Tue, 11 December 2018 12:39 Go to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
using linux (devuan) and latest svn for upp

problem 1.
in attached project only the first thumbnail shows while
the others are not visible but still responding to the mouse

problem 2.
I had to replace callback with std::function to get it to work

any help in pointing out what I am doing wrong in these cases will be appreciated
thx
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 next message
Oblivion is currently offline  Oblivion
Messages: 1091
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

Re: Images not showing and callback not taking lambda [message #50755 is a reply to message #50753] Tue, 11 December 2018 22:37 Go to previous message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
thx oblivion, that did the trick
when I saw "Event" I remembered & saw in some of my older code that I used it before - my memory is packing-up
thx dude
Previous Topic: Problem with DHCTRL on Windows
Next Topic: Framebuffer backend compilation errors
Goto Forum:
  


Current Time: Thu Mar 28 20:12:29 CET 2024

Total time taken to generate the page: 0.01412 seconds