Added more colors to platform, improve on linux

pull/2/head
Benedikt Terhechte 3 years ago
parent 23afef2ea5
commit b1f0d4c187

@ -145,7 +145,7 @@ impl StartupUI {
ui.add(
egui::widgets::Label::new("Email Folder:")
.text_color(Color32::WHITE)
.text_color(platform_colors().text_primary)
.text_style(TextStyle::Body),
);
ui.end_row();
@ -185,6 +185,7 @@ impl StartupUI {
ui.add(
egui::widgets::Label::new("Used to filter send mails")
.text_color(platform_colors().text_secondary)
.text_style(TextStyle::Small),
);
ui.end_row();

@ -9,12 +9,28 @@ pub fn platform_colors(theme: Theme) -> PlatformColors {
// From Google images, Gtk
match theme {
Theme::Light => PlatformColors {
is_light: true,
animation_background: Color32::from_rgb(248, 246, 249),
window_background: Color32::from_rgb(246, 245, 244),
content_background: Color32::from_rgb(254, 254, 254),
text_primary: Color32::from_gray(0),
text_secondary: Color32::from_gray(30),
line1: Color32::from_gray(0),
line2: Color32::from_gray(30),
line3: Color32::from_gray(60),
line4: Color32::from_gray(90),
},
Theme::Dark => PlatformColors {
is_light: false,
animation_background: Color32::from_gray(60),
window_background: Color32::from_rgb(73, 73, 73),
content_background: Color32::from_rgb(34, 32, 40),
text_primary: Color32::from_gray(255),
text_secondary: Color32::from_gray(200),
line1: Color32::from_gray(255),
line2: Color32::from_gray(210),
line3: Color32::from_gray(190),
line4: Color32::from_gray(120),
},
}
}

@ -16,12 +16,28 @@ use super::{PlatformColors, Theme};
pub fn platform_colors(theme: THeme) -> PlatformColors {
match theme {
Theme::Light => PlatformColors {
is_light: true,
animation_background: Color32::from_rgb(248, 246, 249),
window_background: Color32::from_rgb(238, 236, 242),
content_background: Color32::from_rgb(236, 234, 238),
text_primary: Color32::from_gray(0),
text_secondary: Color32::from_gray(30),
line1: Color32::from_gray(0),
line2: Color32::from_gray(30),
line3: Color32::from_gray(60),
line4: Color32::from_gray(90),
},
Theme::Dark => PlatformColors {
is_light: false,
animation_background: Color32::from_rgb(0, 0, 0),
window_background: Color32::from_rgb(36, 30, 42),
content_background: Color32::from_rgb(20, 14, 26),
text_primary: Color32::from_gray(255),
text_secondary: Color32::from_gray(200),
line1: Color32::from_gray(255),
line2: Color32::from_gray(190),
line3: Color32::from_gray(150),
line4: Color32::from_gray(70),
},
}
}

@ -24,8 +24,17 @@ pub use macos::{initial_update, navigation_button};
/// Platform-Native Colors
#[derive(Debug)]
pub struct PlatformColors {
pub is_light: bool,
pub animation_background: Color32,
pub window_background: Color32,
pub content_background: Color32,
pub text_primary: Color32,
pub text_secondary: Color32,
/// Brightest lines to darkest lines
pub line1: Color32,
pub line2: Color32,
pub line3: Color32,
pub line4: Color32,
}
#[allow(unused)]

@ -8,12 +8,28 @@ pub fn platform_colors() -> PlatformColors {
// From Google images, Windows 11
match theme {
Theme::Light => PlatformColors {
is_light: true,
animation_background: Color32::from_rgb(248, 246, 249),
window_background: Color32::from_rgb(241, 243, 246),
content_background: Color32::from_rgb(251, 251, 253),
text_primary: Color32::from_gray(0),
text_secondary: Color32::from_gray(30),
line1: Color32::from_gray(0),
line2: Color32::from_gray(30),
line3: Color32::from_gray(60),
line4: Color32::from_gray(90),
},
Theme::Dark => PlatformColors {
is_light: false,
animation_background: Color32::from_gray(60),
window_background: Color32::from_rgb(32, 32, 32),
content_background: Color32::from_rgb(34, 32, 40),
text_primary: Color32::from_gray(255),
text_secondary: Color32::from_gray(200),
line1: Color32::from_gray(255),
line2: Color32::from_gray(210),
line3: Color32::from_gray(190),
line4: Color32::from_gray(120),
},
}
}

@ -5,6 +5,8 @@ use eframe::egui::{
use std::ops::Rem;
use crate::gui::platform::{platform_colors, PlatformColors};
/// This will draw Ui with a background color and margins.
/// This can be used for calls that don't provide a `Frame`,
/// such as `horizontal` or `vertical`
@ -81,6 +83,8 @@ impl<'a> AnimatedBackground<'a> {
// paint stuff
let rect_size = vec2(size.x / divisions, size.y / divisions);
let colors = platform_colors();
// we only animate if there's no progress
let (offset, add) = if self.animate_progress.is_none() {
// Define the animation speed
@ -142,9 +146,19 @@ impl<'a> AnimatedBackground<'a> {
let rect = Rect::from_min_size(pos, size);
// the fill color is based on the added block count
color_adder += *n;
let color = (color_adder % 50) as u8;
painter.rect_filled(rect, 0.0, Color32::from_gray(color));
painter.rect_stroke(rect, 0.0, Stroke::new(1.0, Color32::from_gray(110)));
let color_addition = if colors.is_light {
-1 * (color_adder % 50) as i8
} else {
(color_adder % 50) as i8
};
let color = Color32::from_rgb(
(colors.animation_background.r() as i8 + color_addition) as u8,
(colors.animation_background.g() as i8 + color_addition) as u8,
(colors.animation_background.b() as i8 + color_addition) as u8,
);
painter.rect_filled(rect, 0.0, color);
painter.rect_stroke(rect, 0.0, Stroke::new(1.0, colors.line3));
}
}
@ -162,6 +176,8 @@ impl<'a> AnimatedBackground<'a> {
recurse: &[(i8, i8, i8)],
total: usize,
) {
let colors = platform_colors();
for y in 0..=(division + 2.0) as i8 {
for x in 0..=(division + 2.0) as i8 {
let fx = ((x - 1) as f32 * size.x) + (offset as f32);
@ -173,14 +189,14 @@ impl<'a> AnimatedBackground<'a> {
// on the x axis take the offset into account
let rx = (*rx).rem((total as i8) + 1);
if rx == x && ry == &y {
Self::draw_segmentation(painter, rect, *rd);
Self::draw_segmentation(painter, rect, *rd, colors);
}
}
}
}
}
fn draw_segmentation(painter: &Painter, into: Rect, divisions: i8) {
fn draw_segmentation(painter: &Painter, into: Rect, divisions: i8, colors: &PlatformColors) {
let mut rect = into;
for d in 0..=divisions {
// division back and forth in direction
@ -207,7 +223,7 @@ impl<'a> AnimatedBackground<'a> {
},
)
};
painter.rect_stroke(next, 0.0, Stroke::new(1.0, Color32::from_gray(70)));
painter.rect_stroke(next, 0.0, Stroke::new(1.0, colors.line4));
rect = next;
}
}

Loading…
Cancel
Save