From 2a3c6d1d2d6fc6630b0c12dab86b8d155d1ca9ba Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Wed, 13 Nov 2024 11:24:41 +1300 Subject: [PATCH] Reapply "Default Theme: Adjust Panel colors and all clickable_frame() bacckground colors" This reverts commit 6b9e08e10f32a1892dde52e5cf09549fdf0580e4. --- gossip-bin/src/ui/dm_chat_list.rs | 1 + gossip-bin/src/ui/handler.rs | 2 ++ gossip-bin/src/ui/people/list.rs | 1 + gossip-bin/src/ui/people/lists.rs | 1 + gossip-bin/src/ui/theme/default.rs | 16 ++++++++++++---- gossip-bin/src/ui/theme/mod.rs | 8 ++++++++ gossip-bin/src/ui/widgets/list_entry.rs | 11 ++++++++++- gossip-bin/src/ui/widgets/relay_entry.rs | 12 ++---------- 8 files changed, 37 insertions(+), 15 deletions(-) diff --git a/gossip-bin/src/ui/dm_chat_list.rs b/gossip-bin/src/ui/dm_chat_list.rs index 4edfe2c65..f40d9d0f6 100644 --- a/gossip-bin/src/ui/dm_chat_list.rs +++ b/gossip-bin/src/ui/dm_chat_list.rs @@ -66,6 +66,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra ui, app, Some(app.theme.main_content_bgcolor()), + Some(app.theme.hovered_content_bgcolor()), |ui, app| { ui.set_min_width(ui.available_width()); ui.set_min_height(AVATAR_SIZE_F32); diff --git a/gossip-bin/src/ui/handler.rs b/gossip-bin/src/ui/handler.rs index 1923ec654..63f37f4bf 100644 --- a/gossip-bin/src/ui/handler.rs +++ b/gossip-bin/src/ui/handler.rs @@ -124,6 +124,7 @@ pub(super) fn update_all_kinds(app: &mut GossipUi, ctx: &Context, ui: &mut Ui) { ui, app, Some(app.theme.main_content_bgcolor()), + Some(app.theme.hovered_content_bgcolor()), |ui, app| { ui.set_min_width(ui.available_width()); @@ -214,6 +215,7 @@ pub(super) fn update_kind(app: &mut GossipUi, _ctx: &Context, ui: &mut Ui, kind: ui, app, Some(app.theme.main_content_bgcolor()), + Some(app.theme.hovered_content_bgcolor()), |ui, app| { ui.set_min_width(ui.available_width()); diff --git a/gossip-bin/src/ui/people/list.rs b/gossip-bin/src/ui/people/list.rs index 1bad7bf05..4359922dc 100644 --- a/gossip-bin/src/ui/people/list.rs +++ b/gossip-bin/src/ui/people/list.rs @@ -222,6 +222,7 @@ pub(super) fn update( ui, app, Some(app.theme.main_content_bgcolor()), + Some(app.theme.hovered_content_bgcolor()), |ui, app| { ui.horizontal(|ui| { // Avatar first diff --git a/gossip-bin/src/ui/people/lists.rs b/gossip-bin/src/ui/people/lists.rs index 7f2001743..3fda7099b 100644 --- a/gossip-bin/src/ui/people/lists.rs +++ b/gossip-bin/src/ui/people/lists.rs @@ -54,6 +54,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra ui, app, Some(app.theme.main_content_bgcolor()), + Some(app.theme.hovered_content_bgcolor()), |ui, app| { ui.set_min_width(ui.available_width()); diff --git a/gossip-bin/src/ui/theme/default.rs b/gossip-bin/src/ui/theme/default.rs index 85222a74a..6b7a47cf8 100644 --- a/gossip-bin/src/ui/theme/default.rs +++ b/gossip-bin/src/ui/theme/default.rs @@ -142,9 +142,17 @@ impl ThemeDef for DefaultTheme { fn main_content_bgcolor(dark_mode: bool) -> Color32 { if dark_mode { - Self::neutral_800() + Color32::BLACK + } else { + Color32::WHITE + } + } + + fn hovered_content_bgcolor(dark_mode: bool) -> Color32 { + if dark_mode { + Self::neutral_950() } else { - Self::neutral_100() + Self::neutral_50() } } @@ -272,7 +280,7 @@ impl ThemeDef for DefaultTheme { // Background colors window_fill: Self::neutral_950(), // pulldown menus and tooltips - panel_fill: Self::neutral_900(), // panel backgrounds, even-table-rows + panel_fill: Color32::from_gray(0x29), // panel backgrounds, even-table-rows faint_bg_color: Color32::from_gray(20), // odd-table-rows extreme_bg_color: Color32::from_gray(45), // text input background; scrollbar background code_bg_color: Color32::from_gray(64), // ??? @@ -364,7 +372,7 @@ impl ThemeDef for DefaultTheme { // Background colors window_fill: Self::neutral_100(), // pulldown menus and tooltips - panel_fill: Self::neutral_50(), // panel backgrounds, even-table-rows + panel_fill: Color32::from_gray(0xF4), // panel backgrounds, even-table-rows faint_bg_color: Color32::from_gray(248), // odd-table-rows extreme_bg_color: Color32::from_gray(246), // text input background; scrollbar background code_bg_color: Color32::from_gray(230), // ??? diff --git a/gossip-bin/src/ui/theme/mod.rs b/gossip-bin/src/ui/theme/mod.rs index 9bc083034..9ee2d93a2 100644 --- a/gossip-bin/src/ui/theme/mod.rs +++ b/gossip-bin/src/ui/theme/mod.rs @@ -235,6 +235,12 @@ macro_rules! theme_dispatch { } } + pub fn hovered_content_bgcolor(&self) -> Color32 { + match self.variant { + $( $variant => $class::hovered_content_bgcolor(self.dark_mode), )+ + } + } + #[allow(dead_code)] pub fn highlighted_note_bgcolor(&self) -> Color32 { match self.variant { @@ -559,6 +565,8 @@ pub trait ThemeDef: Send + Sync { fn main_content_bgcolor(dark_mode: bool) -> Color32; + fn hovered_content_bgcolor(dark_mode: bool) -> Color32; + // Used as background for highlighting unread events fn highlighted_note_bgcolor(dark_mode: bool) -> Color32; diff --git a/gossip-bin/src/ui/widgets/list_entry.rs b/gossip-bin/src/ui/widgets/list_entry.rs index 49053ff74..175db37c2 100644 --- a/gossip-bin/src/ui/widgets/list_entry.rs +++ b/gossip-bin/src/ui/widgets/list_entry.rs @@ -73,13 +73,22 @@ pub(crate) fn clickable_frame( ui: &mut Ui, app: &mut GossipUi, fill: Option, + hover_fill: Option, mut content: impl FnMut(&mut Ui, &mut GossipUi) -> R, ) -> InnerResponse { // now really render the frame let frame = make_frame(ui, fill); let mut prepared = frame.begin(ui); let inner = content(&mut prepared.content_ui, app); - let response = prepared.end(ui); + let response = prepared.allocate_space(ui); + + if response.hovered() { + if let Some(fill) = hover_fill { + prepared.frame.fill = fill; + } + } + + prepared.paint(ui); InnerResponse { inner, response } } diff --git a/gossip-bin/src/ui/widgets/relay_entry.rs b/gossip-bin/src/ui/widgets/relay_entry.rs index bd939a4a5..e3369d968 100644 --- a/gossip-bin/src/ui/widgets/relay_entry.rs +++ b/gossip-bin/src/ui/widgets/relay_entry.rs @@ -206,16 +206,8 @@ impl RelayEntry { let mut hsva: ecolor::HsvaGamma = accent.into(); hsva.v *= 0.8; let accent_hover: Color32 = hsva.into(); - let bg_fill = if app.theme.dark_mode { - app.theme.neutral_800() - } else { - app.theme.neutral_100() - }; - let bg_hover = if app.theme.dark_mode { - app.theme.neutral_950() - } else { - app.theme.neutral_50() - }; + let bg_fill = app.theme.main_content_bgcolor(); + let bg_hover = app.theme.hovered_content_bgcolor(); Self { relay, view: RelayEntryView::List,