[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59877] branches/soc-2013-ui_replay/source /blender: Custom buttons in the menubar copy over the operator properties from the operator button that was dragged there .
Vincent Akkermans
vincent at ack-err.net
Fri Sep 6 13:47:28 CEST 2013
Revision: 59877
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59877
Author: ack-err
Date: 2013-09-06 11:47:28 +0000 (Fri, 06 Sep 2013)
Log Message:
-----------
Custom buttons in the menubar copy over the operator properties from the operator button that was dragged there.
Modified Paths:
--------------
branches/soc-2013-ui_replay/source/blender/blenkernel/BKE_screen.h
branches/soc-2013-ui_replay/source/blender/blenkernel/intern/screen.c
branches/soc-2013-ui_replay/source/blender/blenloader/intern/readfile.c
branches/soc-2013-ui_replay/source/blender/blenloader/intern/writefile.c
branches/soc-2013-ui_replay/source/blender/editors/interface/interface_handlers.c
branches/soc-2013-ui_replay/source/blender/editors/interface/interface_panel.c
branches/soc-2013-ui_replay/source/blender/editors/screen/area.c
branches/soc-2013-ui_replay/source/blender/editors/space_view3d/space_view3d.c
branches/soc-2013-ui_replay/source/blender/makesdna/DNA_screen_types.h
branches/soc-2013-ui_replay/source/blender/windowmanager/WM_api.h
branches/soc-2013-ui_replay/source/blender/windowmanager/WM_types.h
branches/soc-2013-ui_replay/source/blender/windowmanager/intern/wm_dragdrop.c
branches/soc-2013-ui_replay/source/blender/windowmanager/intern/wm_operators.c
branches/soc-2013-ui_replay/source/blender/windowmanager/intern/wm_window.c
Modified: branches/soc-2013-ui_replay/source/blender/blenkernel/BKE_screen.h
===================================================================
--- branches/soc-2013-ui_replay/source/blender/blenkernel/BKE_screen.h 2013-09-06 11:35:59 UTC (rev 59876)
+++ branches/soc-2013-ui_replay/source/blender/blenkernel/BKE_screen.h 2013-09-06 11:47:28 UTC (rev 59877)
@@ -36,6 +36,7 @@
struct ARegion;
struct Header;
struct ListBase;
+struct OperatorListItem;
struct Menu;
struct Panel;
struct Scene;
@@ -318,5 +319,8 @@
void BKE_screen_free(struct bScreen *sc);
unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene);
+/* custom operator button items */
+void BKE_operator_list_item_free(struct OperatorListItem *oli);
+
#endif
Modified: branches/soc-2013-ui_replay/source/blender/blenkernel/intern/screen.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/blenkernel/intern/screen.c 2013-09-06 11:35:59 UTC (rev 59876)
+++ branches/soc-2013-ui_replay/source/blender/blenkernel/intern/screen.c 2013-09-06 11:47:28 UTC (rev 59877)
@@ -271,6 +271,7 @@
{
Panel *pa;
uiList *uilst;
+ OperatorListItem *oli;
if (st) {
ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
@@ -290,7 +291,9 @@
}
for (pa = ar->panels.first; pa; pa = pa->next) {
- BLI_freelistN(&pa->operators);
+ for (oli = pa->operators.first; oli; oli = oli->next) {
+ BKE_operator_list_item_free(oli);
+ }
}
BLI_freelistN(&ar->panels);
@@ -312,7 +315,10 @@
}
}
BLI_freelistN(&ar->ui_lists);
- BLI_freelistN(&ar->operators);
+
+ for (oli = ar->operators.first; oli; oli = oli->next) {
+ BKE_operator_list_item_free(oli);
+ }
}
/* not area itself */
@@ -371,6 +377,15 @@
return layer;
}
+/* Including the OperatorListItem */
+void BKE_operator_list_item_free(OperatorListItem *oli) {
+ if (oli->properties) {
+ IDP_FreeProperty(oli->properties);
+ MEM_freeN(oli->properties);
+ }
+ MEM_freeN(oli);
+}
+
/* ***************** Utilities ********************** */
/* Find a region of the specified type from the given area */
Modified: branches/soc-2013-ui_replay/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/blenloader/intern/readfile.c 2013-09-06 11:35:59 UTC (rev 59876)
+++ branches/soc-2013-ui_replay/source/blender/blenloader/intern/readfile.c 2013-09-06 11:47:28 UTC (rev 59877)
@@ -6109,6 +6109,7 @@
{
Panel *pa;
uiList *ui_list;
+ OperatorListItem *oli;
link_list(fd, &ar->panels);
@@ -6119,6 +6120,12 @@
pa->type = NULL;
link_list(fd, &pa->operators);
+
+ for (oli = pa->operators.first; oli; oli = oli->next) {
+ oli->properties = newdataadr(fd, oli->properties);
+ if (oli->properties)
+ IDP_DirectLinkProperty(oli->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
}
link_list(fd, &ar->ui_lists);
@@ -6132,6 +6139,12 @@
}
link_list(fd, &ar->operators);
+
+ for (oli = ar->operators.first; oli; oli = oli->next) {
+ oli->properties = newdataadr(fd, oli->properties);
+ if (oli->properties)
+ IDP_DirectLinkProperty(oli->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
if (spacetype == SPACE_EMPTY) {
/* unkown space type, don't leak regiondata */
Modified: branches/soc-2013-ui_replay/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/blenloader/intern/writefile.c 2013-09-06 11:35:59 UTC (rev 59876)
+++ branches/soc-2013-ui_replay/source/blender/blenloader/intern/writefile.c 2013-09-06 11:47:28 UTC (rev 59877)
@@ -2368,13 +2368,22 @@
}
}
+static void write_operator_list_item(WriteData *wd, OperatorListItem *oli)
+{
+ writestruct(wd, DATA, "OperatorListItem", 1, oli);
+
+ if (oli->properties) {
+ IDP_WriteProperty(oli->properties, wd);
+ }
+}
+
static void write_panel(WriteData *wd, Panel *pa)
{
OperatorListItem *oli;
writestruct(wd, DATA, "Panel", 1, pa);
for (oli = pa->operators.first; oli; oli = oli->next)
- writestruct(wd, DATA, "OperatorListItem", 1, oli);
+ write_operator_list_item(wd, oli);
}
static void write_region(WriteData *wd, ARegion *ar, int spacetype)
@@ -2497,7 +2506,7 @@
write_uilist(wd, ui_list);
for (oli = ar->operators.first; oli; oli = oli->next)
- writestruct(wd, DATA, "OperatorListItem", 1, oli);
+ write_operator_list_item(wd, oli);
}
sl= sa->spacedata.first;
Modified: branches/soc-2013-ui_replay/source/blender/editors/interface/interface_handlers.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/interface/interface_handlers.c 2013-09-06 11:35:59 UTC (rev 59876)
+++ branches/soc-2013-ui_replay/source/blender/editors/interface/interface_handlers.c 2013-09-06 11:47:28 UTC (rev 59877)
@@ -64,6 +64,7 @@
#include "BKE_tracking.h"
#include "BKE_unit.h"
#include "BKE_paint.h"
+#include "BKE_screen.h"
#include "ED_screen.h"
#include "ED_util.h"
@@ -905,7 +906,7 @@
{
wmDrag *drag;
- drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but), but->opptr);
+ drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but), but->opptr, but->opcontext);
if (but->imb)
WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_rctf_size_x(&but->rect), BLI_rctf_size_y(&but->rect));
}
@@ -5078,7 +5079,8 @@
OperatorListItem *oli;
oli = BLI_findstring(&pa->operators, ot->idname, offsetof(OperatorListItem, optype_idname));
- BLI_freelinkN(&pa->operators, oli);
+ BLI_remlink(&pa->operators, oli);
+ BKE_operator_list_item_free(oli);
}
static void remove_from_menu_bar(bContext *UNUSED(C), void *arg_ar, void *arg_optype)
@@ -5088,7 +5090,8 @@
OperatorListItem *oli;
oli = BLI_findstring(&ar->operators, ot->idname, offsetof(OperatorListItem, optype_idname));
- BLI_freelinkN(&ar->operators, oli);
+ BLI_remlink(&ar->operators, oli);
+ BKE_operator_list_item_free(oli);
}
static bool ui_but_menu(bContext *C, uiBut *but)
Modified: branches/soc-2013-ui_replay/source/blender/editors/interface/interface_panel.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/interface/interface_panel.c 2013-09-06 11:35:59 UTC (rev 59876)
+++ branches/soc-2013-ui_replay/source/blender/editors/interface/interface_panel.c 2013-09-06 11:47:28 UTC (rev 59877)
@@ -1693,9 +1693,10 @@
void uiPanelFree(Panel *pa)
{
if (pa == NULL) return;
+ OperatorListItem *oli;
- for (OperatorListItem *oli = pa->operators.first; oli; oli = oli->next) {
- MEM_freeN(oli);
+ while ((oli = (OperatorListItem*)BLI_pophead(&pa->operators))) {
+ BKE_operator_list_item_free(oli);
}
MEM_freeN(pa);
}
Modified: branches/soc-2013-ui_replay/source/blender/editors/screen/area.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/screen/area.c 2013-09-06 11:35:59 UTC (rev 59876)
+++ branches/soc-2013-ui_replay/source/blender/editors/screen/area.c 2013-09-06 11:47:28 UTC (rev 59877)
@@ -45,6 +45,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_screen.h"
+#include "BKE_idprop.h"
#include "RNA_access.h"
#include "RNA_types.h"
@@ -1901,8 +1902,10 @@
row = uiLayoutRow(layout, TRUE);
for (oli = ar->operators.first; oli; oli = oli->next) {
- if (strcmp(oli->context, CTX_data_mode_string(C)) == 0)
- uiItemO(row, NULL, ICON_NONE, oli->optype_idname);
+ if (strcmp(oli->context, CTX_data_mode_string(C)) == 0) {
+ wmOperatorType *ot = WM_operatortype_find(oli->optype_idname, TRUE);
+ uiItemFullO_ptr(row, ot, ot->name, ICON_AUTOMATIC, IDP_CopyProperty(oli->properties), oli->opcontext, 0);
+ }
}
/* draw bottom bar */
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-09-06 11:35:59 UTC (rev 59876)
+++ branches/soc-2013-ui_replay/source/blender/editors/space_view3d/space_view3d.c 2013-09-06 11:47:28 UTC (rev 59877)
@@ -48,6 +48,7 @@
#include "BKE_icons.h"
#include "BKE_object.h"
#include "BKE_screen.h"
+#include "BKE_idprop.h"
#include "ED_render.h"
#include "ED_space_api.h"
@@ -604,11 +605,18 @@
RNA_string_set(drop->ptr, "filepath", drag->path);
}
-
static void view3d_menubar_drop_copy(const bContext *UNUSED(C), const wmEvent *UNUSED(event), wmDrag *drag, wmDropBox *drop)
{
wmOperatorType *ot = (wmOperatorType*)drag->poin;
- RNA_string_set(drop->ptr, "idname", ot->idname);
+ /* replace the drop ptr with the passed ptr so it can be copied by the drag operator */
+ if (drag->ptr && drag->ptr->data) {
+ WM_operator_properties_free(drop->ptr);
+ drop->ptr->data = IDP_CopyProperty(drag->ptr->data);
+ }
+ /* temporarily set the properties for the drag operator in the copied ptr
+ * this is effectively piggy backing on the properties for the OperatorListItem */
+ RNA_string_set(drop->ptr, "COPY_idname", ot->idname);
+ RNA_int_set(drop->ptr, "COPY_opcontext", drag->opcontext);
}
static int view3d_menubar_drop_poll(bContext *C, wmDrag *drag, const wmEvent *UNUSED(event))
Modified: branches/soc-2013-ui_replay/source/blender/makesdna/DNA_screen_types.h
===================================================================
--- branches/soc-2013-ui_replay/source/blender/makesdna/DNA_screen_types.h 2013-09-06 11:35:59 UTC (rev 59876)
+++ branches/soc-2013-ui_replay/source/blender/makesdna/DNA_screen_types.h 2013-09-06 11:47:28 UTC (rev 59877)
@@ -193,6 +193,9 @@
struct OperatorListItem *next, *prev;
char optype_idname[64];
char context[64];
+ struct IDProperty *properties;
+ int opcontext;
+ int pad;
} OperatorListItem;
@@ -224,13 +227,12 @@
ListBase panels; /* Panel */
ListBase ui_lists; /* uiList */
ListBase handlers; /* wmEventHandler */
+ ListBase operators; /* OperatorListItem for custom tool shelf */
struct wmTimer *regiontimer; /* blend in/out */
char *headerstr; /* use this string to draw info */
void *regiondata; /* XXX 2.50, need spacedata equivalent? */
-
- ListBase operators; /* OperatorListItem for custom tool shelf */
} ARegion;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list