Commit graph

10 commits

Author SHA1 Message Date
Hermet Park
24711e485c infra: renames the source folders
lib -> renderer
bin -> tools
utils -> common
2023-08-28 13:11:24 +09:00
Hermet Park
084e78d98d common: code refactoring for the IteractorAccessor.
The instantiation of the accessor is unnecessary
as it does not require any internal context.

Simplifying its usage would be beneficial.
2023-04-07 18:24:24 +09:00
Hermet Park
5ebde2c9b6 common/accessor: fix uninitialized field.
--warnings.
2023-03-25 10:59:09 +09:00
Hermet Park
9b3c34c3b1 updated copyright. 2023-01-14 13:48:11 +09:00
Hermet Park
dc477e197b common Accessor: removed deprecated api.
the old version of Accessor::access() is redundant,
we replaced it with set().

It's still under the beta, we can remove it immediately.
Note that we've planned to promote them official APIs in v0.9.

Newly changed, tagging beta again...w
2022-11-26 19:02:11 +09:00
JunsuChoi
3ba0b8adff common Accessor: Add access API using std::function 2022-11-25 15:25:49 +09:00
JunsuChoi
6e26aab1b6 common Accessor: Add access api that with data parameter
It supports data parameters that
can pass user data to the callback function.

std::unique_ptr<Picture> access(std::unique_ptr<Picture> picture, bool(*func)(const Paint* paint, void* data), void* data) noexcept;
2022-11-25 15:25:49 +09:00
Rémi Verschelde
46c3fc1f94 Format code files with dos2unix, ensure newline at EOF 2022-07-10 23:21:05 +09:00
Hermet Park
f0141e63de updated copyright date. 2022-01-12 14:08:48 +09:00
Hermet Park
100d98d82e common: Introduced Accessor for traversing the scene-tree.
Basically, this Accessor is a utility to debug the Scene structure,
by traversing the scene-tree by users.

You can search specific nodes to read the property information,
figure out the structure of the scene tree and its size.

We actually don't recommend you to touch the property unless you really
know the each paint's position and role because it's not visible, difficult to
understand its anatomy.

Also, You must underatnd that modifying the nodes of the scene will be going
well with both the art-design structure and the prorgram logic.

In this first version, Accessor only supports for the Picture class.

@example:

auto picture = tvg::Picture::gen();
picture->load("test.svg");

//The callback function from lambda expression.
//This function will be called for every paint nodes of the tree.
auto f = [](const tvg::Paint* paint) -> bool
{
    if (paint->identifier() == Shape::identifier()) {
        //override properties?
        uint8_t r, g, b, a;
        paint->fillColor(&r, &g, &b, &a);
        paint->fill(r / 2, g / 2, b / 2, a);
    }

    //You can return false, to stop traversing immediately.
    return true;
};

auto accessor = tvg::Accessor::gen();

picture = accessor->access(move(picture), f);

...

@Issue: https://github.com/Samsung/thorvg/issues/693
2021-12-23 11:54:44 +09:00