diff --git a/assets/option.svg b/assets/option.svg
new file mode 100644
index 00000000..a4cce5e3
--- /dev/null
+++ b/assets/option.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/ui/mod.rs b/src/ui/mod.rs
index ad87a339..02d2e128 100644
--- a/src/ui/mod.rs
+++ b/src/ui/mod.rs
@@ -207,6 +207,7 @@ struct GossipUi {
about: About,
icon: TextureHandle,
placeholder_avatar: TextureHandle,
+ options_symbol: TextureHandle,
settings: Settings,
avatars: HashMap,
images: HashMap,
@@ -351,17 +352,19 @@ impl GossipUi {
};
// how to load an svg
- // let expand_right_symbol = {
- // let bytes = include_bytes!("../../assets/expand-image.svg");
- // let color_image = egui_extras::image::load_svg_bytes_with_size(
- // bytes,
- // egui_extras::image::FitTo::Size(200, 1000),
- // ).unwrap();
- // cctx.egui_ctx.load_texture(
- // "expand_right_symbol",
- // color_image,
- // TextureOptions::default())
- // };
+ let options_symbol = {
+ let bytes = include_bytes!("../../assets/option.svg");
+ let color_image = egui_extras::image::load_svg_bytes_with_size(
+ bytes,
+ egui_extras::image::FitTo::Size(
+ (cctx.egui_ctx.pixels_per_point() * 40.0) as u32,
+ (cctx.egui_ctx.pixels_per_point() * 40.0) as u32),
+ ).unwrap();
+ cctx.egui_ctx.load_texture(
+ "options_symbol",
+ color_image,
+ TextureOptions::LINEAR)
+ };
let current_dpi = (cctx.egui_ctx.pixels_per_point() * 72.0) as u32;
let (override_dpi, override_dpi_value): (bool, u32) = match settings.override_dpi {
@@ -415,6 +418,7 @@ impl GossipUi {
about: crate::about::about(),
icon: icon_texture_handle,
placeholder_avatar: placeholder_avatar_texture_handle,
+ options_symbol,
settings,
avatars: HashMap::new(),
images: HashMap::new(),
diff --git a/src/ui/relays/activity.rs b/src/ui/relays/activity.rs
index e62318af..46788c0d 100644
--- a/src/ui/relays/activity.rs
+++ b/src/ui/relays/activity.rs
@@ -53,7 +53,9 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr
.show(ui, |ui| {
for relay in relays {
let mut widget =
- widgets::RelayEntry::new(&relay).accent(app.settings.theme.accent_color());
+ widgets::RelayEntry::new(&relay)
+ .accent(app.settings.theme.accent_color())
+ .option_symbol(&app.options_symbol);
if let Some(ref assignment) = GLOBALS.relay_picker.get_relay_assignment(&relay.url)
{
widget = widget.user_count(assignment.pubkeys.len());
diff --git a/src/ui/relays/known.rs b/src/ui/relays/known.rs
index 7b4d10e3..46cbd97f 100644
--- a/src/ui/relays/known.rs
+++ b/src/ui/relays/known.rs
@@ -68,7 +68,10 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr
})
.show(ui, |ui| {
for relay in relays {
- let mut widget = widgets::RelayEntry::new(&relay);
+ let mut widget =
+ widgets::RelayEntry::new(&relay)
+ .accent(app.settings.theme.accent_color())
+ .option_symbol(&app.options_symbol);
if let Some(ref assignment) =
GLOBALS.relay_picker.get_relay_assignment(&relay.url)
{
diff --git a/src/ui/widgets/relay_entry.rs b/src/ui/widgets/relay_entry.rs
index 73f97ffe..4057b6d9 100644
--- a/src/ui/widgets/relay_entry.rs
+++ b/src/ui/widgets/relay_entry.rs
@@ -42,6 +42,7 @@ pub struct RelayEntry<'a> {
stroke: Option,
accent: Option,
highlight: Option,
+ option_symbol: Option<&'a TextureHandle>,
}
impl<'a> RelayEntry<'a> {
@@ -55,6 +56,7 @@ impl<'a> RelayEntry<'a> {
stroke: None,
accent: None,
highlight: None,
+ option_symbol: None,
}
}
@@ -87,6 +89,11 @@ impl<'a> RelayEntry<'a> {
self.highlight = Some(highlight);
self
}
+
+ pub fn option_symbol(mut self, option_symbol: &'a TextureHandle ) -> Self {
+ self.option_symbol = Some(option_symbol);
+ self
+ }
}
impl<'a> RelayEntry<'a> {
@@ -140,6 +147,7 @@ impl<'a> RelayEntry<'a> {
if response.clicked() {
// TODO go to edit mode
}
+ response.on_hover_cursor(CursorIcon::PointingHand);
draw_text_galley_at(ui, pos, galley, Some(color), Some(stroke));
} else {
let pos = rect.right_top() + vec2(-BTN_SIZE - TEXT_RIGHT, 10.0 + MARGIN_TOP);
@@ -151,8 +159,15 @@ impl<'a> RelayEntry<'a> {
} else {
ui.visuals().text_color()
};
- let text = RichText::new("\u{2699}").size(20.0);
- draw_text_at(ui, pos, text.into(), Align::LEFT, Some(color), None);
+ response.on_hover_cursor(CursorIcon::PointingHand);
+ if let Some(symbol) = self.option_symbol {
+ let mut mesh = Mesh::with_texture((symbol).into());
+ mesh.add_rect_with_uv(btn_rect.shrink(2.0), Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), color);
+ ui.painter().add(Shape::mesh(mesh));
+ } else {
+ let text = RichText::new("\u{2699}").size(20.0);
+ draw_text_at(ui, pos, text.into(), Align::LEFT, Some(color), None);
+ }
}
}
@@ -181,7 +196,7 @@ impl<'a> RelayEntry<'a> {
RichText::new(format!("Following: {}", count))
} else {
active = false;
- RichText::new("Following: -")
+ RichText::new("Following: ---")
};
let (galley, response) = allocate_text_at(ui, pos, text.into());
let (color, stroke) = if !active {
@@ -198,6 +213,7 @@ impl<'a> RelayEntry<'a> {
if response.clicked() {
// TODO go to following page for this relay?
}
+ if active { response.on_hover_cursor(CursorIcon::PointingHand); }
draw_text_galley_at(ui, pos, galley, Some(color), Some(stroke));
// ---- Last event ----