1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:07:36 +00:00

SharedGraphics: Add PainterStateSaver RAII helper and Point::operator-().

Two little things to help tidy up a bit in WSWindowManager.
This commit is contained in:
Andreas Kling 2019-03-09 16:54:41 +01:00
parent 3c2139b824
commit 88f6ce152f
3 changed files with 22 additions and 7 deletions

View file

@ -80,3 +80,20 @@ private:
Retained<GraphicsBitmap> m_target;
Vector<State> m_state_stack;
};
class PainterStateSaver {
public:
PainterStateSaver(Painter& painter)
: m_painter(painter)
{
m_painter.save();
}
~PainterStateSaver()
{
m_painter.restore();
}
private:
Painter& m_painter;
};

View file

@ -48,6 +48,8 @@ public:
return !(*this == other);
}
Point operator-() const { return { -m_x, -m_y }; }
operator WSAPI_Point() const;
String to_string() const { return String::format("[%d,%d]", x(), y()); }