Skip to content

Commit

Permalink
Add ayu colors
Browse files Browse the repository at this point in the history
  • Loading branch information
wcampbell0x2a committed Mar 5, 2025
1 parent 562c724 commit 214ac21
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 55 deletions.
22 changes: 17 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ rsadsb_common = { path = "../rsadsb_common" }
hex = "0.4.0"
crossterm = "0.27.0"
clap = { version = "4.5.13", features = ["color", "derive", "wrap_help"] }
ratatui = "0.28.1"
ratatui = "0.29.0"
gpsd_proto = "1.0.0"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
Expand Down
10 changes: 5 additions & 5 deletions apps/src/radar/airplanes.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use ratatui::layout::{Constraint, Rect};
use ratatui::style::{Color, Modifier, Style};
use ratatui::style::{Modifier, Style, Stylize};
use ratatui::widgets::{Block, Row, Table, TableState};
use rsadsb_common::{AirplaneDetails, Airplanes};

use crate::DEFAULT_PRECISION;
use crate::{BLUE, DEFAULT_PRECISION, WHITE};

/// Render Airplanes tab for tui display
pub fn build_tab_airplanes(
Expand Down Expand Up @@ -70,7 +70,7 @@ pub fn build_tab_airplanes(
Constraint::Length(6),
];
let table = Table::new(rows, widths)
.style(Style::default().fg(Color::White))
.style(Style::default().fg(WHITE))
.header(
Row::new(vec![
"ICAO",
Expand All @@ -86,9 +86,9 @@ pub fn build_tab_airplanes(
])
.bottom_margin(1),
)
.block(Block::bordered().title(format!("Airplanes({rows_len})")))
.block(Block::bordered().title(format!("Airplanes({rows_len})").fg(BLUE)))
.column_spacing(1)
.highlight_style(Style::default().add_modifier(Modifier::BOLD))
.row_highlight_style(Style::default().add_modifier(Modifier::BOLD))
.highlight_symbol(">> ");
f.render_stateful_widget(table, chunks[1], &mut airplanes_state.clone());
}
6 changes: 3 additions & 3 deletions apps/src/radar/coverage.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use adsb_deku::cpr::Position;
use adsb_deku::ICAO;
use ratatui::layout::Rect;
use ratatui::style::Color;
use ratatui::style::{Color, Style, Stylize};
use ratatui::widgets::canvas::{Canvas, Points};
use ratatui::widgets::Block;
use rsadsb_common::Airplanes;

use crate::{draw_locations, Settings, MAX_PLOT_HIGH, MAX_PLOT_LOW};
use crate::{draw_locations, Settings, BLUE, MAX_PLOT_HIGH, MAX_PLOT_LOW, WHITE};

/// Accuracy of latitude/longitude for Coverage is affected by this variable.
///
Expand Down Expand Up @@ -69,7 +69,7 @@ pub fn build_tab_coverage(
coverage_airplanes: &[(f64, f64, u32, ICAO)],
) {
let canvas = Canvas::default()
.block(Block::bordered().title("Coverage"))
.block(Block::bordered().style(Style::default().fg(WHITE)).title("Coverage".fg(BLUE)))
.x_bounds([MAX_PLOT_LOW, MAX_PLOT_HIGH])
.y_bounds([MAX_PLOT_LOW, MAX_PLOT_HIGH])
.paint(|ctx| {
Expand Down
16 changes: 9 additions & 7 deletions apps/src/radar/help.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use ratatui::layout::{Constraint, Direction, Layout, Rect};
use ratatui::style::{Color, Style};
use ratatui::style::{Style, Stylize};
use ratatui::widgets::{Block, Row, Table};

use crate::{BLUE, WHITE};

/// Render Help tab for tui display
pub fn build_tab_help(f: &mut ratatui::Frame, chunks: &[Rect]) {
let horizontal_chunks = Layout::default()
Expand Down Expand Up @@ -42,10 +44,10 @@ pub fn build_tab_help(f: &mut ratatui::Frame, chunks: &[Rect]) {
];
let widths = &[Constraint::Percentage(10), Constraint::Percentage(90)];
let table = Table::new(rows, widths)
.style(Style::default().fg(Color::White))
.style(Style::default().fg(WHITE))
.header(Row::new(vec!["Key", "Action"]).bottom_margin(1))
.column_spacing(1)
.block(Block::bordered().title("Key Bindings - Any Tab"));
.block(Block::bordered().title("Key Bindings - Any Tab".fg(BLUE)));
f.render_widget(table, vertical_chunks[1]);

// Second help section
Expand All @@ -59,10 +61,10 @@ pub fn build_tab_help(f: &mut ratatui::Frame, chunks: &[Rect]) {
Row::new(vec!["Enter", "Map position reset"]),
];
let table = Table::new(rows, widths)
.style(Style::default().fg(Color::White))
.style(Style::default().fg(WHITE))
.header(Row::new(vec!["Key", "Action"]).bottom_margin(1))
.column_spacing(1)
.block(Block::bordered().title("Key Bindings - Map or Coverage"));
.block(Block::bordered().title("Key Bindings - Map or Coverage".fg(BLUE)));
f.render_widget(table, vertical_chunks[2]);

// Third help section
Expand All @@ -72,9 +74,9 @@ pub fn build_tab_help(f: &mut ratatui::Frame, chunks: &[Rect]) {
Row::new(vec!["Enter", "Center Map tab on selected aircraft"]),
];
let table = Table::new(rows, widths)
.style(Style::default().fg(Color::White))
.style(Style::default().fg(WHITE))
.header(Row::new(vec!["Key", "Action"]).bottom_margin(1))
.column_spacing(1)
.block(Block::bordered().title("Key Bindings - Airplanes"));
.block(Block::bordered().title("Key Bindings - Airplanes".fg(BLUE)));
f.render_widget(table, vertical_chunks[3]);
}
31 changes: 11 additions & 20 deletions apps/src/radar/map.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use ratatui::layout::Rect;
use ratatui::style::{Color, Style};
use ratatui::style::{Style, Stylize};
use ratatui::text::Span;
use ratatui::widgets::canvas::{Canvas, Line, Points};
use ratatui::widgets::Block;
use rsadsb_common::{AirplaneDetails, Airplanes};

use crate::{draw_lines, draw_locations, Settings, DEFAULT_PRECISION, MAX_PLOT_HIGH, MAX_PLOT_LOW};
use crate::{
draw_lines, draw_locations, Settings, BLUE, DEFAULT_PRECISION, MAX_PLOT_HIGH, MAX_PLOT_LOW,
WHITE,
};

/// Render Map tab for tui display
pub fn build_tab_map(
Expand All @@ -15,7 +18,7 @@ pub fn build_tab_map(
adsb_airplanes: &Airplanes,
) {
let canvas = Canvas::default()
.block(Block::bordered().title("Map"))
.block(Block::bordered().style(Style::default().fg(WHITE)).title("Map".fg(BLUE)))
.x_bounds([MAX_PLOT_LOW, MAX_PLOT_HIGH])
.y_bounds([MAX_PLOT_LOW, MAX_PLOT_HIGH])
.paint(|ctx| {
Expand All @@ -39,7 +42,7 @@ pub fn build_tab_map(
settings.to_xy(position.latitude, position.longitude);

// draw dot on location
ctx.draw(&Points { coords: &[(x, y)], color: Color::White });
ctx.draw(&Points { coords: &[(x, y)], color: WHITE });
}
}
}
Expand Down Expand Up @@ -73,13 +76,7 @@ pub fn build_tab_map(
let y_2 = y + f64::from(LENGTH * (n_heading.to_radians()).cos());
let x_2 = x + f64::from(LENGTH * (n_heading.to_radians()).sin());

ctx.draw(&Line {
x1: x_1,
x2: x_2,
y1: y_1,
y2: y_2,
color: Color::Blue,
});
ctx.draw(&Line { x1: x_1, x2: x_2, y1: y_1, y2: y_2, color: BLUE });

// repeat for the other side (addition, so just modding)
let n_heading = (heading + angle) % 360.0;
Expand All @@ -88,13 +85,7 @@ pub fn build_tab_map(
let y_2 = y + f64::from(LENGTH * (n_heading.to_radians()).cos());
let x_2 = x + f64::from(LENGTH * (n_heading.to_radians()).sin());

ctx.draw(&Line {
x1: x_1,
x2: x_2,
y1: y_1,
y2: y_2,
color: Color::Blue,
});
ctx.draw(&Line { x1: x_1, x2: x_2, y1: y_1, y2: y_2, color: BLUE });
}
}

Expand All @@ -121,12 +112,12 @@ pub fn build_tab_map(
ctx.print(
x,
y + 20.0,
Span::styled(name.to_string(), Style::default().fg(Color::White)),
Span::styled(name.to_string(), Style::default().fg(WHITE)),
);
}

// draw dot on actual lat/lon
ctx.draw(&Points { coords: &[(x, y)], color: Color::Blue });
ctx.draw(&Points { coords: &[(x, y)], color: BLUE });
}
}
});
Expand Down
33 changes: 23 additions & 10 deletions apps/src/radar/radar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crossterm::ExecutableCommand;
use gpsd_proto::{get_data, handshake, ResponseData};
use ratatui::backend::{Backend, CrosstermBackend};
use ratatui::layout::{Alignment, Constraint, Direction, Layout, Rect};
use ratatui::style::{Color, Style};
use ratatui::style::{Color, Style, Styled};
use ratatui::symbols::DOT;
use ratatui::text::Span;
use ratatui::widgets::canvas::{Line, Points};
Expand All @@ -51,6 +51,18 @@ use tracing_subscriber::EnvFilter;

use crate::airplanes::build_tab_airplanes;

// Ayu bell colors
const BLUE: Color = Color::Rgb(0x59, 0xc2, 0xff);
const PURPLE: Color = Color::Rgb(0xd2, 0xa6, 0xff);
const ORANGE: Color = Color::Rgb(0xff, 0x8f, 0x40);
const YELLOW: Color = Color::Rgb(0xe6, 0xb4, 0x50);
const GREEN: Color = Color::Rgb(0xaa, 0xd9, 0x4c);
const RED: Color = Color::Rgb(0xff, 0x33, 0x33);
const DARK_GRAY: Color = Color::Rgb(0x20, 0x27, 0x34);
const GRAY: Color = Color::Rgb(0x44, 0x44, 0x44);
const GRAY_FG: Color = Color::Rgb(100, 100, 100);
const WHITE: Color = Color::Rgb(255, 255, 255);

/// Amount of zoom out from your original lat/long position
const MAX_PLOT_HIGH: f64 = 400.0;
const MAX_PLOT_LOW: f64 = MAX_PLOT_HIGH * -1.0;
Expand Down Expand Up @@ -731,10 +743,11 @@ fn draw(
Block::bordered()
.title(format!(
"rsadsb/radar(v{version}) - ({lat:.DEFAULT_PRECISION$},{long:.DEFAULT_PRECISION$}) {view_type}"
))
)
.set_style(Style::default().fg(GREEN)))
)
.style(Style::default().fg(Color::White))
.highlight_style(Style::default().fg(Color::Green))
.style(Style::default().fg(WHITE))
.highlight_style(Style::default().fg(ORANGE))
.select(settings.tab_selection as usize)
.divider(DOT);

Expand Down Expand Up @@ -820,8 +833,8 @@ fn draw_bottom_chunks(

/// Draw vertical and horizontal lines
fn draw_lines(ctx: &mut ratatui::widgets::canvas::Context<'_>) {
ctx.draw(&Line { x1: MAX_PLOT_HIGH, y1: 0.0, x2: MAX_PLOT_LOW, y2: 0.0, color: Color::White });
ctx.draw(&Line { x1: 0.0, y1: MAX_PLOT_HIGH, x2: 0.0, y2: MAX_PLOT_LOW, color: Color::White });
ctx.draw(&Line { x1: MAX_PLOT_HIGH, y1: 0.0, x2: MAX_PLOT_LOW, y2: 0.0, color: WHITE });
ctx.draw(&Line { x1: 0.0, y1: MAX_PLOT_HIGH, x2: 0.0, y2: MAX_PLOT_LOW, color: WHITE });
}

/// Draw locations on the map
Expand All @@ -830,20 +843,20 @@ pub fn draw_locations(ctx: &mut ratatui::widgets::canvas::Context<'_>, settings:
let (x, y) = settings.to_xy(location.lat, location.long);

// draw location coor
ctx.draw(&Points { coords: &[(x, y)], color: Color::Green });
ctx.draw(&Points { coords: &[(x, y)], color: GREEN });

// draw location name
ctx.print(x, y, Span::styled(location.name.clone(), Style::default().fg(Color::Green)));
ctx.print(x, y, Span::styled(location.name.clone(), Style::default().fg(GREEN)));
}
if let Some(ref airports) = settings.airports {
for Airport { icao, lat, lon, .. } in airports {
let (x, y) = settings.to_xy(*lat, *lon);

// draw city coor
ctx.draw(&Points { coords: &[(x, y)], color: Color::Green });
ctx.draw(&Points { coords: &[(x, y)], color: GREEN });

// draw city name
ctx.print(x, y, Span::styled(icao.to_string(), Style::default().fg(Color::Green)));
ctx.print(x, y, Span::styled(icao.to_string(), Style::default().fg(GREEN)));
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions apps/src/radar/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use std::time::SystemTime;

use adsb_deku::ICAO;
use ratatui::layout::{Constraint, Rect};
use ratatui::style::{Color, Style};
use ratatui::style::{Style, Stylize};
use ratatui::widgets::{Block, Row, Table};
use rsadsb_common::{Added, AirplaneCoor, Airplanes};
use tracing::info;

use crate::{Settings, DEFAULT_PRECISION};
use crate::{Settings, BLUE, DEFAULT_PRECISION, WHITE};

#[derive(Debug, Default)]
pub struct Stats {
Expand Down Expand Up @@ -94,9 +94,8 @@ pub fn build_tab_stats(
// draw table
let widths = &[Constraint::Length(16), Constraint::Length(15), Constraint::Length(200)];
let table = Table::new(rows, widths)
.style(Style::default().fg(Color::White))
.header(Row::new(vec!["Type", "DateTime", "Value"]).bottom_margin(1))
.block(Block::bordered().title("Stats"))
.block(Block::bordered().style(Style::default().fg(WHITE)).title("Stats".fg(BLUE)))
.column_spacing(1);
f.render_widget(table, chunks[1]);
}

0 comments on commit 214ac21

Please sign in to comment.