Skip to content

Commit

Permalink
Add Element::parent
Browse files Browse the repository at this point in the history
  • Loading branch information
sammycage committed Sep 15, 2024
1 parent 396ba5e commit eee9424
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/lunasvg.h
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,12 @@ class LUNASVG_API Element {
*/
bool isNull() const { return m_element == nullptr; }

/**
* @brief Returns the parent element.
* @return The parent element of this element. If this element has no parent, a null `Element` is returned.
*/
Element parent() const;

/**
* @internal
*/
Expand Down
7 changes: 7 additions & 0 deletions source/lunasvg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,13 @@ Box Element::getBoundingBox() const
return Box();
}

Element Element::parent() const
{
if(m_element)
return m_element->parent();
return Element();
}

std::unique_ptr<Document> Document::loadFromFile(const std::string& filename)
{
std::ifstream fs;
Expand Down

0 comments on commit eee9424

Please sign in to comment.