From 7238faa184337b30d53ef7fc69156001bdd1824a Mon Sep 17 00:00:00 2001 From: Michael Davidson Date: Tue, 26 Dec 2023 14:57:59 +1100 Subject: [PATCH] Black, flake8, and clang-format fixes --- .../components/graphical_layout/text_panel.cpp | 15 +++++++-------- esphome/components/graphical_layout/text_panel.py | 3 ++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/esphome/components/graphical_layout/text_panel.cpp b/esphome/components/graphical_layout/text_panel.cpp index 47884a4b34..c38bc82fc3 100644 --- a/esphome/components/graphical_layout/text_panel.cpp +++ b/esphome/components/graphical_layout/text_panel.cpp @@ -8,8 +8,9 @@ namespace esphome { namespace graphical_layout { static const char *const TAG = "textpanel"; -static const int TEXT_ALIGN_X_MASK = (int)display::TextAlign::RIGHT | (int)display::TextAlign::CENTER_HORIZONTAL; -static const int TEXT_ALIGN_Y_MASK = (int)display::TextAlign::BOTTOM | (int)display::TextAlign::BASELINE | (int)display::TextAlign::CENTER_VERTICAL; +static const int TEXT_ALIGN_X_MASK = (int) display::TextAlign::RIGHT | (int) display::TextAlign::CENTER_HORIZONTAL; +static const int TEXT_ALIGN_Y_MASK = + (int) display::TextAlign::BOTTOM | (int) display::TextAlign::BASELINE | (int) display::TextAlign::CENTER_VERTICAL; void TextPanel::dump_config(int indent_depth, int additional_level_depth) { ESP_LOGCONFIG(TAG, "%*sText: %s", indent_depth, "", this->text_.c_str()); @@ -20,8 +21,7 @@ display::Rect TextPanel::measure_item_internal(display::Display *display) { int y1; int width; int height; - display->get_text_bounds(0, 0, this->text_.c_str(), this->font_, this->text_align_, &x1, &y1, &width, - &height); + display->get_text_bounds(0, 0, this->text_.c_str(), this->font_, this->text_align_, &x1, &y1, &width, &height); return display::Rect(0, 0, width, height); } @@ -29,7 +29,7 @@ void TextPanel::render_internal(display::Display *display, display::Rect bounds) int width, height, x_offset, baseline; this->font_->measure(this->text_.c_str(), &width, &x_offset, &baseline, &height); - + const auto x_align = display::TextAlign(int(this->text_align_) & TEXT_ALIGN_X_MASK); const auto y_align = display::TextAlign(int(this->text_align_) & TEXT_ALIGN_Y_MASK); @@ -37,7 +37,7 @@ void TextPanel::render_internal(display::Display *display, display::Rect bounds) switch (x_align) { case display::TextAlign::RIGHT: { - bounds.x = bounds.w - width; + bounds.x = bounds.w - width; break; } case display::TextAlign::CENTER_HORIZONTAL: { @@ -58,7 +58,7 @@ void TextPanel::render_internal(display::Display *display, display::Rect bounds) break; } case display::TextAlign::BASELINE: { - bounds.y = (bounds.h - height) + baseline; + bounds.y = (bounds.h - height) + baseline; break; } case display::TextAlign::CENTER_VERTICAL: { @@ -74,7 +74,6 @@ void TextPanel::render_internal(display::Display *display, display::Rect bounds) auto rendered_alignment = display::TextAlign::TOP_LEFT; display->print(bounds.x, bounds.y, this->font_, this->foreground_color_, rendered_alignment, this->text_.c_str()); - } } // namespace graphical_layout diff --git a/esphome/components/graphical_layout/text_panel.py b/esphome/components/graphical_layout/text_panel.py index f646343a7e..c5080ab8da 100644 --- a/esphome/components/graphical_layout/text_panel.py +++ b/esphome/components/graphical_layout/text_panel.py @@ -31,6 +31,7 @@ TEXT_ALIGN = { "BOTTOM_RIGHT": TextAlign.BOTTOM_RIGHT, } + def get_config_schema(base_item_schema, item_type_schema): return base_item_schema.extend( { @@ -40,7 +41,7 @@ def get_config_schema(base_item_schema, item_type_schema): cv.Optional(CONF_FOREGROUND_COLOR): cv.use_id(color.ColorStruct), cv.Optional(CONF_BACKGROUND_COLOR): cv.use_id(color.ColorStruct), cv.Required(CONF_TEXT): cv.templatable(cv.string), - cv.Optional(CONF_TEXT_ALIGN): cv.enum(TEXT_ALIGN, upper=True) + cv.Optional(CONF_TEXT_ALIGN): cv.enum(TEXT_ALIGN, upper=True), } )