file manager
git clone https://git.lucas.co/cce-files.git
Remove hardcoded colors and use cce_ui theme-based colors
src/main.rs | 4 ++--
src/pages/browse.rs | 29 ++++++++++++++++++++---------
src/pages/preview.rs | 8 ++++----
3 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index e32f712..c6d90c4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -214,8 +214,8 @@ impl FilesystemApp {
match self.current_page {
Page::Browse => {
// Draw background plates for columns
- let plate_bg = [0.08, 0.13, 0.09, 0.45];
- let border_color = [0.15, 0.23, 0.17, 0.7];
+ let plate_bg = cce_ui::color::scrollinglist_bg_color();
+ let border_color = cce_ui::color::color_borders_color();
// Left column plate (Browse)
pc.rect(plate_bg, browse_x, content_y, browse_w, content_h);
diff --git a/src/pages/browse.rs b/src/pages/browse.rs
index 6eccb8c..88ec903 100644
--- a/src/pages/browse.rs
+++ b/src/pages/browse.rs
@@ -1,5 +1,3 @@
-use std::fs;
-use std::os::unix::fs::PermissionsExt;
use std::path::{Path, PathBuf};
use crate::pages::PageContent;
@@ -158,12 +156,17 @@ pub fn next_selection_index(state: &BrowseState, direction: BrowseNavigation) ->
pub fn view(state: &mut BrowseState, cx: f32, cy: f32, cw: f32, ch: f32, select_mode: bool, ctx: &mut cce_ui::context::UiContext) -> PageContent {
let mut pc = PageContent::new();
- let text_dim = [0.53, 0.53, 0.60, 1.0];
- let heading_fg = [0.56, 0.83, 0.56, 1.0]; // Color::from_rgb8(0x8f, 0xd4, 0x8f)
- let selected_bg = [0.16, 0.29, 0.18, 0.8]; // Color::from_rgb8(0x2a, 0x4a, 0x2e)
- let row_bg = [0.12, 0.18, 0.13, 0.6]; // Color::from_rgb8(0x1e, 0x2e, 0x20)
- let accent_fg = [0.36, 0.56, 0.38, 1.0]; // Color::from_rgb8(0x5c, 0x90, 0x60)
- let text_fg = [0.83, 0.83, 0.83, 1.0];
+ let text_dim = cce_ui::color::TEXT_DIM;
+ let heading_fg = cce_ui::color::TEXT_HEADER;
+ let text_fg = cce_ui::color::TEXT_FG;
+ let accent_fg = cce_ui::color::TEXT_ACCENT;
+
+ let selected_bg = {
+ let mut bg = cce_ui::color::highlight_primary_color();
+ bg[3] = 0.8;
+ bg
+ };
+ let row_bg = [1.0, 1.0, 1.0, 0.04];
let gap = 12.0;
let margin = 12.0;
@@ -252,6 +255,14 @@ pub fn view(state: &mut BrowseState, cx: f32, cy: f32, cw: f32, ch: f32, select_
crate::Message::Browse(BrowseMessage::SelectEntry(idx))
};
+ let hover_bg = if is_selected {
+ selected_bg
+ } else {
+ let mut h_bg = cce_ui::color::highlight_primary_color();
+ h_bg[3] = 0.25;
+ h_bg
+ };
+
// Button for row selection/navigation
pc.button(
"",
@@ -260,7 +271,7 @@ pub fn view(state: &mut BrowseState, cx: f32, cy: f32, cw: f32, ch: f32, select_
list_w - 24.0,
28.0,
bg,
- if is_selected { selected_bg } else { [0.22, 0.32, 0.24, 0.8] },
+ hover_bg,
fg,
action,
);
diff --git a/src/pages/preview.rs b/src/pages/preview.rs
index 27baaa4..d38b9ba 100644
--- a/src/pages/preview.rs
+++ b/src/pages/preview.rs
@@ -71,9 +71,9 @@ impl PreviewState {
pub fn view(state: &PreviewState, cx: f32, cy: f32, cw: f32, ch: f32) -> PageContent {
let mut pc = PageContent::new();
- let text_fg = [0.83, 0.83, 0.83, 1.0];
- let text_dim = [0.53, 0.53, 0.60, 1.0];
- let label_fg = [0.56, 0.83, 0.56, 1.0];
+ let text_fg = cce_ui::color::TEXT_FG;
+ let text_dim = cce_ui::color::TEXT_DIM;
+ let label_fg = cce_ui::color::TEXT_ACCENT;
if state.path.is_none() {
pc.text("Select a file to view details", cx + 12.0, cy + 12.0, 13.0, text_dim);
@@ -87,7 +87,7 @@ pub fn view(state: &PreviewState, cx: f32, cy: f32, cw: f32, ch: f32) -> PageCon
preview_sec.content_y = cy + half_h - 20.0;
preview_sec.finish(); // Releases borrow on pc
- let bg_color = [0.07, 0.11, 0.08, 0.5];
+ let bg_color = cce_ui::color::scrollinglist_bg_color();
pc.rect(bg_color, cx + 12.0, cy + 32.0, cw - 24.0, half_h - 40.0);
if let Some(content) = &state.content_preview {