diff options
-rw-r--r-- | release/scripts/ui/space_view3d_toolbar.py | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 144 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 6 | ||||
-rw-r--r-- | source/blender/editors/render/render_preview.c | 135 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 9 |
5 files changed, 149 insertions, 149 deletions
diff --git a/release/scripts/ui/space_view3d_toolbar.py b/release/scripts/ui/space_view3d_toolbar.py index 9bdfd3c5d15..dabd26f6aad 100644 --- a/release/scripts/ui/space_view3d_toolbar.py +++ b/release/scripts/ui/space_view3d_toolbar.py @@ -1126,8 +1126,8 @@ class VIEW3D_PT_tools_brush_appearance(PaintPanel): row = col.row(align=True) row.prop(brush, "icon", text="") - #row = col.row(align=True) - #row.prop(brush, "icon_filepath", text="") + row = col.row(align=True) + row.prop(brush, "icon_filepath", text="") # ********** default tools for weightpaint **************** diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index dcc96e65988..8e3cc0751b5 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -104,8 +104,6 @@ Brush *add_brush(const char *name) /* brush appearance */ - brush->icon_imbuf= get_brush_icon(brush); - brush->add_col[0]= 1.00; /* add mode color is light red */ brush->add_col[1]= 0.39; brush->add_col[2]= 0.39; @@ -130,9 +128,11 @@ Brush *copy_brush(Brush *brush) brushn= copy_libblock(brush); - if(brush->mtex.tex) id_us_plus((ID*)brush->mtex.tex); + if (brush->mtex.tex) + id_us_plus((ID*)brush->mtex.tex); - IMB_refImBuf(brushn->icon_imbuf); + if (brush->icon_imbuf) + brushn->icon_imbuf= IMB_dupImBuf(brush->icon_imbuf); brushn->curve= curvemapping_copy(brush->curve); @@ -151,7 +151,7 @@ void free_brush(Brush *brush) if (brush->mtex.tex) brush->mtex.tex->id.us--; - if (brush->icon==BRUSH_ICON_FILE && brush->icon_imbuf) + if (brush->icon_imbuf) IMB_freeImBuf(brush->icon_imbuf); BKE_previewimg_free(&(brush->preview)); @@ -211,140 +211,6 @@ void make_local_brush(Brush *brush) } } -/* image icon function */ -ImBuf* get_brush_icon(Brush *brush) -{ - extern char datatoc_blob_png; - extern char datatoc_clay_png; - extern char datatoc_crease_png; - extern char datatoc_draw_png; - extern char datatoc_fill_png; - extern char datatoc_flatten_png; - extern char datatoc_grab_png; - extern char datatoc_inflate_png; - extern char datatoc_layer_png; - extern char datatoc_nudge_png; - extern char datatoc_pinch_png; - extern char datatoc_scrape_png; - extern char datatoc_smooth_png; - extern char datatoc_snake_hook_png; - extern char datatoc_thumb_png; - extern char datatoc_twist_png; - - extern int datatoc_blob_png_size; - extern int datatoc_clay_png_size; - extern int datatoc_crease_png_size; - extern int datatoc_draw_png_size; - extern int datatoc_fill_png_size; - extern int datatoc_flatten_png_size; - extern int datatoc_grab_png_size; - extern int datatoc_inflate_png_size; - extern int datatoc_layer_png_size; - extern int datatoc_nudge_png_size; - extern int datatoc_pinch_png_size; - extern int datatoc_scrape_png_size; - extern int datatoc_smooth_png_size; - extern int datatoc_snake_hook_png_size; - extern int datatoc_thumb_png_size; - extern int datatoc_twist_png_size; - - void *icon_data[]= { - 0, - &datatoc_blob_png, - &datatoc_clay_png, - &datatoc_crease_png, - &datatoc_draw_png, - &datatoc_fill_png, - &datatoc_flatten_png, - &datatoc_grab_png, - &datatoc_inflate_png, - &datatoc_layer_png, - &datatoc_nudge_png, - &datatoc_pinch_png, - &datatoc_scrape_png, - &datatoc_smooth_png, - &datatoc_snake_hook_png, - &datatoc_thumb_png, - &datatoc_twist_png, - }; - - size_t icon_size[]= { - 0, - datatoc_blob_png_size, - datatoc_clay_png_size, - datatoc_crease_png_size, - datatoc_draw_png_size, - datatoc_fill_png_size, - datatoc_flatten_png_size, - datatoc_grab_png_size, - datatoc_inflate_png_size, - datatoc_layer_png_size, - datatoc_nudge_png_size, - datatoc_pinch_png_size, - datatoc_scrape_png_size, - datatoc_smooth_png_size, - datatoc_snake_hook_png_size, - datatoc_thumb_png_size, - datatoc_twist_png_size, - }; - - static ImBuf *icon_imbuf[BRUSH_ICON_COUNT]= { 0 }; - - static const int flags = IB_rect|IB_multilayer|IB_metadata; - - static const int default_icon = BRUSH_ICON_DRAW; - - char path[240]; - char *folder; - - if (!(brush->icon_imbuf)) { - if (brush->icon==BRUSH_ICON_FILE) { - - if (brush->icon_filepath[0]) { - // first use the path directly to try and load the file - - BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath)); - BLI_path_abs(path, G.sce); - - brush->icon_imbuf= IMB_loadiffname(path, flags); - - // otherwise lets try to find it in other directories - if (!(brush->icon_imbuf)) { - folder= BLI_get_folder(BLENDER_DATAFILES, "brushicons"); - - path[0]= 0; - - BLI_make_file_string(G.sce, path, folder, brush->icon_filepath); - - if (path[0]) - brush->icon_imbuf= IMB_loadiffname(path, flags); - } - } - - // if all else fails use a default image - if (!(brush->icon_imbuf)) { - if (!icon_imbuf[default_icon]) - icon_imbuf[default_icon]= IMB_ibImageFromMemory(icon_data[default_icon], icon_size[default_icon], flags); - - brush->icon_imbuf= icon_imbuf[default_icon]; - } - } - else { - if (!icon_imbuf[brush->icon]) - icon_imbuf[brush->icon]= IMB_ibImageFromMemory(icon_data[brush->icon], icon_size[brush->icon], flags); - - brush->icon_imbuf= icon_imbuf[brush->icon]; - } - - BKE_icon_changed(BKE_icon_getid(&(brush->id))); - } - - if (!(brush->icon_imbuf)) - printf("get_brush_icon: unable to resolve brush icon imbuf\n"); - - return brush->icon_imbuf; -} - /* Library Operations */ int brush_set_nr(Brush **current_brush, int nr, const char *name) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 06a0eb32a92..de2a3cd47cc 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1540,9 +1540,6 @@ static void lib_link_brush(FileData *fd, Main *main) brush->mtex.tex= newlibadr_us(fd, brush->id.lib, brush->mtex.tex); brush->clone.image= newlibadr_us(fd, brush->id.lib, brush->clone.image); - - brush->preview=0; - brush->icon_imbuf=0; } } } @@ -1557,6 +1554,9 @@ static void direct_link_brush(FileData *fd, Brush *brush) direct_link_curvemapping(fd, brush->curve); else brush_curve_preset(brush, CURVE_PRESET_SHARP); + + brush->preview= NULL; + brush->icon_imbuf= NULL; } static void direct_link_script(FileData *fd, Script *script) diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 8f0c10c0b30..236d40cc2ce 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -101,6 +101,131 @@ static int qtest() {return 0;} /* XXX */ +ImBuf* get_brush_icon(Brush *brush) +{ + extern char datatoc_blob_png; + extern char datatoc_clay_png; + extern char datatoc_crease_png; + extern char datatoc_draw_png; + extern char datatoc_fill_png; + extern char datatoc_flatten_png; + extern char datatoc_grab_png; + extern char datatoc_inflate_png; + extern char datatoc_layer_png; + extern char datatoc_nudge_png; + extern char datatoc_pinch_png; + extern char datatoc_scrape_png; + extern char datatoc_smooth_png; + extern char datatoc_snake_hook_png; + extern char datatoc_thumb_png; + extern char datatoc_twist_png; + + extern int datatoc_blob_png_size; + extern int datatoc_clay_png_size; + extern int datatoc_crease_png_size; + extern int datatoc_draw_png_size; + extern int datatoc_fill_png_size; + extern int datatoc_flatten_png_size; + extern int datatoc_grab_png_size; + extern int datatoc_inflate_png_size; + extern int datatoc_layer_png_size; + extern int datatoc_nudge_png_size; + extern int datatoc_pinch_png_size; + extern int datatoc_scrape_png_size; + extern int datatoc_smooth_png_size; + extern int datatoc_snake_hook_png_size; + extern int datatoc_thumb_png_size; + extern int datatoc_twist_png_size; + + void *icon_data[]= { + 0, + &datatoc_blob_png, + &datatoc_clay_png, + &datatoc_crease_png, + &datatoc_draw_png, + &datatoc_fill_png, + &datatoc_flatten_png, + &datatoc_grab_png, + &datatoc_inflate_png, + &datatoc_layer_png, + &datatoc_nudge_png, + &datatoc_pinch_png, + &datatoc_scrape_png, + &datatoc_smooth_png, + &datatoc_snake_hook_png, + &datatoc_thumb_png, + &datatoc_twist_png, + }; + + size_t icon_size[]= { + 0, + datatoc_blob_png_size, + datatoc_clay_png_size, + datatoc_crease_png_size, + datatoc_draw_png_size, + datatoc_fill_png_size, + datatoc_flatten_png_size, + datatoc_grab_png_size, + datatoc_inflate_png_size, + datatoc_layer_png_size, + datatoc_nudge_png_size, + datatoc_pinch_png_size, + datatoc_scrape_png_size, + datatoc_smooth_png_size, + datatoc_snake_hook_png_size, + datatoc_thumb_png_size, + datatoc_twist_png_size, + }; + + static const int flags = IB_rect|IB_multilayer|IB_metadata; + + static const int default_icon = BRUSH_ICON_DRAW; + + char path[240]; + char *folder; + + if (!(brush->icon_imbuf)) { + if (brush->icon==BRUSH_ICON_FILE) { + + if (brush->icon_filepath[0]) { + // first use the path directly to try and load the file + + BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath)); + BLI_path_abs(path, G.sce); + + brush->icon_imbuf= IMB_loadiffname(path, flags); + + // otherwise lets try to find it in other directories + if (!(brush->icon_imbuf)) { + folder= BLI_get_folder(BLENDER_DATAFILES, "brushicons"); + + path[0]= 0; + + BLI_make_file_string(G.sce, path, folder, brush->icon_filepath); + + if (path[0]) + brush->icon_imbuf= IMB_loadiffname(path, flags); + } + } + + // if all else fails use a default image + if (!(brush->icon_imbuf)) + brush->icon_imbuf= IMB_ibImageFromMemory(icon_data[default_icon], icon_size[default_icon], flags); + } + else { + if (!(brush->icon_imbuf)) + brush->icon_imbuf= IMB_ibImageFromMemory(icon_data[brush->icon], icon_size[brush->icon], flags); + } + + BKE_icon_changed(BKE_icon_getid(&(brush->id))); + } + + if (!(brush->icon_imbuf)) + printf("get_brush_icon: unable to resolve brush icon imbuf\n"); + + return brush->icon_imbuf; +} + typedef struct ShaderPreview { /* from wmJob */ void *owner; @@ -1114,6 +1239,14 @@ static void common_preview_startjob(void *customdata, short *stop, short *do_upd shader_preview_startjob(customdata, stop, do_update); } +static void common_preview_endjob(void *customdata) +{ + ShaderPreview *sp= customdata; + + if(sp->id && GS(sp->id->name) == ID_BR) + WM_main_add_notifier(NC_BRUSH|NA_EDITED, sp->id); +} + /* exported functions */ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *rect, int sizex, int sizey) @@ -1136,7 +1269,7 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r /* setup job */ WM_jobs_customdata(steve, sp, shader_preview_free); WM_jobs_timer(steve, 0.1, NC_MATERIAL, NC_MATERIAL); - WM_jobs_callbacks(steve, common_preview_startjob, NULL, NULL, NULL); + WM_jobs_callbacks(steve, common_preview_startjob, NULL, NULL, common_preview_endjob); WM_jobs_start(CTX_wm_manager(C), steve); } diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index b73b5f22141..bc71a862f4b 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -110,11 +110,12 @@ static void rna_Brush_icon_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Brush *br= (Brush*)ptr->data; - if (br->icon==BRUSH_ICON_FILE && br->icon_imbuf) + if (br->icon_imbuf) { IMB_freeImBuf(br->icon_imbuf); + br->icon_imbuf= NULL; + } - br->icon_imbuf= NULL; - br->icon_imbuf= get_brush_icon(br); + BKE_icon_changed(BKE_icon_getid(&(br->id))); WM_main_add_notifier(NC_BRUSH|NA_EDITED, br); } @@ -260,7 +261,7 @@ static void rna_def_brush(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem brush_icon_items[] = { - //{BRUSH_ICON_FILE, "FILE", 0, "File", ""}, + {BRUSH_ICON_FILE, "FILE", 0, "Use Image File", ""}, {BRUSH_ICON_BLOB, "BLOB", 0, "Blob", ""}, {BRUSH_ICON_CREASE, "CREASE", 0, "Crease", ""}, {BRUSH_ICON_CLAY, "CLAY", 0, "Clay", ""}, |