From 447e3bdce7ef9728bdbdc3cdc2f949b93656c38f Mon Sep 17 00:00:00 2001 From: Michael Davidson Date: Fri, 22 Dec 2023 20:35:37 +1100 Subject: [PATCH] Clang fixes --- esphome/components/display/display.h | 2 +- .../graphical_layout/display_rendering_panel.cpp | 2 +- .../graphical_layout/display_rendering_panel.h | 10 ++++++---- .../components/graphical_layout/horizontal_stack.cpp | 2 +- esphome/components/graphical_layout/horizontal_stack.h | 6 +++--- esphome/components/graphical_layout/layout_item.h | 2 +- esphome/components/graphical_layout/text_panel.cpp | 2 +- esphome/components/graphical_layout/text_panel.h | 10 ++++++---- esphome/components/graphical_layout/vertical_stack.cpp | 2 +- esphome/components/graphical_layout/vertical_stack.h | 6 +++--- 10 files changed, 24 insertions(+), 20 deletions(-) diff --git a/esphome/components/display/display.h b/esphome/components/display/display.h index 662f7ea60a..a38922a663 100644 --- a/esphome/components/display/display.h +++ b/esphome/components/display/display.h @@ -517,7 +517,7 @@ class Display : public PollingComponent { * @param[in] x: x coordinate as the new local. Absolute to the displays underlying 0 * @param[in] y: y coordinate as the new local. Absolute to the displays underlying 0 */ - void set_local_coordinate(int x, int y) { this->local_coordinate_.push_back(Point(x, y)); }; + void set_local_coordinate(int x, int y) { this->local_coordinate_.emplace_back(x, y); }; /** Changes the local coordinates to be to be (x_local + x_offset, y_local + y_offset) * After calling a pixel drawn at (10, 20) would be drawn to the screen at diff --git a/esphome/components/graphical_layout/display_rendering_panel.cpp b/esphome/components/graphical_layout/display_rendering_panel.cpp index 0bf3c2c30d..5218c72fe9 100644 --- a/esphome/components/graphical_layout/display_rendering_panel.cpp +++ b/esphome/components/graphical_layout/display_rendering_panel.cpp @@ -14,7 +14,7 @@ void DisplayRenderingPanel::dump_config(int indent_depth, int additional_level_d ESP_LOGCONFIG(TAG, "%*sHas drawing lambda: %s", indent_depth, "", YESNO(this->lambda_ != nullptr)); } -const display::Rect DisplayRenderingPanel::measure_item(display::Display *display) { +display::Rect DisplayRenderingPanel::measure_item(display::Display *display) { return display::Rect(0, 0, this->width_, this->width_); } diff --git a/esphome/components/graphical_layout/display_rendering_panel.h b/esphome/components/graphical_layout/display_rendering_panel.h index 6c78ce9fb2..a48b2b393e 100644 --- a/esphome/components/graphical_layout/display_rendering_panel.h +++ b/esphome/components/graphical_layout/display_rendering_panel.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "esphome/components/graphical_layout/graphical_layout.h" #include "esphome/components/font/font.h" @@ -14,13 +16,13 @@ using display_writer_t = std::function; */ class DisplayRenderingPanel : 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); + display::Rect measure_item(display::Display *display) override; + void render(display::Display *display, display::Rect bounds) override; + void dump_config(int indent_depth, int additional_level_depth) override; void set_width(int width) { this->width_ = width; }; void set_height(int height) { this->height_ = height; }; - void set_lambda(display_writer_t lambda) { this->lambda_ = lambda; }; + void set_lambda(display_writer_t lambda) { this->lambda_ = std::move(lambda); }; protected: int width_{0}; diff --git a/esphome/components/graphical_layout/horizontal_stack.cpp b/esphome/components/graphical_layout/horizontal_stack.cpp index f17295fcbd..5e4b32929f 100644 --- a/esphome/components/graphical_layout/horizontal_stack.cpp +++ b/esphome/components/graphical_layout/horizontal_stack.cpp @@ -18,7 +18,7 @@ void HorizontalStack::dump_config(int indent_depth, int additional_level_depth) } } -const display::Rect HorizontalStack::measure_item(display::Display *display) { +display::Rect HorizontalStack::measure_item(display::Display *display) { display::Rect rect(this->item_padding_, 0, 0, 0); for (LayoutItem *child : this->children_) { diff --git a/esphome/components/graphical_layout/horizontal_stack.h b/esphome/components/graphical_layout/horizontal_stack.h index 683ad82d0c..f8b017f055 100644 --- a/esphome/components/graphical_layout/horizontal_stack.h +++ b/esphome/components/graphical_layout/horizontal_stack.h @@ -11,10 +11,10 @@ namespace graphical_layout { */ class HorizontalStack : public ContainerLayoutItem { public: - const display::Rect measure_item(display::Display *display); - void render(display::Display *display, display::Rect bounds); + display::Rect measure_item(display::Display *display) override; + void render(display::Display *display, display::Rect bounds) override; + void dump_config(int indent_depth, int additional_level_depth) override; - void dump_config(int indent_depth, int additional_level_depth); void set_item_padding(int item_padding) { this->item_padding_ = item_padding; }; protected: diff --git a/esphome/components/graphical_layout/layout_item.h b/esphome/components/graphical_layout/layout_item.h index 68147317bb..aeeb3035d7 100644 --- a/esphome/components/graphical_layout/layout_item.h +++ b/esphome/components/graphical_layout/layout_item.h @@ -15,7 +15,7 @@ class LayoutItem { * * param[in] display: Display that will be used for rendering. May be used to help with calculations */ - virtual const display::Rect measure_item(display::Display *display) = 0; + virtual display::Rect measure_item(display::Display *display) = 0; /** Perform the rendering of the item to the display * diff --git a/esphome/components/graphical_layout/text_panel.cpp b/esphome/components/graphical_layout/text_panel.cpp index bb3f96df1e..228c8432ef 100644 --- a/esphome/components/graphical_layout/text_panel.cpp +++ b/esphome/components/graphical_layout/text_panel.cpp @@ -13,7 +13,7 @@ void TextPanel::dump_config(int indent_depth, int additional_level_depth) { ESP_LOGCONFIG(TAG, "%*sText: %s", indent_depth, "", this->text_.c_str()); } -const display::Rect TextPanel::measure_item(display::Display *display) { +display::Rect TextPanel::measure_item(display::Display *display) { int x1; int y1; int width; diff --git a/esphome/components/graphical_layout/text_panel.h b/esphome/components/graphical_layout/text_panel.h index bf61cf6e8e..5c0d7832ec 100644 --- a/esphome/components/graphical_layout/text_panel.h +++ b/esphome/components/graphical_layout/text_panel.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "esphome/components/graphical_layout/graphical_layout.h" #include "esphome/components/font/font.h" @@ -12,12 +14,12 @@ 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); + display::Rect measure_item(display::Display *display) override; + void render(display::Display *display, display::Rect bounds) override; + void dump_config(int indent_depth, int additional_level_depth) override; void set_item_padding(int item_padding) { this->item_padding_ = item_padding; }; - void set_text(std::string text) { this->text_ = text; }; + void set_text(std::string text) { this->text_ = std::move(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; }; diff --git a/esphome/components/graphical_layout/vertical_stack.cpp b/esphome/components/graphical_layout/vertical_stack.cpp index 21c07d64d4..09ef685ab2 100644 --- a/esphome/components/graphical_layout/vertical_stack.cpp +++ b/esphome/components/graphical_layout/vertical_stack.cpp @@ -18,7 +18,7 @@ void VerticalStack::dump_config(int indent_depth, int additional_level_depth) { } } -const display::Rect VerticalStack::measure_item(display::Display *display) { +display::Rect VerticalStack::measure_item(display::Display *display) { display::Rect rect(0, this->item_padding_, 0, 0); for (LayoutItem *child : this->children_) { diff --git a/esphome/components/graphical_layout/vertical_stack.h b/esphome/components/graphical_layout/vertical_stack.h index d91edc09dc..df89b63f2b 100644 --- a/esphome/components/graphical_layout/vertical_stack.h +++ b/esphome/components/graphical_layout/vertical_stack.h @@ -10,10 +10,10 @@ namespace graphical_layout { */ class VerticalStack : public ContainerLayoutItem { public: - const display::Rect measure_item(display::Display *display); - void render(display::Display *display, display::Rect bounds); + display::Rect measure_item(display::Display *display) override; + void render(display::Display *display, display::Rect bounds) override; + void dump_config(int indent_depth, int additional_level_depth) override; - void dump_config(int indent_depth, int additional_level_depth); void set_item_padding(int item_padding) { this->item_padding_ = item_padding; }; protected: