mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 12:15:33 +01:00
Fix check for empty clipping array (#4421)
This commit is contained in:
parent
f8acc45be4
commit
58eeb6b1b8
@ -16,11 +16,11 @@ const Color COLOR_OFF(0, 0, 0, 0);
|
||||
const Color COLOR_ON(255, 255, 255, 255);
|
||||
|
||||
void Rect::expand(int16_t horizontal, int16_t vertical) {
|
||||
if ((*this).is_set() && ((*this).w >= (-2 * horizontal)) && ((*this).h >= (-2 * vertical))) {
|
||||
(*this).x = (*this).x - horizontal;
|
||||
(*this).y = (*this).y - vertical;
|
||||
(*this).w = (*this).w + (2 * horizontal);
|
||||
(*this).h = (*this).h + (2 * vertical);
|
||||
if (this->is_set() && (this->w >= (-2 * horizontal)) && (this->h >= (-2 * vertical))) {
|
||||
this->x = this->x - horizontal;
|
||||
this->y = this->y - vertical;
|
||||
this->w = this->w + (2 * horizontal);
|
||||
this->h = this->h + (2 * vertical);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -400,60 +400,48 @@ class DisplayBuffer {
|
||||
*/
|
||||
virtual DisplayType get_display_type() = 0;
|
||||
|
||||
///
|
||||
/// Set the clipping rectangle for further drawing
|
||||
///
|
||||
/// \param[in] rect: Pointer to Rect for clipping (or NULL for entire screen)
|
||||
///
|
||||
/// \return true if success, false if error
|
||||
///
|
||||
/** Set the clipping rectangle for further drawing
|
||||
*
|
||||
* @param[in] rect: Pointer to Rect for clipping (or NULL for entire screen)
|
||||
*
|
||||
* return true if success, false if error
|
||||
*/
|
||||
void start_clipping(Rect rect);
|
||||
void start_clipping(int16_t left, int16_t top, int16_t right, int16_t bottom) {
|
||||
start_clipping(Rect(left, top, right - left, bottom - top));
|
||||
};
|
||||
|
||||
///
|
||||
/// Add a rectangular region to the invalidation region
|
||||
/// - This is usually called when an element has been modified
|
||||
///
|
||||
/// \param[in] rect: Rectangle to add to the invalidation region
|
||||
///
|
||||
/// \return none
|
||||
///
|
||||
/** Add a rectangular region to the invalidation region
|
||||
* - This is usually called when an element has been modified
|
||||
*
|
||||
* @param[in] rect: Rectangle to add to the invalidation region
|
||||
*/
|
||||
void extend_clipping(Rect rect);
|
||||
void extend_clipping(int16_t left, int16_t top, int16_t right, int16_t bottom) {
|
||||
this->extend_clipping(Rect(left, top, right - left, bottom - top));
|
||||
};
|
||||
|
||||
///
|
||||
/// substract a rectangular region to the invalidation region
|
||||
/// - This is usually called when an element has been modified
|
||||
///
|
||||
/// \param[in] rect: Rectangle to add to the invalidation region
|
||||
///
|
||||
/// \return none
|
||||
///
|
||||
/** substract a rectangular region to the invalidation region
|
||||
* - This is usually called when an element has been modified
|
||||
*
|
||||
* @param[in] rect: Rectangle to add to the invalidation region
|
||||
*/
|
||||
void shrink_clipping(Rect rect);
|
||||
void shrink_clipping(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
|
||||
this->shrink_clipping(Rect(left, top, right - left, bottom - top));
|
||||
};
|
||||
|
||||
///
|
||||
/// Reset the invalidation region
|
||||
///
|
||||
/// \return none
|
||||
///
|
||||
/** Reset the invalidation region
|
||||
*/
|
||||
void end_clipping();
|
||||
|
||||
///
|
||||
/// Get the current the clipping rectangle
|
||||
///
|
||||
///
|
||||
/// \return rect for active clipping region
|
||||
///
|
||||
/** Get the current the clipping rectangle
|
||||
*
|
||||
* return rect for active clipping region
|
||||
*/
|
||||
Rect get_clipping();
|
||||
|
||||
bool is_clipping() const { return this->clipping_rectangle_.empty(); }
|
||||
bool is_clipping() const { return !this->clipping_rectangle_.empty(); }
|
||||
|
||||
protected:
|
||||
void vprintf_(int x, int y, Font *font, Color color, TextAlign align, const char *format, va_list arg);
|
||||
|
Loading…
Reference in New Issue
Block a user