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 |
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 |
Oblivion
Messages: 1112 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
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Tue, 11 December 2018 22:11] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Sat Sep 21 00:21:16 CEST 2024
Total time taken to generate the page: 0.02438 seconds
|