Struct rsvg::node::CascadedValues
source · pub struct CascadedValues<'a> {
inner: CascadedInner<'a>,
pub context_stroke: Option<Rc<PaintSource>>,
pub context_fill: Option<Rc<PaintSource>>,
}
Expand description
Can obtain computed values from a node
In our tree of SVG elements (Node in our parlance), each node stores a ComputedValues
that
gets computed during the initial CSS cascade. However, sometimes nodes need to be rendered
outside the normal hierarchy. For example, the <use>
element can “instance” a subtree from
elsewhere in the SVG; it causes the instanced subtree to re-cascade from the computed values for
the <use>
element.
You can then call the get()
method on the resulting CascadedValues
to get a
&ComputedValues
whose fields you can access.
Fields§
§inner: CascadedInner<'a>
§context_stroke: Option<Rc<PaintSource>>
§context_fill: Option<Rc<PaintSource>>
Implementations§
source§impl<'a> CascadedValues<'a>
impl<'a> CascadedValues<'a>
sourcepub fn clone_with_node(&self, node: &'a Node<NodeData>) -> CascadedValues<'a>
pub fn clone_with_node(&self, node: &'a Node<NodeData>) -> CascadedValues<'a>
Creates a CascadedValues
that has the same cascading mode as &self
This is what nodes should normally use to draw their children from their draw()
method.
Nodes that need to override the cascade for their children can use new_from_values()
instead.
sourcepub fn new_from_node(node: &Node<NodeData>) -> CascadedValues<'_>
pub fn new_from_node(node: &Node<NodeData>) -> CascadedValues<'_>
Creates a CascadedValues
that will hold the node
’s computed values
This is to be used only in the toplevel drawing function, or in elements like <marker>
that don’t propagate their parent’s cascade to their children. All others should use
new()
to derive the cascade from an existing one.
sourcepub fn new_from_values(
node: &'a Node<NodeData>,
values: &ComputedValues,
fill: Option<Rc<PaintSource>>,
stroke: Option<Rc<PaintSource>>,
) -> CascadedValues<'a>
pub fn new_from_values( node: &'a Node<NodeData>, values: &ComputedValues, fill: Option<Rc<PaintSource>>, stroke: Option<Rc<PaintSource>>, ) -> CascadedValues<'a>
Creates a CascadedValues
that will override the node
’s cascade with the specified
values
This is for the <use>
element, which draws the element which it references with the
<use>
’s own cascade, not with the element’s original cascade.
sourcepub fn get(&'a self) -> &'a ComputedValues
pub fn get(&'a self) -> &'a ComputedValues
Returns the cascaded ComputedValues
.
Nodes should use this from their Draw::draw()
implementation to get the
ComputedValues
from the CascadedValues
that got passed to draw()
.
Auto Trait Implementations§
impl<'a> Freeze for CascadedValues<'a>
impl<'a> !RefUnwindSafe for CascadedValues<'a>
impl<'a> !Send for CascadedValues<'a>
impl<'a> !Sync for CascadedValues<'a>
impl<'a> Unpin for CascadedValues<'a>
impl<'a> !UnwindSafe for CascadedValues<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.