[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18936] branches/blender2.5/blender/source /blender: * Added description string to operator types, should be set along with ot->idname when defining ops.
Campbell Barton
ideasman42 at gmail.com
Thu Feb 12 04:39:58 CET 2009
Revision: 18936
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18936
Author: campbellbarton
Date: 2009-02-12 04:39:56 +0100 (Thu, 12 Feb 2009)
Log Message:
-----------
* Added description string to operator types, should be set along with ot->idname when defining ops.
* User interface uses this as a tooltip when NULL or "" is given.
* Python doc generation includes this description
* Python defined ops take the description as an argument.
* NULL check to image_ops.c, was crashing on exit when there was an image open.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/interface/interface.c
branches/blender2.5/blender/source/blender/editors/space_image/image_ops.c
branches/blender2.5/blender/source/blender/editors/space_sequencer/sequencer_add.c
branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h
branches/blender2.5/blender/source/blender/python/epy_doc_gen.py
branches/blender2.5/blender/source/blender/python/intern/bpy_opwrapper.c
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c 2009-02-12 01:47:45 UTC (rev 18935)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c 2009-02-12 03:39:56 UTC (rev 18936)
@@ -2308,6 +2308,10 @@
if(ot) str= ot->name;
else str= opname;
}
+
+ if ((!tip || tip[0]=='\0') && ot->description) {
+ tip= ot->description;
+ }
but= ui_def_but(block, type, -1, str, x1, y1, x2, y2, NULL, 0, 0, 0, 0, tip);
but->opname= opname;
Modified: branches/blender2.5/blender/source/blender/editors/space_image/image_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_image/image_ops.c 2009-02-12 01:47:45 UTC (rev 18935)
+++ branches/blender2.5/blender/source/blender/editors/space_image/image_ops.c 2009-02-12 03:39:56 UTC (rev 18936)
@@ -1221,6 +1221,9 @@
ImBuf *ibuf= ED_space_image_buffer(sima);
ImageSampleInfo *info= arg_info;
+ if(ibuf == NULL)
+ return;
+
draw_image_info(ar, ibuf->channels, info->x, info->y, info->colp,
info->colfp, info->zp, info->zfp);
}
Modified: branches/blender2.5/blender/source/blender/editors/space_sequencer/sequencer_add.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_sequencer/sequencer_add.c 2009-02-12 01:47:45 UTC (rev 18935)
+++ branches/blender2.5/blender/source/blender/editors/space_sequencer/sequencer_add.c 2009-02-12 03:39:56 UTC (rev 18936)
@@ -213,6 +213,7 @@
/* identifiers */
ot->name= "Add Scene Strip";
ot->idname= "SEQUENCER_OT_add_scene_strip";
+ ot->description= "Add a strip to the sequencer using a blender scene as a source";
/* api callbacks */
ot->invoke= sequencer_add_scene_strip_invoke;
@@ -300,6 +301,7 @@
/* identifiers */
ot->name= "Add Movie Strip";
ot->idname= "SEQUENCER_OT_add_movie_strip";
+ ot->description= "Add a movie strip to the sequencer";
/* api callbacks */
ot->invoke= sequencer_add_movie_strip_invoke;
@@ -400,6 +402,7 @@
/* identifiers */
ot->name= "Add Sound Strip";
ot->idname= "SEQUENCER_OT_add_sound_strip";
+ ot->description= "Add a sound strip to the sequencer";
/* api callbacks */
ot->invoke= sequencer_add_sound_strip_invoke;
@@ -492,6 +495,7 @@
/* identifiers */
ot->name= "Add Image Strip";
ot->idname= "SEQUENCER_OT_add_image_strip";
+ ot->description= "Add an image or image sequence to the sequencer";
/* api callbacks */
ot->invoke= sequencer_add_image_strip_invoke;
@@ -623,6 +627,7 @@
/* identifiers */
ot->name= "Add Effect Strip";
ot->idname= "SEQUENCER_OT_add_effect_strip";
+ ot->description= "Add an effect to the sequencer, most are applied ontop of existing strips";
/* api callbacks */
ot->invoke= sequencer_add_effect_strip_invoke;
Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h 2009-02-12 01:47:45 UTC (rev 18935)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h 2009-02-12 03:39:56 UTC (rev 18936)
@@ -123,7 +123,8 @@
struct wmOperatorType *next, *prev;
char *name; /* text for ui, undo */
- char *idname; /* unique identifier */
+ char *idname; /* unique identifier */
+ char *description; /* tooltips and python docs */
/* this callback executes the operator without any interactive input,
* parameters may be provided through operator properties. cannot use
Modified: branches/blender2.5/blender/source/blender/python/epy_doc_gen.py
===================================================================
--- branches/blender2.5/blender/source/blender/python/epy_doc_gen.py 2009-02-12 01:47:45 UTC (rev 18935)
+++ branches/blender2.5/blender/source/blender/python/epy_doc_gen.py 2009-02-12 03:39:56 UTC (rev 18936)
@@ -265,6 +265,7 @@
out.write('def %s(%s):\n' % (op, ', '.join(kw_args)))
out.write('\t"""\n')
+ out.write('\t%s\n' % rna_struct.description)
for desc in kw_arg_attrs:
out.write('\t%s\n' % desc)
out.write('\t at rtype: None\n')
Modified: branches/blender2.5/blender/source/blender/python/intern/bpy_opwrapper.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/intern/bpy_opwrapper.c 2009-02-12 01:47:45 UTC (rev 18935)
+++ branches/blender2.5/blender/source/blender/python/intern/bpy_opwrapper.c 2009-02-12 03:39:56 UTC (rev 18936)
@@ -44,6 +44,7 @@
void *next, *prev;
char idname[OP_MAX_TYPENAME];
char name[OP_MAX_TYPENAME];
+ char description[OP_MAX_TYPENAME]; // XXX should be longer?
PyObject *py_invoke;
PyObject *py_exec;
} PyOperatorType;
@@ -276,6 +277,7 @@
/* identifiers */
ot->name= pyot->name;
ot->idname= pyot->idname;
+ ot->description= pyot->description;
/* api callbacks */
if (pyot->py_invoke != Py_None)
@@ -342,10 +344,11 @@
char *idname= NULL;
char *name= NULL;
+ char *description= NULL;
PyObject *invoke= NULL;
PyObject *exec= NULL;
- if (!PyArg_ParseTuple(args, "ssOO", &idname, &name, &invoke, &exec)) {
+ if (!PyArg_ParseTuple(args, "sssOO", &idname, &name, &description, &invoke, &exec)) {
PyErr_SetString( PyExc_AttributeError, "expected 2 strings and 2 function objects");
return NULL;
}
@@ -362,8 +365,9 @@
pyot= MEM_callocN(sizeof(PyOperatorType), "PyOperatorType");
- strcpy(pyot->idname, idname);
- strcpy(pyot->name, name);
+ strncpy(pyot->idname, idname, sizeof(pyot->idname));
+ strncpy(pyot->name, name, sizeof(pyot->name));
+ strncpy(pyot->description, description, sizeof(pyot->description));
pyot->py_invoke= invoke;
pyot->py_exec= exec;
Py_INCREF(invoke);
Modified: branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c 2009-02-12 01:47:45 UTC (rev 18935)
+++ branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c 2009-02-12 03:39:56 UTC (rev 18936)
@@ -101,7 +101,7 @@
ot= MEM_callocN(sizeof(wmOperatorType), "operatortype");
ot->srna= RNA_def_struct(&BLENDER_RNA, "", "OperatorProperties");
opfunc(ot);
- RNA_def_struct_ui_text(ot->srna, ot->name, "DOC_BROKEN"); /* TODO - add a discription to wmOperatorType? */
+ RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description:""); // XXX All ops should have a description but for now allow them not to.
RNA_def_struct_identifier(ot->srna, ot->idname);
BLI_addtail(&global_ops, ot);
}
More information about the Bf-blender-cvs
mailing list