Outliner: Add debugging utility to print an elements path
No user visible changes expected. Adds a function that prints the "path" of an element, that is, the ancestor elements starting from the root, separated by slashes. This can be useful for debugging. The function isn't used.
This commit is contained in:
parent
2a3e4d8bcd
commit
735b26053e
|
@ -4,6 +4,9 @@
|
|||
* \ingroup spoutliner
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "DNA_anim_types.h"
|
||||
#include "DNA_listBase.h"
|
||||
#include "DNA_space_types.h"
|
||||
|
@ -111,6 +114,17 @@ std::optional<BIFIconID> AbstractTreeElement::getIcon() const
|
|||
return {};
|
||||
}
|
||||
|
||||
void AbstractTreeElement::print_path()
|
||||
{
|
||||
std::string path = legacy_te_.name;
|
||||
|
||||
for (TreeElement *parent = legacy_te_.parent; parent; parent = parent->parent) {
|
||||
path = parent->name + std::string_view("/") + path;
|
||||
}
|
||||
|
||||
std::cout << path << std::endl;
|
||||
}
|
||||
|
||||
void AbstractTreeElement::uncollapse_by_default(TreeElement *legacy_te)
|
||||
{
|
||||
if (!TREESTORE(legacy_te)->used) {
|
||||
|
|
|
@ -74,6 +74,16 @@ class AbstractTreeElement {
|
|||
*/
|
||||
virtual std::optional<BIFIconID> getIcon() const;
|
||||
|
||||
/**
|
||||
* Debugging helper: Print effective path of this tree element, constructed out of the
|
||||
* #TreeElement.name of each element. E.g.:
|
||||
* - Lorem
|
||||
* - ipsum dolor sit
|
||||
* - amet
|
||||
* will print: Lorem/ipsum dolor sit/amet.
|
||||
*/
|
||||
void print_path();
|
||||
|
||||
/**
|
||||
* Expand this tree element if it is displayed for the first time (as identified by its
|
||||
* tree-store element).
|
||||
|
|
Loading…
Reference in New Issue