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:
authorElia Sarti <vekoon@gmail.com>2009-07-25 19:26:06 +0400
committerElia Sarti <vekoon@gmail.com>2009-07-25 19:26:06 +0400
commit24d39c0de496cb8c3640564757cae2c383efa154 (patch)
treeb7f7f0c5c168ac00da14404893e7bab62769a130 /source/blender/editors
parent5b12cb937890f1f85f365b4b1658cef241384ea2 (diff)
2.5 / Drag & Drop
Commit of basic architecture. Sorry, nothing fun to play with yet. Added two events: MOUSEDRAG and MOUSEDROP. MOUSEDRAG is sent when left-mouse clicking and then moving the cursor and every time the cursor is moved until the user releases the mouse button, thus generating a MOUSEDROP. Also added two dummy drag operators in view3d and outliner (place holders for now). Brecht and Ton: feel free to check/edit especially the event system code. I'm not sure that's the right way to do it. Also, I'm getting some mem leaks which I suspect are caused by my code.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_outliner/outliner.c51
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h2
-rw-r--r--source/blender/editors/space_outliner/outliner_ops.c5
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h1
-rw-r--r--source/blender/editors/space_view3d/view3d_ops.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c50
6 files changed, 113 insertions, 0 deletions
diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c
index 6ac094b3ad3..0df0cb46473 100644
--- a/source/blender/editors/space_outliner/outliner.c
+++ b/source/blender/editors/space_outliner/outliner.c
@@ -3452,6 +3452,57 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot)
}
+/* ****** Drag & Drop ****** */
+
+static int outliner_drag_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ wmWindow *win= CTX_wm_window(C);
+ Object *ob= CTX_data_active_object(C);
+ PointerRNA ptr;
+
+ RNA_pointer_create(NULL, &RNA_Object, ob, &ptr);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int outliner_drag_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+ switch(event->type) {
+ case MOUSEDRAG:
+
+ break;
+ case MOUSEDROP:
+ return OPERATOR_FINISHED;
+ case ESCKEY:
+ return OPERATOR_CANCELLED;
+ }
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int outliner_drag_exec(bContext *C, wmOperator *op)
+{
+ return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_drag(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Drag";
+ ot->idname= "OUTLINER_OT_drag";
+
+ /* api callbacks */
+ ot->invoke= outliner_drag_invoke;
+ ot->modal= outliner_drag_modal;
+ ot->exec= outliner_drag_exec;
+
+ ot->poll= ED_operator_outliner_active;
+
+ /* flags */
+ /* ot->flag= OPTYPE_UNDO; */
+}
+
+
/* ******************** */
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index fc305361fe1..d5986f3ebbd 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -127,6 +127,8 @@ void OUTLINER_OT_group_operation(struct wmOperatorType *ot);
void OUTLINER_OT_id_operation(struct wmOperatorType *ot);
void OUTLINER_OT_data_operation(struct wmOperatorType *ot);
+void OUTLINER_OT_drag(struct wmOperatorType *ot);
+
void OUTLINER_OT_show_one_level(struct wmOperatorType *ot);
void OUTLINER_OT_show_active(struct wmOperatorType *ot);
void OUTLINER_OT_show_hierarchy(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index 2e11eb379b4..417851982a3 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -56,6 +56,8 @@ void outliner_operatortypes(void)
WM_operatortype_append(OUTLINER_OT_id_operation);
WM_operatortype_append(OUTLINER_OT_data_operation);
+ WM_operatortype_append(OUTLINER_OT_drag);
+
WM_operatortype_append(OUTLINER_OT_show_one_level);
WM_operatortype_append(OUTLINER_OT_show_active);
WM_operatortype_append(OUTLINER_OT_show_hierarchy);
@@ -87,6 +89,9 @@ void outliner_keymap(wmWindowManager *wm)
WM_keymap_add_item(keymap, "OUTLINER_OT_item_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "OUTLINER_OT_operation", RIGHTMOUSE, KM_PRESS, 0, 0);
+ /* drag & drop */
+ WM_keymap_add_item(keymap, "OUTLINER_OT_drag", MOUSEDRAG, KM_ANY, 0, 0);
+
WM_keymap_add_item(keymap, "OUTLINER_OT_show_hierarchy", HOMEKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "OUTLINER_OT_show_active", PERIODKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 3e9382509f4..382ba68e95f 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -115,6 +115,7 @@ void VIEW3D_OT_select_extend(struct wmOperatorType *ot);
void VIEW3D_OT_select_circle(struct wmOperatorType *ot);
void VIEW3D_OT_select_border(struct wmOperatorType *ot);
void VIEW3D_OT_select_lasso(struct wmOperatorType *ot);
+void VIEW3D_OT_drag(struct wmOperatorType *ot);
/* view3d_view.c */
void VIEW3D_OT_smoothview(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index 112847272e5..69b297b2e03 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -73,6 +73,7 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_view_center);
WM_operatortype_append(VIEW3D_OT_select);
WM_operatortype_append(VIEW3D_OT_select_border);
+ WM_operatortype_append(VIEW3D_OT_drag);
WM_operatortype_append(VIEW3D_OT_clip_border);
WM_operatortype_append(VIEW3D_OT_select_circle);
WM_operatortype_append(VIEW3D_OT_smoothview);
@@ -216,6 +217,9 @@ void view3d_keymap(wmWindowManager *wm)
WM_keymap_add_item(keymap, "VIEW3D_OT_camera_to_view", PAD0, KM_PRESS, KM_ALT|KM_CTRL, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_snap_menu", SKEY, KM_PRESS, KM_SHIFT, 0);
+
+ /* drag & drop */
+ WM_keymap_add_item(keymap, "VIEW3D_OT_drag", MOUSEDRAG, KM_ANY, 0, 0);
/* radial control */
RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 2537982210a..8182069c142 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -1598,6 +1598,56 @@ void VIEW3D_OT_select(wmOperatorType *ot)
}
+/* ****** Drag & Drop ****** */
+
+static int view3d_drag_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ wmWindow *win= CTX_wm_window(C);
+ Object *ob= CTX_data_active_object(C);
+ PointerRNA ptr;
+
+ RNA_pointer_create(NULL, &RNA_Object, ob, &ptr);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int view3d_drag_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+ switch(event->type) {
+ case MOUSEDRAG:
+
+ break;
+ case MOUSEDROP:
+ return OPERATOR_FINISHED;
+ case ESCKEY:
+ return OPERATOR_CANCELLED;
+ }
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int view3d_drag_exec(bContext *C, wmOperator *op)
+{
+ return OPERATOR_FINISHED;
+}
+
+void VIEW3D_OT_drag(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Drag";
+ ot->idname= "VIEW3D_OT_drag";
+
+ /* api callbacks */
+ ot->invoke= view3d_drag_invoke;
+ ot->modal= view3d_drag_modal;
+ ot->exec= view3d_drag_exec;
+ ot->poll= ED_operator_view3d_active;
+
+ /* flags */
+ /* ot->flag= OPTYPE_UNDO; */
+}
+
+
/* -------------------- circle select --------------------------------------------- */
static void mesh_circle_doSelectVert(void *userData, EditVert *eve, int x, int y, int index)