Clip widget draw calls which are outside _cur_dpi

This commit is contained in:
Jonathan G Rennison
2020-02-20 00:49:32 +00:00
parent 08af3b38d9
commit 3517068e30
2 changed files with 16 additions and 0 deletions

View File

@@ -14,6 +14,7 @@
#include "core/bitmath_func.hpp"
#include "core/math_func.hpp"
#include "strings_type.h"
#include "gfx_func.h"
#include "gfx_type.h"
#include "window_type.h"
@@ -183,6 +184,13 @@ public:
uint8 padding_bottom; ///< Paddings added to the bottom of the widget. Managed by parent container widget.
uint8 padding_left; ///< Paddings added to the left of the widget. Managed by parent container widget. (parent container may swap this with padding_right for RTL)
inline bool IsOutsideDrawArea() const
{
if ((int)(this->pos_x + this->current_x) <= _cur_dpi->left || (int)(this->pos_x) >= _cur_dpi->left + _cur_dpi->width) return true;
if ((int)(this->pos_y + this->current_y) <= _cur_dpi->top || (int)(this->pos_y) >= _cur_dpi->top + _cur_dpi->height) return true;
return false;
}
protected:
inline void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height);
};