You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.5 KiB
61 lines
1.5 KiB
4 weeks ago
|
#pragma once
|
||
|
#include <ftxui/dom/node.hpp> // for Render
|
||
|
#include <ftxui/component/component.hpp>
|
||
|
#include <ftxui/component/mouse.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 <SFML/Graphics/Color.hpp>
|
||
|
#include <locale>
|
||
|
#include <codecvt>
|
||
|
#include "color.hpp"
|
||
|
#include "point.hpp"
|
||
|
|
||
|
const int UI_PANEL_BORDER_PX=5;
|
||
|
|
||
|
using ftxui::Renderer, ftxui::Component, ftxui::Element, ftxui::Screen;
|
||
|
|
||
|
class Panel {
|
||
|
public:
|
||
|
int x;
|
||
|
int y;
|
||
|
int width;
|
||
|
int height;
|
||
|
bool has_border = false;
|
||
|
bool must_clear = true;
|
||
|
bool grid = false;
|
||
|
sf::Color default_bg = ColorValue::BLACK;
|
||
|
sf::Color default_fg = ColorValue::LIGHT_LIGHT;
|
||
|
sf::Color border_color = ColorValue::MID;
|
||
|
int border_px = UI_PANEL_BORDER_PX;
|
||
|
|
||
|
bool $dirty = true;
|
||
|
Component $component = nullptr;
|
||
|
Screen $screen;
|
||
|
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> $converter;
|
||
|
std::wstring $screenout;
|
||
|
|
||
|
Panel(int x, int y, int width, int height, bool is_grid=false) :
|
||
|
x(x),
|
||
|
y(y),
|
||
|
width(width),
|
||
|
height(height),
|
||
|
grid(is_grid),
|
||
|
$screen(Screen(width, height))
|
||
|
{
|
||
|
must_clear = !is_grid;
|
||
|
};
|
||
|
|
||
|
void resize(int width, int height);
|
||
|
void set_renderer(Component renderer);
|
||
|
void add(Component child);
|
||
|
void render();
|
||
|
void mouse_click(ftxui::Mouse::Button btn, Point pos);
|
||
|
void mouse_release(ftxui::Mouse::Button btn, Point pos);
|
||
|
void key_press(ftxui::Event event);
|
||
|
const std::wstring &to_string();
|
||
|
const Screen &screen();
|
||
|
};
|