mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-19 01:38:08 +08:00
Remove input.hpp
This commit is contained in:

committed by
Arthur Sonzogni

parent
7ee6edfd1f
commit
26db8228f9
@@ -26,22 +26,22 @@ std::shared_ptr<T> Make(Args&&... args) {
|
||||
|
||||
Component Button(ConstStringRef label,
|
||||
std::function<void()> on_click,
|
||||
ConstRef<ButtonOption> = {});
|
||||
Ref<ButtonOption> = {});
|
||||
Component Checkbox(ConstStringRef label,
|
||||
bool* checked,
|
||||
ConstRef<CheckboxOption> option = {});
|
||||
Ref<CheckboxOption> option = {});
|
||||
Component Input(StringRef content,
|
||||
ConstStringRef placeholder,
|
||||
ConstRef<InputOption> option = {});
|
||||
Ref<InputOption> option = {});
|
||||
Component Menu(const std::vector<std::wstring>* entries,
|
||||
int* selected_,
|
||||
ConstRef<MenuOption> = {});
|
||||
Ref<MenuOption> = {});
|
||||
Component Radiobox(const std::vector<std::wstring>* entries,
|
||||
int* selected_,
|
||||
ConstRef<RadioboxOption> option = {});
|
||||
Ref<RadioboxOption> option = {});
|
||||
Component Toggle(const std::vector<std::wstring>* entries,
|
||||
int* selected,
|
||||
ConstRef<ToggleOption> option = {});
|
||||
Ref<ToggleOption> option = {});
|
||||
template <class T> // T = {int, float, long}
|
||||
Component Slider(StringRef label, T* value, T min, T max, T increment);
|
||||
Component Renderer(Component child, std::function<Element()>);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#define FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP
|
||||
|
||||
#include <ftxui/dom/elements.hpp>
|
||||
#include <ftxui/util/ref.hpp>
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
@@ -42,6 +43,8 @@ struct InputOption {
|
||||
std::function<void()> on_change = [] {};
|
||||
/// Called when the user presses enter.
|
||||
std::function<void()> on_enter = [] {};
|
||||
|
||||
Ref<int> cursor_position = 0;
|
||||
};
|
||||
|
||||
/// @brief Option for the Radiobox component.
|
||||
|
@@ -1,52 +0,0 @@
|
||||
#ifndef FTXUI_COMPONENT_INPUT_H_
|
||||
#define FTXUI_COMPONENT_INPUT_H_
|
||||
|
||||
#include <functional> // for function
|
||||
#include <string> // for wstring
|
||||
|
||||
#include "ftxui/component/component.hpp" // for Component
|
||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||
#include "ftxui/dom/elements.hpp" // for Element
|
||||
#include "ftxui/screen/box.hpp" // for Box
|
||||
#include "ftxui/screen/string.hpp" // for ConstStringRef, StringRef
|
||||
|
||||
namespace ftxui {
|
||||
struct Event;
|
||||
|
||||
/// @brief An input box. The user can type text into it.
|
||||
/// @ingroup component.
|
||||
class InputBase : public ComponentBase {
|
||||
public:
|
||||
// Access this interface from a Component
|
||||
static InputBase* From(Component component);
|
||||
|
||||
// Constructor.
|
||||
InputBase(StringRef content,
|
||||
ConstStringRef placeholder,
|
||||
ConstRef<InputOption> option = {});
|
||||
~InputBase() override = default;
|
||||
|
||||
// State.
|
||||
int cursor_position = 0;
|
||||
|
||||
// Component implementation.
|
||||
Element Render() override;
|
||||
bool OnEvent(Event) override;
|
||||
|
||||
private:
|
||||
StringRef content_;
|
||||
ConstStringRef placeholder_;
|
||||
|
||||
bool OnMouseEvent(Event);
|
||||
Box input_box_;
|
||||
Box cursor_box_;
|
||||
ConstRef<InputOption> option_;
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
||||
#endif /* end of include guard: FTXUI_COMPONENT_INPUT_H_ */
|
||||
|
||||
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be found in
|
||||
// the LICENSE file.
|
@@ -24,7 +24,7 @@ class MenuBase : public ComponentBase {
|
||||
// Constructor.
|
||||
MenuBase(const std::vector<std::wstring>* entries,
|
||||
int* selected_,
|
||||
ConstRef<MenuOption> option = {});
|
||||
Ref<MenuOption> option = {});
|
||||
~MenuBase() override = default;
|
||||
|
||||
// State.
|
||||
@@ -37,7 +37,7 @@ class MenuBase : public ComponentBase {
|
||||
protected:
|
||||
const std::vector<std::wstring>* const entries_;
|
||||
int* selected_ = 0;
|
||||
ConstRef<MenuOption> option_;
|
||||
Ref<MenuOption> option_;
|
||||
|
||||
bool OnMouseEvent(Event);
|
||||
|
||||
|
@@ -24,7 +24,7 @@ class RadioboxBase : public ComponentBase {
|
||||
// Constructor.
|
||||
RadioboxBase(const std::vector<std::wstring>* entries,
|
||||
int* selected,
|
||||
ConstRef<RadioboxOption> option = {});
|
||||
Ref<RadioboxOption> option = {});
|
||||
~RadioboxBase() override = default;
|
||||
|
||||
int focused = 0;
|
||||
@@ -40,7 +40,7 @@ class RadioboxBase : public ComponentBase {
|
||||
bool OnMouseEvent(Event event);
|
||||
int cursor_position = 0;
|
||||
std::vector<Box> boxes_;
|
||||
ConstRef<RadioboxOption> option_;
|
||||
Ref<RadioboxOption> option_;
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
@@ -23,7 +23,7 @@ class ToggleBase : public ComponentBase {
|
||||
// Constructor.
|
||||
ToggleBase(const std::vector<std::wstring>* entries,
|
||||
int* selected,
|
||||
ConstRef<ToggleOption> option = {});
|
||||
Ref<ToggleOption> option = {});
|
||||
~ToggleBase() override = default;
|
||||
|
||||
// State.
|
||||
@@ -39,7 +39,7 @@ class ToggleBase : public ComponentBase {
|
||||
|
||||
bool OnMouseEvent(Event event);
|
||||
std::vector<Box> boxes_;
|
||||
ConstRef<ToggleOption> option_;
|
||||
Ref<ToggleOption> option_;
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
Reference in New Issue
Block a user