[Bf-blender-cvs] [e0442a955ba] master: UI Code Quality: Port Outliner Grease Pencil layers to new design

Julian Eisel noreply at git.blender.org
Fri Mar 5 14:46:34 CET 2021


Commit: e0442a955badbbf7ee6f280bb988054175802bc1
Author: Julian Eisel
Date:   Fri Mar 5 12:28:15 2021 +0100
Branches: master
https://developer.blender.org/rBe0442a955badbbf7ee6f280bb988054175802bc1

UI Code Quality: Port Outliner Grease Pencil layers to new design

Continuation of work in 2e221de4ceee and 249e4df110e0. Now the tree-element
types have to be ported one by one. This is probably the most straight forward
type to port.

===================================================================

M	source/blender/editors/space_outliner/CMakeLists.txt
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/editors/space_outliner/tree/tree_element.cc
A	source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.cc
A	source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.hh

===================================================================

diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt
index d54265aa292..040410c0bdd 100644
--- a/source/blender/editors/space_outliner/CMakeLists.txt
+++ b/source/blender/editors/space_outliner/CMakeLists.txt
@@ -57,6 +57,7 @@ set(SRC
   tree/tree_element.cc
   tree/tree_element_anim_data.cc
   tree/tree_element_driver_base.cc
+  tree/tree_element_gpencil_layer.cc
   tree/tree_element_nla.cc
 
   outliner_intern.h
@@ -66,6 +67,7 @@ set(SRC
   tree/tree_element.hh
   tree/tree_element_anim_data.hh
   tree/tree_element_driver_base.hh
+  tree/tree_element_gpencil_layer.hh
   tree/tree_element_nla.hh
 )
 
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index f94f19246fa..0d82ba992c2 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1016,16 +1016,16 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
       outliner_add_id_contents(space_outliner, te, tselem, id);
     }
   }
-  else if (ELEM(type, TSE_ANIM_DATA, TSE_DRIVER_BASE, TSE_NLA, TSE_NLA_ACTION, TSE_NLA_TRACK)) {
+  else if (ELEM(type,
+                TSE_ANIM_DATA,
+                TSE_DRIVER_BASE,
+                TSE_NLA,
+                TSE_NLA_ACTION,
+                TSE_NLA_TRACK,
+                TSE_GP_LAYER)) {
     /* Should already use new AbstractTreeElement design. */
     BLI_assert(0);
   }
-  else if (type == TSE_GP_LAYER) {
-    bGPDlayer *gpl = (bGPDlayer *)idv;
-
-    te->name = gpl->info;
-    te->directdata = gpl;
-  }
   else if (type == TSE_SEQUENCE) {
     Sequence *seq = (Sequence *)idv;
 
diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc
index 27846614994..a692aae37c3 100644
--- a/source/blender/editors/space_outliner/tree/tree_element.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element.cc
@@ -22,6 +22,7 @@
 
 #include "tree_element_anim_data.hh"
 #include "tree_element_driver_base.hh"
+#include "tree_element_gpencil_layer.hh"
 #include "tree_element_nla.hh"
 
 #include "tree_element.h"
@@ -46,6 +47,8 @@ static AbstractTreeElement *tree_element_create(int type, TreeElement &legacy_te
       return new TreeElementNLATrack(legacy_te, *static_cast<NlaTrack *>(idv));
     case TSE_NLA_ACTION:
       return new TreeElementNLAAction(legacy_te);
+    case TSE_GP_LAYER:
+      return new TreeElementGPencilLayer(legacy_te, *static_cast<bGPDlayer *>(idv));
     default:
       break;
   }
diff --git a/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.cc b/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.cc
new file mode 100644
index 00000000000..91e6fdcde4b
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.cc
@@ -0,0 +1,40 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup spoutliner
+ */
+
+#include "BLI_utildefines.h"
+
+#include "DNA_gpencil_types.h"
+
+#include "../outliner_intern.h"
+
+#include "tree_element_gpencil_layer.hh"
+
+namespace blender::ed::outliner {
+
+TreeElementGPencilLayer::TreeElementGPencilLayer(TreeElement &legacy_te, bGPDlayer &gplayer)
+    : AbstractTreeElement(legacy_te)
+{
+  BLI_assert(legacy_te.store_elem->type == TSE_GP_LAYER);
+  /* this element's info */
+  legacy_te.name = gplayer.info;
+  legacy_te.directdata = &gplayer;
+}
+
+}  // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.hh b/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.hh
new file mode 100644
index 00000000000..dd18dd42344
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.hh
@@ -0,0 +1,34 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup spoutliner
+ */
+
+#pragma once
+
+#include "tree_element.hh"
+
+struct bGPDlayer;
+
+namespace blender::ed::outliner {
+
+class TreeElementGPencilLayer : public AbstractTreeElement {
+ public:
+  TreeElementGPencilLayer(TreeElement &legacy_te, bGPDlayer &gplayer);
+};
+
+}  // namespace blender::ed::outliner



More information about the Bf-blender-cvs mailing list