mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 12:15:33 +01:00
Add [horizontal|vertical]_child_align_to_string methods
Used as part of ESP_LOGCONFIG() to aide in human readability
This commit is contained in:
parent
f061ff4ee4
commit
9b658980b2
@ -11,7 +11,7 @@ static const char *const TAG = "horizontalstack";
|
||||
|
||||
void HorizontalStack::dump_config(int indent_depth, int additional_level_depth) {
|
||||
ESP_LOGCONFIG(TAG, "%*sItem Padding: %i", indent_depth, "", this->item_padding_);
|
||||
ESP_LOGCONFIG(TAG, "%*sChild alignment: %i", indent_depth, "", (int) this->child_align_);
|
||||
ESP_LOGCONFIG(TAG, "%*sChild alignment: %s", indent_depth, "", vertical_child_align_to_string(this->child_align_));
|
||||
ESP_LOGCONFIG(TAG, "%*sChildren: %i", indent_depth, "", this->children_.size());
|
||||
|
||||
for (LayoutItem *child : this->children_) {
|
||||
|
@ -55,5 +55,35 @@ void LayoutItem::render(display::Display *display, display::Rect bounds) {
|
||||
display->pop_local_coordinates();
|
||||
}
|
||||
|
||||
const LogString *horizontal_child_align_to_string(HorizontalChildAlign align) {
|
||||
switch (align) {
|
||||
case HorizontalChildAlign::LEFT:
|
||||
return LOG_STR("LEFT");
|
||||
case HorizontalChildAlign::CENTER_HORIZONTAL:
|
||||
return LOG_STR("CENTER_HORIZONTAL");
|
||||
case HorizontalChildAlign::RIGHT:
|
||||
return LOG_STR("RIGHT");
|
||||
case HorizontalChildAlign::STRETCH_TO_FIT_WIDTH:
|
||||
return LOG_STR("STRETCH_TO_FIT_WIDTH");
|
||||
default:
|
||||
return LOG_STR("UNKNOWN");
|
||||
}
|
||||
}
|
||||
|
||||
const LogString *vertical_child_align_to_string(VerticalChildAlign align){
|
||||
switch (align) {
|
||||
case VerticalChildAlign::TOP:
|
||||
return LOG_STR("TOP");
|
||||
case VerticalChildAlign::CENTER_VERTICAL:
|
||||
return LOG_STR("CENTER_VERTICAL");
|
||||
case VerticalChildAlign::BOTTOM:
|
||||
return LOG_STR("BOTTOM");
|
||||
case VerticalChildAlign::STRETCH_TO_FIT_HEIGHT:
|
||||
return LOG_STR("STRETCH_TO_FIT_HEIGHT");
|
||||
default:
|
||||
return LOG_STR("UNKNOWN");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace graphical_layout
|
||||
} // namespace esphome
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/color.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace display {
|
||||
@ -100,5 +101,8 @@ class LayoutItem {
|
||||
Color border_color_{Color(0, 0, 0, 0)};
|
||||
};
|
||||
|
||||
const LogString *horizontal_child_align_to_string(HorizontalChildAlign align);
|
||||
const LogString *vertical_child_align_to_string(VerticalChildAlign align);
|
||||
|
||||
} // namespace graphical_layout
|
||||
} // namespace esphome
|
||||
|
@ -11,7 +11,7 @@ static const char *const TAG = "verticalstack";
|
||||
|
||||
void VerticalStack::dump_config(int indent_depth, int additional_level_depth) {
|
||||
ESP_LOGCONFIG(TAG, "%*sItem Padding: %i", indent_depth, "", this->item_padding_);
|
||||
ESP_LOGCONFIG(TAG, "%*sChild alignment: %i", indent_depth, "", (int) this->child_align_);
|
||||
ESP_LOGCONFIG(TAG, "%*sChild alignment: %s", indent_depth, "", horizontal_child_align_to_string(this->child_align_));
|
||||
ESP_LOGCONFIG(TAG, "%*sChildren: %i", indent_depth, "", this->children_.size());
|
||||
|
||||
for (LayoutItem *child : this->children_) {
|
||||
|
Loading…
Reference in New Issue
Block a user