Merge with trunk r38225
[blender-staging.git] / source / blender / editors / interface / interface_templates.c
index 25dbb68a25872a1d38aaf789ceec5aead19ffa86..9b1d4e1a627292445702f2d21fe385002ec4689a 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_dynamicpaint_types.h"
 #include "DNA_key_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_userdef_types.h"
@@ -43,6 +44,7 @@
 #include "BKE_animsys.h"
 #include "BKE_colortools.h"
 #include "BKE_context.h"
+#include "BKE_dynamicpaint.h"
 #include "BKE_global.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
@@ -741,7 +743,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif
                uiBlockBeginAlign(block);
                /* Softbody not allowed in this situation, enforce! */
                if ( ((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) 
-                       && (md->type!=eModifierType_Surface) ) 
+                       && !ELEM(md->type, eModifierType_Surface, eModifierType_DynamicPaint) ) 
                {
                        uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
                        uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
@@ -798,7 +800,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif
                box= uiLayoutBox(column);
                row= uiLayoutRow(box, 0);
                
-               if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) {
+               if (!ELEM3(md->type, eModifierType_Collision, eModifierType_Surface, eModifierType_DynamicPaint)) {
                        /* only here obdata, the rest of modifiers is ob level */
                        uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
                        
@@ -2025,6 +2027,13 @@ static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon, int
        else if(RNA_struct_is_a(itemptr->type, &RNA_TextureSlot)) {
                id= RNA_pointer_get(itemptr, "texture").data;
        }
+       else if(RNA_struct_is_a(itemptr->type, &RNA_DynamicPaintSurface)) {
+               DynamicPaintSurface *surface= (DynamicPaintSurface*)itemptr->data;
+
+               if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) return ICON_TEXTURE_SHADED;
+               else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) return ICON_OUTLINER_DATA_MESH;
+               else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) return ICON_FILE_IMAGE;
+       }
 
        /* get icon from ID */
        if(id) {
@@ -2121,6 +2130,24 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
                //uiItemR(row, itemptr, "mute", 0, "", ICON_MUTE_IPO_OFF);
                uiBlockSetEmboss(block, UI_EMBOSS);
        }
+       else if(itemptr->type == &RNA_DynamicPaintSurface) {
+               char name_final[96];
+               char *enum_name;
+               PropertyRNA *prop = RNA_struct_find_property(itemptr, "surface_type");
+               DynamicPaintSurface *surface= (DynamicPaintSurface*)itemptr->data;
+
+               RNA_property_enum_name(C, itemptr, prop, RNA_property_enum_get(itemptr, prop), &enum_name);
+
+               sprintf(name_final, "%s (%s)",name,enum_name);
+               uiItemL(sub, name_final, icon);
+               if (dynamicPaint_surfaceHasColorPreview(surface)) {
+                       uiBlockSetEmboss(block, UI_EMBOSSN);
+                       uiDefIconButR(block, OPTION, 0, (surface->flags & MOD_DPAINT_PREVIEW) ? ICON_RESTRICT_VIEW_OFF : ICON_RESTRICT_VIEW_ON,
+                               0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "show_preview", 0, 0, 0, 0, 0, NULL);
+                       uiBlockSetEmboss(block, UI_EMBOSS);
+               }
+               uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "is_active", i, 0, 0, 0, 0,  NULL);
+       }
        else
                uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */