Skip to content

Commit

Permalink
resizable ui
Browse files Browse the repository at this point in the history
  • Loading branch information
jb55 committed Jul 6, 2023
1 parent 12dbdf6 commit 5fec8bd
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::contacts::Contacts;
use crate::fonts::setup_fonts;
use crate::images::fetch_img;
use crate::{Error, Result};

Check warning on line 6 in src/app.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

unused import: `Error`

Check warning on line 6 in src/app.rs

View workflow job for this annotation

GitHub Actions / Check

unused import: `Error`

Check failure on line 6 in src/app.rs

View workflow job for this annotation

GitHub Actions / Clippy

unused import: `Error`

Check warning on line 6 in src/app.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused import: `Error`
use egui::{ColorImage, Context, TextureHandle, TextureId};
use egui::{ColorImage, Context, Key, TextureHandle, TextureId};

Check warning on line 7 in src/app.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

unused imports: `ColorImage`, `Key`

Check warning on line 7 in src/app.rs

View workflow job for this annotation

GitHub Actions / Check

unused imports: `ColorImage`, `Key`

Check failure on line 7 in src/app.rs

View workflow job for this annotation

GitHub Actions / Clippy

unused imports: `ColorImage`, `Key`

Check warning on line 7 in src/app.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused imports: `ColorImage`, `Key`
use enostr::{ClientMessage, EventId, Filter, Profile, Pubkey, RelayEvent, RelayMessage};
use poll_promise::Promise;
use std::collections::{HashMap, HashSet};
Expand Down Expand Up @@ -93,20 +93,25 @@ fn send_initial_filters(pool: &mut RelayPool, relay_url: &str) {
}
}

fn try_process_event(damus: &mut Damus) {
let m_ev = damus.pool.try_recv();
if m_ev.is_none() {
return;
fn try_process_event(damus: &mut Damus, ctx: &egui::Context) {
let amount = 0.1;
if ctx.input(|i| i.key_pressed(egui::Key::PlusEquals)) {
ctx.set_pixels_per_point(ctx.pixels_per_point() + amount);
} else if ctx.input(|i| i.key_pressed(egui::Key::Minus)) {
ctx.set_pixels_per_point(ctx.pixels_per_point() - amount);
}
let ev = m_ev.unwrap();
let relay = ev.relay.to_owned();

match ev.event {
RelayEvent::Opened => send_initial_filters(&mut damus.pool, &relay),
// TODO: handle reconnects
RelayEvent::Closed => warn!("{} connection closed", &relay),
RelayEvent::Other(msg) => debug!("other event {:?}", &msg),
RelayEvent::Message(msg) => process_message(damus, &relay, msg),

// pool stuff
if let Some(ev) = damus.pool.try_recv() {
let relay = ev.relay.to_owned();

match ev.event {
RelayEvent::Opened => send_initial_filters(&mut damus.pool, &relay),
// TODO: handle reconnects
RelayEvent::Closed => warn!("{} connection closed", &relay),
RelayEvent::Other(msg) => debug!("other event {:?}", &msg),
RelayEvent::Message(msg) => process_message(damus, &relay, msg),
}
}
//info!("recv {:?}", ev)
}
Expand All @@ -119,7 +124,7 @@ fn update_damus(damus: &mut Damus, ctx: &egui::Context) {
damus.state = DamusState::Initialized;
}

try_process_event(damus);
try_process_event(damus, ctx);
}

fn process_metadata_event(damus: &mut Damus, ev: &Event) {
Expand Down

0 comments on commit 5fec8bd

Please sign in to comment.