[Bf-blender-cvs] [d283cc1] soc-2016-layer_manager: Add operator for adding layers

Julian Eisel noreply at git.blender.org
Tue May 24 03:04:03 CEST 2016


Commit: d283cc10611256a87e8fffcbdabd8555417c64a7
Author: Julian Eisel
Date:   Tue May 24 02:52:14 2016 +0200
Branches: soc-2016-layer_manager
https://developer.blender.org/rBd283cc10611256a87e8fffcbdabd8555417c64a7

Add operator for adding layers

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

M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/screen/CMakeLists.txt
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/space_layers/CMakeLists.txt
A	source/blender/editors/space_layers/layers_intern.h
A	source/blender/editors/space_layers/layers_ops.c
M	source/blender/editors/space_layers/space_layers.c

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

diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 6a558d1..32c0ad5 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -158,6 +158,7 @@ int     ED_operator_image_active(struct bContext *C);
 int     ED_operator_nla_active(struct bContext *C);
 int     ED_operator_logic_active(struct bContext *C);
 int     ED_operator_info_active(struct bContext *C);
+int     ED_operator_layers_active(struct bContext *C);
 int     ED_operator_console_active(struct bContext *C);
 
 
diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt
index ed86ffa..89cb62d 100644
--- a/source/blender/editors/screen/CMakeLists.txt
+++ b/source/blender/editors/screen/CMakeLists.txt
@@ -53,6 +53,10 @@ if(WITH_INTERNATIONAL)
 	add_definitions(-DWITH_INTERNATIONAL)
 endif()
 
+if(WITH_ADVANCED_LAYERS)
+	add_definitions(-DWITH_ADVANCED_LAYERS)
+endif()
+
 add_definitions(${GL_DEFINITIONS})
 
 blender_add_lib(bf_editor_screen "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 4111f67..9ffe9f6 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -320,6 +320,12 @@ int ED_operator_info_active(bContext *C)
 	return ed_spacetype_test(C, SPACE_INFO);
 }
 
+#ifdef WITH_ADVANCED_LAYERS
+int ED_operator_layers_active(bContext *C)
+{
+	return ed_spacetype_test(C, SPACE_LAYERS);
+}
+#endif
 
 int ED_operator_console_active(bContext *C)
 {
diff --git a/source/blender/editors/space_layers/CMakeLists.txt b/source/blender/editors/space_layers/CMakeLists.txt
index f193d5d..094248a 100644
--- a/source/blender/editors/space_layers/CMakeLists.txt
+++ b/source/blender/editors/space_layers/CMakeLists.txt
@@ -33,7 +33,10 @@ set(INC_SYS
 )
 
 set(SRC
+	layers_ops.c
 	space_layers.c
+
+	layers_intern.h
 )
 
 blender_add_lib(bf_editor_space_layers "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_layers/layers_intern.h b/source/blender/editors/space_layers/layers_intern.h
new file mode 100644
index 0000000..95d6a40
--- /dev/null
+++ b/source/blender/editors/space_layers/layers_intern.h
@@ -0,0 +1,32 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_layers/layers_intern.h
+ *  \ingroup splayers
+ */
+
+
+#ifndef __LAYERS_INTERN_H__
+#define __LAYERS_INTERN_H__
+
+void layers_operatortypes(void);
+
+#endif  /* __LAYERS_INTERN_H__ */
+
diff --git a/source/blender/editors/space_layers/layers_ops.c b/source/blender/editors/space_layers/layers_ops.c
new file mode 100644
index 0000000..567ef25
--- /dev/null
+++ b/source/blender/editors/space_layers/layers_ops.c
@@ -0,0 +1,70 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_layers/layers_ops.c
+ *  \ingroup splayers
+ */
+
+#include "BKE_context.h"
+
+#include "BLI_compiler_attrs.h"
+
+#include "DNA_windowmanager_types.h"
+
+#include "ED_object.h"
+#include "ED_screen.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "layers_intern.h" /* own include */
+
+
+static int layer_add_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
+{
+	if (true) { /* context check (like: slayer->context == SLAYER_CONTEXT_OBJECT) */
+		Scene *scene = CTX_data_scene(C);
+		ED_object_layer_add(scene->object_layers);
+	}
+	return OPERATOR_FINISHED;
+}
+
+static void LAYERS_OT_layer_add(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Add Layer";
+	ot->idname = "LAYERS_OT_layer_add";
+	ot->description = "Add a new layer to the layer list";
+
+	/* api callbacks */
+	ot->invoke = layer_add_invoke;
+	ot->poll = ED_operator_layers_active;
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+
+/* ************************** registration - operator types **********************************/
+
+void layers_operatortypes(void)
+{
+	WM_operatortype_append(LAYERS_OT_layer_add);
+}
diff --git a/source/blender/editors/space_layers/space_layers.c b/source/blender/editors/space_layers/space_layers.c
index c1a2232..a30371c 100644
--- a/source/blender/editors/space_layers/space_layers.c
+++ b/source/blender/editors/space_layers/space_layers.c
@@ -40,6 +40,8 @@
 
 #include "WM_types.h"
 
+#include "layers_intern.h" /* own include */
+
 
 /* ******************** default callbacks for layer manager space ***************** */
 
@@ -117,6 +119,7 @@ void ED_spacetype_layers(void)
 
 	st->new = layers_new;
 	st->duplicate = layers_duplicate;
+	st->operatortypes = layers_operatortypes;
 
 	/* regions: main window */
 	art = MEM_callocN(sizeof(ARegionType), "spacetype layers region");




More information about the Bf-blender-cvs mailing list