From 046065b3077f10f9f5ce4056c253ffdb4182fbed Mon Sep 17 00:00:00 2001 From: Michael Davidson Date: Sun, 31 Dec 2023 12:41:37 +1100 Subject: [PATCH] Use local defintions of COLOR_ON / COLOR_OFF --- esphome/components/graphical_layout/layout_item.cpp | 3 +++ esphome/components/graphical_layout/layout_item.h | 5 ++++- esphome/components/graphical_layout/text_panel.h | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/esphome/components/graphical_layout/layout_item.cpp b/esphome/components/graphical_layout/layout_item.cpp index e4c43c01e9..3085eafee9 100644 --- a/esphome/components/graphical_layout/layout_item.cpp +++ b/esphome/components/graphical_layout/layout_item.cpp @@ -8,6 +8,9 @@ namespace graphical_layout { static const char *const TAG = "layoutitem"; +const Color COLOR_OFF(0, 0, 0, 0); +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); int margin_border_padding = this->margin_ + this->border_ + this->padding_; diff --git a/esphome/components/graphical_layout/layout_item.h b/esphome/components/graphical_layout/layout_item.h index 0b7a6bf8bb..ee6793cc1a 100644 --- a/esphome/components/graphical_layout/layout_item.h +++ b/esphome/components/graphical_layout/layout_item.h @@ -11,6 +11,9 @@ class Rect; namespace graphical_layout { +extern const Color COLOR_ON; +extern const Color COLOR_OFF; + /* HorizontalChildAlign is used to control alignment of children horizontally */ enum class HorizontalChildAlign { /* Aligns all children to the left of their available width */ @@ -105,7 +108,7 @@ class LayoutItem { int margin_{0}; int padding_{0}; int border_{0}; - Color border_color_{Color::BLACK}; + Color border_color_{COLOR_ON}; }; const LogString *horizontal_child_align_to_string(HorizontalChildAlign align); diff --git a/esphome/components/graphical_layout/text_panel.h b/esphome/components/graphical_layout/text_panel.h index 2198a746e0..0d45a3b71b 100644 --- a/esphome/components/graphical_layout/text_panel.h +++ b/esphome/components/graphical_layout/text_panel.h @@ -26,8 +26,8 @@ class TextPanel : public LayoutItem { TemplatableValue text_{}; display::BaseFont *font_{nullptr}; display::TextAlign text_align_{display::TextAlign::TOP_LEFT}; - Color foreground_color_{display::COLOR_ON}; - Color background_color_{display::COLOR_OFF}; + Color foreground_color_{COLOR_ON}; + Color background_color_{COLOR_OFF}; }; } // namespace graphical_layout