mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 18:59:59 +08:00
Modify signature of Container::Tab(...) (#92)
Take selector at the end to get more pleasing results with clang-format.
This commit is contained in:
parent
2723616dc8
commit
7daeac25c0
@ -337,13 +337,15 @@ int main(int argc, const char* argv[]) {
|
||||
L"htop", L"color", L"spinner", L"gauge", L"compiler",
|
||||
};
|
||||
auto tab_selection = Toggle(&tab_entries, &tab_index);
|
||||
auto tab_content = Container::Tab(&tab_index, {
|
||||
htop,
|
||||
color_tab_renderer,
|
||||
spinner_tab_renderer,
|
||||
gauge_component,
|
||||
compiler_renderer,
|
||||
});
|
||||
auto tab_content = Container::Tab(
|
||||
{
|
||||
htop,
|
||||
color_tab_renderer,
|
||||
spinner_tab_renderer,
|
||||
gauge_component,
|
||||
compiler_renderer,
|
||||
},
|
||||
&tab_index);
|
||||
|
||||
auto main_container = Container::Vertical({
|
||||
tab_selection,
|
||||
|
@ -66,10 +66,12 @@ int main(int argc, const char* argv[]) {
|
||||
border;
|
||||
});
|
||||
|
||||
auto main_container = Container::Tab(&depth, {
|
||||
depth_0_renderer,
|
||||
depth_1_renderer,
|
||||
});
|
||||
auto main_container = Container::Tab(
|
||||
{
|
||||
depth_0_renderer,
|
||||
depth_1_renderer,
|
||||
},
|
||||
&depth);
|
||||
|
||||
auto main_renderer = Renderer(main_container, [&] {
|
||||
Element document = depth_0_renderer->Render();
|
||||
|
@ -41,11 +41,12 @@ int main(int argc, const char* argv[]) {
|
||||
};
|
||||
int tab_3_selected = 0;
|
||||
auto tab_container = Container::Tab(
|
||||
&tab_selected, {
|
||||
Radiobox(&tab_1_entries, &tab_1_selected),
|
||||
Radiobox(&tab_2_entries, &tab_2_selected),
|
||||
Radiobox(&tab_3_entries, &tab_3_selected),
|
||||
});
|
||||
{
|
||||
Radiobox(&tab_1_entries, &tab_1_selected),
|
||||
Radiobox(&tab_2_entries, &tab_2_selected),
|
||||
Radiobox(&tab_3_entries, &tab_3_selected),
|
||||
},
|
||||
&tab_selected);
|
||||
|
||||
auto container = Container::Vertical({
|
||||
tab_toggle,
|
||||
|
@ -41,11 +41,12 @@ int main(int argc, const char* argv[]) {
|
||||
};
|
||||
int tab_3_selected = 0;
|
||||
auto tab_container = Container::Tab(
|
||||
&tab_selected, {
|
||||
Radiobox(&tab_1_entries, &tab_1_selected),
|
||||
Radiobox(&tab_2_entries, &tab_2_selected),
|
||||
Radiobox(&tab_3_entries, &tab_3_selected),
|
||||
});
|
||||
{
|
||||
Radiobox(&tab_1_entries, &tab_1_selected),
|
||||
Radiobox(&tab_2_entries, &tab_2_selected),
|
||||
Radiobox(&tab_3_entries, &tab_3_selected),
|
||||
},
|
||||
&tab_selected);
|
||||
|
||||
auto container = Container::Horizontal({
|
||||
tab_menu,
|
||||
|
@ -36,7 +36,7 @@ Component Slider(StringRef label, T* value, T min, T max, T increment);
|
||||
namespace Container {
|
||||
Component Vertical(Components children);
|
||||
Component Horizontal(Components children);
|
||||
Component Tab(int* selector, Components children);
|
||||
Component Tab(Components children, int* selector);
|
||||
} // namespace Container
|
||||
|
||||
} // namespace ftxui
|
||||
|
@ -18,7 +18,7 @@ class ContainerBase : public ComponentBase {
|
||||
static Component Horizontal(Components children);
|
||||
|
||||
static Component Tab(int* selector);
|
||||
static Component Tab(int* selector, Components children);
|
||||
static Component Tab(Components children, int* selector);
|
||||
|
||||
~ContainerBase() override = default;
|
||||
|
||||
|
@ -62,15 +62,15 @@ Component Horizontal(Components children) {
|
||||
///
|
||||
/// ```cpp
|
||||
/// int tab_drawn = 0;
|
||||
/// auto container = Container::Tab(&tab_drawn, {
|
||||
/// auto container = Container::Tab({
|
||||
/// children_1,
|
||||
/// children_2,
|
||||
/// children_3,
|
||||
/// children_4,
|
||||
/// });
|
||||
/// }, &tab_drawn);
|
||||
/// ```
|
||||
Component Tab(int* selector, Components children) {
|
||||
return ContainerBase::Tab(selector, std::move(children));
|
||||
Component Tab(Components children, int* selector) {
|
||||
return ContainerBase::Tab(std::move(children), selector);
|
||||
}
|
||||
|
||||
} // namespace Container
|
||||
@ -107,11 +107,11 @@ Component ContainerBase::Horizontal(Components children) {
|
||||
|
||||
// static
|
||||
Component ContainerBase::Tab(int* selector) {
|
||||
return Tab(selector, {});
|
||||
return Tab({}, selector);
|
||||
}
|
||||
|
||||
// static
|
||||
Component ContainerBase::Tab(int* selector, Components children) {
|
||||
Component ContainerBase::Tab(Components children, int* selector) {
|
||||
auto container = std::make_shared<ContainerBase>();
|
||||
container->selector_ = selector;
|
||||
container->event_handler_ = &ContainerBase::TabEvent;
|
||||
|
Loading…
Reference in New Issue
Block a user