mirror of
https://github.com/esphome/esphome.git
synced 2024-12-12 08:24:55 +01:00
ci-custom and clang-format fixes
This commit is contained in:
parent
b18e217313
commit
5f5c35e779
2 changed files with 27 additions and 24 deletions
|
@ -13,7 +13,9 @@ const Color COLOR_ON(255, 255, 255, 255);
|
|||
|
||||
display::Rect LayoutItem::measure_item(display::Display *display) {
|
||||
display::Rect inner_size = this->measure_item_internal(display);
|
||||
return display::Rect(0, 0, this->margin_.horizontal() + this->border_.horizontal() + this->padding_.horizontal() + inner_size.w, this->margin_.vertical() + this->border_.vertical() + this->padding_.vertical() + inner_size.h);
|
||||
return display::Rect(
|
||||
0, 0, this->margin_.horizontal() + this->border_.horizontal() + this->padding_.horizontal() + inner_size.w,
|
||||
this->margin_.vertical() + this->border_.vertical() + this->padding_.vertical() + inner_size.h);
|
||||
}
|
||||
|
||||
void LayoutItem::render(display::Display *display, display::Rect bounds) {
|
||||
|
@ -34,22 +36,28 @@ void LayoutItem::render(display::Display *display, display::Rect bounds) {
|
|||
}
|
||||
// Left Rectangle
|
||||
if (this->border_.left > 0) {
|
||||
display->filled_rectangle(border_bounds.x, border_bounds.y + this->border_.top, this->border_.left, border_bounds.h - this->border_.bottom - this->border_.top);
|
||||
display->filled_rectangle(border_bounds.x, border_bounds.y + this->border_.top, this->border_.left,
|
||||
border_bounds.h - this->border_.bottom - this->border_.top);
|
||||
}
|
||||
// Bottom Rectangle
|
||||
if (this->border_.bottom > 0) {
|
||||
display->filled_rectangle(border_bounds.x, border_bounds.h - this->border_.bottom, border_bounds.w, this->border_.bottom);
|
||||
display->filled_rectangle(border_bounds.x, border_bounds.h - this->border_.bottom, border_bounds.w,
|
||||
this->border_.bottom);
|
||||
}
|
||||
// Right Rectangle
|
||||
if (this->border_.right > 0) {
|
||||
display->filled_rectangle(border_bounds.w - this->border_.right, border_bounds.y + this->border_.top, this->border_.right, border_bounds.h - this->border_.bottom - this->border_.top);
|
||||
display->filled_rectangle(border_bounds.w - this->border_.right, border_bounds.y + this->border_.top,
|
||||
this->border_.right, border_bounds.h - this->border_.bottom - this->border_.top);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Padding
|
||||
display->set_local_coordinates_relative_to_current(this->border_.left + this->padding_.left, this->border_.top + this->padding_.top);
|
||||
display::Rect internal_bounds(0, 0, bounds.w - this->margin_.horizontal() - this->border_.horizontal() - this->padding_.horizontal(), bounds.h - this->margin_.vertical() - this->border_.vertical() - this->padding_.vertical());
|
||||
display->set_local_coordinates_relative_to_current(this->border_.left + this->padding_.left,
|
||||
this->border_.top + this->padding_.top);
|
||||
display::Rect internal_bounds(
|
||||
0, 0, bounds.w - this->margin_.horizontal() - this->border_.horizontal() - this->padding_.horizontal(),
|
||||
bounds.h - this->margin_.vertical() - this->border_.vertical() - this->padding_.vertical());
|
||||
|
||||
// Rendering
|
||||
this->render_internal(display, internal_bounds);
|
||||
|
@ -66,8 +74,8 @@ void LayoutItem::render(display::Display *display, display::Rect bounds) {
|
|||
void LayoutItem::dump_config_base_properties(const char *tag, int indent_depth) {
|
||||
ESP_LOGCONFIG(tag, "%*sMargin: : (L: %i, T: %i, R: %i, B: %i)", indent_depth, "", this->margin_.left,
|
||||
this->margin_.top, this->margin_.right, this->margin_.bottom);
|
||||
ESP_LOGCONFIG(tag, "%*sBorder: (L: %i, T: %i, R: %i, B: %i)", indent_depth, "", this->border_.left,
|
||||
this->border_.top, this->border_.right, this->border_.bottom);
|
||||
ESP_LOGCONFIG(tag, "%*sBorder: (L: %i, T: %i, R: %i, B: %i)", indent_depth, "", this->border_.left, this->border_.top,
|
||||
this->border_.right, this->border_.bottom);
|
||||
ESP_LOGCONFIG(tag, "%*sBorder Color: (R: %i, G: %i, B: %i)", indent_depth, "", this->border_color_.r,
|
||||
this->border_color_.g, this->border_color_.b);
|
||||
ESP_LOGCONFIG(tag, "%*sPadding: : (L: %i, T: %i, R: %i, B: %i)", indent_depth, "", this->padding_.left,
|
||||
|
|
|
@ -45,7 +45,7 @@ enum class VerticalChildAlign {
|
|||
};
|
||||
|
||||
struct Dimension {
|
||||
Dimension() {};
|
||||
Dimension(){};
|
||||
Dimension(int16_t padding) {
|
||||
this->left = padding;
|
||||
this->top = padding;
|
||||
|
@ -58,21 +58,20 @@ struct Dimension {
|
|||
this->right = right;
|
||||
this->bottom = bottom;
|
||||
}
|
||||
|
||||
|
||||
/* Gets the total padding for the horizontal direction (left + right) */
|
||||
inline int16_t horizontal() const { return this->left + this->right; };
|
||||
/* Gets the total padding for the vertical direction (top + bottom) */
|
||||
inline int16_t vertical() const { return this->top + this->bottom; };
|
||||
|
||||
/* Returns true if any value is set to a non-zero value*/
|
||||
inline bool any() const {
|
||||
return this->left > 0 || this->top > 0 || this->right > 0 || this->bottom > 0;
|
||||
inline bool any() const {
|
||||
return this->left > 0 || this->top > 0 || this->right > 0 || this->bottom > 0;
|
||||
};
|
||||
|
||||
/* Returns true if all dimensions are equal to the value */
|
||||
inline bool equals(int16_t value) const {
|
||||
return this->left == value && this->top == value && this->right == value
|
||||
&& this->bottom == value;
|
||||
return this->left == value && this->top == value && this->right == value && this->bottom == value;
|
||||
}
|
||||
|
||||
int16_t left{0};
|
||||
|
@ -137,19 +136,15 @@ class LayoutItem {
|
|||
virtual void setup_complete(){};
|
||||
|
||||
void set_margin(int margin) { this->margin_ = Dimension(margin); };
|
||||
void set_margin(int left, int top, int right, int bottom) {
|
||||
this->margin_ = Dimension(left, top, right, bottom);
|
||||
}
|
||||
void set_margin(int left, int top, int right, int bottom) { this->margin_ = Dimension(left, top, right, bottom); }
|
||||
|
||||
void set_padding(int padding) { this->padding_ = Dimension(padding); };
|
||||
void set_padding(int left, int top, int right, int bottom) {
|
||||
this->padding_ = Dimension(left, top, right, bottom);
|
||||
}
|
||||
void set_padding(int left, int top, int right, int bottom) { this->padding_ = Dimension(left, top, right, bottom); }
|
||||
|
||||
void set_border(int border) { this->border_ = Dimension(border); };
|
||||
void set_border(int left, int top, int right, int bottom) {
|
||||
this->border_ = Dimension(left, top, right, bottom);
|
||||
}
|
||||
void set_border(int left, int top, int right, int bottom) { this->border_ = Dimension(left, top, right, bottom); }
|
||||
|
||||
void set_border_color(Color color) { this->border_color_ = color; };
|
||||
|
||||
|
||||
protected:
|
||||
Dimension margin_{};
|
||||
|
|
Loading…
Reference in a new issue