Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Sat, 29 Apr 2017 06:32:25 +0000 (16:32 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 29 Apr 2017 06:32:30 +0000 (16:32 +1000)
doc/python_api/examples/bpy.types.Menu.4.py [new file with mode: 0644]
intern/cycles/render/image.cpp
source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
source/blender/compositor/operations/COM_PlaneTrackOperation.cpp
source/blender/editors/interface/interface_handlers.c
source/blender/editors/render/render_opengl.c
source/blender/freestyle/intern/application/AppView.cpp

diff --git a/doc/python_api/examples/bpy.types.Menu.4.py b/doc/python_api/examples/bpy.types.Menu.4.py
new file mode 100644 (file)
index 0000000..04ceb66
--- /dev/null
@@ -0,0 +1,81 @@
+"""
+Extending the Button Context Menu
++++++++++++++++++++++++++++++++++
+
+This example enables you to insert your own menu entry into the common
+right click menu that you get while hovering over a value field,
+color, string, etc.
+
+To make the example work, you have to first select an object
+then right click on an user interface element (maybe a color in the
+material properties) and choose *Execute Custom Action*.
+
+Executing the operator will then print all values.
+"""
+
+import bpy
+from bpy.types import Menu
+
+
+def dump(obj, text):
+    for attr in dir(obj):
+        print("%r.%s = %s" % (obj, attr, getattr(obj, attr)))
+
+
+class WM_OT_button_context_test(bpy.types.Operator):
+    """Right click entry test"""
+    bl_idname = "wm.button_context_test"
+    bl_label = "Run Context Test"
+
+    @classmethod
+    def poll(cls, context):
+        return context.active_object is not None
+
+    def execute(self, context):
+        value = getattr(context, "button_pointer", None)
+        if value is not None:
+            dump(value, "button_pointer")
+
+        value = getattr(context, "button_prop", None)
+        if value is not None:
+            dump(value, "button_prop")
+
+        value = getattr(context, "button_operator", None)
+        if value is not None:
+            dump(value, "button_operator")
+
+        return {'FINISHED'}
+
+
+# This class has to be exactly named like that to insert an entry in the right click menu
+class WM_MT_button_context(Menu):
+    bl_label = "Unused"
+
+    def draw(self, context):
+        pass
+
+
+def menu_func(self, context):
+    layout = self.layout
+    layout.separator()
+    layout.operator(WM_OT_button_context_test.bl_idname)
+
+classes = (
+    WM_OT_button_context_test,
+    WM_MT_button_context,
+)
+
+
+def register():
+    for cls in classes:
+        bpy.utils.register_class(cls)
+    bpy.types.WM_MT_button_context.append(menu_func)
+
+
+def unregister():
+    for cls in classes:
+        bpy.utils.unregister_class(cls)
+    bpy.types.WM_MT_button_context.remove(menu_func)
+
+if __name__ == "__main__":
+    register()
index 04c8673262230576eea3623501555f06c647ef02..d26ea3e14e081a4a7a786e5dceb03a6c79c09e48 100644 (file)
@@ -888,26 +888,44 @@ void ImageManager::device_free_image(Device *device, DeviceScene *dscene, ImageD
                        device_memory *tex_img = NULL;
                        switch(type) {
                                case IMAGE_DATA_TYPE_FLOAT4:
+                                       if(slot >= dscene->tex_float4_image.size()) {
+                                               break;
+                                       }
                                        tex_img = dscene->tex_float4_image[slot];
                                        dscene->tex_float4_image[slot] = NULL;
                                        break;
                                case IMAGE_DATA_TYPE_BYTE4:
+                                       if(slot >= dscene->tex_byte4_image.size()) {
+                                               break;
+                                       }
                                        tex_img = dscene->tex_byte4_image[slot];
                                        dscene->tex_byte4_image[slot]= NULL;
                                        break;
                                case IMAGE_DATA_TYPE_HALF4:
+                                       if(slot >= dscene->tex_half4_image.size()) {
+                                               break;
+                                       }
                                        tex_img = dscene->tex_half4_image[slot];
                                        dscene->tex_half4_image[slot]= NULL;
                                        break;
                                case IMAGE_DATA_TYPE_FLOAT:
+                                       if(slot >= dscene->tex_float_image.size()) {
+                                               break;
+                                       }
                                        tex_img = dscene->tex_float_image[slot];
                                        dscene->tex_float_image[slot] = NULL;
                                        break;
                                case IMAGE_DATA_TYPE_BYTE:
+                                       if(slot >= dscene->tex_byte_image.size()) {
+                                               break;
+                                       }
                                        tex_img = dscene->tex_byte_image[slot];
                                        dscene->tex_byte_image[slot]= NULL;
                                        break;
                                case IMAGE_DATA_TYPE_HALF:
+                                       if(slot >= dscene->tex_half_image.size()) {
+                                               break;
+                                       }
                                        tex_img = dscene->tex_half_image[slot];
                                        dscene->tex_half_image[slot]= NULL;
                                        break;
index fb8730c9fa0ee312931c1f74ac1cb421fe28d773..d6affa6eee9a7b1696f2caa9b29a9c475abfd9d8 100644 (file)
@@ -29,8 +29,6 @@
 #include "BLI_math_color.h"
 
 extern "C" {
-#  include "BLI_jitter.h"
-
 #  include "BKE_node.h"
 }
 
index a56aa0cbaa6f98b55183000356caea54d6996cea..070b7562b2d1229bb7cc80cd6d644083999d1a93 100644 (file)
@@ -29,8 +29,6 @@
 #include "BLI_math_color.h"
 
 extern "C" {
-#  include "BLI_jitter.h"
-
 #  include "BKE_movieclip.h"
 #  include "BKE_node.h"
 #  include "BKE_tracking.h"
index ccf1c7305a9377d183bc73fb4dc753344a9ad498..59e0961f0db039c163942fe1b5a4ade8e6f2b050 100644 (file)
@@ -6752,6 +6752,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
 {
        uiPopupMenu *pup;
        uiLayout *layout;
+       MenuType *mt = WM_menutype_find("WM_MT_button_context", true);
        bool is_array, is_array_component;
        uiStringInfo label = {BUT_GET_LABEL, NULL};
 
@@ -6783,6 +6784,12 @@ static bool ui_but_menu(bContext *C, uiBut *but)
                /*bool is_idprop = RNA_property_is_idprop(prop);*/ /* XXX does not work as expected, not strictly needed */
                bool is_set = RNA_property_is_set(ptr, prop);
 
+               /* set the prop and pointer data for python access to the hovered ui element; TODO, index could be supported as well*/
+               PointerRNA temp_ptr;
+               RNA_pointer_create(NULL, &RNA_Property, but->rnaprop, &temp_ptr);
+               uiLayoutSetContextPointer(layout,"button_prop", &temp_ptr);
+               uiLayoutSetContextPointer(layout,"button_pointer", ptr);
+
                /* second slower test, saved people finding keyframe items in menus when its not possible */
                if (is_anim)
                        is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop);
@@ -6998,7 +7005,10 @@ static bool ui_but_menu(bContext *C, uiBut *but)
                                                0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
                        UI_but_func_set(but2, popup_add_shortcut_func, but, NULL);
                }
-               
+
+               /* Set the operator pointer for python access */
+               uiLayoutSetContextPointer(layout,"button_operator", but->opptr);
+
                uiItemS(layout);
        }
 
@@ -7045,6 +7055,14 @@ static bool ui_but_menu(bContext *C, uiBut *but)
        }
        uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0);
 
+       mt = WM_menutype_find("WM_MT_button_context", false);
+       if (mt) {
+               Menu menu = {NULL};
+               menu.layout = uiLayoutColumn(layout, false);
+               menu.type = mt;
+               mt->draw(C, &menu);
+       }
+
        UI_popup_menu_end(C, pup);
 
        return true;
index 8ac223b13898798227ea9a5bd8413e087df8b597..a8f3d1739bdb46e3482b97f7a849905d0eae26e0 100644 (file)
@@ -38,7 +38,6 @@
 #include "BLI_math_color_blend.h"
 #include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
-#include "BLI_jitter.h"
 #include "BLI_threads.h"
 #include "BLI_task.h"
 
index c331d1de9c96b170ac7451c32df737cb07ce3de4..9b1b02c8ee243fa63fc7ea4517d2087d94dc14ef 100644 (file)
  *  \ingroup freestyle
  */
 
-/* This header file needs to be included first, in order to avoid a
-   compilation with MinGW (see the commit log of revision 28253) */
-extern "C" {
-#include "BLI_jitter.h"
-}
-
 #include <iostream>
 
 #include "Controller.h"