mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-21 02:23:48 +01:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ea189f1d9 | ||
|
|
8af671d8ed | ||
|
|
9047bdd741 | ||
|
|
61b992cb48 |
No files matched your search
Generated
+3
-2
@@ -4022,15 +4022,16 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proton-gallery-rs"
|
name = "proton-gallery-rs"
|
||||||
version = "0.1.1"
|
version = "0.1.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dc9c9bbb76a5fba4071ee90de4aada71c292c0e408024ddfb04a12869291404a"
|
checksum = "5a978cc4dc990ae1941209fece17c952a11dbaee392b358ca64c0c836cb2ec21"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes-gcm 0.11.1",
|
"aes-gcm 0.11.1",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"getrandom 0.4.3",
|
"getrandom 0.4.3",
|
||||||
"hex",
|
"hex",
|
||||||
"kamadak-exif",
|
"kamadak-exif",
|
||||||
|
"proton-base-rs",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ categories = ["filesystem", "command-line-utilities"]
|
|||||||
proton-sdk = { version = "0.12.2" }
|
proton-sdk = { version = "0.12.2" }
|
||||||
proton-drive-rs = { version = "0.12.2" }
|
proton-drive-rs = { version = "0.12.2" }
|
||||||
proton-gallery-app-rs = "0.1.0"
|
proton-gallery-app-rs = "0.1.0"
|
||||||
proton-gallery-rs = "0.1.1"
|
proton-gallery-rs = "0.1.3"
|
||||||
chrono = { version = "0.4", default-features = false, features = ["std"] }
|
chrono = { version = "0.4", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
# Internal crates.
|
# Internal crates.
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
//! a single photo opens it in its town, and photos taken on one spot, which
|
//! a single photo opens it in its town, and photos taken on one spot, which
|
||||||
//! never part, are listed to pick from.
|
//! never part, are listed to pick from.
|
||||||
|
|
||||||
|
// Markers merge the same way in every Proton gallery app.
|
||||||
|
use proton_gallery_rs::places::{Bubble, bubble_radius, cluster, compact_count};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
@@ -137,13 +139,6 @@ fn parse_ring(line: &str) -> Option<Ring> {
|
|||||||
Some(Ring { points, min, max })
|
Some(Ring { points, min, max })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Radius in px of a marker holding `photos` photos: big enough to make the
|
|
||||||
/// photo out, and growing with the count, but slowly, so a home town with
|
|
||||||
/// thousands doesn't cover a continent.
|
|
||||||
fn bubble_radius(photos: usize) -> f64 {
|
|
||||||
18.0 + 2.0 * (photos.max(1) as f64).ln()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// What the map shows: which part of the world, at what size.
|
/// What the map shows: which part of the world, at what size.
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
struct View {
|
struct View {
|
||||||
@@ -195,17 +190,6 @@ struct Marker {
|
|||||||
target: Target,
|
target: Target,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One marker as last drawn, standing for one or more [`Marker`]s: where, how
|
|
||||||
/// big, and which (indices into [`MapState::markers`], the one with the most
|
|
||||||
/// photos first).
|
|
||||||
struct Bubble {
|
|
||||||
x: f64,
|
|
||||||
y: f64,
|
|
||||||
radius: f64,
|
|
||||||
photos: usize,
|
|
||||||
members: Vec<usize>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A street-map tile ready to draw, and the names on it.
|
/// A street-map tile ready to draw, and the names on it.
|
||||||
struct CachedTile {
|
struct CachedTile {
|
||||||
surface: cairo::ImageSurface,
|
surface: cairo::ImageSurface,
|
||||||
@@ -1648,52 +1632,6 @@ fn spread(points: &[World]) -> f64 {
|
|||||||
span(&mut xs.into_iter()).max(span(&mut ys.into_iter()))
|
span(&mut xs.into_iter()).max(span(&mut ys.into_iter()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Merge markers whose circles would overlap on screen, the one with the
|
|
||||||
/// most photos claiming its neighbours (the first of equals, when counts
|
|
||||||
/// tie). Markers off screen are left out.
|
|
||||||
fn cluster(screen: &[(f64, f64)], counts: &[usize], width: f64, height: f64) -> Vec<Bubble> {
|
|
||||||
let mut order: Vec<usize> = (0..screen.len()).collect();
|
|
||||||
order.sort_by(|a, b| counts[*b].cmp(&counts[*a]));
|
|
||||||
let mut bubbles: Vec<Bubble> = Vec::new();
|
|
||||||
for index in order {
|
|
||||||
let (x, y) = screen[index];
|
|
||||||
let reach = bubble_radius(counts[index]);
|
|
||||||
if x < -reach || y < -reach || x > width + reach || y > height + reach {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
match bubbles
|
|
||||||
.iter_mut()
|
|
||||||
.find(|b| (b.x - x).hypot(b.y - y) < b.radius + reach * 0.5)
|
|
||||||
{
|
|
||||||
Some(bubble) => {
|
|
||||||
bubble.photos += counts[index];
|
|
||||||
bubble.radius = bubble_radius(bubble.photos);
|
|
||||||
bubble.members.push(index);
|
|
||||||
}
|
|
||||||
None => bubbles.push(Bubble {
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
radius: reach,
|
|
||||||
photos: counts[index],
|
|
||||||
members: vec![index],
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Smallest last, so a small marker next to a big one stays clickable.
|
|
||||||
bubbles.sort_by(|a, b| b.radius.total_cmp(&a.radius));
|
|
||||||
bubbles
|
|
||||||
}
|
|
||||||
|
|
||||||
/// "7", "840", "1.2k", "35k": short enough to fit a marker. Digits and the
|
|
||||||
/// "k" read the same in every language the app ships.
|
|
||||||
fn compact_count(n: usize) -> String {
|
|
||||||
match n {
|
|
||||||
0..1_000 => n.to_string(),
|
|
||||||
1_000..10_000 => format!("{:.1}k", n as f64 / 1_000.0),
|
|
||||||
_ => format!("{}k", n / 1_000),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_color(cr: &cairo::Context, color: >k4::gdk::RGBA, alpha: f32) {
|
fn set_color(cr: &cairo::Context, color: >k4::gdk::RGBA, alpha: f32) {
|
||||||
cr.set_source_rgba(
|
cr.set_source_rgba(
|
||||||
f64::from(color.red()),
|
f64::from(color.red()),
|
||||||
|
|||||||
Reference in new issue
Block a user