2018-10-10 01:06:03 +08:00
|
|
|
#ifndef FTXUI_COMPONENT_TOGGLE_H_
|
|
|
|
#define FTXUI_COMPONENT_TOGGLE_H_
|
|
|
|
|
|
|
|
#include "ftxui/component/component.hpp"
|
|
|
|
#include <functional>
|
2019-01-03 07:35:59 +08:00
|
|
|
#include <string>
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
namespace ftxui {
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
class Toggle : public Component {
|
|
|
|
public:
|
|
|
|
// Constructor.
|
2019-01-13 01:24:46 +08:00
|
|
|
~Toggle() override = default;
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
// State.
|
2019-01-20 05:06:05 +08:00
|
|
|
int selected = 0;
|
2019-01-13 05:25:49 +08:00
|
|
|
std::vector<std::wstring> entries = {L"On", L"Off"};
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-20 05:06:05 +08:00
|
|
|
Decorator focused_style = inverted;
|
|
|
|
Decorator selected_style = bold;
|
|
|
|
Decorator normal_style = dim;
|
|
|
|
|
2018-10-10 01:06:03 +08:00
|
|
|
// Callback.
|
|
|
|
std::function<void()> on_change = [](){};
|
|
|
|
|
|
|
|
// Component implementation.
|
2019-01-12 22:00:08 +08:00
|
|
|
Element Render() override;
|
2018-10-19 04:58:38 +08:00
|
|
|
bool OnEvent(Event) override;
|
2018-10-10 01:06:03 +08:00
|
|
|
};
|
|
|
|
|
2019-01-07 00:10:35 +08:00
|
|
|
} // namespace ftxui::Component
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
#endif /* end of include guard: FTXUI_COMPONENT_TOGGLE_H_ */
|