[librsvg/wip/rust-api] CairoRenderer: add a get_geometry_for_element() method
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/wip/rust-api] CairoRenderer: add a get_geometry_for_element() method
- Date: Mon, 18 Feb 2019 18:58:48 +0000 (UTC)
commit cd9d2cb301022fc34e105737e7fd71eceb94ae72
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Feb 18 11:29:02 2019 -0600
CairoRenderer: add a get_geometry_for_element() method
librsvg_crate/src/lib.rs | 11 +++++++++++
rsvg_internals/src/drawing_ctx.rs | 11 +++++++++++
rsvg_internals/src/handle.rs | 2 +-
rsvg_internals/src/lib.rs | 2 ++
4 files changed, 25 insertions(+), 1 deletion(-)
---
diff --git a/librsvg_crate/src/lib.rs b/librsvg_crate/src/lib.rs
index 6f5a8a88..0d7d3ebc 100644
--- a/librsvg_crate/src/lib.rs
+++ b/librsvg_crate/src/lib.rs
@@ -143,6 +143,17 @@ impl<'a> CairoRenderer<'a> {
.map(|dimensions| (dimensions.width, dimensions.height))
}
+ /// Returns (ink_rect, logical_rect)
+ pub fn get_geometry_for_element(
+ &self,
+ id: Option<&str>,
+ ) -> Result<(cairo::Rectangle, cairo::Rectangle), RenderingError> {
+ self.handle
+ .0
+ .get_geometry_sub(id)
+ .map(|(i, l)| (i.into(), l.into()))
+ }
+
pub fn render(&self, cr: &cairo::Context) -> Result<(), RenderingError> {
self.handle.0.render_cairo_sub(cr, None)
}
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index fadc9be1..6f8df89c 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -905,6 +905,17 @@ impl From<cairo::Rectangle> for RsvgRectangle {
}
}
+impl From<RsvgRectangle> for cairo::Rectangle {
+ fn from(r: RsvgRectangle) -> cairo::Rectangle {
+ cairo::Rectangle {
+ x: r.x,
+ y: r.y,
+ width: r.width,
+ height: r.height,
+ }
+ }
+}
+
pub struct AcquiredNode(Rc<RefCell<Vec<RsvgNode>>>, RsvgNode);
impl Drop for AcquiredNode {
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index 1e9af90c..4859dafb 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -410,7 +410,7 @@ impl Handle {
}
/// Returns (ink_rect, logical_rect)
- fn get_geometry_sub(
+ pub fn get_geometry_sub(
&self,
id: Option<&str>,
) -> Result<(RsvgRectangle, RsvgRectangle), RenderingError> {
diff --git a/rsvg_internals/src/lib.rs b/rsvg_internals/src/lib.rs
index cbdabfd1..ee22d16f 100644
--- a/rsvg_internals/src/lib.rs
+++ b/rsvg_internals/src/lib.rs
@@ -44,6 +44,8 @@ pub use color::{rsvg_css_parse_color, ColorKind, ColorSpec};
pub use dpi::{rsvg_rust_set_default_dpi_x_y, Dpi};
+pub use drawing_ctx::RsvgRectangle;
+
pub use error::{rsvg_rust_error_quark, LoadingError, RenderingError};
pub use handle::{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]