mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-11-04 13:38:14 +08:00 
			
		
		
		
	Remove explicit default destructors (#157)
From CppCoreGuidelines: Rule of Zero: C.20: If you can avoid defining default operations, do. C.52: Use inheriting constructors to import constructors into a derived class that does not need further explicit initialization. DRY forward and using declarations. Miscellaneous: Fix format.sh to output examples with normalised paths in sorted order. Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							b3a333b417
						
					
				
				
					commit
					21d746e858
				
			@@ -23,8 +23,6 @@ class ButtonBase : public ComponentBase {
 | 
			
		||||
             Ref<ButtonOption> option)
 | 
			
		||||
      : label_(label), on_click_(on_click), option_(std::move(option)) {}
 | 
			
		||||
 | 
			
		||||
  ~ButtonBase() override = default;
 | 
			
		||||
 | 
			
		||||
  // Component implementation:
 | 
			
		||||
  Element Render() override {
 | 
			
		||||
    auto style = Focused() ? inverted : nothing;
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,6 @@ class CatchEventBase : public ComponentBase {
 | 
			
		||||
  // Constructor.
 | 
			
		||||
  CatchEventBase(std::function<bool(Event)> on_event)
 | 
			
		||||
      : on_event_(std::move(on_event)) {}
 | 
			
		||||
  ~CatchEventBase() override = default;
 | 
			
		||||
 | 
			
		||||
  // Component implementation.
 | 
			
		||||
  bool OnEvent(Event event) override {
 | 
			
		||||
 
 | 
			
		||||
@@ -29,8 +29,6 @@ class CheckboxBase : public ComponentBase {
 | 
			
		||||
#endif
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ~CheckboxBase() override = default;
 | 
			
		||||
 | 
			
		||||
 private:
 | 
			
		||||
  // Component implementation.
 | 
			
		||||
  Element Render() override {
 | 
			
		||||
 
 | 
			
		||||
@@ -14,10 +14,7 @@
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
 | 
			
		||||
namespace {
 | 
			
		||||
class CaptureMouseImpl : public CapturedMouseInterface {
 | 
			
		||||
 public:
 | 
			
		||||
  ~CaptureMouseImpl() override {}
 | 
			
		||||
};
 | 
			
		||||
class CaptureMouseImpl : public CapturedMouseInterface {};
 | 
			
		||||
}  // namespace
 | 
			
		||||
 | 
			
		||||
ComponentBase::~ComponentBase() {
 | 
			
		||||
@@ -161,9 +158,9 @@ void ComponentBase::TakeFocus() {
 | 
			
		||||
/// @param event
 | 
			
		||||
/// @ingroup component
 | 
			
		||||
CapturedMouse ComponentBase::CaptureMouse(const Event& event) {
 | 
			
		||||
  if (!event.screen_)
 | 
			
		||||
    return std::make_unique<CaptureMouseImpl>();
 | 
			
		||||
  return event.screen_->CaptureMouse();
 | 
			
		||||
  if (event.screen_)
 | 
			
		||||
    return event.screen_->CaptureMouse();
 | 
			
		||||
  return std::make_unique<CaptureMouseImpl>();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace ftxui
 | 
			
		||||
 
 | 
			
		||||
@@ -53,8 +53,6 @@ class ContainerBase : public ComponentBase {
 | 
			
		||||
    return container;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ~ContainerBase() override = default;
 | 
			
		||||
 | 
			
		||||
  // Component override.
 | 
			
		||||
  bool OnEvent(Event event) override {
 | 
			
		||||
    if (event.is_mouse())
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,6 @@ class InputBase : public ComponentBase {
 | 
			
		||||
            ConstStringRef placeholder,
 | 
			
		||||
            Ref<InputOption> option)
 | 
			
		||||
      : content_(content), placeholder_(placeholder), option_(option) {}
 | 
			
		||||
  ~InputBase() override = default;
 | 
			
		||||
 | 
			
		||||
  int& cursor_position() { return *(option_->cursor_position); }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,6 @@ class RadioboxBase : public ComponentBase {
 | 
			
		||||
      option_->style_unchecked = L"( )";
 | 
			
		||||
#endif
 | 
			
		||||
  }
 | 
			
		||||
  ~RadioboxBase() override = default;
 | 
			
		||||
 | 
			
		||||
 private:
 | 
			
		||||
  Element Render() override {
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,6 @@ class RendererBase : public ComponentBase {
 | 
			
		||||
 | 
			
		||||
  // Constructor.
 | 
			
		||||
  RendererBase(std::function<Element()> render) : render_(std::move(render)) {}
 | 
			
		||||
  ~RendererBase() override = default;
 | 
			
		||||
 | 
			
		||||
  // Component implementation.
 | 
			
		||||
  Element Render() override { return render_(); }
 | 
			
		||||
 
 | 
			
		||||
@@ -29,8 +29,6 @@ class ToggleBase : public ComponentBase {
 | 
			
		||||
             Ref<ToggleOption> option)
 | 
			
		||||
      : entries_(entries), selected_(selected), option_(std::move(option)) {}
 | 
			
		||||
 | 
			
		||||
  ~ToggleBase() override = default;
 | 
			
		||||
 | 
			
		||||
 private:
 | 
			
		||||
  Element Render() override {
 | 
			
		||||
    Elements children;
 | 
			
		||||
 
 | 
			
		||||
@@ -11,8 +11,7 @@ namespace ftxui {
 | 
			
		||||
 | 
			
		||||
class Blink : public NodeDecorator {
 | 
			
		||||
 public:
 | 
			
		||||
  Blink(Elements children) : NodeDecorator(std::move(children)) {}
 | 
			
		||||
  ~Blink() override {}
 | 
			
		||||
  using NodeDecorator::NodeDecorator;
 | 
			
		||||
 | 
			
		||||
  void Render(Screen& screen) override {
 | 
			
		||||
    Node::Render(screen);
 | 
			
		||||
 
 | 
			
		||||
@@ -11,8 +11,7 @@ namespace ftxui {
 | 
			
		||||
 | 
			
		||||
class Bold : public NodeDecorator {
 | 
			
		||||
 public:
 | 
			
		||||
  Bold(Elements children) : NodeDecorator(std::move(children)) {}
 | 
			
		||||
  ~Bold() override {}
 | 
			
		||||
  using NodeDecorator::NodeDecorator;
 | 
			
		||||
 | 
			
		||||
  void Render(Screen& screen) override {
 | 
			
		||||
    for (int y = box_.y_min; y <= box_.y_max; ++y) {
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,6 @@ class Border : public Node {
 | 
			
		||||
                std::end(simple_border_charset)) {}
 | 
			
		||||
  Border(Elements children, Pixel pixel)
 | 
			
		||||
      : Node(std::move(children)), charset_pixel(10, pixel) {}
 | 
			
		||||
  ~Border() override {}
 | 
			
		||||
 | 
			
		||||
  std::vector<Pixel> charset_pixel;
 | 
			
		||||
  std::vector<wchar_t> charset;
 | 
			
		||||
 
 | 
			
		||||
@@ -13,8 +13,7 @@ using ftxui::Screen;
 | 
			
		||||
 | 
			
		||||
class ClearUnder : public NodeDecorator {
 | 
			
		||||
 public:
 | 
			
		||||
  ClearUnder(Elements children) : NodeDecorator(std::move(children)) {}
 | 
			
		||||
  ~ClearUnder() override {}
 | 
			
		||||
  using NodeDecorator::NodeDecorator;
 | 
			
		||||
 | 
			
		||||
  void Render(Screen& screen) override {
 | 
			
		||||
    for (int y = box_.y_min; y <= box_.y_max; ++y) {
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,6 @@ class FgColor : public NodeDecorator {
 | 
			
		||||
 public:
 | 
			
		||||
  FgColor(Elements children, Color color)
 | 
			
		||||
      : NodeDecorator(std::move(children)), color_(color) {}
 | 
			
		||||
  ~FgColor() override {}
 | 
			
		||||
 | 
			
		||||
  void Render(Screen& screen) override {
 | 
			
		||||
    for (int y = box_.y_min; y <= box_.y_max; ++y) {
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,6 @@ namespace ftxui {
 | 
			
		||||
class DBox : public Node {
 | 
			
		||||
 public:
 | 
			
		||||
  DBox(Elements children) : Node(std::move(children)) {}
 | 
			
		||||
  ~DBox() {}
 | 
			
		||||
 | 
			
		||||
  void ComputeRequirement() override {
 | 
			
		||||
    requirement_.min_x = 0;
 | 
			
		||||
 
 | 
			
		||||
@@ -9,12 +9,9 @@
 | 
			
		||||
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
 | 
			
		||||
using ftxui::Screen;
 | 
			
		||||
 | 
			
		||||
class Dim : public NodeDecorator {
 | 
			
		||||
 public:
 | 
			
		||||
  Dim(Elements children) : NodeDecorator(std::move(children)) {}
 | 
			
		||||
  ~Dim() override {}
 | 
			
		||||
  using NodeDecorator::NodeDecorator;
 | 
			
		||||
 | 
			
		||||
  void Render(Screen& screen) override {
 | 
			
		||||
    Node::Render(screen);
 | 
			
		||||
 
 | 
			
		||||
@@ -67,9 +67,8 @@ void function_not_flex(Requirement& r) {
 | 
			
		||||
 | 
			
		||||
class Flex : public Node {
 | 
			
		||||
 public:
 | 
			
		||||
  Flex(FlexFunction f) { f_ = f; }
 | 
			
		||||
  Flex(FlexFunction f) : f_(f) {}
 | 
			
		||||
  Flex(FlexFunction f, Element child) : Node(unpack(std::move(child))), f_(f) {}
 | 
			
		||||
  ~Flex() override {}
 | 
			
		||||
  void ComputeRequirement() override {
 | 
			
		||||
    requirement_.min_x = 0;
 | 
			
		||||
    requirement_.min_y = 0;
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,6 @@ static wchar_t charset[] = L"  ▏▎▍▌▋▊▉█";
 | 
			
		||||
class Gauge : public Node {
 | 
			
		||||
 public:
 | 
			
		||||
  Gauge(float progress) : progress_(progress) {}
 | 
			
		||||
  ~Gauge() override {}
 | 
			
		||||
 | 
			
		||||
  void ComputeRequirement() override {
 | 
			
		||||
    requirement_.flex_grow_x = 1;
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,6 @@ const wchar_t charset[] = L" ▗▐▖▄▟▌▙█";
 | 
			
		||||
class Graph : public Node {
 | 
			
		||||
 public:
 | 
			
		||||
  Graph(GraphFunction graph_function) : graph_function_(graph_function) {}
 | 
			
		||||
  ~Graph() override {}
 | 
			
		||||
 | 
			
		||||
  void ComputeRequirement() override {
 | 
			
		||||
    requirement_.flex_grow_x = 1;
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,6 @@ namespace ftxui {
 | 
			
		||||
class HBox : public Node {
 | 
			
		||||
 public:
 | 
			
		||||
  HBox(Elements children) : Node(std::move(children)) {}
 | 
			
		||||
  ~HBox() {}
 | 
			
		||||
 | 
			
		||||
  void ComputeRequirement() override {
 | 
			
		||||
    requirement_.min_x = 0;
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,6 @@ namespace ftxui {
 | 
			
		||||
class HFlow : public Node {
 | 
			
		||||
 public:
 | 
			
		||||
  HFlow(Elements children) : Node(std::move(children)) {}
 | 
			
		||||
  ~HFlow() {}
 | 
			
		||||
 | 
			
		||||
  void ComputeRequirement() override {
 | 
			
		||||
    requirement_.min_x = 1;
 | 
			
		||||
 
 | 
			
		||||
@@ -9,12 +9,9 @@
 | 
			
		||||
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
 | 
			
		||||
using ftxui::Screen;
 | 
			
		||||
 | 
			
		||||
class Inverted : public NodeDecorator {
 | 
			
		||||
 public:
 | 
			
		||||
  Inverted(Elements children) : NodeDecorator(std::move(children)) {}
 | 
			
		||||
  ~Inverted() override {}
 | 
			
		||||
  using NodeDecorator::NodeDecorator;
 | 
			
		||||
 | 
			
		||||
  void Render(Screen& screen) override {
 | 
			
		||||
    Node::Render(screen);
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,6 @@
 | 
			
		||||
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
 | 
			
		||||
using ftxui::Screen;
 | 
			
		||||
 | 
			
		||||
Node::Node() {}
 | 
			
		||||
Node::Node(Elements children) : children_(std::move(children)) {}
 | 
			
		||||
Node::~Node() {}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,6 @@ struct Box;
 | 
			
		||||
class NodeDecorator : public Node {
 | 
			
		||||
 public:
 | 
			
		||||
  NodeDecorator(Elements children) : Node(std::move(children)) {}
 | 
			
		||||
  ~NodeDecorator() override {}
 | 
			
		||||
  void ComputeRequirement() override;
 | 
			
		||||
  void SetBox(Box box) override;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,6 @@ class Reflect : public Node {
 | 
			
		||||
 public:
 | 
			
		||||
  Reflect(Element child, Box& box)
 | 
			
		||||
      : Node(unpack(std::move(child))), reflected_box_(box) {}
 | 
			
		||||
  ~Reflect() override {}
 | 
			
		||||
 | 
			
		||||
  void ComputeRequirement() final {
 | 
			
		||||
    Node::ComputeRequirement();
 | 
			
		||||
 
 | 
			
		||||
@@ -13,8 +13,6 @@ using ftxui::Screen;
 | 
			
		||||
 | 
			
		||||
class Separator : public Node {
 | 
			
		||||
 public:
 | 
			
		||||
  Separator() {}
 | 
			
		||||
  ~Separator() override {}
 | 
			
		||||
  void ComputeRequirement() override {
 | 
			
		||||
    requirement_.min_x = 1;
 | 
			
		||||
    requirement_.min_y = 1;
 | 
			
		||||
@@ -41,7 +39,6 @@ class Separator : public Node {
 | 
			
		||||
class SeparatorWithPixel : public Separator {
 | 
			
		||||
 public:
 | 
			
		||||
  SeparatorWithPixel(Pixel pixel) : pixel_(pixel) {}
 | 
			
		||||
  ~SeparatorWithPixel() override {}
 | 
			
		||||
  void Render(Screen& screen) override {
 | 
			
		||||
    for (int y = box_.y_min; y <= box_.y_max; ++y) {
 | 
			
		||||
      for (int x = box_.x_min; x <= box_.x_max; ++x) {
 | 
			
		||||
 
 | 
			
		||||
@@ -19,8 +19,6 @@ class Size : public Node {
 | 
			
		||||
        constraint_(constraint),
 | 
			
		||||
        value_(value) {}
 | 
			
		||||
 | 
			
		||||
  ~Size() override {}
 | 
			
		||||
 | 
			
		||||
  void ComputeRequirement() override {
 | 
			
		||||
    Node::ComputeRequirement();
 | 
			
		||||
    requirement_ = children_[0]->requirement();
 | 
			
		||||
 
 | 
			
		||||
@@ -15,8 +15,7 @@ using ftxui::Screen;
 | 
			
		||||
 | 
			
		||||
class Text : public Node {
 | 
			
		||||
 public:
 | 
			
		||||
  Text(std::wstring text) : Node(), text_(text) {}
 | 
			
		||||
  ~Text() {}
 | 
			
		||||
  Text(std::wstring text) : text_(text) {}
 | 
			
		||||
 | 
			
		||||
  void ComputeRequirement() override {
 | 
			
		||||
    requirement_.min_x = wstring_width(text_);
 | 
			
		||||
@@ -47,11 +46,10 @@ class Text : public Node {
 | 
			
		||||
 | 
			
		||||
class VText : public Node {
 | 
			
		||||
 public:
 | 
			
		||||
  VText(std::wstring text) : Node(), text_(text) {
 | 
			
		||||
  VText(std::wstring text) : text_(text) {
 | 
			
		||||
    for (auto& c : text_)
 | 
			
		||||
      width_ = std::max(width_, wchar_width(c));
 | 
			
		||||
  }
 | 
			
		||||
  ~VText() {}
 | 
			
		||||
 | 
			
		||||
  void ComputeRequirement() override {
 | 
			
		||||
    requirement_.min_x = width_;
 | 
			
		||||
 
 | 
			
		||||
@@ -9,12 +9,9 @@
 | 
			
		||||
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
 | 
			
		||||
using ftxui::Screen;
 | 
			
		||||
 | 
			
		||||
class Underlined : public NodeDecorator {
 | 
			
		||||
 public:
 | 
			
		||||
  Underlined(Elements children) : NodeDecorator(std::move(children)) {}
 | 
			
		||||
  ~Underlined() override {}
 | 
			
		||||
  using NodeDecorator::NodeDecorator;
 | 
			
		||||
 | 
			
		||||
  void Render(Screen& screen) override {
 | 
			
		||||
    Node::Render(screen);
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,6 @@ namespace ftxui {
 | 
			
		||||
class VBox : public Node {
 | 
			
		||||
 public:
 | 
			
		||||
  VBox(Elements children) : Node(std::move(children)) {}
 | 
			
		||||
  ~VBox() {}
 | 
			
		||||
 | 
			
		||||
  void ComputeRequirement() override {
 | 
			
		||||
    requirement_.min_x = 0;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user