From 1d4e65a963653ce886d2a741b25c5c743e4f3167 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Wed, 28 Dec 2022 16:58:17 +1300 Subject: [PATCH] More ui copy stuff --- src/ui/feed.rs | 5 ++++- src/ui/widgets/copy_button.rs | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ui/feed.rs b/src/ui/feed.rs index bb7557fb..b2a97359 100644 --- a/src/ui/feed.rs +++ b/src/ui/feed.rs @@ -171,7 +171,10 @@ fn render_post( ui.add_space(10.0); - ui.label("(i)").on_hover_ui(|ui| { + if ui.add(CopyButton {}).clicked() { + ui.output().copied_text = event.id.as_hex_string(); + } + ui.label("[ID]").on_hover_ui(|ui| { ui.label(&format!("ID: {}", event.id.as_hex_string())); }); }); diff --git a/src/ui/widgets/copy_button.rs b/src/ui/widgets/copy_button.rs index 3372c064..8fd79f8f 100644 --- a/src/ui/widgets/copy_button.rs +++ b/src/ui/widgets/copy_button.rs @@ -32,8 +32,8 @@ impl CopyButton { closed: false, fill: Color32::TRANSPARENT, stroke: Stroke { - width: 1.5, - color: Color32::from_rgb(0xb1, 0xa2, 0x96), + width: 1.0, + color: Color32::from_rgb(0x8d, 0x7f, 0x73), }, })); @@ -63,8 +63,8 @@ impl CopyButton { closed: true, fill: Color32::TRANSPARENT, stroke: Stroke { - width: 1.5, - color: Color32::from_rgb(0xb1, 0xa2, 0x96), + width: 1.0, + color: Color32::from_rgb(0x8d, 0x7f, 0x73), }, })); } @@ -88,7 +88,7 @@ impl Widget for CopyButton { x: rect.min.x + padding.x + shift, y: rect.min.y + padding.y + shift, }; - Self::paint(ui, pos); + Self::paint(ui, ui.painter().round_pos_to_pixels(pos)); response }