Merging r38704 through r38732 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 26 Jul 2011 15:56:53 +0000 (15:56 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 26 Jul 2011 15:56:53 +0000 (15:56 +0000)
18 files changed:
doc/python_api/examples/mathutils.Vector.py
release/scripts/startup/bl_ui/space_text.py
release/scripts/templates/ui_menu.py [new file with mode: 0644]
release/scripts/templates/ui_menu_simple.py [new file with mode: 0644]
release/scripts/templates/ui_panel_simple.py [moved from release/scripts/templates/panel_simple.py with 76% similarity]
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/intern/text.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/object/object_add.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/transform/transform_snap.c
source/blender/editors/util/undo.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/makesrna/intern/rna_object_api.c
source/blender/makesrna/intern/rna_wm.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm.c
source/blenderplayer/bad_level_call_stubs/stubs.c

index 880b4ef2590185231f94419acb32aaa59e789349..bf1fc70353f52978b027243e79544c556118fd2e 100644 (file)
@@ -1,15 +1,15 @@
 import mathutils
 
 # zero length vector
-vec = mathutils.Vector((0, 0, 1))
+vec = mathutils.Vector((0.0, 0.0, 1.0))
 
 # unit length vector
 vec_a = vec.copy().normalize()
 
-vec_b = mathutils.Vector((0, 1, 2))
+vec_b = mathutils.Vector((0.0, 1.0, 2.0))
 
-vec2d = mathutils.Vector((1, 2))
-vec3d = mathutils.Vector((1, 0, 0))
+vec2d = mathutils.Vector((1.0, 2.0))
+vec3d = mathutils.Vector((1.0, 0.0, 0.0))
 vec4d = vec_a.to_4d()
 
 # other mathutuls types
@@ -34,9 +34,9 @@ vec_a + vec_b
 vec_a - vec_b
 vec_a * vec_b
 vec_a * 10.0
-vec_a * matrix
+matrix * vec_a
+quat * vec_a
 vec_a * vec_b
-vec_a * quat
 -vec_a
 
 
@@ -44,6 +44,7 @@ vec_a * quat
 x = vec_a[0]
 len(vec)
 vec_a[:] = vec_b
+vec_a[:] = 1.0, 2.0, 3.0
 vec2d[:] = vec3d[:2]
 
 
index 0fc8d937f6683b05b9a067a84fcb21786bf80878..582c9442a4a2ce56273ab9fd169d0c17780eaf82 100644 (file)
@@ -16,7 +16,7 @@
 #
 # ##### END GPL LICENSE BLOCK #####
 
-# <pep8 compliant>
+# <pep8-80 compliant>
 import bpy
 
 
@@ -36,10 +36,13 @@ class TEXT_HT_header(bpy.types.Header):
             sub = row.row(align=True)
             sub.menu("TEXT_MT_view")
             sub.menu("TEXT_MT_text")
+
             if text:
                 sub.menu("TEXT_MT_edit")
                 sub.menu("TEXT_MT_format")
 
+            sub.menu("TEXT_MT_templates")
+
         if text and text.is_modified:
             row = layout.row()
             row.alert = True
@@ -63,11 +66,13 @@ class TEXT_HT_header(bpy.types.Header):
             row = layout.row()
             if text.filepath:
                 if text.is_dirty:
-                    row.label(text="File: *%s (unsaved)" % text.filepath)
+                    row.label(text="File: *%r (unsaved)" % text.filepath)
                 else:
-                    row.label(text="File: %s" % text.filepath)
+                    row.label(text="File: %r" % text.filepath)
             else:
-                row.label(text="Text: External" if text.library else "Text: Internal")
+                row.label(text="Text: External"
+                          if text.library
+                          else "Text: Internal")
 
 
 class TEXT_PT_properties(bpy.types.Panel):
@@ -150,8 +155,12 @@ class TEXT_MT_view(bpy.types.Menu):
 
         layout.separator()
 
-        layout.operator("text.move", text="Top of File").type = 'FILE_TOP'
-        layout.operator("text.move", text="Bottom of File").type = 'FILE_BOTTOM'
+        layout.operator("text.move",
+                        text="Top of File",
+                        ).type = 'FILE_TOP'
+        layout.operator("text.move",
+                        text="Bottom of File",
+                        ).type = 'FILE_BOTTOM'
 
 
 class TEXT_MT_text(bpy.types.Menu):
@@ -185,19 +194,15 @@ class TEXT_MT_text(bpy.types.Menu):
             # XXX   uiMenuItemO(head, 0, "text.refresh_pyconstraints");
             #endif
 
-        layout.separator()
-
-        layout.menu("TEXT_MT_templates")
-
 
 class TEXT_MT_templates(bpy.types.Menu):
-    '''
-    Creates the menu items by scanning scripts/templates
-    '''
-    bl_label = "Script Templates"
+    bl_label = "Templates"
 
     def draw(self, context):
-        self.path_menu(bpy.utils.script_paths("templates"), "text.open", {"internal": True})
+        self.path_menu(bpy.utils.script_paths("templates"),
+                       "text.open",
+                       {"internal": True},
+                       )
 
 
 class TEXT_MT_edit_select(bpy.types.Menu):
@@ -246,8 +251,12 @@ class TEXT_MT_edit_to3d(bpy.types.Menu):
     def draw(self, context):
         layout = self.layout
 
-        layout.operator("text.to_3d_object", text="One Object").split_lines = False
-        layout.operator("text.to_3d_object", text="One Object Per Line").split_lines = True
+        layout.operator("text.to_3d_object",
+                        text="One Object",
+                        ).split_lines = False
+        layout.operator("text.to_3d_object",
+                        text="One Object Per Line",
+                        ).split_lines = True
 
 
 class TEXT_MT_edit(bpy.types.Menu):
diff --git a/release/scripts/templates/ui_menu.py b/release/scripts/templates/ui_menu.py
new file mode 100644 (file)
index 0000000..d3923b5
--- /dev/null
@@ -0,0 +1,49 @@
+import bpy
+
+
+class CustomMenu(bpy.types.Menu):
+    bl_label = "Custom Menu"
+    bl_idname = "OBJECT_MT_custom_menu"
+
+    def draw(self, context):
+        layout = self.layout
+
+        layout.operator("wm.open_mainfile")
+        layout.operator("wm.save_as_mainfile").copy = True
+
+        layout.operator("object.shade_smooth")
+
+        layout.label(text="Hello world!", icon='WORLD_DATA')
+
+        # use an operator enum property to populate a submenu
+        layout.operator_menu_enum("object.select_by_type",
+                                  property="type",
+                                  text="Select All by Type...",
+                                  )
+
+        # call another menu
+        layout.operator("wm.call_menu", text="Unwrap").name = "VIEW3D_MT_uv_map"
+
+
+def draw_item(self, context):
+       layout = self.layout
+       layout.menu(CustomMenu.bl_idname)
+
+
+def register():
+    bpy.utils.register_class(CustomMenu)
+
+    # lets add ourselves to the main header
+    bpy.types.INFO_HT_header.append(draw_item)
+
+
+def unregister():
+    bpy.utils.unregister_class(CustomMenu)
+
+    bpy.types.INFO_HT_header.remove(draw_item)
+
+if __name__ == "__main__":
+    register()
+
+    # The menu can also be called from scripts
+    bpy.ops.wm.call_menu(name=CustomMenu.bl_idname)
diff --git a/release/scripts/templates/ui_menu_simple.py b/release/scripts/templates/ui_menu_simple.py
new file mode 100644 (file)
index 0000000..2129dfd
--- /dev/null
@@ -0,0 +1,26 @@
+import bpy
+
+
+class SimpleCustomMenu(bpy.types.Menu):
+    bl_label = "Simple Custom Menu"
+    bl_idname = "OBJECT_MT_simple_custom_menu"
+
+    def draw(self, context):
+        layout = self.layout
+
+        layout.operator("wm.open_mainfile")
+        layout.operator("wm.save_as_mainfile")
+
+
+def register():
+    bpy.utils.register_class(SimpleCustomMenu)
+
+
+def unregister():
+    bpy.utils.unregister_class(SimpleCustomMenu)
+
+if __name__ == "__main__":
+    register()
+
+    # The menu can also be called from scripts
+    bpy.ops.wm.call_menu(name=SimpleCustomMenu.bl_idname)
similarity index 76%
rename from release/scripts/templates/panel_simple.py
rename to release/scripts/templates/ui_panel_simple.py
index e5bf70cb6546743bbd6c1574b9b06d811efed9bf..cde6126b6262c26a7cf45c36fea3872559622261 100644 (file)
@@ -1,8 +1,9 @@
 import bpy
 
 
-class OBJECT_PT_hello(bpy.types.Panel):
+class HelloWorldPanel(bpy.types.Panel):
     bl_label = "Hello World Panel"
+    bl_idname = "OBJECT_PT_hello"
     bl_space_type = "PROPERTIES"
     bl_region_type = "WINDOW"
     bl_context = "object"
@@ -22,11 +23,11 @@ class OBJECT_PT_hello(bpy.types.Panel):
 
 
 def register():
-    bpy.utils.register_class(OBJECT_PT_hello)
+    bpy.utils.register_class(HelloWorldPanel)
 
 
 def unregister():
-    bpy.utils.unregister_class(OBJECT_PT_hello)
+    bpy.utils.unregister_class(HelloWorldPanel)
 
 
 if __name__ == "__main__":
index 25fb6f9f9ff00c19da1620250de0053b4b57f6ef..18f6ad21333b144ba7ae23d68cf43b9cc35eb16f 100644 (file)
@@ -53,7 +53,7 @@ extern "C" {
                /* can be left blank, otherwise a,b,c... etc with no quotes */
 #define BLENDER_VERSION_CHAR   a
                /* alpha/beta/rc/release, docs use this */
-#define BLENDER_VERSION_CYCLE  release
+#define BLENDER_VERSION_CYCLE  beta
 
 struct ListBase;
 struct MemFile;
index da329503c9f161b2fa6632ca4cee684797dc8fec..56723476251f6fc264b10e618377544c8fba9c2e 100644 (file)
@@ -400,7 +400,13 @@ Text *add_text(const char *file, const char *relpath)
                llen++;
        }
 
-       if (llen!=0 || ta->nlines==0) {
+       /* create new line in cases:
+          - rest of line (if last line in file hasn't got \n terminator).
+            in this case content of such line would be used to fill text line buffer
+          - file is empty. in this case new line is needed to start editing from.
+          - last characted in buffer is \n. in this case new line is needed to
+            deal with newline at end of file. (see [#28087]) (sergey) */
+       if (llen!=0 || ta->nlines==0 || buffer[len-1]=='\n') {
                tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline");
                tmp->line= (char*) MEM_mallocN(llen+1, "textline_string");
                tmp->format= NULL;
index 62043f240e453fb6c44b4e38578edbb196226cb8..9e7717260e6f50a7a39930d08b49a2ceee8b6b8d 100644 (file)
@@ -484,6 +484,17 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                        }
                }
        }
+       else if (ELEM(but->type, MENU, PULLDOWN)) {
+               if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
+                       if(but->menu_create_func && WM_menutype_contains((MenuType *)but->poin)) {
+                               MenuType *mt= (MenuType *)but->poin;
+                               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s", mt->idname);
+                               data->color[data->totline]= 0x888888;
+                               data->totline++;
+                       }
+               }
+
+       }
 
        assert(data->totline < MAX_TOOLTIP_LINES);
        
index 7ca172c694575cb7a838e183ec634a5aa2563a9e..f5f97c6a5f6b2d0f7c14c4493675ccec7e32e3c5 100644 (file)
@@ -806,14 +806,14 @@ static int object_delete_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
-       int islamp= 0;
+       /* int islamp= 0; */ /* UNUSED */
        
        if(CTX_data_edit_object(C)) 
                return OPERATOR_CANCELLED;
        
        CTX_DATA_BEGIN(C, Base*, base, selected_bases) {
 
-               if(base->object->type==OB_LAMP) islamp= 1;
+               /* if(base->object->type==OB_LAMP) islamp= 1; */
 
                /* deselect object -- it could be used in other scenes */
                base->object->flag &= ~SELECT;
index 9ff73767b4c4753cd6d5aa89f7661ab69d43dcbd..d563c07baf3a196c5b68d959b2c8df7c302eb0ba 100644 (file)
@@ -129,7 +129,6 @@ void ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d)
                }
                else {
                        ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist);
-                       root_parent= v3d->camera;
                        DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB);
                        WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, v3d->camera);
                }
index d9d9b0f91028451135b210e5b5338e8bade3e24b..a4307ea336d324f2f6f79ce8945ef6db022bcf8a 100644 (file)
@@ -1944,6 +1944,11 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea
        int i;
        float asp[3] = {1.0f, 1.0f, 1.0f}; // TODO: Remove hard coded limit here (3)
 
+       if(max_index > 3) {
+               printf("applyGrid: invalid index %d, clamping\n", max_index);
+               max_index= 3;
+       }
+
        // Early bailing out if no need to snap
        if (fac[action] == 0.0f)
                return;
index 8a6ec7f75dbe516dec1a5919bda48fd387ae733f..a2381a208ef015a452d0e73fa1eeb8a5a3ae62dd 100644 (file)
@@ -358,19 +358,25 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
                                ret= 1;
                        }
                }
+               else {
+                       if (G.f & G_DEBUG) {
+                               printf("redo_cb: WM_operator_repeat_check returned false %s\n", op->type->name);
+                       }
+               }
 
                /* set region back */
                CTX_wm_region_set(C, ar);
        }
        else {
                if (G.f & G_DEBUG) {
-                       printf("redo_cb: WM_operator_repeat_check returned false %s\n", op->type->name);
+                       printf("redo_cb: ED_undo_operator_repeat called with NULL 'op'\n");
                }
        }
 
        return ret;
 }
 
+
 void ED_undo_operator_repeat_cb(bContext *C, void *arg_op, void *UNUSED(arg_unused))
 {
        ED_undo_operator_repeat(C, (wmOperator *)arg_op);
index d0393c970a62bf198ac9100fa63815a550a95786..70659994c558fc863a841945731940a843cce225 100644 (file)
@@ -1060,8 +1060,8 @@ static void weld_align_uv(bContext *C, int tool)
        if(tool == 's' || tool == 't' || tool == 'u') {
                 /* pass 1&2 variables */
                int i, j;
-               int starttmpl= -1, connectedtostarttmpl, startcorner;
-               int endtmpl= -1,   connectedtoendtmpl,   endcorner;
+               int starttmpl= -1, connectedtostarttmpl= -1, startcorner;
+               int endtmpl= -1,   connectedtoendtmpl= -1,   endcorner;
                MTFace *startface, *endface;
                int itmpl, jtmpl;
                EditVert *eve;
index 9018fd8c71a41025491ea07dbde566b192b568ad..21fa28af01a5b830999579ac38354847af3b2f6e 100644 (file)
@@ -544,7 +544,7 @@ void RNA_api_object(StructRNA *srna)
        /* location of point for test and max distance */
        parm= RNA_def_float_vector(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
        RNA_def_property_flag(parm, PROP_REQUIRED);
-       parm= RNA_def_float(func, "max_dist", sqrt(FLT_MAX), 0.0, FLT_MAX, "", "", 0.0, FLT_MAX);
+       RNA_def_float(func, "max_dist", sqrt(FLT_MAX), 0.0, FLT_MAX, "", "", 0.0, FLT_MAX);
 
        /* return location and normal */
        parm= RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "The location on the object closest to the point", -1e4, 1e4);
index 7ea4701dec3eb68432828227ebca614cea25c7e5..73221c47c90c3efa535744ad571bed647aaea2d2 100644 (file)
@@ -940,7 +940,7 @@ static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void *
                        rna_Operator_unregister(bmain, ot->ext.srna);
        }
 
-       /* create a new menu type */
+       /* create a new operator type */
        dummyot.ext.srna= RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator");
        RNA_def_struct_flag(dummyot.ext.srna, STRUCT_NO_IDPROPERTIES); /* operator properties are registered separately */
        dummyot.ext.data= data;
index 67294a8eb53a6ed2b52514b8e1cec9ae7f5a50c7..e6325e2101a4bd356eff34234cd029d83080b56f 100644 (file)
@@ -272,6 +272,7 @@ void                WM_operator_py_idname(char *to, const char *from);
 /* *************** menu types ******************** */
 struct MenuType                *WM_menutype_find(const char *idname, int quiet);
 int                                    WM_menutype_add(struct MenuType* mt);
+int                                    WM_menutype_contains(struct MenuType* mt);
 void                           WM_menutype_freelink(struct MenuType* mt);
 void                           WM_menutype_free(void);
 
index bcd5cf38f8835740c1ec7dbe4101727db099f12b..a535c0bc1f8e783439e8aa0451de86ab4f81ba5a 100644 (file)
@@ -175,6 +175,12 @@ int WM_menutype_add(MenuType* mt)
        return 1;
 }
 
+/* inefficient but only used for tooltip code */
+int WM_menutype_contains(MenuType* mt)
+{
+       return (mt != NULL && BLI_findindex(&menutypes, mt) != -1);
+}
+
 void WM_menutype_freelink(MenuType* mt)
 {
        BLI_freelinkN(&menutypes, mt);
index af179a30fb1edfe114c73cb67e3ad3271a20a641..0c8aa6a59595ac459db52faf016fd326481b2a72 100644 (file)
@@ -136,7 +136,6 @@ int RE_RenderInProgress(struct Render *re){return 0;}
 struct Scene *RE_GetScene(struct Render *re){return (struct Scene *) NULL;}
 void RE_Database_Free(struct Render *re){}
 void RE_FreeRender(struct Render *re){}
-void RE_shade_external(struct Render *re, struct ShadeInput *shi, struct ShadeResult *shr){}
 void RE_DataBase_GetView(struct Render *re, float mat[][4]){}
 int externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta){return 0;}
 float texture_value_blend(float tex, float out, float fact, float facg, int blendtype, int flip){return 0.0f;}