mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
clean up
This commit is contained in:
parent
d4b70fd85c
commit
cfbcbfd7de
@ -2,11 +2,9 @@ use super::{GossipUi, Page};
|
|||||||
use crate::comms::BusMessage;
|
use crate::comms::BusMessage;
|
||||||
use crate::globals::{Globals, GLOBALS};
|
use crate::globals::{Globals, GLOBALS};
|
||||||
use crate::ui::widgets::CopyButton;
|
use crate::ui::widgets::CopyButton;
|
||||||
use eframe::{egui, epaint};
|
use eframe::egui;
|
||||||
use egui::{Align, Color32, Context, Layout, Pos2, RichText, ScrollArea, Shape, TextStyle, Ui, Vec2};
|
use egui::{Align, Color32, Context, Layout, RichText, ScrollArea, TextStyle, Ui, Vec2};
|
||||||
use epaint::{PathShape, Stroke};
|
|
||||||
use nostr_types::{EventKind, Id};
|
use nostr_types::{EventKind, Id};
|
||||||
use tracing::info;
|
|
||||||
|
|
||||||
pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Frame, ui: &mut Ui) {
|
pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Frame, ui: &mut Ui) {
|
||||||
let feed = Globals::blocking_get_feed(true);
|
let feed = Globals::blocking_get_feed(true);
|
||||||
@ -78,7 +76,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
|
|||||||
|
|
||||||
fn render_post(
|
fn render_post(
|
||||||
app: &mut GossipUi,
|
app: &mut GossipUi,
|
||||||
ctx: &Context,
|
_ctx: &Context,
|
||||||
_frame: &mut eframe::Frame,
|
_frame: &mut eframe::Frame,
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
id: Id,
|
id: Id,
|
||||||
@ -218,8 +216,7 @@ fn render_post(
|
|||||||
|
|
||||||
if app.settings.view_threaded {
|
if app.settings.view_threaded {
|
||||||
for reply_id in replies {
|
for reply_id in replies {
|
||||||
render_post(app, ctx, _frame, ui, reply_id, indent + 1);
|
render_post(app, _ctx, _frame, ui, reply_id, indent + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ mod relays;
|
|||||||
mod settings;
|
mod settings;
|
||||||
mod stats;
|
mod stats;
|
||||||
mod style;
|
mod style;
|
||||||
mod you;
|
|
||||||
mod widgets;
|
mod widgets;
|
||||||
|
mod you;
|
||||||
|
|
||||||
use crate::about::About;
|
use crate::about::About;
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
|
@ -37,7 +37,6 @@ pub(super) fn update(_app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::F
|
|||||||
|
|
||||||
ui.with_layout(Layout::top_down(Align::Center), |ui| {
|
ui.with_layout(Layout::top_down(Align::Center), |ui| {
|
||||||
ScrollArea::vertical().show(ui, |ui| {
|
ScrollArea::vertical().show(ui, |ui| {
|
||||||
ui.label("This is the scroll area top");
|
|
||||||
for relay in relays.iter_mut() {
|
for relay in relays.iter_mut() {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.label(&relay.url);
|
ui.label(&relay.url);
|
||||||
@ -65,7 +64,6 @@ pub(super) fn update(_app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::F
|
|||||||
ui.add_space(12.0);
|
ui.add_space(12.0);
|
||||||
ui.separator();
|
ui.separator();
|
||||||
}
|
}
|
||||||
ui.label("This is the scroll area bottom");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,46 +1,71 @@
|
|||||||
use eframe::{egui, epaint};
|
use eframe::{egui, epaint};
|
||||||
use egui::{Color32, Pos2, Response, Sense, Shape, Ui, Vec2, Widget};
|
use egui::{Color32, Pos2, Response, Sense, Shape, Ui, Vec2, Widget};
|
||||||
use epaint::{PathShape, Stroke};
|
use epaint::{PathShape, Stroke};
|
||||||
use tracing::debug;
|
|
||||||
|
|
||||||
pub struct CopyButton {}
|
pub struct CopyButton {}
|
||||||
|
|
||||||
impl CopyButton {
|
impl CopyButton {
|
||||||
pub fn new() -> CopyButton {
|
|
||||||
CopyButton { }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn paint(ui: &mut Ui, corner: Pos2) {
|
fn paint(ui: &mut Ui, corner: Pos2) {
|
||||||
ui.painter().add(Shape::Path(PathShape {
|
ui.painter().add(Shape::Path(PathShape {
|
||||||
points: vec![
|
points: vec![
|
||||||
Pos2 { x: corner.x + 2.0, y: corner.y + 8.0 },
|
Pos2 {
|
||||||
Pos2 { x: corner.x + 0.0, y: corner.y + 8.0 },
|
x: corner.x + 2.0,
|
||||||
Pos2 { x: corner.x + 0.0, y: corner.y + 0.0 },
|
y: corner.y + 8.0,
|
||||||
Pos2 { x: corner.x + 8.0, y: corner.y + 0.0 },
|
},
|
||||||
Pos2 { x: corner.x + 8.0, y: corner.y + 2.0 },
|
Pos2 {
|
||||||
|
x: corner.x + 0.0,
|
||||||
|
y: corner.y + 8.0,
|
||||||
|
},
|
||||||
|
Pos2 {
|
||||||
|
x: corner.x + 0.0,
|
||||||
|
y: corner.y + 0.0,
|
||||||
|
},
|
||||||
|
Pos2 {
|
||||||
|
x: corner.x + 8.0,
|
||||||
|
y: corner.y + 0.0,
|
||||||
|
},
|
||||||
|
Pos2 {
|
||||||
|
x: corner.x + 8.0,
|
||||||
|
y: corner.y + 2.0,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
closed: false,
|
closed: false,
|
||||||
fill: Color32::TRANSPARENT,
|
fill: Color32::TRANSPARENT,
|
||||||
stroke: Stroke {
|
stroke: Stroke {
|
||||||
width: 1.5,
|
width: 1.5,
|
||||||
color: Color32::from_rgb(0xb1, 0xa2, 0x96)
|
color: Color32::from_rgb(0xb1, 0xa2, 0x96),
|
||||||
}
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
ui.painter().add(Shape::Path(PathShape {
|
ui.painter().add(Shape::Path(PathShape {
|
||||||
points: vec![
|
points: vec![
|
||||||
Pos2 { x: corner.x + 4.0, y: corner.y + 4.0 },
|
Pos2 {
|
||||||
Pos2 { x: corner.x + 4.0, y: corner.y + 12.0 },
|
x: corner.x + 4.0,
|
||||||
Pos2 { x: corner.x + 12.0, y: corner.y + 12.0 },
|
y: corner.y + 4.0,
|
||||||
Pos2 { x: corner.x + 12.0, y: corner.y + 4.0 },
|
},
|
||||||
Pos2 { x: corner.x + 4.0, y: corner.y + 4.0 },
|
Pos2 {
|
||||||
|
x: corner.x + 4.0,
|
||||||
|
y: corner.y + 12.0,
|
||||||
|
},
|
||||||
|
Pos2 {
|
||||||
|
x: corner.x + 12.0,
|
||||||
|
y: corner.y + 12.0,
|
||||||
|
},
|
||||||
|
Pos2 {
|
||||||
|
x: corner.x + 12.0,
|
||||||
|
y: corner.y + 4.0,
|
||||||
|
},
|
||||||
|
Pos2 {
|
||||||
|
x: corner.x + 4.0,
|
||||||
|
y: corner.y + 4.0,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
closed: true,
|
closed: true,
|
||||||
fill: Color32::TRANSPARENT,
|
fill: Color32::TRANSPARENT,
|
||||||
stroke: Stroke {
|
stroke: Stroke {
|
||||||
width: 1.5,
|
width: 1.5,
|
||||||
color: Color32::from_rgb(0xb1, 0xa2, 0x96)
|
color: Color32::from_rgb(0xb1, 0xa2, 0x96),
|
||||||
}
|
},
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,11 +75,15 @@ impl Widget for CopyButton {
|
|||||||
let padding = ui.spacing().button_padding;
|
let padding = ui.spacing().button_padding;
|
||||||
let space = Vec2 {
|
let space = Vec2 {
|
||||||
x: 12.0 + padding.x * 2.0,
|
x: 12.0 + padding.x * 2.0,
|
||||||
y: 12.0 + padding.y * 2.0
|
y: 12.0 + padding.y * 2.0,
|
||||||
};
|
};
|
||||||
let (id, rect) = ui.allocate_space(space);
|
let (id, rect) = ui.allocate_space(space);
|
||||||
let response = ui.interact(rect, id, Sense::click());
|
let response = ui.interact(rect, id, Sense::click());
|
||||||
let shift = if response.is_pointer_button_down_on() { 2.0 } else { 0.0 };
|
let shift = if response.is_pointer_button_down_on() {
|
||||||
|
2.0
|
||||||
|
} else {
|
||||||
|
0.0
|
||||||
|
};
|
||||||
let pos = Pos2 {
|
let pos = Pos2 {
|
||||||
x: rect.min.x + padding.x + shift,
|
x: rect.min.x + padding.x + shift,
|
||||||
y: rect.min.y + padding.y + shift,
|
y: rect.min.y + padding.y + shift,
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
|
|
||||||
mod copy_button;
|
mod copy_button;
|
||||||
pub use copy_button::CopyButton;
|
pub use copy_button::CopyButton;
|
||||||
|
Loading…
Reference in New Issue
Block a user