parent
baaf56d4de
commit
9bc9c9007f
@ -0,0 +1,24 @@ |
||||
#include "panel.hpp" |
||||
|
||||
void Panel::resize(int width, int height) { |
||||
$screen = Screen(width, height); |
||||
} |
||||
|
||||
void Panel::set_renderer(std::function< Element()> render) { |
||||
$component = Renderer(render); |
||||
} |
||||
|
||||
Screen &Panel::render() { |
||||
if($must_clear) $screen.Clear(); |
||||
Render($screen, $component->Render()); |
||||
return $screen; |
||||
} |
||||
|
||||
std::wstring Panel::to_string() { |
||||
std::string screenout = $screen.ToString(); |
||||
return $converter.from_bytes(screenout); |
||||
} |
||||
|
||||
Screen &Panel::screen() { |
||||
return $screen; |
||||
} |
@ -0,0 +1,39 @@ |
||||
#pragma once |
||||
#include <ftxui/dom/node.hpp> // for Render |
||||
#include <ftxui/component/component.hpp> |
||||
#include <ftxui/screen/screen.hpp> |
||||
#include <ftxui/dom/canvas.hpp> |
||||
#include <ftxui/screen/screen.hpp> |
||||
#include <ftxui/dom/canvas.hpp> |
||||
#include <ftxui/screen/screen.hpp> |
||||
#include <ftxui/dom/canvas.hpp> |
||||
#include <locale> |
||||
#include <codecvt> |
||||
|
||||
using ftxui::Renderer, ftxui::Component, ftxui::Element, ftxui::Screen; |
||||
|
||||
struct Panel { |
||||
int x; |
||||
int y; |
||||
int width; |
||||
int height; |
||||
Component $component; |
||||
Screen $screen; |
||||
bool $must_clear = true; |
||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> $converter; |
||||
|
||||
Panel(int width, int height, int x, int y, bool must_clear=true) : |
||||
x(x), |
||||
y(y), |
||||
width(width), |
||||
height(height), |
||||
$screen(width, height), |
||||
$must_clear(must_clear) |
||||
{}; |
||||
|
||||
void resize(int width, int height); |
||||
void set_renderer(std::function< Element()> render); |
||||
Screen &render(); |
||||
std::wstring to_string(); |
||||
Screen &screen(); |
||||
}; |
Loading…
Reference in new issue