Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2767,3 +2767,17 @@ scrolledwindow.merge-dialog-scroll {
.assistant-edit-bar .assistant-removed {
color: @error_color;
}

/* Leave the row geometry intact while its hover actions cover the right edge. */
.row-hover-actions {
background-color: @view_bg_color;
border-radius: 999px;
padding: 2px;
box-shadow: 0 0 0 1px alpha(currentColor, 0.15), 0 1px 4px alpha(black, 0.2);
}

.row-hover-actions button {
min-width: 28px;
min-height: 26px;
padding: 0;
}
34 changes: 33 additions & 1 deletion src/ui/message_row/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! Building one row's widgets, once, for the factory to bind over and over.

use super::row::RowWidgets;
use super::{SwipeSurface, ACCOUNT_COLUMN_PX, PEOPLE_COLUMN_PX, SENDER_COLUMN_PX, TAGS_COLUMN_PX};
use super::{
RowAction, SwipeSurface, ACCOUNT_COLUMN_PX, PEOPLE_COLUMN_PX, SENDER_COLUMN_PX, TAGS_COLUMN_PX,
};
use crate::i18n::i18n;
use crate::ui::column_bin::ColumnBin;
use adw::prelude::*;
Expand Down Expand Up @@ -237,6 +239,32 @@ pub(super) fn build_widgets() -> RowWidgets {
node.set_valign(gtk::Align::Center);
overlay.add_overlay(&node);

// Keep the actions above the row content without changing its size.
let hover_box = gtk::Box::new(gtk::Orientation::Horizontal, 0);
hover_box.add_css_class("row-hover-actions");
hover_box.set_halign(gtk::Align::End);
hover_box.set_valign(gtk::Align::Center);
hover_box.set_margin_end(6);
hover_box.set_visible(false);
let hover_buttons = [
(RowAction::ToggleStar, "starred-symbolic", i18n("Star")),
(RowAction::Archive, "mail-archive-symbolic", i18n("Archive")),
(RowAction::Delete, "user-trash-symbolic", i18n("Delete")),
]
.map(|(action, icon, tooltip)| {
let button = gtk::Button::from_icon_name(icon);
button.add_css_class("flat");
button.add_css_class("circular");
button.set_focusable(false);
button.set_focus_on_click(false);
button.set_tooltip_text(Some(&tooltip));
hover_box.append(&button);
(action, button)
});
let [(_, hover_star), ..] = &hover_buttons;
let hover_star = hover_star.clone();
overlay.add_overlay(&hover_box);

RowWidgets {
host,
revealer,
Expand All @@ -247,6 +275,10 @@ pub(super) fn build_widgets() -> RowWidgets {
swipe_icon,
swipe_label,
overlay,
hover_box,
hover_star,
hover_buttons,
hover_motion: gtk::EventControllerMotion::new(),
rail_stub,
node,
content,
Expand Down
8 changes: 8 additions & 0 deletions src/ui/message_row/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ impl Row {
starred && look.show_stars
});
w.star.set_opacity(if starred { 1.0 } else { 0.0 });
w.hover_star
.set_tooltip_text(Some(&i18n(if starred { "Remove Star" } else { "Star" })));
if starred {
w.hover_star.add_css_class("star-active");
} else {
w.hover_star.remove_css_class("star-active");
}
// A card shows it beside its other marks when there is one (#563).
w.importance.set_visible(if single {
col(ListColumn::Importance)
Expand Down Expand Up @@ -475,6 +482,7 @@ impl Row {
}
drop(st);
self.w.host.set_css_classes(&v);
self.sync_hover_actions();
}

/// Rebuild the row's chips when the keywords, the labels or the tags
Expand Down
42 changes: 42 additions & 0 deletions src/ui/message_row/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ pub(super) struct RowWidgets {
pub(super) swipe_icon: gtk::Image,
pub(super) swipe_label: gtk::Label,
pub(super) overlay: gtk::Overlay,
pub(super) hover_box: gtk::Box,
pub(super) hover_star: gtk::Button,
pub(super) hover_buttons: [(RowAction, gtk::Button); 3],
pub(super) hover_motion: gtk::EventControllerMotion,
pub(super) rail_stub: gtk::Box,
pub(super) node: gtk::Box,
pub(super) content: gtk::Box,
Expand Down Expand Up @@ -284,6 +288,43 @@ impl Row {

self.wire_swipe();
self.wire_fold();
self.wire_hover();
}

/// Send the same actions as the row's menu.
fn wire_hover(&self) {
let motion = &self.w.hover_motion;
let weak = self.me.clone();
motion.connect_contains_pointer_notify(move |_| {
if let Some(row) = weak.upgrade() {
row.sync_hover_actions();
}
});
self.w.host.add_controller(motion.clone());

for (action, button) in &self.w.hover_buttons {
let action = *action;
let weak = self.me.clone();
button.connect_clicked(move |_| {
if let Some(row) = weak.upgrade() {
row.act(action);
}
});
}
}

pub(super) fn sync_hover_actions(&self) {
let visible = {
let st = self.st.borrow();
self.w.hover_motion.contains_pointer()
&& !st.dragging
&& !st.swipe_active
&& st.item.as_ref().is_some_and(|item| {
let data = item.data();
data.meta.revealed && data.meta.folded.is_none()
})
};
self.w.hover_box.set_visible(visible);
}

// ── Binding ──
Expand Down Expand Up @@ -397,6 +438,7 @@ impl Row {
a.pause();
}
self.w.surface.set_progress_px(0.0);
self.w.hover_box.set_visible(false);
self.w.revealer.set_transition_duration(0);
self.w.revealer.set_reveal_child(true);
self.w.revealer.set_transition_duration(200);
Expand Down