mirror of
https://github.com/esphome/esphome.git
synced 2024-12-12 08:24:55 +01:00
Apply clang-tidy fixes
This commit is contained in:
parent
65825516d4
commit
ee77485a2d
2 changed files with 15 additions and 16 deletions
|
@ -36,14 +36,14 @@ void TextRunPanel::setup_complete() {
|
||||||
|
|
||||||
display::Rect TextRunPanel::measure_item_internal(display::Display *display) {
|
display::Rect TextRunPanel::measure_item_internal(display::Display *display) {
|
||||||
CalculatedLayout calculated =
|
CalculatedLayout calculated =
|
||||||
this->determine_layout(display, display::Rect(0, 0, this->max_width_, display->get_height()), true);
|
this->determine_layout_(display, display::Rect(0, 0, this->max_width_, display->get_height()), true);
|
||||||
return calculated.bounds;
|
return calculated.bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextRunPanel::render_internal(display::Display *display, display::Rect bounds) {
|
void TextRunPanel::render_internal(display::Display *display, display::Rect bounds) {
|
||||||
ESP_LOGD(TAG, "Rendering to (%i, %i)", bounds.w, bounds.h);
|
ESP_LOGD(TAG, "Rendering to (%i, %i)", bounds.w, bounds.h);
|
||||||
|
|
||||||
CalculatedLayout layout = this->determine_layout(display, bounds, true);
|
CalculatedLayout layout = this->determine_layout_(display, bounds, true);
|
||||||
|
|
||||||
for (const auto &calculated : layout.runs) {
|
for (const auto &calculated : layout.runs) {
|
||||||
if (calculated->run->background_color_ != display::COLOR_OFF) {
|
if (calculated->run->background_color_ != display::COLOR_OFF) {
|
||||||
|
@ -62,7 +62,7 @@ void TextRunPanel::render_internal(display::Display *display, display::Rect boun
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<CalculatedTextRun>> TextRunPanel::split_runs_into_words() {
|
std::vector<std::shared_ptr<CalculatedTextRun>> TextRunPanel::split_runs_into_words_() {
|
||||||
std::vector<std::shared_ptr<CalculatedTextRun>> runs;
|
std::vector<std::shared_ptr<CalculatedTextRun>> runs;
|
||||||
|
|
||||||
for (TextRunBase *run : this->text_runs_) {
|
for (TextRunBase *run : this->text_runs_) {
|
||||||
|
@ -94,7 +94,7 @@ std::vector<std::shared_ptr<CalculatedTextRun>> TextRunPanel::split_runs_into_wo
|
||||||
return runs;
|
return runs;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<LineInfo>> TextRunPanel::fit_words_to_bounds(
|
std::vector<std::shared_ptr<LineInfo>> TextRunPanel::fit_words_to_bounds_(
|
||||||
const std::vector<std::shared_ptr<CalculatedTextRun>> &runs, display::Rect bounds) {
|
const std::vector<std::shared_ptr<CalculatedTextRun>> &runs, display::Rect bounds) {
|
||||||
int x_offset = 0;
|
int x_offset = 0;
|
||||||
int y_offset = 0;
|
int y_offset = 0;
|
||||||
|
@ -104,8 +104,7 @@ std::vector<std::shared_ptr<LineInfo>> TextRunPanel::fit_words_to_bounds(
|
||||||
auto current_line = std::make_shared<LineInfo>(current_line_number);
|
auto current_line = std::make_shared<LineInfo>(current_line_number);
|
||||||
lines.push_back(current_line);
|
lines.push_back(current_line);
|
||||||
|
|
||||||
for (int i = 0; i < runs.size(); i++) {
|
for (const auto &run : runs) {
|
||||||
const auto &run = runs.at(i);
|
|
||||||
if (run->bounds.w + x_offset > bounds.w) {
|
if (run->bounds.w + x_offset > bounds.w) {
|
||||||
// Overflows the current line create a new line
|
// Overflows the current line create a new line
|
||||||
x_offset = 0;
|
x_offset = 0;
|
||||||
|
@ -129,7 +128,7 @@ std::vector<std::shared_ptr<LineInfo>> TextRunPanel::fit_words_to_bounds(
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextRunPanel::apply_alignment_to_lines(std::vector<std::shared_ptr<LineInfo>> &lines,
|
void TextRunPanel::apply_alignment_to_lines_(std::vector<std::shared_ptr<LineInfo>> &lines,
|
||||||
display::TextAlign alignment) {
|
display::TextAlign alignment) {
|
||||||
const auto x_align = display::TextAlign(int(this->text_align_) & TEXT_ALIGN_X_MASK);
|
const auto x_align = display::TextAlign(int(this->text_align_) & TEXT_ALIGN_X_MASK);
|
||||||
const auto y_align = display::TextAlign(int(this->text_align_) & TEXT_ALIGN_Y_MASK);
|
const auto y_align = display::TextAlign(int(this->text_align_) & TEXT_ALIGN_Y_MASK);
|
||||||
|
@ -193,10 +192,10 @@ void TextRunPanel::apply_alignment_to_lines(std::vector<std::shared_ptr<LineInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CalculatedLayout TextRunPanel::determine_layout(display::Display *display, display::Rect bounds, bool apply_alignment) {
|
CalculatedLayout TextRunPanel::determine_layout_(display::Display *display, display::Rect bounds, bool apply_alignment) {
|
||||||
std::vector<std::shared_ptr<CalculatedTextRun>> runs = this->split_runs_into_words();
|
std::vector<std::shared_ptr<CalculatedTextRun>> runs = this->split_runs_into_words_();
|
||||||
std::vector<std::shared_ptr<LineInfo>> lines = this->fit_words_to_bounds(runs, bounds);
|
std::vector<std::shared_ptr<LineInfo>> lines = this->fit_words_to_bounds_(runs, bounds);
|
||||||
this->apply_alignment_to_lines(lines, this->text_align_);
|
this->apply_alignment_to_lines_(lines, this->text_align_);
|
||||||
|
|
||||||
CalculatedLayout layout;
|
CalculatedLayout layout;
|
||||||
layout.runs = runs;
|
layout.runs = runs;
|
||||||
|
|
|
@ -131,7 +131,7 @@ class LineInfo {
|
||||||
public:
|
public:
|
||||||
LineInfo(int line_number) { this->line_number = line_number; }
|
LineInfo(int line_number) { this->line_number = line_number; }
|
||||||
|
|
||||||
void add_run(std::shared_ptr<CalculatedTextRun> run) {
|
void add_run(const std::shared_ptr<CalculatedTextRun> &run) {
|
||||||
this->total_width += run->bounds.w;
|
this->total_width += run->bounds.w;
|
||||||
this->max_height = std::max(this->max_height, run->bounds.h);
|
this->max_height = std::max(this->max_height, run->bounds.h);
|
||||||
this->max_baseline = std::max(this->max_baseline, run->baseline);
|
this->max_baseline = std::max(this->max_baseline, run->baseline);
|
||||||
|
@ -166,11 +166,11 @@ class TextRunPanel : public LayoutItem {
|
||||||
void set_debug_outline_runs(bool debug_outline_runs) { this->debug_outline_runs_ = debug_outline_runs; };
|
void set_debug_outline_runs(bool debug_outline_runs) { this->debug_outline_runs_ = debug_outline_runs; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CalculatedLayout determine_layout(display::Display *display, display::Rect bounds, bool apply_alignment);
|
CalculatedLayout determine_layout_(display::Display *display, display::Rect bounds, bool apply_alignment);
|
||||||
std::vector<std::shared_ptr<CalculatedTextRun>> split_runs_into_words();
|
std::vector<std::shared_ptr<CalculatedTextRun>> split_runs_into_words_();
|
||||||
std::vector<std::shared_ptr<LineInfo>> fit_words_to_bounds(
|
std::vector<std::shared_ptr<LineInfo>> fit_words_to_bounds_(
|
||||||
const std::vector<std::shared_ptr<CalculatedTextRun>> &runs, display::Rect bounds);
|
const std::vector<std::shared_ptr<CalculatedTextRun>> &runs, display::Rect bounds);
|
||||||
void apply_alignment_to_lines(std::vector<std::shared_ptr<LineInfo>> &lines, display::TextAlign alignment);
|
void apply_alignment_to_lines_(std::vector<std::shared_ptr<LineInfo>> &lines, display::TextAlign alignment);
|
||||||
|
|
||||||
std::vector<TextRunBase *> text_runs_;
|
std::vector<TextRunBase *> text_runs_;
|
||||||
display::TextAlign text_align_{display::TextAlign::TOP_LEFT};
|
display::TextAlign text_align_{display::TextAlign::TOP_LEFT};
|
||||||
|
|
Loading…
Reference in a new issue