[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36908] branches/soc-2010-jwilkins/source/ blender/windowmanager/intern/wm_operators.c: Merged wm_operators. c with trunk.
Jason Wilkins
Jason.A.Wilkins at gmail.com
Thu May 26 11:08:37 CEST 2011
Revision: 36908
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36908
Author: jwilkins
Date: 2011-05-26 09:08:37 +0000 (Thu, 26 May 2011)
Log Message:
-----------
Merged wm_operators.c with trunk. Had to set asside my on-surface brush code so I can reintegrate it later. revisions 34399-36874
Modified Paths:
--------------
branches/soc-2010-jwilkins/source/blender/windowmanager/intern/wm_operators.c
Property Changed:
----------------
branches/soc-2010-jwilkins/source/blender/windowmanager/intern/wm_operators.c
Modified: branches/soc-2010-jwilkins/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/windowmanager/intern/wm_operators.c 2011-05-26 07:16:56 UTC (rev 36907)
+++ branches/soc-2010-jwilkins/source/blender/windowmanager/intern/wm_operators.c 2011-05-26 09:08:37 UTC (rev 36908)
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -26,12 +26,19 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/windowmanager/intern/wm_operators.c
+ * \ingroup wm
+ */
+
+
#include <float.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stddef.h>
+#include <assert.h>
+#include "GHOST_C-api.h"
#include "MEM_guardedalloc.h"
@@ -54,6 +61,7 @@
#include "BLO_readfile.h"
#include "BKE_blender.h"
+#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_idprop.h"
@@ -386,10 +394,13 @@
BLI_addtail(&ot->macro, otmacro);
{
+ /* operator should always be found but in the event its not. dont segfault */
wmOperatorType *otsub = WM_operatortype_find(idname, 0);
+ if(otsub) {
RNA_def_pointer_runtime(ot->srna, otsub->idname, otsub->srna,
otsub->name, otsub->description);
}
+ }
return otmacro;
}
@@ -641,7 +652,7 @@
return op->type->exec(C, op);
}
else {
- pup= uiPupMenuBegin(C, op->type->name, ICON_NULL);
+ pup= uiPupMenuBegin(C, op->type->name, ICON_NONE);
layout= uiPupMenuLayout(pup);
uiItemsFullEnumO(layout, op->type->idname, (char*)RNA_property_identifier(prop), op->ptr->data, WM_OP_EXEC_REGION_WIN, 0);
uiPupMenuEnd(C, pup);
@@ -689,11 +700,16 @@
wmOperatorType *ot= arg1;
if(ot) {
- PointerRNA props_ptr;
- WM_operator_properties_create_ptr(&props_ptr, ot);
- RNA_property_enum_set(&props_ptr, ot->prop, GET_INT_FROM_POINTER(arg2));
- WM_operator_name_call(C, ot->idname, WM_OP_EXEC_DEFAULT, &props_ptr);
- WM_operator_properties_free(&props_ptr);
+ if(ot->prop) {
+ PointerRNA props_ptr;
+ WM_operator_properties_create_ptr(&props_ptr, ot);
+ RNA_property_enum_set(&props_ptr, ot->prop, GET_INT_FROM_POINTER(arg2));
+ WM_operator_name_call(C, ot->idname, WM_OP_EXEC_DEFAULT, &props_ptr);
+ WM_operator_properties_free(&props_ptr);
+ }
+ else {
+ printf("operator_enum_call_cb: op->prop for '%s' is NULL\n", ot->idname);
+ }
}
}
@@ -716,7 +732,7 @@
/* fake button, it holds space for search items */
uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxhHeight(), 180, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
- uiPopupBoundsBlock(block, 6.0f, 0, -20); /* move it downwards, mouse over button */
+ uiPopupBoundsBlock(block, 6, 0, -20); /* move it downwards, mouse over button */
uiEndBlock(C, block);
event= *(win->eventstate); /* XXX huh huh? make api call */
@@ -750,7 +766,7 @@
pup= uiPupMenuBegin(C, "OK?", ICON_QUESTION);
layout= uiPupMenuLayout(pup);
- uiItemFullO(layout, op->type->idname, message, ICON_NULL, properties, WM_OP_EXEC_REGION_WIN, 0);
+ uiItemFullO(layout, op->type->idname, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0);
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
@@ -867,6 +883,19 @@
return 1;
}
+wmOperator *WM_operator_last_redo(const bContext *C)
+{
+ wmWindowManager *wm= CTX_wm_manager(C);
+ wmOperator *op;
+
+ /* only for operators that are registered and did an undo push */
+ for(op= wm->operators.last; op; op= op->prev)
+ if((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO))
+ break;
+
+ return op;
+}
+
static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
{
wmOperator *op= arg_op;
@@ -892,7 +921,7 @@
uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE);
- uiPopupBoundsBlock(block, 4.0f, 0, 0);
+ uiPopupBoundsBlock(block, 4, 0, 0);
uiEndBlock(C, block);
return block;
@@ -926,7 +955,6 @@
wmOperator *op= data->op;
uiBlock *block;
uiLayout *layout;
- uiBut *btn;
uiStyle *style= U.uistyles.first;
block = uiBeginBlock(C, ar, "operator dialog", UI_EMBOSS);
@@ -942,12 +970,21 @@
/* clear so the OK button is left alone */
uiBlockSetFunc(block, NULL, NULL, NULL);
+ /* new column so as not to interfear with custom layouts [#26436] */
+ {
+ uiBlock *col_block;
+ uiLayout *col;
+ uiBut *btn;
+
+ col= uiLayoutColumn(layout, FALSE);
+ col_block= uiLayoutGetBlock(col);
/* Create OK button, the callback of which will execute op */
- btn= uiDefBut(block, BUT, 0, "OK", 0, 0, 0, 20, NULL, 0, 0, 0, 0, "");
- uiButSetFunc(btn, dialog_exec_cb, op, block);
+ btn= uiDefBut(col_block, BUT, 0, "OK", 0, -30, 0, 20, NULL, 0, 0, 0, 0, "");
+ uiButSetFunc(btn, dialog_exec_cb, op, col_block);
+ }
/* center around the mouse */
- uiPopupBoundsBlock(block, 4.0f, data->width/-2, data->height/2);
+ uiPopupBoundsBlock(block, 4, data->width/-2, data->height/2);
uiEndBlock(C, block);
return block;
@@ -970,7 +1007,7 @@
/* since ui is defined the auto-layout args are not used */
uiLayoutOperatorButs(C, layout, op, NULL, 'V', 0);
- uiPopupBoundsBlock(block, 4.0f, 0, 0);
+ uiPopupBoundsBlock(block, 4, 0, 0);
uiEndBlock(C, block);
return block;
@@ -1019,10 +1056,15 @@
int WM_operator_redo_popup(bContext *C, wmOperator *op)
{
+ /* CTX_wm_reports(C) because operator is on stack, not active in event system */
if((op->type->flag & OPTYPE_REGISTER)==0) {
- BKE_reportf(op->reports, RPT_ERROR, "Operator '%s' does not have register enabled, incorrect invoke function.", op->type->idname);
+ BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s' does not have register enabled, incorrect invoke function.", op->type->idname);
return OPERATOR_CANCELLED;
}
+ if(op->type->poll && op->type->poll(C)==0) {
+ BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s': wrong context.", op->type->idname);
+ return OPERATOR_CANCELLED;
+ }
uiPupBlock(C, wm_block_create_redo, op);
@@ -1080,6 +1122,29 @@
*/
}
+static int wm_resource_check_prev(void)
+{
+
+ char *res= BLI_get_folder_version(BLENDER_RESOURCE_PATH_USER, BLENDER_VERSION, TRUE);
+
+ // if(res) printf("USER: %s\n", res);
+
+#if 0 /* ignore the local folder */
+ if(res == NULL) {
+ /* with a local dir, copying old files isnt useful since local dir get priority for config */
+ res= BLI_get_folder_version(BLENDER_RESOURCE_PATH_LOCAL, BLENDER_VERSION, TRUE);
+ }
+#endif
+
+ // if(res) printf("LOCAL: %s\n", res);
+ if(res) {
+ return FALSE;
+ }
+ else {
+ return (BLI_get_folder_version(BLENDER_RESOURCE_PATH_USER, BLENDER_VERSION - 1, TRUE) != NULL);
+ }
+}
+
static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(arg))
{
uiBlock *block;
@@ -1089,7 +1154,7 @@
struct RecentFile *recent;
int i;
MenuType *mt= WM_menutype_find("USERPREF_MT_splash", TRUE);
- char url[64];
+ char url[96];
#ifdef NAN_BUILDINFO
int ver_width, rev_width;
@@ -1106,8 +1171,8 @@
sprintf(revision_str, "r%s", build_rev);
BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi);
- ver_width = BLF_width(style->widgetlabel.uifont_id, version_str)+5;
- rev_width = BLF_width(style->widgetlabel.uifont_id, revision_str)+5;
+ ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_str) + 5;
+ rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_str) + 5;
#endif //NAN_BUILDINFO
block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
@@ -1127,13 +1192,13 @@
uiBlockSetEmboss(block, UI_EMBOSS);
/* show the splash menu (containing interaction presets), using python */
if (mt) {
- Menu menu= {0};
+ Menu menu= {NULL};
menu.layout= layout;
menu.type= mt;
mt->draw(C, &menu);
// wmWindowManager *wm= CTX_wm_manager(C);
-// uiItemM(layout, C, "USERPREF_MT_keyconfigs", U.keyconfigstr, ICON_NULL);
+// uiItemM(layout, C, "USERPREF_MT_keyconfigs", U.keyconfigstr, ICON_NONE);
}
uiBlockSetEmboss(block, UI_EMBOSSP);
@@ -1141,26 +1206,38 @@
split = uiLayoutSplit(layout, 0, 0);
col = uiLayoutColumn(split, 0);
- uiItemL(col, "Links", ICON_NULL);
+ uiItemL(col, "Links", ICON_NONE);
uiItemStringO(col, "Donations", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment/");
- uiItemStringO(col, "Release Log", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-256-beta/");
- uiItemStringO(col, "Manual", ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:Manual");
+ uiItemStringO(col, "Release Log", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-257/");
+ uiItemStringO(col, "Manual", ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.5/Manual");
uiItemStringO(col, "Blender Website", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/");
uiItemStringO(col, "User Community", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community/"); //
+ if(strcmp(STRINGIFY(BLENDER_VERSION_CYCLE), "release")==0) {
+ BLI_snprintf(url, sizeof(url), "http://www.blender.org/documentation/blender_python_api_%d_%d" STRINGIFY(BLENDER_VERSION_CHAR) "_release", BLENDER_VERSION/100, BLENDER_VERSION%100);
+ }
+ else {
BLI_snprintf(url, sizeof(url), "http://www.blender.org/documentation/blender_python_api_%d_%d_%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION);
+ }
uiItemStringO(col, "Python API Reference", ICON_URL, "WM_OT_url_open", "url", url);
- uiItemL(col, "", ICON_NULL);
+ uiItemL(col, "", ICON_NONE);
col = uiLayoutColumn(split, 0);
- uiItemL(col, "Recent", ICON_NULL);
+
+ if(wm_resource_check_prev()) {
+ uiItemO(col, NULL, ICON_NEW, "WM_OT_copy_prev_settings");
+ uiItemS(col);
+ }
+
+ uiItemL(col, "Recent", ICON_NONE);
for(recent = G.recent_files.first, i=0; (i<5) && (recent); recent = recent->next, i++) {
uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
}
+
uiItemS(col);
uiItemO(col, NULL, ICON_RECOVER_LAST, "WM_OT_recover_last_session");
- uiItemL(col, "", ICON_NULL);
+ uiItemL(col, "", ICON_NONE);
- uiCenteredBoundsBlock(block, 0.0f);
+ uiCenteredBoundsBlock(block, 0);
uiEndBlock(C, block);
return block;
@@ -1237,7 +1314,7 @@
/* fake button, it holds space for search items */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list