mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-16 08:04:21 +08:00
Add gauge and frame.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
add_subdirectory(frame)
|
||||
add_subdirectory(gauge)
|
||||
add_subdirectory(separator)
|
||||
add_subdirectory(vbox_hbox)
|
||||
|
4
examples/frame/CMakeLists.txt
Normal file
4
examples/frame/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
add_executable(frame_example
|
||||
main.cpp
|
||||
)
|
||||
target_link_libraries(frame_example PRIVATE ftxui)
|
35
examples/frame/main.cpp
Normal file
35
examples/frame/main.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
#include "ftxui/core/screen.hpp"
|
||||
#include "ftxui/core/dom/elements.hpp"
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
using namespace ftxui::dom;
|
||||
auto document =
|
||||
hbox(
|
||||
frame(
|
||||
vbox(
|
||||
text(L"Line 1"),
|
||||
text(L"Line 2"),
|
||||
text(L"Line 3"),
|
||||
frame(
|
||||
vbox(
|
||||
text(L"Line 4"),
|
||||
text(L"Line 5"),
|
||||
text(L"Line 6")
|
||||
)
|
||||
),
|
||||
text(L"Line 7"),
|
||||
text(L"Line 8"),
|
||||
text(L"Line 9")
|
||||
)
|
||||
),
|
||||
flex()
|
||||
);
|
||||
auto screen = ftxui::Screen::TerminalOutput(document);
|
||||
Render(screen, document.get());
|
||||
std::cout << screen.ToString() << std::endl;
|
||||
}
|
@@ -1,30 +1,22 @@
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
#include "ftxui/core/screen.hpp"
|
||||
#include "ftxui/core/dom/elements.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
using namespace ftxui::dom;
|
||||
auto document =
|
||||
hbox(
|
||||
flex(vbox(
|
||||
gauge(0.1),
|
||||
gauge(0.2),
|
||||
gauge(0.3)
|
||||
)),
|
||||
flex(vbox(
|
||||
gauge(0.1),
|
||||
gauge(0.8),
|
||||
gauge(0.3)
|
||||
))
|
||||
);
|
||||
//auto screen = ftxui::Screen::WholeTerminal();
|
||||
auto screen = ftxui::Screen::TerminalOutput(document);
|
||||
Render(screen, document.get());
|
||||
for(float percentage = 0; percentage <= 1.0; percentage+=0.001) {
|
||||
using namespace ftxui::dom;
|
||||
auto document =
|
||||
hbox(text(L"gauge = -"), flex(gauge(percentage)), text(L"-"));
|
||||
auto screen = ftxui::Screen(100, 1);
|
||||
Render(screen, document.get());
|
||||
std::cout << '\r' << screen.ToString() << std::flush;
|
||||
|
||||
std::cout << screen.ToString();
|
||||
|
||||
getchar();
|
||||
|
||||
return 0;
|
||||
using namespace std::chrono_literals;
|
||||
std::this_thread::sleep_for(0.01s);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user