mirror of
https://github.com/esphome/esphome.git
synced 2024-12-12 08:24:55 +01:00
Add dump_config_base_properties to LayoutItem - displays the basic properties of the item (Margin, Border, Padding)
This commit is contained in:
parent
b1b85cdada
commit
fed36a0af5
9 changed files with 22 additions and 2 deletions
|
@ -93,7 +93,7 @@ async def build_layout_item_pvariable(config):
|
||||||
cg.add(var.set_border_color(border_color))
|
cg.add(var.set_border_color(border_color))
|
||||||
|
|
||||||
padding = await cg.templatable(config[CONF_PADDING], args=[], output_type=int)
|
padding = await cg.templatable(config[CONF_PADDING], args=[], output_type=int)
|
||||||
cg.add(var.set_margin(padding))
|
cg.add(var.set_padding(padding))
|
||||||
|
|
||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace graphical_layout {
|
||||||
static const char *const TAG = "displayrenderingpanel";
|
static const char *const TAG = "displayrenderingpanel";
|
||||||
|
|
||||||
void DisplayRenderingPanel::dump_config(int indent_depth, int additional_level_depth) {
|
void DisplayRenderingPanel::dump_config(int indent_depth, int additional_level_depth) {
|
||||||
|
this->dump_config_base_properties(TAG, indent_depth);
|
||||||
ESP_LOGCONFIG(TAG, "%*sDimensions: %ix%i", indent_depth, "", this->width_.value(), this->height_.value());
|
ESP_LOGCONFIG(TAG, "%*sDimensions: %ix%i", indent_depth, "", this->width_.value(), this->height_.value());
|
||||||
ESP_LOGCONFIG(TAG, "%*sHas drawing lambda: %s", indent_depth, "", YESNO(this->lambda_ != nullptr));
|
ESP_LOGCONFIG(TAG, "%*sHas drawing lambda: %s", indent_depth, "", YESNO(this->lambda_ != nullptr));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace graphical_layout {
|
||||||
static const char *const TAG = "fixeddimensionpanel";
|
static const char *const TAG = "fixeddimensionpanel";
|
||||||
|
|
||||||
void FixedDimensionPanel::dump_config(int indent_depth, int additional_level_depth) {
|
void FixedDimensionPanel::dump_config(int indent_depth, int additional_level_depth) {
|
||||||
ESP_LOGCONFIG(TAG, "%*sWidth: %i (Will use display width: %s)", indent_depth, "", this->width_.value(),
|
this->dump_config_base_properties(TAG, indent_depth);
|
||||||
YESNO(this->width_.value() < 1));
|
YESNO(this->width_.value() < 1));
|
||||||
ESP_LOGCONFIG(TAG, "%*sHeight: %i (Will use display height: %s)", indent_depth, "", this->height_.value(),
|
ESP_LOGCONFIG(TAG, "%*sHeight: %i (Will use display height: %s)", indent_depth, "", this->height_.value(),
|
||||||
YESNO(this->height_.value() < 1));
|
YESNO(this->height_.value() < 1));
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace graphical_layout {
|
||||||
static const char *const TAG = "horizontalstack";
|
static const char *const TAG = "horizontalstack";
|
||||||
|
|
||||||
void HorizontalStack::dump_config(int indent_depth, int additional_level_depth) {
|
void HorizontalStack::dump_config(int indent_depth, int additional_level_depth) {
|
||||||
|
this->dump_config_base_properties(TAG, indent_depth);
|
||||||
ESP_LOGCONFIG(TAG, "%*sItem Padding: %i", indent_depth, "", this->item_padding_);
|
ESP_LOGCONFIG(TAG, "%*sItem Padding: %i", indent_depth, "", this->item_padding_);
|
||||||
ESP_LOGCONFIG(TAG, "%*sChild alignment: %s", indent_depth, "",
|
ESP_LOGCONFIG(TAG, "%*sChild alignment: %s", indent_depth, "",
|
||||||
LOG_STR_ARG(vertical_child_align_to_string(this->child_align_)));
|
LOG_STR_ARG(vertical_child_align_to_string(this->child_align_)));
|
||||||
|
|
|
@ -55,6 +55,14 @@ void LayoutItem::render(display::Display *display, display::Rect bounds) {
|
||||||
display->pop_local_coordinates();
|
display->pop_local_coordinates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LayoutItem::dump_config_base_properties(const char *tag, int indent_depth) {
|
||||||
|
ESP_LOGCONFIG(tag, "%*sMargin: %i", indent_depth, "", this->margin_);
|
||||||
|
ESP_LOGCONFIG(tag, "%*sBorder: %i", indent_depth, "", this->border_);
|
||||||
|
ESP_LOGCONFIG(tag, "%*sBorder Color: (R: %i, G: %i, B: %i)", indent_depth, "", this->border_color_.r,
|
||||||
|
this->border_color_.g, this->border_color_.b);
|
||||||
|
ESP_LOGCONFIG(tag, "%*sPadding: %i", indent_depth, "", this->padding_);
|
||||||
|
}
|
||||||
|
|
||||||
const LogString *horizontal_child_align_to_string(HorizontalChildAlign align) {
|
const LogString *horizontal_child_align_to_string(HorizontalChildAlign align) {
|
||||||
switch (align) {
|
switch (align) {
|
||||||
case HorizontalChildAlign::LEFT:
|
case HorizontalChildAlign::LEFT:
|
||||||
|
|
|
@ -84,6 +84,13 @@ class LayoutItem {
|
||||||
*/
|
*/
|
||||||
virtual void dump_config(int indent_depth, int additional_level_depth) = 0;
|
virtual void dump_config(int indent_depth, int additional_level_depth) = 0;
|
||||||
|
|
||||||
|
/** Dumps the base properties of the LayoutItem. Should be called by implementors dump_config()
|
||||||
|
*
|
||||||
|
* param[in] tag: Tag to pass to ESP_LOGCONFIG
|
||||||
|
* param[in] indent_depth: Depth to indent the config
|
||||||
|
*/
|
||||||
|
void dump_config_base_properties(const char *tag, int indent_depth);
|
||||||
|
|
||||||
/** Called once all setup has been completed (i.e. after code generation and all your set_ methods
|
/** Called once all setup has been completed (i.e. after code generation and all your set_ methods
|
||||||
* have been called). Can be used to finalise any configuration
|
* have been called). Can be used to finalise any configuration
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -13,6 +13,7 @@ static const int TEXT_ALIGN_Y_MASK =
|
||||||
(int) display::TextAlign::BOTTOM | (int) display::TextAlign::BASELINE | (int) display::TextAlign::CENTER_VERTICAL;
|
(int) display::TextAlign::BOTTOM | (int) display::TextAlign::BASELINE | (int) display::TextAlign::CENTER_VERTICAL;
|
||||||
|
|
||||||
void TextPanel::dump_config(int indent_depth, int additional_level_depth) {
|
void TextPanel::dump_config(int indent_depth, int additional_level_depth) {
|
||||||
|
this->dump_config_base_properties(TAG, indent_depth);
|
||||||
std::string text = this->text_.value();
|
std::string text = this->text_.value();
|
||||||
ESP_LOGCONFIG(TAG, "%*sText Align: %s", indent_depth, "",
|
ESP_LOGCONFIG(TAG, "%*sText Align: %s", indent_depth, "",
|
||||||
LOG_STR_ARG(display::text_align_to_string(this->text_align_)));
|
LOG_STR_ARG(display::text_align_to_string(this->text_align_)));
|
||||||
|
|
|
@ -13,6 +13,7 @@ static const int TEXT_ALIGN_Y_MASK =
|
||||||
(int) display::TextAlign::BOTTOM | (int) display::TextAlign::BASELINE | (int) display::TextAlign::CENTER_VERTICAL;
|
(int) display::TextAlign::BOTTOM | (int) display::TextAlign::BASELINE | (int) display::TextAlign::CENTER_VERTICAL;
|
||||||
|
|
||||||
void TextRunPanel::dump_config(int indent_depth, int additional_level_depth) {
|
void TextRunPanel::dump_config(int indent_depth, int additional_level_depth) {
|
||||||
|
this->dump_config_base_properties(TAG, indent_depth);
|
||||||
ESP_LOGCONFIG(TAG, "%*sMin Width: %i", indent_depth, "", this->min_width_);
|
ESP_LOGCONFIG(TAG, "%*sMin Width: %i", indent_depth, "", this->min_width_);
|
||||||
ESP_LOGCONFIG(TAG, "%*sMax Width: %i", indent_depth, "", this->max_width_);
|
ESP_LOGCONFIG(TAG, "%*sMax Width: %i", indent_depth, "", this->max_width_);
|
||||||
ESP_LOGCONFIG(TAG, "%*sText Align: %s", indent_depth, "",
|
ESP_LOGCONFIG(TAG, "%*sText Align: %s", indent_depth, "",
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace graphical_layout {
|
||||||
static const char *const TAG = "verticalstack";
|
static const char *const TAG = "verticalstack";
|
||||||
|
|
||||||
void VerticalStack::dump_config(int indent_depth, int additional_level_depth) {
|
void VerticalStack::dump_config(int indent_depth, int additional_level_depth) {
|
||||||
|
this->dump_config_base_properties(TAG, indent_depth);
|
||||||
ESP_LOGCONFIG(TAG, "%*sItem Padding: %i", indent_depth, "", this->item_padding_);
|
ESP_LOGCONFIG(TAG, "%*sItem Padding: %i", indent_depth, "", this->item_padding_);
|
||||||
ESP_LOGCONFIG(TAG, "%*sChild alignment: %s", indent_depth, "",
|
ESP_LOGCONFIG(TAG, "%*sChild alignment: %s", indent_depth, "",
|
||||||
LOG_STR_ARG(horizontal_child_align_to_string(this->child_align_)));
|
LOG_STR_ARG(horizontal_child_align_to_string(this->child_align_)));
|
||||||
|
|
Loading…
Reference in a new issue