From 1324c623fe768289beb3a6bb85fe0c859628714a Mon Sep 17 00:00:00 2001 From: Greg Ercolano Date: Sun, 8 Jan 2023 09:42:58 -0800 Subject: Add new Fl_Rect::inset(lt,top,rt,bot) method --- FL/Fl_Rect.H | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'FL') diff --git a/FL/Fl_Rect.H b/FL/Fl_Rect.H index a73a0e732..0de6dfcb2 100644 --- a/FL/Fl_Rect.H +++ b/FL/Fl_Rect.H @@ -125,6 +125,24 @@ public: w_ -= Fl::box_dw(bt); h_ -= Fl::box_dh(bt); } + + /** Move all edges in by \p left, \p top, \p right, \p bottom. + + Shrinks the rectangle on all sides keeping the center of the + rectangle at the same spot. + + If any value is negative, the rectangle is enlarged. + + Values are not range checked; it is possible to create + an invalid or empty rectangle. + */ + void inset(int left, int top, int right, int bottom) { + x_ += left; + y_ += top; + w_ -= (left + right); + h_ -= (top + bottom); + } + }; // class Fl_Rect #endif // Fl_Rect_H -- cgit v1.2.3