mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-10-17 00:38:09 +08:00
Flatten the namespaces.
Remove: * ftxui::screen * ftxui::dom * ftxui::component Keep: * ftxui
This commit is contained in:
@@ -5,19 +5,40 @@
|
||||
#include "ftxui/component/event.hpp"
|
||||
#include "ftxui/dom/elements.hpp"
|
||||
|
||||
namespace ftxui::component {
|
||||
namespace ftxui {
|
||||
|
||||
class Delegate;
|
||||
class Focus;
|
||||
|
||||
class Component {
|
||||
public:
|
||||
|
||||
class Delegate {
|
||||
public:
|
||||
Delegate() {}
|
||||
virtual ~Delegate() {}
|
||||
|
||||
// A Delegate shadows a component.
|
||||
virtual void Register(Component* component) = 0;
|
||||
virtual Component* component() = 0;
|
||||
|
||||
// Create new children.
|
||||
virtual Delegate* NewChild() = 0;
|
||||
virtual std::vector<Delegate*> children() = 0;
|
||||
|
||||
// Navigate in the tree.
|
||||
virtual Delegate* PreviousSibling() = 0;
|
||||
virtual Delegate* NextSibling() = 0;
|
||||
virtual Delegate* Parent() = 0;
|
||||
virtual Delegate* Root() = 0;
|
||||
};
|
||||
|
||||
// Constructor/Destructor.
|
||||
Component(Delegate* delegate);
|
||||
virtual ~Component();
|
||||
|
||||
// Render the component.
|
||||
virtual dom::Element Render();
|
||||
virtual Element Render();
|
||||
|
||||
// Handle an event. By default, it calls this function on each children.
|
||||
virtual bool OnEvent(Event even);
|
||||
@@ -38,6 +59,6 @@ class Component {
|
||||
Delegate* delegate_;
|
||||
};
|
||||
|
||||
} // namespace ftxui::component
|
||||
} // namespace ftxui
|
||||
|
||||
#endif /* end of include guard: FTXUI_COMPONENT_COMPONENT_HPP */
|
||||
|
@@ -4,7 +4,6 @@
|
||||
#include "ftxui/component/component.hpp"
|
||||
|
||||
namespace ftxui {
|
||||
namespace component {
|
||||
|
||||
// A component where focus and events are automatically handled for you.
|
||||
// Please use ComponentVertical or ComponentHorizontal.
|
||||
@@ -20,7 +19,6 @@ class ComponentDirection : public Component {
|
||||
Component* active_child_;
|
||||
};
|
||||
|
||||
} // namespace component
|
||||
} // namespace ftxui
|
||||
|
||||
#endif /* end of include guard: FTXUI_COMPONENT_COMPONENT_DIRECTION_H_ */
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "ftxui/component/component_direction.hpp"
|
||||
|
||||
namespace ftxui::component {
|
||||
namespace ftxui {
|
||||
|
||||
// A component where focus and events are automatically handled for you.
|
||||
// It assumes its children are put in the horizontal direction.
|
||||
@@ -13,6 +13,6 @@ class ComponentHorizontal : public ComponentDirection {
|
||||
bool HandleDirection(Event) override;
|
||||
};
|
||||
|
||||
} // namespace ftxui::component
|
||||
} // namespace ftxui
|
||||
|
||||
#endif /* end of include guard: FTXUI_COMPONENT_COMPONENT_HORIZONTAL_H_ */
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "ftxui/component/component_direction.hpp"
|
||||
|
||||
namespace ftxui::component {
|
||||
namespace ftxui {
|
||||
|
||||
// A component where focus and events are automatically handled for you.
|
||||
// It assumes its children are put in the vertical direction.
|
||||
@@ -13,6 +13,6 @@ class ComponentVertical : public ComponentDirection {
|
||||
bool HandleDirection(Event) override;
|
||||
};
|
||||
|
||||
} // namespace ftxui::component
|
||||
} // namespace ftxui
|
||||
|
||||
#endif /* end of include guard: FTXUI_COMPONENT_COMPONENT_VERTICAL_H_ */
|
||||
|
@@ -3,30 +3,11 @@
|
||||
|
||||
#include "ftxui/dom/elements.hpp"
|
||||
|
||||
namespace ftxui::component {
|
||||
namespace ftxui {
|
||||
|
||||
class Component;
|
||||
|
||||
class Delegate {
|
||||
public:
|
||||
Delegate() {}
|
||||
virtual ~Delegate() {}
|
||||
|
||||
// A Delegate shadows a component.
|
||||
virtual void Register(Component* component) = 0;
|
||||
virtual Component* component() = 0;
|
||||
|
||||
// Create new children.
|
||||
virtual Delegate* NewChild() = 0;
|
||||
virtual std::vector<Delegate*> children() = 0;
|
||||
|
||||
// Navigate in the tree.
|
||||
virtual Delegate* PreviousSibling() = 0;
|
||||
virtual Delegate* NextSibling() = 0;
|
||||
virtual Delegate* Parent() = 0;
|
||||
virtual Delegate* Root() = 0;
|
||||
};
|
||||
|
||||
} // namespace ftxui::component
|
||||
} // namespace ftxui
|
||||
|
||||
#endif /* end of include guard: FTXUI_COMPONENT_DELEGATE_HPP */
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include <vector>
|
||||
#include <array>
|
||||
|
||||
namespace ftxui::component {
|
||||
namespace ftxui {
|
||||
|
||||
struct Event{
|
||||
public:
|
||||
@@ -31,7 +31,7 @@ struct Event{
|
||||
};
|
||||
|
||||
|
||||
} // namespace ftxui::component
|
||||
} // namespace ftxui
|
||||
|
||||
|
||||
#endif /* end of include guard: FTXUI_COMPONENT_EVENT_HPP */
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include "ftxui/component/component.hpp"
|
||||
#include <functional>
|
||||
|
||||
namespace ftxui::component {
|
||||
namespace ftxui {
|
||||
|
||||
class Input : public Component {
|
||||
public:
|
||||
@@ -21,13 +21,13 @@ class Input : public Component {
|
||||
std::function<void()> on_enter = [](){};
|
||||
|
||||
// Component implementation.
|
||||
dom::Element Render() override;
|
||||
Element Render() override;
|
||||
bool OnEvent(Event) override;
|
||||
|
||||
private:
|
||||
int cursor_position = 0;
|
||||
};
|
||||
|
||||
} // namespace ftxui::component
|
||||
} // namespace ftxui
|
||||
|
||||
#endif /* end of include guard: FTXUI_COMPONENT_INPUT_H_ */
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include "ftxui/dom/elements.hpp"
|
||||
#include <functional>
|
||||
|
||||
namespace ftxui::component {
|
||||
namespace ftxui {
|
||||
|
||||
class Menu : public Component {
|
||||
public:
|
||||
@@ -16,16 +16,16 @@ class Menu : public Component {
|
||||
std::vector<std::wstring> entries = {};
|
||||
int selected = 0;
|
||||
|
||||
dom::Decorator active_style = dom::inverted;
|
||||
dom::Decorator selected_style = dom::bold;
|
||||
dom::Decorator normal_style = dom::nothing;
|
||||
Decorator active_style = inverted;
|
||||
Decorator selected_style = bold;
|
||||
Decorator normal_style = nothing;
|
||||
|
||||
// State update callback.
|
||||
std::function<void()> on_change = [](){};
|
||||
std::function<void()> on_enter = [](){};
|
||||
|
||||
// Component implementation.
|
||||
dom::Element Render() override;
|
||||
Element Render() override;
|
||||
bool OnEvent(Event) override;
|
||||
};
|
||||
|
||||
|
@@ -1,26 +1,26 @@
|
||||
#ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
|
||||
#define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
|
||||
|
||||
#include "ftxui/component/component.hpp"
|
||||
#include "ftxui/screen/screen.hpp"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace ftxui::component {
|
||||
namespace ftxui {
|
||||
|
||||
class Delegate;
|
||||
class Component;
|
||||
|
||||
class ScreenInteractive : public ftxui::screen::Screen {
|
||||
class ScreenInteractive : public ftxui::Screen {
|
||||
public:
|
||||
static ScreenInteractive FixedSize(size_t dimx, size_t dimy);
|
||||
static ScreenInteractive Fullscreen();
|
||||
static ScreenInteractive TerminalOutput();
|
||||
|
||||
~ScreenInteractive();
|
||||
component::Delegate* delegate();
|
||||
void Loop();
|
||||
std::function<void()> ExitLoopClosure();
|
||||
|
||||
Component::Delegate* delegate();
|
||||
|
||||
private:
|
||||
class Delegate;
|
||||
std::unique_ptr<Delegate> delegate_;
|
||||
@@ -38,6 +38,6 @@ class ScreenInteractive : public ftxui::screen::Screen {
|
||||
ScreenInteractive(size_t dimx, size_t dimy, Dimension dimension);
|
||||
};
|
||||
|
||||
} // namespace ftxui::component
|
||||
} // namespace ftxui
|
||||
|
||||
#endif /* end of include guard: FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP */
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
namespace ftxui::component {
|
||||
namespace ftxui {
|
||||
|
||||
class Toggle : public Component {
|
||||
public:
|
||||
@@ -20,7 +20,7 @@ class Toggle : public Component {
|
||||
std::function<void()> on_change = [](){};
|
||||
|
||||
// Component implementation.
|
||||
dom::Element Render() override;
|
||||
Element Render() override;
|
||||
bool OnEvent(Event) override;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user