Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions build-aux/inno_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ def run_command(command, error_message):
f"Collecting angle dependency ({angle_dll}) DLLs failed",
)

# add libcrypto-3-x64.dll and libssl-3-x64.dll
run_command(
f"cp {build_environment_path}/bin/libcrypto-3-x64.dll {dlls_dir}",
"Collecting libcrypto-3-x64.dll failed",
)
run_command(
f"cp {build_environment_path}/bin/libssl-3-x64.dll {dlls_dir}",
"Collecting libssl-3-x64.dll failed",
)

# Collect necessary GSchema Xml's and compile them into a `gschemas.compiled`
print("Collecting and compiling GSchemas...", file=sys.stderr)
gschemas_dir = os.path.join(build_root, "gschemas")
Expand Down
14 changes: 7 additions & 7 deletions crates/rnote-engine/src/document/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,18 @@ impl Document {
);

if include_content {
let rendered_bounds = store.key_tree.get_bounds();
let content_bounds = if store.keytree_is_empty() {
// If doc is empty, resize to one page with the format size
Aabb::new(na::point![0.0, 0.0], self.config.format.size().into())
.extend_right_and_bottom_by(na::vector![padding_horizontal, padding_vertical])
} else {
let rendered_bounds = store.get_bounds();

let content_bounds = if rendered_bounds.area() > 0.0 {
Aabb::new(
na::point![rendered_bounds.lower()[0], rendered_bounds.lower()[1]],
na::point![rendered_bounds.upper()[0], rendered_bounds.upper()[1]],
)
.extend_right_and_bottom_by(na::vector![padding_horizontal, padding_vertical])
} else {
// If doc is empty, resize to one page with the format size
Aabb::new(na::point![0.0, 0.0], self.config.format.size().into())
.extend_right_and_bottom_by(na::vector![padding_horizontal, padding_vertical])
};
new_bounds.merge(&content_bounds);
}
Expand Down Expand Up @@ -306,7 +306,7 @@ impl Document {
.merged(&viewport.extend_by(na::vector![padding_horizontal, padding_vertical]));

if include_content {
let rendered_bounds = store.key_tree.get_bounds();
let rendered_bounds = store.get_bounds();

let content_bounds = if rendered_bounds.area() > 0.0 {
Aabb::new(
Expand Down
8 changes: 6 additions & 2 deletions crates/rnote-engine/src/store/keytree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use rstar::AABB;
use rstar::primitives::GeomWithData;

/// The rtree object that holds the bounds and [StrokeKey].
pub(crate) type KeyTreeObject = GeomWithData<rstar::primitives::Rectangle<[f64; 2]>, StrokeKey>;
type KeyTreeObject = GeomWithData<rstar::primitives::Rectangle<[f64; 2]>, StrokeKey>;

#[derive(Debug, Default)]
/// A Rtree with [StrokeKey]'s as associated data.
///
/// Used for faster spatial queries.
pub(crate) struct KeyTree(rstar::RTree<KeyTreeObject, rstar::DefaultParams>);
pub(super) struct KeyTree(rstar::RTree<KeyTreeObject, rstar::DefaultParams>);

impl KeyTree {
/// Insert a new tree object with the given [StrokeKey] and bounds.
Expand Down Expand Up @@ -78,6 +78,10 @@ impl KeyTree {
pub fn get_bounds(&self) -> AABB<[f64; 2]> {
self.0.root().envelope()
}

pub(crate) fn is_empty(&self) -> bool {
self.0.size() == 0
}
}

fn new_keytree_object(key: StrokeKey, bounds: Aabb) -> KeyTreeObject {
Expand Down
11 changes: 10 additions & 1 deletion crates/rnote-engine/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod trash_comp;
pub use chrono_comp::ChronoComponent;
use keytree::KeyTree;
pub use render_comp::RenderComponent;
use rstar::AABB;
pub use selection_comp::SelectionComponent;
pub use trash_comp::TrashComponent;

Expand Down Expand Up @@ -95,7 +96,7 @@ pub struct StrokeStore {
///
/// Needs to be updated with `update_with_key()` when strokes changed their geometry or position!
#[serde(skip)]
pub(crate) key_tree: KeyTree,
key_tree: KeyTree,
}

impl Default for StrokeStore {
Expand Down Expand Up @@ -383,4 +384,12 @@ impl StrokeStore {

widget_flags
}

pub(super) fn get_bounds(&self) -> AABB<[f64; 2]> {
self.key_tree.get_bounds()
}

pub(super) fn keytree_is_empty(&self) -> bool {
self.key_tree.is_empty()
}
}
4 changes: 2 additions & 2 deletions crates/rnote-engine/src/store/render_comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl StrokeStore {

// iterate a second time on stroke keys that we know are not in
// the viewport
// This way we can skip calculting their bounds
// This way we can skip calculating their bounds
for (_key, render_comp) in self
.render_components
.iter_mut()
Expand Down Expand Up @@ -700,7 +700,7 @@ impl StrokeStore {
}

// draw the rtree root
let tree_bounds = self.key_tree.get_tree().root().envelope();
let tree_bounds = self.key_tree.get_bounds();
visual_debug::draw_bounds_to_gtk_snapshot(
Aabb::new(
na::point![tree_bounds.lower()[0], tree_bounds.lower()[1]],
Expand Down
8 changes: 6 additions & 2 deletions crates/rnote-engine/src/store/stroke_comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ impl StrokeStore {

/// Calculate the height needed to fit all strokes.
pub(crate) fn calc_height(&self) -> f64 {
let bounds = self.key_tree.get_tree().root().envelope();
bounds.upper()[1] - bounds.lower()[1]
if self.keytree_is_empty() {
return 0.0;
} else {
let bounds = self.key_tree.get_bounds();
bounds.upper()[1] - bounds.lower()[1]
}
}

/// Calculate the width needed to fit all strokes.
Expand Down
2 changes: 2 additions & 0 deletions crates/rnote-engine/src/store/trash_comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ impl StrokeStore {
trash_comp.trashed = trash;
// remove the key from the rtree (so that the rtree holds information
// only for non trashed strokes)
// Remark : the corresponding stroke will hold onto its rendernodes and image
// until `regenerate_rendering_in_viewport_threaded` is called again
if trash {
self.key_tree.remove_with_key(key);
} else {
Expand Down
Loading