[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59556] branches/soc-2013-ui_replay/source /blender/editors/space_view3d/space_view3d.c: Can only add an operator to a custom panel or to the menubar if it isn' t already present.

Vincent Akkermans vincent at ack-err.net
Tue Aug 27 17:29:14 CEST 2013


Revision: 59556
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59556
Author:   ack-err
Date:     2013-08-27 15:29:14 +0000 (Tue, 27 Aug 2013)
Log Message:
-----------
Can only add an operator to a custom panel or to the menubar if it isn't already present.

Modified Paths:
--------------
    branches/soc-2013-ui_replay/source/blender/editors/space_view3d/space_view3d.c

Modified: branches/soc-2013-ui_replay/source/blender/editors/space_view3d/space_view3d.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/space_view3d/space_view3d.c	2013-08-27 15:27:41 UTC (rev 59555)
+++ branches/soc-2013-ui_replay/source/blender/editors/space_view3d/space_view3d.c	2013-08-27 15:29:14 UTC (rev 59556)
@@ -610,13 +610,16 @@
 	RNA_string_set(drop->ptr, "idname", ot->idname);
 }
 
-static int view3d_menubar_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
+static int view3d_menubar_drop_poll(bContext *C, wmDrag *drag, const wmEvent *UNUSED(event))
 {
 	wmOperatorType *ot = (wmOperatorType*)drag->poin;
+	ARegion *ar = CTX_wm_region(C);
 
-	if (drag->type == WM_DRAG_OP && ot) {
-		return 1;
+	if (drag->type == WM_DRAG_OP && ot && ar && ar->regiontype == RGN_TYPE_MENU_BAR) {
+		if (!BLI_findstring(&ar->operators, ot->idname, offsetof(OperatorListItem, optype_idname)))
+			return 1;
 	}
+	
 	return 0;
 }
 
@@ -654,12 +657,15 @@
 {
 	wmOperatorType *ot = (wmOperatorType*)drag->poin;
 	Panel *pa = NULL;
+	void *present_p = NULL;
 
 	if (drag->type == WM_DRAG_OP && ot) {
 		pa = over_panel(C, event);
-		return (pa != NULL);
+		if (pa != NULL)
+			present_p = BLI_findstring(&pa->operators, ot->idname, offsetof(OperatorListItem, optype_idname));
 	}
-	return 0;
+	
+	return pa != NULL && present_p == NULL;
 }
 
 /* region dropbox definition */




More information about the Bf-blender-cvs mailing list