From f749d2635318c41aac20c92bba8427f838542923 Mon Sep 17 00:00:00 2001 From: Michael Davidson Date: Sun, 17 Dec 2023 21:39:09 +1100 Subject: [PATCH] More clang/ling fixes --- .../components/graphical_layout/__init__.py | 7 ++-- .../graphical_layout/graphical_layout.cpp | 1 - .../graphical_layout/graphical_layout.h | 28 ++++++++-------- .../graphical_layout/horizontal_stack.h | 14 ++++---- .../components/graphical_layout/text_panel.h | 32 +++++++++---------- .../components/graphical_layout/text_panel.py | 1 - .../graphical_layout/vertical_stack.h | 14 ++++---- 7 files changed, 49 insertions(+), 48 deletions(-) diff --git a/esphome/components/graphical_layout/__init__.py b/esphome/components/graphical_layout/__init__.py index 1770dac0d8..c7fd044ac4 100644 --- a/esphome/components/graphical_layout/__init__.py +++ b/esphome/components/graphical_layout/__init__.py @@ -23,6 +23,7 @@ CONF_ITEM_TYPE = "type" BASE_ITEM_SCHEMA = cv.Schema({}) + def item_type_schema(value): return ITEM_TYPE_SCHEMA(value) @@ -32,7 +33,9 @@ ITEM_TYPE_SCHEMA = cv.typed_schema( text_panel.CONF_TYPE: BASE_ITEM_SCHEMA.extend( { cv.GenerateID(): cv.declare_id(text_panel.TextPanel), - cv.Optional(text_panel.CONF_ITEM_PADDING, default=0): cv.templatable(cv.int_), + cv.Optional(text_panel.CONF_ITEM_PADDING, default=0): cv.templatable( + cv.int_ + ), cv.Required(text_panel.CONF_FONT): cv.use_id(font.Font), cv.Optional(text_panel.CONF_FOREGROUND_COLOR): cv.use_id( color.ColorStruct @@ -64,7 +67,7 @@ ITEM_TYPE_SCHEMA = cv.typed_schema( cv.ensure_list(item_type_schema), cv.Length(min=1) ), } - ) + ), } ) diff --git a/esphome/components/graphical_layout/graphical_layout.cpp b/esphome/components/graphical_layout/graphical_layout.cpp index 9c9a2e1bff..5773b84aab 100644 --- a/esphome/components/graphical_layout/graphical_layout.cpp +++ b/esphome/components/graphical_layout/graphical_layout.cpp @@ -3,7 +3,6 @@ #include "esphome/components/display/display.h" #include "esphome/core/log.h" - namespace esphome { namespace graphical_layout { diff --git a/esphome/components/graphical_layout/graphical_layout.h b/esphome/components/graphical_layout/graphical_layout.h index 6543a18894..cafc0ebf21 100644 --- a/esphome/components/graphical_layout/graphical_layout.h +++ b/esphome/components/graphical_layout/graphical_layout.h @@ -16,22 +16,22 @@ namespace graphical_layout { /** Component used for rendering the layout*/ class RootLayoutComponent : public Component { - public: - void setup() override; - void dump_config() override; +public: + void setup() override; + void dump_config() override; - /** Render the graphical layout to the screen - * - * param[in] display: Display that will be rendered to - * param[in] x: x coordinate to render at - * param[in] y: y coorindate to render at - */ - void render_at(display::Display *display, int x, int y); - - void set_layout_root(LayoutItem *layout) { this->layout_root_ = layout; }; + /** Render the graphical layout to the screen + * + * param[in] display: Display that will be rendered to + * param[in] x: x coordinate to render at + * param[in] y: y coorindate to render at + */ + void render_at(display::Display *display, int x, int y); + + void set_layout_root(LayoutItem *layout) { this->layout_root_ = layout; }; - protected: - LayoutItem *layout_root_{nullptr}; +protected: + LayoutItem *layout_root_{nullptr}; }; } // namespace graphical_layout diff --git a/esphome/components/graphical_layout/horizontal_stack.h b/esphome/components/graphical_layout/horizontal_stack.h index d79b90cd5d..da2bcedc2c 100644 --- a/esphome/components/graphical_layout/horizontal_stack.h +++ b/esphome/components/graphical_layout/horizontal_stack.h @@ -10,15 +10,15 @@ namespace graphical_layout { * The HorizontalStack is a UI element which will render a series of items left-to-right across a display */ class HorizontalStack : public ContainerLayoutItem { - public: - const display::Rect measure_item(display::Display *display); - void render(display::Display *display, display::Rect bounds); +public: + const display::Rect measure_item(display::Display *display); + void render(display::Display *display, display::Rect bounds); - void dump_config(int indent_depth, int additional_level_depth); - void set_item_padding(int item_padding) { this->item_padding_ = item_padding; }; + void dump_config(int indent_depth, int additional_level_depth); + void set_item_padding(int item_padding) { this->item_padding_ = item_padding; }; - protected: - int item_padding_{0}; +protected: + int item_padding_{0}; }; } diff --git a/esphome/components/graphical_layout/text_panel.h b/esphome/components/graphical_layout/text_panel.h index c88d31c35f..80e2aef184 100644 --- a/esphome/components/graphical_layout/text_panel.h +++ b/esphome/components/graphical_layout/text_panel.h @@ -12,24 +12,24 @@ const Color COLOR_OFF(0, 0, 0, 0); /** The TextPanel is a UI item that renders a single line of text to a display */ class TextPanel : public LayoutItem { - public: - const display::Rect measure_item(display::Display *display); - void render(display::Display *display, display::Rect bounds); - void dump_config(int indent_depth, int additional_level_depth); +public: + const display::Rect measure_item(display::Display *display); + void render(display::Display *display, display::Rect bounds); + void dump_config(int indent_depth, int additional_level_depth); - void set_item_padding(int item_padding) { this->item_padding_ = item_padding; }; - void set_text(std::string text) { this->text_ = text; }; - void set_font(display::BaseFont *font) { this->font_ = font; }; - void set_foreground_color(Color foreground_color) { this->foreground_color_ = foreground_color; }; - void set_background_color(Color background_color) { this->background_color_ = background_color; }; + void set_item_padding(int item_padding) { this->item_padding_ = item_padding; }; + void set_text(std::string text) { this->text_ = text; }; + void set_font(display::BaseFont *font) { this->font_ = font; }; + void set_foreground_color(Color foreground_color) { this->foreground_color_ = foreground_color; }; + void set_background_color(Color background_color) { this->background_color_ = background_color; }; - - protected: - int item_padding_{0}; - std::string text_{}; - display::BaseFont *font_{nullptr}; - Color foreground_color_{COLOR_ON}; - Color background_color_{COLOR_OFF}; + +protected: + int item_padding_{0}; + std::string text_{}; + display::BaseFont *font_{nullptr}; + Color foreground_color_{COLOR_ON}; + Color background_color_{COLOR_OFF}; }; } diff --git a/esphome/components/graphical_layout/text_panel.py b/esphome/components/graphical_layout/text_panel.py index a50c9ab124..b74dc74def 100644 --- a/esphome/components/graphical_layout/text_panel.py +++ b/esphome/components/graphical_layout/text_panel.py @@ -1,5 +1,4 @@ import esphome.codegen as cg -from esphome.components import font, color from esphome.const import CONF_ID graphical_layout_ns = cg.esphome_ns.namespace("graphical_layout") diff --git a/esphome/components/graphical_layout/vertical_stack.h b/esphome/components/graphical_layout/vertical_stack.h index 995a350739..12fbfa4ba7 100644 --- a/esphome/components/graphical_layout/vertical_stack.h +++ b/esphome/components/graphical_layout/vertical_stack.h @@ -10,15 +10,15 @@ namespace graphical_layout { /** The HorizontalStack is a UI element which will render a series of items top to bottom down a display */ class VerticalStack : public ContainerLayoutItem { - public: - const display::Rect measure_item(display::Display *display); - void render(display::Display *display, display::Rect bounds); +public: + const display::Rect measure_item(display::Display *display); + void render(display::Display *display, display::Rect bounds); - void dump_config(int indent_depth, int additional_level_depth); - void set_item_padding(int item_padding) { this->item_padding_ = item_padding; }; + void dump_config(int indent_depth, int additional_level_depth); + void set_item_padding(int item_padding) { this->item_padding_ = item_padding; }; - protected: - int item_padding_{0}; +protected: + int item_padding_{0}; }; }