-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revamp of node colors, now the files and folders are colored differently
- Loading branch information
1 parent
295a59e
commit bd501cf
Showing
4 changed files
with
59 additions
and
71 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,53 @@ | ||
use gtk::gdk::RGBA; | ||
use once_cell::sync::Lazy; | ||
|
||
// https://www.schemecolor.com/light-to-dark-blue.php | ||
#[derive(Copy, Clone, PartialEq)] | ||
pub enum NodeColor { | ||
Blue1, | ||
Blue2, | ||
Blue3, | ||
Blue4, | ||
Blue5, | ||
} | ||
// light blue #bcd2e8 | ||
const DIR_R: f32 = 0xbc as f32 / 256.0; | ||
const DIR_G: f32 = 0xd2 as f32 / 256.0; | ||
const DIR_B: f32 = 0xe8 as f32 / 256.0; | ||
const DIR_A: f32 = 0xff as f32 / 256.0; | ||
|
||
// bisque color #ffc0cb | ||
const FILE_R: f32 = 0xff as f32 / 256.0; | ||
const FILE_G: f32 = 0xc0 as f32 / 256.0; | ||
const FILE_B: f32 = 0xcb as f32 / 256.0; | ||
const FILE_A: f32 = 0xff as f32 / 256.0; | ||
|
||
// TODO: get once_cell statics here to generate RGBA only once | ||
impl NodeColor { | ||
pub fn get_rgba(&self) -> RGBA { | ||
match *self { | ||
NodeColor::Blue1 => RGBA::new( | ||
0xbc as f32 / 256.0, | ||
0xd2 as f32 / 256.0, | ||
0xe8 as f32 / 256.0, | ||
0xff as f32 / 256.0, | ||
), | ||
NodeColor::Blue2 => RGBA::new( | ||
0x91 as f32 / 256.0, | ||
0xba as f32 / 256.0, | ||
0xd6 as f32 / 256.0, | ||
0xff as f32 / 256.0, | ||
), | ||
NodeColor::Blue3 => RGBA::new( | ||
0x73 as f32 / 256.0, | ||
0xa5 as f32 / 256.0, | ||
0xc6 as f32 / 256.0, | ||
0xff as f32 / 256.0, | ||
), | ||
NodeColor::Blue4 => RGBA::new( | ||
0x52 as f32 / 256.0, | ||
0x8a as f32 / 256.0, | ||
0xae as f32 / 256.0, | ||
0xff as f32 / 256.0, | ||
), | ||
NodeColor::Blue5 => RGBA::new( | ||
0x2e as f32 / 256.0, | ||
0x59 as f32 / 256.0, | ||
0x84 as f32 / 256.0, | ||
0xff as f32 / 256.0, | ||
), | ||
} | ||
} | ||
static DIR: Lazy<[RGBA; 5]> = Lazy::new(|| { | ||
(0..5) | ||
.map(|depth| { | ||
RGBA::new( | ||
DIR_R * (1.1 * DIR_R / 1.0).powi(depth as i32), | ||
DIR_G * (1.1 * DIR_G / 1.0).powi(depth as i32), | ||
DIR_B * (1.1 * DIR_B / 1.0).powi(depth as i32), | ||
DIR_A, | ||
) | ||
}) | ||
.collect::<Vec<RGBA>>() | ||
.try_into() | ||
.unwrap() | ||
}); | ||
|
||
/*pub fn next_color(&self) -> Self { | ||
match *self { | ||
NodeColor::Blue1 => NodeColor::Blue2, | ||
NodeColor::Blue2 => NodeColor::Blue3, | ||
NodeColor::Blue3 => NodeColor::Blue4, | ||
NodeColor::Blue4 => NodeColor::Blue5, | ||
NodeColor::Blue5 => NodeColor::Blue1, | ||
} | ||
}*/ | ||
static FILE: Lazy<[RGBA; 5]> = Lazy::new(|| { | ||
(0..5) | ||
.map(|depth| { | ||
RGBA::new( | ||
FILE_R * (1.1 * FILE_R / 1.0).powi(depth as i32), | ||
FILE_G * (1.1 * FILE_G / 1.0).powi(depth as i32), | ||
FILE_B * (1.1 * FILE_B / 1.0).powi(depth as i32), | ||
FILE_A, | ||
) | ||
}) | ||
.collect::<Vec<RGBA>>() | ||
.try_into() | ||
.unwrap() | ||
}); | ||
|
||
pub fn depth_dir_color(depth: usize) -> RGBA { | ||
DIR[depth % 5] | ||
} | ||
|
||
pub fn depth_color(mut depth: usize) -> Self { | ||
depth %= 5; | ||
match depth { | ||
0 => NodeColor::Blue1, | ||
1 => NodeColor::Blue2, | ||
2 => NodeColor::Blue3, | ||
3 => NodeColor::Blue4, | ||
4 => NodeColor::Blue5, | ||
_ => NodeColor::Blue1, | ||
} | ||
} | ||
pub fn depth_file_color(depth: usize) -> RGBA { | ||
FILE[depth % 5] | ||
} |