Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2017-01-30 20:10:12 +0300
committerDalai Felinto <dfelinto@gmail.com>2017-01-30 20:21:36 +0300
commit8605eb9c971db41a350a1f11d08bc0d56cecae2d (patch)
treefdd6ea8badb105165cd67d965a8962d48cdb643e
parent1bfc6e79eea93dfd9f32b508f10b1055d3f15fb1 (diff)
Collection related operators barebones
Those are the operators for the collections editor, and the collection property panel
-rw-r--r--source/blender/blenkernel/BKE_layer.h1
-rw-r--r--source/blender/editors/space_collections/collections_ops.c315
2 files changed, 315 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 0f328700bfb..88411132106 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -38,6 +38,7 @@ extern "C" {
#define TODO_LAYER_OVERRIDE /* CollectionOverride */
#define TODO_LAYER_CONTEXT /* get/set current (context) SceneLayer */
#define TODO_LAYER_BASE /* Base to ObjectBase related TODO */
+#define TODO_LAYER_OPERATORS /* collection mamanger and property panel operators */
#define TODO_LAYER /* generic todo */
struct LayerCollection;
diff --git a/source/blender/editors/space_collections/collections_ops.c b/source/blender/editors/space_collections/collections_ops.c
index c822ac1e824..ff62696621f 100644
--- a/source/blender/editors/space_collections/collections_ops.c
+++ b/source/blender/editors/space_collections/collections_ops.c
@@ -22,16 +22,329 @@
* \ingroup spcollections
*/
+#include "BKE_context.h"
+#include "BKE_layer.h"
+#include "BKE_report.h"
+
+#include "ED_screen.h"
+
#include "WM_api.h"
+#include "WM_types.h"
+
#include "collections_intern.h" /* own include */
+/* -------------------------------------------------------------------- */
+/* polls */
+
+static SceneCollection *collection_manager_collection_active(bContext *C)
+{
+ TODO_LAYER_OPERATORS;
+ /* consider that we may have overrides active
+ * leading to no active collections */
+ return CTX_data_scene_collection(C);
+}
+
+static int operator_not_master_collection_active(bContext *C)
+{
+ if (ED_operator_collections_active(C) == false) {
+ return 0;
+ }
+
+ SceneCollection *sc = collection_manager_collection_active(C);
+ if (sc == NULL) {
+ return 1;
+ }
+
+ return (sc == BKE_collection_master(CTX_data_scene(C))) ? 0 : 1;
+}
+
+static int operator_top_collection_active(bContext *C)
+{
+ if (ED_operator_collections_active(C) == false) {
+ return 0;
+ }
+
+ SceneCollection *sc = collection_manager_collection_active(C);
+ if (sc == NULL) {
+ return 0;
+ }
+
+ TODO_LAYER_OPERATORS;
+ /* see if it's a top collection */
+ return 1;
+}
+
+static int operator_collection_active(bContext *C)
+{
+ if (ED_operator_collections_active(C) == false) {
+ return 0;
+ }
+ return collection_manager_collection_active(C) ? 1 : 0;
+}
+
+/* -------------------------------------------------------------------- */
+/* collection manager operators */
+
+static int collection_link_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event))
+{
+ TODO_LAYER_OPERATORS;
+ BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_OT_collection_link not implemented yet");
+ return OPERATOR_CANCELLED;
+}
+
+static void COLLECTIONS_OT_collection_link(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Add Collection";
+ ot->idname = "COLLECTIONS_OT_collection_link";
+ ot->description = "Link a new collection to the active layer";
+
+ /* api callbacks */
+ ot->invoke = collection_link_invoke;
+ ot->poll = ED_operator_collections_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int collection_unlink_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event))
+{
+ TODO_LAYER_OPERATORS;
+ BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_OT_collection_unlink not implemented yet");
+ return OPERATOR_CANCELLED;
+}
+
+static void COLLECTIONS_OT_collection_unlink(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Add Collection";
+ ot->idname = "COLLECTIONS_OT_collection_unlink";
+ ot->description = "Link a new collection to the active layer";
+
+ /* api callbacks */
+ ot->invoke = collection_unlink_invoke;
+ ot->poll = operator_top_collection_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int collection_new_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ Scene *scene = CTX_data_scene(C);
+ SceneLayer *sl = CTX_data_scene_layer(C);
+
+ SceneCollection *sc = BKE_collection_add(scene, NULL, NULL);
+ BKE_collection_link(sl, sc);
+
+ TODO_LAYER_OPERATORS;
+ /* make sure the active element of the editor is correct */
+
+ /* add name as part of operator properties ? */
+ BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_OT_collection_new not implemented yet");
+ return OPERATOR_CANCELLED;
+}
+
+static void COLLECTIONS_OT_collection_new(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "New Collection";
+ ot->idname = "COLLECTIONS_OT_collection_new";
+ ot->description = "Add a new collection to the scene, and link it to the active layer";
+
+ /* api callbacks */
+ ot->invoke = collection_new_invoke;
+ ot->poll = ED_operator_collections_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int override_new_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event))
+{
+ TODO_LAYER_OPERATORS;
+ TODO_LAYER_OVERRIDE;
+ BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_OT_override_new not implemented yet");
+ return OPERATOR_CANCELLED;
+}
+
+static void COLLECTIONS_OT_override_new(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "New Override";
+ ot->idname = "COLLECTIONS_OT_override_new";
+ ot->description = "Add a new override to the active collection";
+
+ /* api callbacks */
+ ot->invoke = override_new_invoke;
+ ot->poll = operator_collection_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int delete_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event))
+{
+ TODO_LAYER_OPERATORS;
+ BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_OT_delete not implemented yet");
+ return OPERATOR_CANCELLED;
+}
+
+static void COLLECTIONS_OT_delete(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Delete";
+ ot->idname = "COLLECTIONS_OT_delete";
+ ot->description = "Delete active override or collection";
+
+ /* api callbacks */
+ ot->invoke = delete_invoke;
+ ot->poll = operator_not_master_collection_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int select_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event))
+{
+ TODO_LAYER_OPERATORS;
+ BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_OT_select not implemented yet");
+ return OPERATOR_CANCELLED;
+}
+
+static void COLLECTIONS_OT_select(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Select";
+ ot->idname = "COLLECTIONS_OT_select";
+ ot->description = "Change active collection or override";
+
+ /* api callbacks */
+ ot->invoke = select_invoke;
+ ot->poll = ED_operator_collections_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int rename_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event))
+{
+ TODO_LAYER_OPERATORS;
+ BKE_report(op->reports, RPT_ERROR, "COLLECTIONS_rename not implemented yet");
+ return OPERATOR_CANCELLED;
+}
+
+static void COLLECTIONS_OT_rename(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Rename";
+ ot->idname = "COLLECTIONS_OT_rename";
+ ot->description = "Rename active collection or override";
+
+ /* api callbacks */
+ ot->invoke = rename_invoke;
+ ot->poll = operator_not_master_collection_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+/* -------------------------------------------------------------------- */
+/* property editor operators */
+
+static int stubs_invoke(bContext *UNUSED(C), wmOperator *op, const wmEvent *UNUSED(event))
+{
+ TODO_LAYER_OPERATORS;
+ BKE_report(op->reports, RPT_ERROR, "Operator not implemented yet");
+ return OPERATOR_CANCELLED;
+}
+
+static void COLLECTIONS_OT_objects_add(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Add Objects";
+ ot->idname = "COLLECTIONS_OT_objects_add";
+ ot->description = "Add selected objects to collection";
+
+ /* api callbacks */
+ ot->invoke = stubs_invoke;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static void COLLECTIONS_OT_objects_remove(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Remove Object";
+ ot->idname = "COLLECTIONS_OT_objects_remove";
+ ot->description = "Remove object from collection";
+
+ /* api callbacks */
+ ot->invoke = stubs_invoke;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static void COLLECTIONS_OT_objects_select(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Select Objects";
+ ot->idname = "COLLECTIONS_OT_objects_select";
+ ot->description = "Selected collection objects";
+
+ /* api callbacks */
+ ot->invoke = stubs_invoke;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static void COLLECTIONS_OT_objects_deselect(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Deselect Objects";
+ ot->idname = "COLLECTIONS_OT_objects_deselect";
+ ot->description = "Deselected collection objects";
+
+ /* api callbacks */
+ ot->invoke = stubs_invoke;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
/* ************************** registration - operator types **********************************/
void collections_operatortypes(void)
{
+ WM_operatortype_append(COLLECTIONS_OT_delete);
+ WM_operatortype_append(COLLECTIONS_OT_select);
+ WM_operatortype_append(COLLECTIONS_OT_rename);
+ WM_operatortype_append(COLLECTIONS_OT_collection_link);
+ WM_operatortype_append(COLLECTIONS_OT_collection_unlink);
+ WM_operatortype_append(COLLECTIONS_OT_collection_new);
+ WM_operatortype_append(COLLECTIONS_OT_override_new);
+
+ WM_operatortype_append(COLLECTIONS_OT_objects_add);
+ WM_operatortype_append(COLLECTIONS_OT_objects_remove);
+ WM_operatortype_append(COLLECTIONS_OT_objects_select);
+ WM_operatortype_append(COLLECTIONS_OT_objects_deselect);
}
-void collections_keymap(wmKeyConfig *UNUSED(keyconf))
+void collections_keymap(wmKeyConfig *keyconf)
{
+ wmKeyMap *keymap = WM_keymap_find(keyconf, "Collections Manager", SPACE_COLLECTIONS, 0);
+
+ /* selection */
+ WM_keymap_add_item(keymap, "COLLECTIONS_OT_select", LEFTMOUSE, KM_CLICK, 0, 0);
+
+ WM_keymap_add_item(keymap, "COLLECTIONS_OT_rename", LEFTMOUSE, KM_DBL_CLICK, 0, 0);
+ WM_keymap_add_item(keymap, "COLLECTIONS_OT_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
+
+ WM_keymap_add_item(keymap, "COLLECTIONS_OT_collection_new", NKEY, KM_PRESS, KM_CTRL, 0);
+
+ WM_keymap_add_item(keymap, "COLLECTIONS_OT_delete", XKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "COLLECTIONS_OT_delete", DELKEY, KM_PRESS, 0, 0);
}