Initial Grease Pencil 3.0 stage #106848
|
@ -68,8 +68,10 @@ class Layer;
|
||||||
*/
|
*/
|
||||||
class TreeNode : public ::GreasePencilLayerTreeNode {
|
class TreeNode : public ::GreasePencilLayerTreeNode {
|
||||||
public:
|
public:
|
||||||
|
TreeNode();
|
||||||
explicit TreeNode(GreasePencilLayerTreeNodeType type);
|
explicit TreeNode(GreasePencilLayerTreeNodeType type);
|
||||||
explicit TreeNode(GreasePencilLayerTreeNodeType type, StringRefNull name);
|
explicit TreeNode(GreasePencilLayerTreeNodeType type, StringRefNull name);
|
||||||
|
TreeNode(const TreeNode &other);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -174,6 +176,11 @@ class Layer : public ::GreasePencilLayer {
|
||||||
Layer(const Layer &other);
|
Layer(const Layer &other);
|
||||||
~Layer();
|
~Layer();
|
||||||
|
|
||||||
|
StringRefNull name() const
|
||||||
|
{
|
||||||
|
return this->base.name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \returns the frames mapping.
|
* \returns the frames mapping.
|
||||||
*/
|
*/
|
||||||
|
@ -254,14 +261,12 @@ class LayerGroup : public ::GreasePencilLayerTreeGroup {
|
||||||
*/
|
*/
|
||||||
LayerGroup &add_group(LayerGroup *group);
|
LayerGroup &add_group(LayerGroup *group);
|
||||||
LayerGroup &add_group(StringRefNull name);
|
LayerGroup &add_group(StringRefNull name);
|
||||||
// void add_group(LayerGroup &&group);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a layer at the end of this group and returns it.
|
* Adds a layer at the end of this group and returns it.
|
||||||
*/
|
*/
|
||||||
Layer &add_layer(Layer *layer);
|
Layer &add_layer(Layer *layer);
|
||||||
Layer &add_layer(StringRefNull name);
|
Layer &add_layer(StringRefNull name);
|
||||||
// Layer &add_layer(Layer &&layer);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of direct nodes in this group.
|
* Returns the number of direct nodes in this group.
|
||||||
|
@ -324,6 +329,15 @@ class GreasePencilRuntime {
|
||||||
|
|
||||||
} // namespace blender::bke
|
} // namespace blender::bke
|
||||||
|
|
||||||
|
inline blender::bke::greasepencil::TreeNode &GreasePencilLayerTreeNode::wrap()
|
||||||
|
{
|
||||||
|
return *reinterpret_cast<blender::bke::greasepencil::TreeNode *>(this);
|
||||||
|
}
|
||||||
|
inline const blender::bke::greasepencil::TreeNode &GreasePencilLayerTreeNode::wrap() const
|
||||||
|
{
|
||||||
|
return *reinterpret_cast<const blender::bke::greasepencil::TreeNode *>(this);
|
||||||
|
}
|
||||||
|
|
||||||
inline blender::bke::greasepencil::Layer &GreasePencilLayer::wrap()
|
inline blender::bke::greasepencil::Layer &GreasePencilLayer::wrap()
|
||||||
{
|
{
|
||||||
return *reinterpret_cast<blender::bke::greasepencil::Layer *>(this);
|
return *reinterpret_cast<blender::bke::greasepencil::Layer *>(this);
|
||||||
|
|
|
@ -248,34 +248,35 @@ IDTypeInfo IDType_ID_GP = {
|
||||||
|
|
||||||
namespace blender::bke::greasepencil {
|
namespace blender::bke::greasepencil {
|
||||||
|
|
||||||
TreeNode::TreeNode(GreasePencilLayerTreeNodeType type)
|
TreeNode::TreeNode()
|
||||||
{
|
{
|
||||||
this->type = type;
|
this->next = this->prev = nullptr;
|
||||||
|
this->parent = nullptr;
|
||||||
|
|
||||||
this->name = nullptr;
|
this->name = nullptr;
|
||||||
|
this->flag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeNode::TreeNode(GreasePencilLayerTreeNodeType type, StringRefNull name)
|
TreeNode::TreeNode(GreasePencilLayerTreeNodeType type) : TreeNode()
|
||||||
|
{
|
||||||
|
this->type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
TreeNode::TreeNode(GreasePencilLayerTreeNodeType type, StringRefNull name) : TreeNode()
|
||||||
{
|
{
|
||||||
this->type = type;
|
this->type = type;
|
||||||
this->name = BLI_strdup(name.c_str());
|
this->name = BLI_strdup(name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TreeNode::TreeNode(const TreeNode &other)
|
TreeNode::TreeNode(const TreeNode &other)
|
||||||
// : TreeNode::TreeNode(GreasePencilLayerTreeNodeType(other.type))
|
: TreeNode::TreeNode(GreasePencilLayerTreeNodeType(other.type))
|
||||||
// {
|
{
|
||||||
// if (other.name) {
|
if (other.name) {
|
||||||
// this->name = BLI_strdup(other.name);
|
this->name = BLI_strdup(other.name);
|
||||||
// }
|
}
|
||||||
// this->flag = other.flag;
|
this->flag = other.flag;
|
||||||
// copy_v3_v3_uchar(this->color, other.color);
|
copy_v3_v3_uchar(this->color, other.color);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// TreeNode::~TreeNode()
|
|
||||||
// {
|
|
||||||
// if (this->name) {
|
|
||||||
// MEM_freeN(this->name);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
const LayerGroup &TreeNode::as_group() const
|
const LayerGroup &TreeNode::as_group() const
|
||||||
{
|
{
|
||||||
|
@ -324,10 +325,7 @@ LayerMask::~LayerMask()
|
||||||
|
|
||||||
Layer::Layer()
|
Layer::Layer()
|
||||||
{
|
{
|
||||||
this->base.type = GP_LAYER_TREE_LEAF;
|
this->base = TreeNode(GP_LAYER_TREE_LEAF);
|
||||||
this->base.next = this->base.prev = nullptr;
|
|
||||||
this->base.parent = nullptr;
|
|
||||||
this->base.name = nullptr;
|
|
||||||
|
|
||||||
this->frames_storage.size = 0;
|
this->frames_storage.size = 0;
|
||||||
this->frames_storage.keys = nullptr;
|
this->frames_storage.keys = nullptr;
|
||||||
|
@ -345,14 +343,12 @@ Layer::Layer(StringRefNull name) : Layer()
|
||||||
|
|
||||||
Layer::Layer(const Layer &other) : Layer()
|
Layer::Layer(const Layer &other) : Layer()
|
||||||
{
|
{
|
||||||
if (other.base.name) {
|
this->base = TreeNode(other.base.wrap());
|
||||||
this->base.name = BLI_strdup(other.base.name);
|
|
||||||
}
|
|
||||||
this->base.flag = other.base.flag;
|
|
||||||
copy_v3_v3_uchar(this->base.color, other.base.color);
|
|
||||||
|
|
||||||
/* TODO: duplicate masks. */
|
/* TODO: duplicate masks. */
|
||||||
|
|
||||||
|
/* Note: We do not duplicate the frame storage since it is only needed for writing. */
|
||||||
|
|
||||||
this->blend_mode = other.blend_mode;
|
this->blend_mode = other.blend_mode;
|
||||||
this->opacity = other.opacity;
|
this->opacity = other.opacity;
|
||||||
|
|
||||||
|
@ -459,10 +455,7 @@ void Layer::tag_frames_map_keys_changed()
|
||||||
|
|
||||||
LayerGroup::LayerGroup()
|
LayerGroup::LayerGroup()
|
||||||
{
|
{
|
||||||
this->base.type = GP_LAYER_TREE_GROUP;
|
this->base = TreeNode(GP_LAYER_TREE_GROUP);
|
||||||
this->base.next = this->base.prev = nullptr;
|
|
||||||
this->base.parent = nullptr;
|
|
||||||
this->base.name = nullptr;
|
|
||||||
|
|
||||||
BLI_listbase_clear(&this->children);
|
BLI_listbase_clear(&this->children);
|
||||||
|
|
||||||
|
@ -476,9 +469,7 @@ LayerGroup::LayerGroup(StringRefNull name) : LayerGroup()
|
||||||
|
|
||||||
LayerGroup::LayerGroup(const LayerGroup &other) : LayerGroup()
|
LayerGroup::LayerGroup(const LayerGroup &other) : LayerGroup()
|
||||||
{
|
{
|
||||||
if (other.base.name) {
|
this->base = TreeNode(other.base.wrap());
|
||||||
this->base.name = BLI_strdup(other.base.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
LISTBASE_FOREACH (GreasePencilLayerTreeNode *, child, &other.children) {
|
LISTBASE_FOREACH (GreasePencilLayerTreeNode *, child, &other.children) {
|
||||||
switch (child->type) {
|
switch (child->type) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ class GreasePencilRuntime;
|
||||||
class GreasePencilDrawingRuntime;
|
class GreasePencilDrawingRuntime;
|
||||||
namespace greasepencil {
|
namespace greasepencil {
|
||||||
class DrawingRuntime;
|
class DrawingRuntime;
|
||||||
|
class TreeNode;
|
||||||
class Layer;
|
class Layer;
|
||||||
class LayerRuntime;
|
class LayerRuntime;
|
||||||
class LayerGroup;
|
class LayerGroup;
|
||||||
|
@ -250,6 +251,10 @@ typedef struct GreasePencilLayerTreeNode {
|
||||||
* See `GreasePencilLayerTreeNodeFlag`.
|
* See `GreasePencilLayerTreeNodeFlag`.
|
||||||
*/
|
*/
|
||||||
uint32_t flag;
|
uint32_t flag;
|
||||||
|
#ifdef __cplusplus
|
||||||
|
blender::bke::greasepencil::TreeNode &wrap();
|
||||||
|
const blender::bke::greasepencil::TreeNode &wrap() const;
|
||||||
|
#endif
|
||||||
} GreasePencilLayerTreeNode;
|
} GreasePencilLayerTreeNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue