codestrand 0.1.0__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codestrand-0.1.0 → codestrand-0.1.1}/Cargo.lock +1 -1
- {codestrand-0.1.0 → codestrand-0.1.1}/Cargo.toml +6 -1
- {codestrand-0.1.0 → codestrand-0.1.1}/PKG-INFO +1 -1
- {codestrand-0.1.0 → codestrand-0.1.1}/pyproject.toml +1 -1
- {codestrand-0.1.0 → codestrand-0.1.1}/src/scene.rs +157 -29
- {codestrand-0.1.0 → codestrand-0.1.1}/src/theme.rs +5 -2
- {codestrand-0.1.0 → codestrand-0.1.1}/LICENSE +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/LICENSE-APACHE +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/README.md +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/codestrand.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/LICENSE.txt +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/README.md +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/mapping.json +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/c.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/changelog.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/console.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/contributing.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/cpp.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/css.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/docker.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/editorconfig.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/file.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/git.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/go-mod.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/go.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/h.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/hpp.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/html.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/javascript.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/json.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/license.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/lock.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/markdown.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/nodejs.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/npm.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/pnpm.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/powershell.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/python-misc.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/python.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/react.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/react_ts.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/readme.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/ruff.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/rust.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/toml.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/typescript.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/uv.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/yaml.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/assets/material/svg/yarn.svg +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/rust-toolchain.toml +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/src/cache.rs +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/src/camera.rs +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/src/contributors.rs +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/src/export.rs +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/src/history.rs +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/src/layout/planner.rs +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/src/layout.rs +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/src/main.rs +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/src/model/measurement.rs +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/src/model.rs +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/src/theme/icons.rs +0 -0
- {codestrand-0.1.0 → codestrand-0.1.1}/src/timeline.rs +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "codestrand"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.1"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
rust-version = "1.99.1"
|
|
6
6
|
description = "A Git history visualiser with restrained 3D depth and animated diffs"
|
|
@@ -51,5 +51,10 @@ toml = { version = "1.1.8", default-features = false, features = ["parse", "serd
|
|
|
51
51
|
[profile.dev]
|
|
52
52
|
debug = 0
|
|
53
53
|
|
|
54
|
+
[profile.release]
|
|
55
|
+
lto = "fat"
|
|
56
|
+
codegen-units = 1
|
|
57
|
+
strip = true
|
|
58
|
+
|
|
54
59
|
[dev-dependencies]
|
|
55
60
|
image = { version = "0.25", default-features = false, features = ["png"] }
|
|
@@ -321,7 +321,8 @@ fn setup(world: &mut World) {
|
|
|
321
321
|
padding: UiRect::axes(px(3.0), px(1.0)),
|
|
322
322
|
..default()
|
|
323
323
|
},
|
|
324
|
-
|
|
324
|
+
theme.label_shadow,
|
|
325
|
+
ZIndex::default(),
|
|
325
326
|
Visibility::Hidden,
|
|
326
327
|
UiTargetCamera(camera),
|
|
327
328
|
Label,
|
|
@@ -939,56 +940,86 @@ fn ground(point: Vec2) -> Vec3 {
|
|
|
939
940
|
Vec3::new(point.x, 0.0, point.y)
|
|
940
941
|
}
|
|
941
942
|
|
|
942
|
-
fn
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
};
|
|
948
|
-
let (camera, transform) = (camera.clone(), *transform);
|
|
949
|
-
let playback = world.resource::<Playback>();
|
|
950
|
-
let mut caption = playback.0.caption();
|
|
951
|
-
if let Some(camera) = world.get_resource::<PreviewCamera>() {
|
|
952
|
-
caption.push_str(" | ");
|
|
953
|
-
caption.push_str(&camera.caption());
|
|
954
|
-
}
|
|
955
|
-
let mut wanted = playback.0.labels();
|
|
956
|
-
wanted.sort_by_key(|label| label.kind);
|
|
943
|
+
fn place_labels(
|
|
944
|
+
mut wanted: Vec<(model::Label, Vec2, f32)>,
|
|
945
|
+
height: f32,
|
|
946
|
+
) -> Vec<(model::Label, Vec2, f32)> {
|
|
947
|
+
wanted.sort_by_key(|(label, ..)| label.kind);
|
|
957
948
|
let mut placed: Vec<Rect> = Vec::new();
|
|
958
949
|
let mut chosen = Vec::new();
|
|
959
|
-
for label in wanted {
|
|
960
|
-
let Ok(point) = camera.world_to_viewport(&transform, label.position) else {
|
|
961
|
-
continue;
|
|
962
|
-
};
|
|
950
|
+
for (label, point, distance) in wanted {
|
|
963
951
|
let width = 8.0
|
|
964
952
|
+ 8.6
|
|
965
953
|
* f32::from(
|
|
966
954
|
u16::try_from(label.text.chars().count()).unwrap_or(u16::MAX),
|
|
967
955
|
);
|
|
968
|
-
let rect = Rect::from_corners(
|
|
969
|
-
point,
|
|
970
|
-
point + Vec2::new(width, playback.0.theme().label_height),
|
|
971
|
-
);
|
|
956
|
+
let rect = Rect::from_corners(point, point + Vec2::new(width, height));
|
|
972
957
|
if rect.min.x < 0.0
|
|
973
958
|
|| rect.min.y < 0.0
|
|
974
959
|
|| rect.max.x > 1280.0
|
|
975
960
|
|| rect.max.y > 720.0
|
|
976
|
-
||
|
|
961
|
+
|| (label.kind != model::LabelKind::Avatar
|
|
962
|
+
&& placed.iter().any(|other| !other.intersect(rect).is_empty()))
|
|
977
963
|
{
|
|
978
964
|
continue;
|
|
979
965
|
}
|
|
980
966
|
placed.push(rect);
|
|
981
|
-
chosen.push((
|
|
967
|
+
chosen.push((label, point, distance));
|
|
982
968
|
if chosen.len() == LABELS {
|
|
983
969
|
break;
|
|
984
970
|
}
|
|
985
971
|
}
|
|
986
|
-
|
|
972
|
+
chosen.sort_by(|(a, _, a_distance), (b, _, b_distance)| {
|
|
973
|
+
let a_avatar = a.kind == model::LabelKind::Avatar;
|
|
974
|
+
let b_avatar = b.kind == model::LabelKind::Avatar;
|
|
975
|
+
a_avatar
|
|
976
|
+
.cmp(&b_avatar)
|
|
977
|
+
.then_with(|| b_distance.total_cmp(a_distance))
|
|
978
|
+
});
|
|
979
|
+
chosen
|
|
980
|
+
}
|
|
981
|
+
fn labels(world: &mut World) {
|
|
982
|
+
let mut camera_query =
|
|
983
|
+
world.query_filtered::<(&Camera, &GlobalTransform), With<SceneCamera>>();
|
|
984
|
+
let Ok((camera, transform)) = camera_query.single(world) else {
|
|
985
|
+
return;
|
|
986
|
+
};
|
|
987
|
+
let (camera, transform) = (camera.clone(), *transform);
|
|
988
|
+
let playback = world.resource::<Playback>();
|
|
989
|
+
let mut caption = playback.0.caption();
|
|
990
|
+
if let Some(camera) = world.get_resource::<PreviewCamera>() {
|
|
991
|
+
caption.push_str(" | ");
|
|
992
|
+
caption.push_str(&camera.caption());
|
|
993
|
+
}
|
|
994
|
+
let geometry = playback.0.theme();
|
|
995
|
+
let wanted = playback.0.labels().into_iter().filter_map(|label| {
|
|
996
|
+
let point = camera.world_to_viewport(&transform, label.position).ok()?;
|
|
997
|
+
let anchor = if label.kind == model::LabelKind::Avatar {
|
|
998
|
+
label.position - geometry.avatar_label_offset
|
|
999
|
+
} else {
|
|
1000
|
+
label.position
|
|
1001
|
+
};
|
|
1002
|
+
let distance = transform.translation().distance_squared(anchor);
|
|
1003
|
+
Some((label, point, distance))
|
|
1004
|
+
});
|
|
1005
|
+
let chosen = place_labels(wanted.collect(), geometry.label_height);
|
|
1006
|
+
let mut query = world.query_filtered::<(
|
|
1007
|
+
&mut Text,
|
|
1008
|
+
&mut Node,
|
|
1009
|
+
&mut Visibility,
|
|
1010
|
+
&mut TextColor,
|
|
1011
|
+
&mut ZIndex,
|
|
1012
|
+
), With<Label>>();
|
|
987
1013
|
let theme = &world.resource::<Palette>().theme;
|
|
988
1014
|
let (emphasis_color, landmark_color) = (theme.label_emphasis, theme.label_landmark);
|
|
989
1015
|
let mut chosen = chosen.into_iter();
|
|
990
|
-
for (mut text, mut node, mut visibility, mut color
|
|
991
|
-
|
|
1016
|
+
for (index, (mut text, mut node, mut visibility, mut color, mut z_index)) in
|
|
1017
|
+
query.iter_mut(world).enumerate()
|
|
1018
|
+
{
|
|
1019
|
+
if let Some((label, point, _)) = chosen.next() {
|
|
1020
|
+
z_index.0 = i32::try_from(index).expect("label pool fits in i32");
|
|
1021
|
+
let emphasis = label.kind != model::LabelKind::Landmark;
|
|
1022
|
+
let label = label.text;
|
|
992
1023
|
if text.0 != label {
|
|
993
1024
|
text.0 = label;
|
|
994
1025
|
}
|
|
@@ -1019,6 +1050,103 @@ fn labels(world: &mut World) {
|
|
|
1019
1050
|
mod tests {
|
|
1020
1051
|
use super::*;
|
|
1021
1052
|
|
|
1053
|
+
fn projected_label(
|
|
1054
|
+
text: &str,
|
|
1055
|
+
kind: model::LabelKind,
|
|
1056
|
+
point: Vec2,
|
|
1057
|
+
distance: f32,
|
|
1058
|
+
) -> (model::Label, Vec2, f32) {
|
|
1059
|
+
(
|
|
1060
|
+
model::Label {
|
|
1061
|
+
text: text.to_owned(),
|
|
1062
|
+
kind,
|
|
1063
|
+
position: Vec3::ZERO,
|
|
1064
|
+
},
|
|
1065
|
+
point,
|
|
1066
|
+
distance,
|
|
1067
|
+
)
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
#[test]
|
|
1071
|
+
fn overlapping_avatar_names_survive_in_far_to_near_order() {
|
|
1072
|
+
let point = Vec2::splat(100.0);
|
|
1073
|
+
let chosen = place_labels(
|
|
1074
|
+
vec![
|
|
1075
|
+
projected_label("near", model::LabelKind::Avatar, point, 4.0),
|
|
1076
|
+
projected_label("far", model::LabelKind::Avatar, point, 25.0),
|
|
1077
|
+
],
|
|
1078
|
+
20.0,
|
|
1079
|
+
);
|
|
1080
|
+
assert_eq!(
|
|
1081
|
+
chosen
|
|
1082
|
+
.iter()
|
|
1083
|
+
.map(|(label, ..)| label.text.as_str())
|
|
1084
|
+
.collect::<Vec<_>>(),
|
|
1085
|
+
["far", "near"]
|
|
1086
|
+
);
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
#[test]
|
|
1090
|
+
fn directory_and_activity_labels_still_declutter_around_names() {
|
|
1091
|
+
let point = Vec2::splat(100.0);
|
|
1092
|
+
let separate = Vec2::splat(300.0);
|
|
1093
|
+
let chosen = place_labels(
|
|
1094
|
+
vec![
|
|
1095
|
+
projected_label(
|
|
1096
|
+
"blocked directory",
|
|
1097
|
+
model::LabelKind::Landmark,
|
|
1098
|
+
point,
|
|
1099
|
+
1.0,
|
|
1100
|
+
),
|
|
1101
|
+
projected_label(
|
|
1102
|
+
"blocked activity",
|
|
1103
|
+
model::LabelKind::Activity,
|
|
1104
|
+
point,
|
|
1105
|
+
1.0,
|
|
1106
|
+
),
|
|
1107
|
+
projected_label("name", model::LabelKind::Avatar, point, 25.0),
|
|
1108
|
+
projected_label("directory", model::LabelKind::Landmark, separate, 1.0),
|
|
1109
|
+
projected_label("activity", model::LabelKind::Activity, separate, 1.0),
|
|
1110
|
+
projected_label(
|
|
1111
|
+
"visible activity",
|
|
1112
|
+
model::LabelKind::Activity,
|
|
1113
|
+
Vec2::splat(500.0),
|
|
1114
|
+
1.0,
|
|
1115
|
+
),
|
|
1116
|
+
],
|
|
1117
|
+
20.0,
|
|
1118
|
+
);
|
|
1119
|
+
assert_eq!(
|
|
1120
|
+
chosen
|
|
1121
|
+
.iter()
|
|
1122
|
+
.map(|(label, ..)| label.text.as_str())
|
|
1123
|
+
.collect::<Vec<_>>(),
|
|
1124
|
+
["directory", "visible activity", "name"]
|
|
1125
|
+
);
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
#[test]
|
|
1129
|
+
fn label_bounds_capacity_and_equal_distance_order_stay_stable() {
|
|
1130
|
+
let mut wanted = vec![projected_label(
|
|
1131
|
+
"outside",
|
|
1132
|
+
model::LabelKind::Avatar,
|
|
1133
|
+
Vec2::splat(-1.0),
|
|
1134
|
+
1.0,
|
|
1135
|
+
)];
|
|
1136
|
+
wanted.extend((0..=LABELS).map(|index| {
|
|
1137
|
+
projected_label(
|
|
1138
|
+
&index.to_string(),
|
|
1139
|
+
model::LabelKind::Avatar,
|
|
1140
|
+
Vec2::splat(100.0),
|
|
1141
|
+
1.0,
|
|
1142
|
+
)
|
|
1143
|
+
}));
|
|
1144
|
+
let chosen = place_labels(wanted, 20.0);
|
|
1145
|
+
assert_eq!(chosen.len(), LABELS);
|
|
1146
|
+
assert_eq!(chosen[0].0.text, "0");
|
|
1147
|
+
assert_eq!(chosen[LABELS - 1].0.text, (LABELS - 1).to_string());
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1022
1150
|
#[test]
|
|
1023
1151
|
fn svg_glyphs_render_into_complete_colour_mip_chains() {
|
|
1024
1152
|
for glyph in Theme::neon().glyphs {
|
|
@@ -35,7 +35,7 @@ pub(super) struct Theme {
|
|
|
35
35
|
pub(super) directory_edge_widths: Vec<f32>,
|
|
36
36
|
pub(super) directory_edge_height: f32,
|
|
37
37
|
pub(super) label: Color,
|
|
38
|
-
pub(super)
|
|
38
|
+
pub(super) label_shadow: TextShadow,
|
|
39
39
|
pub(super) heading: Color,
|
|
40
40
|
pub(super) label_emphasis: Color,
|
|
41
41
|
pub(super) label_landmark: Color,
|
|
@@ -131,7 +131,10 @@ impl Theme {
|
|
|
131
131
|
directory_edge_widths: vec![0.20, 0.15, 0.11, 0.08],
|
|
132
132
|
directory_edge_height: 0.025,
|
|
133
133
|
label: Color::srgb(0.72, 0.83, 0.9),
|
|
134
|
-
|
|
134
|
+
label_shadow: TextShadow {
|
|
135
|
+
offset: Vec2::splat(1.5),
|
|
136
|
+
color: Color::srgb(0.008, 0.016, 0.03),
|
|
137
|
+
},
|
|
135
138
|
heading: Color::srgb(0.65, 0.8, 0.87),
|
|
136
139
|
label_emphasis: Color::srgb(0.88, 0.95, 1.0),
|
|
137
140
|
label_landmark: Color::srgb(0.62, 0.86, 0.95),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|