mirror of
https://github.com/esphome/esphome.git
synced 2024-12-12 08:24:55 +01:00
clang fixes
This commit is contained in:
parent
f749d26353
commit
2227a091c5
14 changed files with 72 additions and 75 deletions
|
@ -174,10 +174,10 @@ void Display::menu(int x, int y, graphical_display_menu::GraphicalDisplayMenu *m
|
|||
#endif // USE_GRAPHICAL_DISPLAY_MENU
|
||||
|
||||
#ifdef USE_GRAPHICAL_LAYOUT
|
||||
void Display::render_layout(int x, int y, graphical_layout::RootLayoutComponent *layout) {
|
||||
void Display::render_layout(int x, int y, graphical_layout::RootLayoutComponent *layout) {
|
||||
display::Rect b2(x, y, 100, 100);
|
||||
layout->render_at(this, x, y);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void Display::get_text_bounds(int x, int y, const char *text, BaseFont *font, TextAlign align, int *x1, int *y1,
|
||||
|
@ -358,7 +358,6 @@ void Display::set_local_coordinates_relative_to_current(int x_offset, int y_offs
|
|||
p.y += y_offset;
|
||||
|
||||
this->local_coordinate_.push_back(p);
|
||||
|
||||
}
|
||||
void Display::pop_local_coordinates() {
|
||||
if (this->local_coordinate_.empty()) {
|
||||
|
|
|
@ -2,9 +2,9 @@ import esphome.codegen as cg
|
|||
import esphome.config_validation as cv
|
||||
from esphome.components import font, color
|
||||
from esphome.const import CONF_ID
|
||||
from esphome.components.graphical_layout import horizontal_stack
|
||||
from esphome.components.graphical_layout import vertical_stack
|
||||
from esphome.components.graphical_layout import text_panel
|
||||
from . import horizontal_stack
|
||||
from . import vertical_stack
|
||||
from . import text_panel
|
||||
|
||||
graphical_layout_ns = cg.esphome_ns.namespace("graphical_layout")
|
||||
RootLayoutComponent = graphical_layout_ns.class_("RootLayoutComponent", cg.Component)
|
||||
|
|
|
@ -17,9 +17,7 @@ class ContainerLayoutItem : public LayoutItem {
|
|||
public:
|
||||
|
||||
/** Adds an item to this container */
|
||||
void add_item(LayoutItem *child) {
|
||||
this->children_.push_back(child);
|
||||
}
|
||||
void add_item(LayoutItem *child) { this->children_.push_back(child); }
|
||||
|
||||
protected:
|
||||
std::vector<LayoutItem *> children_;
|
||||
|
|
|
@ -19,7 +19,7 @@ void RootLayoutComponent::dump_config() {
|
|||
void RootLayoutComponent::render_at(display::Display *display, int x, int y) {
|
||||
display->set_local_coordinate(x, y);
|
||||
|
||||
display::Rect layout_rect = this->layout_root_->measure_item(display);
|
||||
display::Rect layout _rect = this->layout_root_->measure_item(display);
|
||||
display::Rect clipping_rect = display::Rect(x, y, layout_rect.w, layout_rect.h);
|
||||
|
||||
// TODO: Should clipping be relative to local?
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace esphome {
|
|||
namespace display {
|
||||
class Display;
|
||||
class Rect;
|
||||
}
|
||||
} // namespace display
|
||||
|
||||
namespace graphical_layout {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
namespace esphome {
|
||||
namespace graphical_layout {
|
||||
|
||||
static const char*TAG = "horizontalstack";
|
||||
static const char *TAG = "horizontalstack";
|
||||
|
||||
void HorizontalStack::dump_config(int indent_depth, int additional_level_depth) {
|
||||
ESP_LOGCONFIG(TAG, "%*sItem Padding: %i", indent_depth, "", this->item_padding_);
|
||||
|
@ -47,5 +47,5 @@ void HorizontalStack::render(display::Display *display, display::Rect bounds) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace graphical_layout
|
||||
} // namespace esphome
|
||||
|
|
|
@ -8,18 +8,18 @@ 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:
|
||||
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; };
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int item_padding_{0};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace graphical_layout
|
||||
} // namespace esphome
|
||||
|
|
|
@ -33,5 +33,5 @@ class LayoutItem {
|
|||
virtual void dump_config(int indent_depth, int additional_level_depth) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace graphical_layout
|
||||
} // namespace esphome
|
||||
|
|
|
@ -19,7 +19,8 @@ const display::Rect TextPanel::measure_item(display::Display *display) {
|
|||
int width;
|
||||
int height;
|
||||
|
||||
display->get_text_bounds(0, 0, this->text_.c_str(), this->font_, display::TextAlign::TOP_LEFT, &x1, &y1, &width, &height);
|
||||
display->get_text_bounds(0, 0, this->text_.c_str(), this->font_, display::TextAlign::TOP_LEFT, &x1, &y1, &width,
|
||||
&height);
|
||||
|
||||
return display::Rect(0, 0, width, height);
|
||||
}
|
||||
|
@ -28,5 +29,5 @@ void TextPanel::render(display::Display *display, display::Rect bounds) {
|
|||
display->print(0, 0, this->font_, this->foreground_color_, display::TextAlign::TOP_LEFT, this->text_.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace graphical_layout
|
||||
} // namespace esphome
|
||||
|
|
|
@ -12,7 +12,7 @@ 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:
|
||||
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);
|
||||
|
@ -24,7 +24,7 @@ public:
|
|||
void set_background_color(Color background_color) { this->background_color_ = background_color; };
|
||||
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int item_padding_{0};
|
||||
std::string text_{};
|
||||
display::BaseFont *font_{nullptr};
|
||||
|
@ -32,5 +32,5 @@ protected:
|
|||
Color background_color_{COLOR_OFF};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace graphical_layout
|
||||
} // namespace esphome
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
namespace esphome {
|
||||
namespace graphical_layout {
|
||||
|
||||
static const char*TAG = "verticalstack";
|
||||
static const char *TAG = "verticalstack";
|
||||
|
||||
void VerticalStack::dump_config(int indent_depth, int additional_level_depth) {
|
||||
ESP_LOGCONFIG(TAG, "%*sItem Padding: %i", indent_depth, "", this->item_padding_);
|
||||
|
@ -46,5 +46,5 @@ void VerticalStack::render(display::Display *display, display::Rect bounds) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace graphical_layout
|
||||
} // namespace esphome
|
||||
|
|
|
@ -3,23 +3,22 @@
|
|||
#include "esphome/components/graphical_layout/graphical_layout.h"
|
||||
#include "esphome/components/graphical_layout/container_layout_item.h"
|
||||
|
||||
|
||||
namespace esphome {
|
||||
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:
|
||||
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; };
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int item_padding_{0};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace graphical_layout
|
||||
} // namespace esphome
|
||||
|
|
Loading…
Reference in a new issue