dot-viewer 0.1.1

A viewer/debugger for large DAGs in Vim-like TUI
mod app;
mod input;
mod popup;
mod tabs;
mod utils;
mod view;

use tui::{
    layout::{Constraint, Direction, Layout, Rect},
    style::{Color, Style},
    widgets::{Block, Borders},
};

pub(crate) use crate::ui::app::draw_app;

pub(super) fn surrounding_block(title: String, highlight: bool) -> Block<'static> {
    let color = if highlight { Color::Yellow } else { Color::White };

    Block::default().borders(Borders::ALL).border_style(Style::default().fg(color)).title(title)
}

pub(super) fn centered_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect {
    let popup_layout = Layout::default()
        .direction(Direction::Vertical)
        .constraints(
            [
                Constraint::Percentage((100 - percent_y) / 2),
                Constraint::Percentage(percent_y),
                Constraint::Percentage((100 - percent_y) / 2),
            ]
            .as_ref(),
        )
        .split(r);

    Layout::default()
        .direction(Direction::Horizontal)
        .constraints(
            [
                Constraint::Percentage((100 - percent_x) / 2),
                Constraint::Percentage(percent_x),
                Constraint::Percentage((100 - percent_x) / 2),
            ]
            .as_ref(),
        )
        .split(popup_layout[1])[1]
}