mirror of
https://github.com/Boof2015/prism.git
synced 2026-08-17 19:24:03 +02:00
early tui layout
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Prism::Tui {
|
||||
|
||||
enum class PanelId {
|
||||
Spectrum,
|
||||
Levels,
|
||||
};
|
||||
|
||||
enum class SplitAxis {
|
||||
Rows,
|
||||
Columns,
|
||||
};
|
||||
|
||||
enum class LayoutPreset {
|
||||
Automatic,
|
||||
Stacked,
|
||||
Columns,
|
||||
};
|
||||
|
||||
struct LayoutNode {
|
||||
std::optional<PanelId> panel;
|
||||
SplitAxis axis = SplitAxis::Rows;
|
||||
int weight = 1;
|
||||
std::vector<LayoutNode> children;
|
||||
|
||||
static LayoutNode leaf(PanelId panel, int weight = 1);
|
||||
static LayoutNode split(SplitAxis axis,
|
||||
std::vector<LayoutNode> children,
|
||||
int weight = 1);
|
||||
bool isLeaf() const { return panel.has_value(); }
|
||||
};
|
||||
|
||||
struct PanelRect {
|
||||
PanelId panel = PanelId::Spectrum;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
};
|
||||
|
||||
struct DashboardLayout {
|
||||
bool terminalTooSmall = true;
|
||||
LayoutPreset requestedPreset = LayoutPreset::Automatic;
|
||||
LayoutPreset resolvedPreset = LayoutPreset::Stacked;
|
||||
LayoutNode root;
|
||||
std::vector<PanelRect> panels;
|
||||
};
|
||||
|
||||
constexpr int kMinimumTerminalWidth = 44;
|
||||
constexpr int kMinimumTerminalHeight = 12;
|
||||
|
||||
DashboardLayout buildDashboardLayout(int width,
|
||||
int height,
|
||||
LayoutPreset requestedPreset,
|
||||
std::optional<PanelId> expandedPanel = std::nullopt);
|
||||
LayoutPreset nextLayoutPreset(LayoutPreset preset);
|
||||
std::string layoutPresetName(LayoutPreset preset);
|
||||
std::vector<PanelId> panelOrder();
|
||||
PanelId nextPanel(PanelId panel, bool reverse = false);
|
||||
|
||||
} // namespace Prism::Tui
|
||||
Reference in New Issue
Block a user