mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
API: enable users to use an accessor to traverse Scene
remove the restriction of targeting only Picture. now, any kind of paints can be adaptable here.
This commit is contained in:
parent
a5f67ee92c
commit
b59c7a0bee
2 changed files with 7 additions and 7 deletions
|
@ -2113,7 +2113,7 @@ public:
|
|||
/**
|
||||
* @brief Set the access function for traversing the Picture scene tree nodes.
|
||||
*
|
||||
* @param[in] picture The picture node to traverse the internal scene-tree.
|
||||
* @param[in] paint The paint node to traverse the internal scene-tree.
|
||||
* @param[in] func The callback function calling for every paint nodes of the Picture.
|
||||
* @param[in] data Data passed to the @p func as its argument.
|
||||
*
|
||||
|
@ -2121,7 +2121,7 @@ public:
|
|||
*
|
||||
* @note Experimental API
|
||||
*/
|
||||
Result set(const Picture* picture, std::function<bool(const Paint* paint, void* data)> func, void* data) noexcept;
|
||||
Result set(Paint* paint, std::function<bool(const Paint* paint, void* data)> func, void* data) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Generate a unique ID (hash key) from a given name.
|
||||
|
|
|
@ -64,17 +64,17 @@ TVG_DEPRECATED unique_ptr<Picture> Accessor::set(unique_ptr<Picture> picture, fu
|
|||
}
|
||||
|
||||
|
||||
Result Accessor::set(const Picture* picture, function<bool(const Paint* paint, void* data)> func, void* data) noexcept
|
||||
Result Accessor::set(Paint* paint, function<bool(const Paint* paint, void* data)> func, void* data) noexcept
|
||||
{
|
||||
if (!picture || !func) return Result::InvalidArguments;
|
||||
if (!paint || !func) return Result::InvalidArguments;
|
||||
|
||||
//Use the Preorder Tree-Search
|
||||
//Use the Preorder Tree-Searc
|
||||
|
||||
//Root
|
||||
if (!func(picture, data)) return Result::Success;
|
||||
if (!func(paint, data)) return Result::Success;
|
||||
|
||||
//Children
|
||||
if (auto it = IteratorAccessor::iterator(picture)) {
|
||||
if (auto it = IteratorAccessor::iterator(paint)) {
|
||||
accessChildren(it, func, data);
|
||||
delete(it);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue