mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-23 03:10:01 +08:00
Pass -Wshadow (#97)
Requested from: https://github.com/robinlinden/hastur/pull/12
This commit is contained in:
parent
cf4fdf257e
commit
a574a6c3ee
@ -158,6 +158,7 @@ foreach(lib screen dom component)
|
|||||||
target_compile_options(${lib} PRIVATE "-Werror")
|
target_compile_options(${lib} PRIVATE "-Werror")
|
||||||
target_compile_options(${lib} PRIVATE "-Wmissing-declarations")
|
target_compile_options(${lib} PRIVATE "-Wmissing-declarations")
|
||||||
target_compile_options(${lib} PRIVATE "-Wdeprecated")
|
target_compile_options(${lib} PRIVATE "-Wdeprecated")
|
||||||
|
target_compile_options(${lib} PRIVATE "-Wshadow-all")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -35,9 +35,9 @@ class Node {
|
|||||||
// Step 3: Draw this element.
|
// Step 3: Draw this element.
|
||||||
virtual void Render(Screen& screen);
|
virtual void Render(Screen& screen);
|
||||||
|
|
||||||
std::vector<Element> children;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
std::vector<Element> children_;
|
||||||
Requirement requirement_;
|
Requirement requirement_;
|
||||||
Box box_;
|
Box box_;
|
||||||
};
|
};
|
||||||
|
@ -49,8 +49,8 @@ RadioboxBase* RadioboxBase::From(Component component) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RadioboxBase::RadioboxBase(const std::vector<std::wstring>* entries,
|
RadioboxBase::RadioboxBase(const std::vector<std::wstring>* entries,
|
||||||
int* selected_)
|
int* selected)
|
||||||
: entries_(entries), selected_(selected_) {}
|
: entries_(entries), selected_(selected) {}
|
||||||
|
|
||||||
Element RadioboxBase::Render() {
|
Element RadioboxBase::Render() {
|
||||||
std::vector<Element> elements;
|
std::vector<Element> elements;
|
||||||
|
@ -44,7 +44,7 @@ class TerminalInputParser {
|
|||||||
CursorReporting cursor;
|
CursorReporting cursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
Output(Type type) : type(type) {}
|
Output(Type t) : type(t) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
void Send(Output type);
|
void Send(Output type);
|
||||||
|
@ -29,12 +29,12 @@ class Border : public Node {
|
|||||||
|
|
||||||
void ComputeRequirement() override {
|
void ComputeRequirement() override {
|
||||||
Node::ComputeRequirement();
|
Node::ComputeRequirement();
|
||||||
requirement_ = children[0]->requirement();
|
requirement_ = children_[0]->requirement();
|
||||||
requirement_.min_x += 2;
|
requirement_.min_x += 2;
|
||||||
requirement_.min_y += 2;
|
requirement_.min_y += 2;
|
||||||
if (children.size() == 2) {
|
if (children_.size() == 2) {
|
||||||
requirement_.min_x =
|
requirement_.min_x =
|
||||||
std::max(requirement_.min_x, children[1]->requirement().min_x + 2);
|
std::max(requirement_.min_x, children_[1]->requirement().min_x + 2);
|
||||||
}
|
}
|
||||||
requirement_.selected_box.x_min++;
|
requirement_.selected_box.x_min++;
|
||||||
requirement_.selected_box.x_max++;
|
requirement_.selected_box.x_max++;
|
||||||
@ -44,24 +44,24 @@ class Border : public Node {
|
|||||||
|
|
||||||
void SetBox(Box box) override {
|
void SetBox(Box box) override {
|
||||||
Node::SetBox(box);
|
Node::SetBox(box);
|
||||||
if (children.size() == 2) {
|
if (children_.size() == 2) {
|
||||||
Box title_box;
|
Box title_box;
|
||||||
title_box.x_min = box.x_min + 1;
|
title_box.x_min = box.x_min + 1;
|
||||||
title_box.x_max = box.x_max - 1;
|
title_box.x_max = box.x_max - 1;
|
||||||
title_box.y_min = box.y_min;
|
title_box.y_min = box.y_min;
|
||||||
title_box.y_max = box.y_min;
|
title_box.y_max = box.y_min;
|
||||||
children[1]->SetBox(title_box);
|
children_[1]->SetBox(title_box);
|
||||||
}
|
}
|
||||||
box.x_min++;
|
box.x_min++;
|
||||||
box.x_max--;
|
box.x_max--;
|
||||||
box.y_min++;
|
box.y_min++;
|
||||||
box.y_max--;
|
box.y_max--;
|
||||||
children[0]->SetBox(box);
|
children_[0]->SetBox(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Render(Screen& screen) override {
|
void Render(Screen& screen) override {
|
||||||
// Draw content.
|
// Draw content.
|
||||||
children[0]->Render(screen);
|
children_[0]->Render(screen);
|
||||||
|
|
||||||
// Draw the border.
|
// Draw the border.
|
||||||
if (box_.x_min >= box_.x_max || box_.y_min >= box_.y_max)
|
if (box_.x_min >= box_.x_max || box_.y_min >= box_.y_max)
|
||||||
@ -88,8 +88,8 @@ class Border : public Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw title.
|
// Draw title.
|
||||||
if (children.size() == 2)
|
if (children_.size() == 2)
|
||||||
children[1]->Render(screen);
|
children_[1]->Render(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderChar(Screen& screen) {
|
void RenderChar(Screen& screen) {
|
||||||
|
@ -22,7 +22,7 @@ class DBox : public Node {
|
|||||||
requirement_.flex_grow_y = 0;
|
requirement_.flex_grow_y = 0;
|
||||||
requirement_.flex_shrink_x = 0;
|
requirement_.flex_shrink_x = 0;
|
||||||
requirement_.flex_shrink_y = 0;
|
requirement_.flex_shrink_y = 0;
|
||||||
for (auto& child : children) {
|
for (auto& child : children_) {
|
||||||
child->ComputeRequirement();
|
child->ComputeRequirement();
|
||||||
requirement_.min_x =
|
requirement_.min_x =
|
||||||
std::max(requirement_.min_x, child->requirement().min_x);
|
std::max(requirement_.min_x, child->requirement().min_x);
|
||||||
@ -39,17 +39,17 @@ class DBox : public Node {
|
|||||||
void SetBox(Box box) override {
|
void SetBox(Box box) override {
|
||||||
Node::SetBox(box);
|
Node::SetBox(box);
|
||||||
|
|
||||||
for (auto& child : children)
|
for (auto& child : children_)
|
||||||
child->SetBox(box);
|
child->SetBox(box);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief Stack several element on top of each other.
|
/// @brief Stack several element on top of each other.
|
||||||
/// @param children The input element.
|
/// @param children_ The input element.
|
||||||
/// @return The right aligned element.
|
/// @return The right aligned element.
|
||||||
/// @ingroup dom
|
/// @ingroup dom
|
||||||
Element dbox(Elements children) {
|
Element dbox(Elements children_) {
|
||||||
return std::make_shared<DBox>(std::move(children));
|
return std::make_shared<DBox>(std::move(children_));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ftxui
|
} // namespace ftxui
|
||||||
|
@ -73,17 +73,17 @@ class Flex : public Node {
|
|||||||
void ComputeRequirement() override {
|
void ComputeRequirement() override {
|
||||||
requirement_.min_x = 0;
|
requirement_.min_x = 0;
|
||||||
requirement_.min_y = 0;
|
requirement_.min_y = 0;
|
||||||
if (!children.empty()) {
|
if (!children_.empty()) {
|
||||||
children[0]->ComputeRequirement();
|
children_[0]->ComputeRequirement();
|
||||||
requirement_ = children[0]->requirement();
|
requirement_ = children_[0]->requirement();
|
||||||
}
|
}
|
||||||
f_(requirement_);
|
f_(requirement_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetBox(Box box) override {
|
void SetBox(Box box) override {
|
||||||
if (children.empty())
|
if (children_.empty())
|
||||||
return;
|
return;
|
||||||
children[0]->SetBox(box);
|
children_[0]->SetBox(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
FlexFunction f_;
|
FlexFunction f_;
|
||||||
|
@ -21,7 +21,7 @@ class Select : public Node {
|
|||||||
|
|
||||||
void ComputeRequirement() override {
|
void ComputeRequirement() override {
|
||||||
Node::ComputeRequirement();
|
Node::ComputeRequirement();
|
||||||
requirement_ = children[0]->requirement();
|
requirement_ = children_[0]->requirement();
|
||||||
auto& selected_box = requirement_.selected_box;
|
auto& selected_box = requirement_.selected_box;
|
||||||
selected_box.x_min = 0;
|
selected_box.x_min = 0;
|
||||||
selected_box.y_min = 0;
|
selected_box.y_min = 0;
|
||||||
@ -32,7 +32,7 @@ class Select : public Node {
|
|||||||
|
|
||||||
void SetBox(Box box) override {
|
void SetBox(Box box) override {
|
||||||
box_ = box;
|
box_ = box;
|
||||||
children[0]->SetBox(box);
|
children_[0]->SetBox(box);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ class Frame : public Node {
|
|||||||
|
|
||||||
void ComputeRequirement() override {
|
void ComputeRequirement() override {
|
||||||
Node::ComputeRequirement();
|
Node::ComputeRequirement();
|
||||||
requirement_ = children[0]->requirement();
|
requirement_ = children_[0]->requirement();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetBox(Box box) override {
|
void SetBox(Box box) override {
|
||||||
@ -98,13 +98,13 @@ class Frame : public Node {
|
|||||||
children_box.y_max = box.y_min + internal_dimy - dy;
|
children_box.y_max = box.y_min + internal_dimy - dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
children[0]->SetBox(children_box);
|
children_[0]->SetBox(children_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Render(Screen& screen) override {
|
void Render(Screen& screen) override {
|
||||||
AutoReset<Box> stencil(&screen.stencil,
|
AutoReset<Box> stencil(&screen.stencil,
|
||||||
Box::Intersection(box_, screen.stencil));
|
Box::Intersection(box_, screen.stencil));
|
||||||
children[0]->Render(screen);
|
children_[0]->Render(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -22,7 +22,7 @@ class HBox : public Node {
|
|||||||
requirement_.flex_grow_y = 0;
|
requirement_.flex_grow_y = 0;
|
||||||
requirement_.flex_shrink_x = 0;
|
requirement_.flex_shrink_x = 0;
|
||||||
requirement_.flex_shrink_y = 0;
|
requirement_.flex_shrink_y = 0;
|
||||||
for (auto& child : children) {
|
for (auto& child : children_) {
|
||||||
child->ComputeRequirement();
|
child->ComputeRequirement();
|
||||||
if (requirement_.selection < child->requirement().selection) {
|
if (requirement_.selection < child->requirement().selection) {
|
||||||
requirement_.selection = child->requirement().selection;
|
requirement_.selection = child->requirement().selection;
|
||||||
@ -46,7 +46,7 @@ class HBox : public Node {
|
|||||||
int flex_grow_sum = 0;
|
int flex_grow_sum = 0;
|
||||||
int flex_shrink_sum = 0;
|
int flex_shrink_sum = 0;
|
||||||
int flex_shrink_size = 0;
|
int flex_shrink_size = 0;
|
||||||
for (auto& child : children) {
|
for (auto& child : children_) {
|
||||||
const Requirement& r = child->requirement();
|
const Requirement& r = child->requirement();
|
||||||
flex_grow_sum += r.flex_grow_x;
|
flex_grow_sum += r.flex_grow_x;
|
||||||
flex_shrink_sum += r.min_x * r.flex_shrink_x;
|
flex_shrink_sum += r.min_x * r.flex_shrink_x;
|
||||||
@ -67,7 +67,7 @@ class HBox : public Node {
|
|||||||
|
|
||||||
void SetBoxGrow(Box box, int extra_space, int flex_grow_sum) {
|
void SetBoxGrow(Box box, int extra_space, int flex_grow_sum) {
|
||||||
int x = box.x_min;
|
int x = box.x_min;
|
||||||
for (auto& child : children) {
|
for (auto& child : children_) {
|
||||||
Box child_box = box;
|
Box child_box = box;
|
||||||
const Requirement& r = child->requirement();
|
const Requirement& r = child->requirement();
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class HBox : public Node {
|
|||||||
|
|
||||||
void SetBoxShrinkEasy(Box box, int extra_space, int flex_shrink_sum) {
|
void SetBoxShrinkEasy(Box box, int extra_space, int flex_shrink_sum) {
|
||||||
int x = box.x_min;
|
int x = box.x_min;
|
||||||
for (auto& child : children) {
|
for (auto& child : children_) {
|
||||||
Box child_box = box;
|
Box child_box = box;
|
||||||
const Requirement& r = child->requirement();
|
const Requirement& r = child->requirement();
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ class HBox : public Node {
|
|||||||
|
|
||||||
void SetBoxShrinkHard(Box box, int extra_space, int size) {
|
void SetBoxShrinkHard(Box box, int extra_space, int size) {
|
||||||
int x = box.x_min;
|
int x = box.x_min;
|
||||||
for (auto& child : children) {
|
for (auto& child : children_) {
|
||||||
Box child_box = box;
|
Box child_box = box;
|
||||||
const Requirement& r = child->requirement();
|
const Requirement& r = child->requirement();
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class HFlow : public Node {
|
|||||||
requirement_.flex_grow_y = 1;
|
requirement_.flex_grow_y = 1;
|
||||||
requirement_.flex_shrink_x = 0;
|
requirement_.flex_shrink_x = 0;
|
||||||
requirement_.flex_shrink_y = 0;
|
requirement_.flex_shrink_y = 0;
|
||||||
for (auto& child : children)
|
for (auto& child : children_)
|
||||||
child->ComputeRequirement();
|
child->ComputeRequirement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class HFlow : public Node {
|
|||||||
int y = box.y_min;
|
int y = box.y_min;
|
||||||
int y_next = y; // The position of next row of elements.
|
int y_next = y; // The position of next row of elements.
|
||||||
|
|
||||||
for (auto& child : children) {
|
for (auto& child : children_) {
|
||||||
Requirement requirement = child->requirement();
|
Requirement requirement = child->requirement();
|
||||||
|
|
||||||
// Does it fit the end of the row?
|
// Does it fit the end of the row?
|
||||||
|
@ -8,13 +8,13 @@ namespace ftxui {
|
|||||||
using ftxui::Screen;
|
using ftxui::Screen;
|
||||||
|
|
||||||
Node::Node() {}
|
Node::Node() {}
|
||||||
Node::Node(Elements children) : children(std::move(children)) {}
|
Node::Node(Elements children) : children_(std::move(children)) {}
|
||||||
Node::~Node() {}
|
Node::~Node() {}
|
||||||
|
|
||||||
/// @brief Compute how much space an elements needs.
|
/// @brief Compute how much space an elements needs.
|
||||||
/// @ingroup dom
|
/// @ingroup dom
|
||||||
void Node::ComputeRequirement() {
|
void Node::ComputeRequirement() {
|
||||||
for (auto& child : children)
|
for (auto& child : children_)
|
||||||
child->ComputeRequirement();
|
child->ComputeRequirement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ void Node::SetBox(Box box) {
|
|||||||
/// @brief Display an element on a ftxui::Screen.
|
/// @brief Display an element on a ftxui::Screen.
|
||||||
/// @ingroup dom
|
/// @ingroup dom
|
||||||
void Node::Render(Screen& screen) {
|
void Node::Render(Screen& screen) {
|
||||||
for (auto& child : children)
|
for (auto& child : children_)
|
||||||
child->Render(screen);
|
child->Render(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@ namespace ftxui {
|
|||||||
|
|
||||||
void NodeDecorator::ComputeRequirement() {
|
void NodeDecorator::ComputeRequirement() {
|
||||||
Node::ComputeRequirement();
|
Node::ComputeRequirement();
|
||||||
requirement_ = children[0]->requirement();
|
requirement_ = children_[0]->requirement();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeDecorator::SetBox(Box box) {
|
void NodeDecorator::SetBox(Box box) {
|
||||||
Node::SetBox(box);
|
Node::SetBox(box);
|
||||||
children[0]->SetBox(box);
|
children_[0]->SetBox(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ftxui
|
} // namespace ftxui
|
||||||
|
@ -13,22 +13,22 @@ namespace ftxui {
|
|||||||
class Reflect : public Node {
|
class Reflect : public Node {
|
||||||
public:
|
public:
|
||||||
Reflect(Element child, Box& box)
|
Reflect(Element child, Box& box)
|
||||||
: Node(unpack(std::move(child))), box_(box) {}
|
: Node(unpack(std::move(child))), reflected_box_(box) {}
|
||||||
~Reflect() override {}
|
~Reflect() override {}
|
||||||
|
|
||||||
void ComputeRequirement() final {
|
void ComputeRequirement() final {
|
||||||
Node::ComputeRequirement();
|
Node::ComputeRequirement();
|
||||||
requirement_ = children[0]->requirement();
|
requirement_ = children_[0]->requirement();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetBox(Box box) final {
|
void SetBox(Box box) final {
|
||||||
box_ = box;
|
reflected_box_ = box;
|
||||||
Node::SetBox(box_);
|
Node::SetBox(reflected_box_);
|
||||||
children[0]->SetBox(box_);
|
children_[0]->SetBox(reflected_box_);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Box& box_;
|
Box& reflected_box_;
|
||||||
};
|
};
|
||||||
|
|
||||||
Decorator reflect(Box& box) {
|
Decorator reflect(Box& box) {
|
||||||
|
@ -45,10 +45,12 @@ class Separator : public Node {
|
|||||||
|
|
||||||
class SeparatorWithPixel : public Separator {
|
class SeparatorWithPixel : public Separator {
|
||||||
public:
|
public:
|
||||||
SeparatorWithPixel(Pixel p) : p(p) {}
|
SeparatorWithPixel(Pixel pixel) : pixel_(pixel) {}
|
||||||
~SeparatorWithPixel() override {}
|
~SeparatorWithPixel() override {}
|
||||||
void Render(Screen& screen) override { RenderWithPixel(screen, p); }
|
void Render(Screen& screen) override { RenderWithPixel(screen, pixel_); }
|
||||||
Pixel p;
|
|
||||||
|
private:
|
||||||
|
Pixel pixel_;
|
||||||
};
|
};
|
||||||
|
|
||||||
Element separator() {
|
Element separator() {
|
||||||
|
@ -23,7 +23,7 @@ class Size : public Node {
|
|||||||
|
|
||||||
void ComputeRequirement() override {
|
void ComputeRequirement() override {
|
||||||
Node::ComputeRequirement();
|
Node::ComputeRequirement();
|
||||||
requirement_ = children[0]->requirement();
|
requirement_ = children_[0]->requirement();
|
||||||
|
|
||||||
auto& value = direction_ == WIDTH ? requirement_.min_x : requirement_.min_y;
|
auto& value = direction_ == WIDTH ? requirement_.min_x : requirement_.min_y;
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ class Size : public Node {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
children[0]->SetBox(box);
|
children_[0]->SetBox(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -22,7 +22,7 @@ class VBox : public Node {
|
|||||||
requirement_.flex_grow_y = 0;
|
requirement_.flex_grow_y = 0;
|
||||||
requirement_.flex_shrink_x = 0;
|
requirement_.flex_shrink_x = 0;
|
||||||
requirement_.flex_shrink_y = 0;
|
requirement_.flex_shrink_y = 0;
|
||||||
for (auto& child : children) {
|
for (auto& child : children_) {
|
||||||
child->ComputeRequirement();
|
child->ComputeRequirement();
|
||||||
if (requirement_.selection < child->requirement().selection) {
|
if (requirement_.selection < child->requirement().selection) {
|
||||||
requirement_.selection = child->requirement().selection;
|
requirement_.selection = child->requirement().selection;
|
||||||
@ -46,7 +46,7 @@ class VBox : public Node {
|
|||||||
int flex_grow_sum = 0;
|
int flex_grow_sum = 0;
|
||||||
int flex_shrink_sum = 0;
|
int flex_shrink_sum = 0;
|
||||||
int flex_shrink_size = 0;
|
int flex_shrink_size = 0;
|
||||||
for (auto& child : children) {
|
for (auto& child : children_) {
|
||||||
const Requirement& r = child->requirement();
|
const Requirement& r = child->requirement();
|
||||||
flex_grow_sum += r.flex_grow_y;
|
flex_grow_sum += r.flex_grow_y;
|
||||||
flex_shrink_sum += r.min_y * r.flex_shrink_y;
|
flex_shrink_sum += r.min_y * r.flex_shrink_y;
|
||||||
@ -67,7 +67,7 @@ class VBox : public Node {
|
|||||||
|
|
||||||
void SetBoxGrow(Box box, int extra_space, int flex_grow_sum) {
|
void SetBoxGrow(Box box, int extra_space, int flex_grow_sum) {
|
||||||
int y = box.y_min;
|
int y = box.y_min;
|
||||||
for (auto& child : children) {
|
for (auto& child : children_) {
|
||||||
Box child_box = box;
|
Box child_box = box;
|
||||||
const Requirement& r = child->requirement();
|
const Requirement& r = child->requirement();
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class VBox : public Node {
|
|||||||
|
|
||||||
void SetBoxShrinkEasy(Box box, int extra_space, int flex_shrink_sum) {
|
void SetBoxShrinkEasy(Box box, int extra_space, int flex_shrink_sum) {
|
||||||
int y = box.y_min;
|
int y = box.y_min;
|
||||||
for (auto& child : children) {
|
for (auto& child : children_) {
|
||||||
Box child_box = box;
|
Box child_box = box;
|
||||||
const Requirement& r = child->requirement();
|
const Requirement& r = child->requirement();
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ class VBox : public Node {
|
|||||||
|
|
||||||
void SetBoxShrinkHard(Box box, int extra_space, int size) {
|
void SetBoxShrinkHard(Box box, int extra_space, int size) {
|
||||||
int y = box.y_min;
|
int y = box.y_min;
|
||||||
for (auto& child : children) {
|
for (auto& child : children_) {
|
||||||
Box child_box = box;
|
Box child_box = box;
|
||||||
const Requirement& r = child->requirement();
|
const Requirement& r = child->requirement();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user