Skip to main content
ferro
Lead
November 23, 2023
Solved

"const Rect & Drawable::getRect ()" prohibits use as a parameter in e.g. "Screen::invalidateRect ()"

  • November 23, 2023
  • 1 reply
  • 860 views

Hi Gfx Team,

Could Drawable::getRect () in Drawable.hpp

 

const Rect & getRect() const
{
 return rect;
}

 

be changed to

 

Rect getRect() const
{
 return rect;
}

 

 

so it can be used as a parameter in e.g.

 

void Screen::invalidateRect ( Rect & invalidatedArea ) const
{
 container.invalidateRect ( invalidatedArea );
}

 

 

With the current implementation one has to write

 

Screen::invalidateRect ( Rect { Drawable::getRect () } );

 

 

If not, could you add a variation e.g.

 

Rect getRectValue() const
{
 return rect;
}

 

Thanks

Ferro

 

 

 

 

 

This topic has been closed for replies.
Best answer by Mohammad MORADI ESFAHANIASL

Hello @ferro ,

Thank you for the good suggestion. I think it would be easier if you use Drawable.invalidateRect() to avoid dealing with coordination conversion (for instance, from local to global).
But, anyway, you can easily copy Drawable.hpp to your project and apply changes to it. For example, you can overload the invalidateRect() like this:

void invalidateRect (const Rect& invalidatedArea) const 
{
 Rect r = invalidatedArea;
 invalidateRect(r);
}

 

You can read more about apply changes to widgets here 

 

I hope this helps you,
Best regards

1 reply

ST Employee
February 6, 2024

Hello @ferro ,

Thank you for the good suggestion. I think it would be easier if you use Drawable.invalidateRect() to avoid dealing with coordination conversion (for instance, from local to global).
But, anyway, you can easily copy Drawable.hpp to your project and apply changes to it. For example, you can overload the invalidateRect() like this:

void invalidateRect (const Rect& invalidatedArea) const 
{
 Rect r = invalidatedArea;
 invalidateRect(r);
}

 

You can read more about apply changes to widgets here 

 

I hope this helps you,
Best regards