diff options
author | Jason Wilkins <Jason.A.Wilkins@gmail.com> | 2010-07-20 06:18:10 +0400 |
---|---|---|
committer | Jason Wilkins <Jason.A.Wilkins@gmail.com> | 2010-07-20 06:18:10 +0400 |
commit | 80e63236464a7e864c45e163dd059ffe61735926 (patch) | |
tree | 4fb120608572fd4a3126838be24253e68bf1e693 /source/blender/makesrna/intern | |
parent | 1033b60824c291089e568e1b20b8b1a734cb28e1 (diff) |
* Images for brush icons are now reloaded when they are needed from an external file
* First, try to load the file from the given filename. This is either absolute or relative to the current .blend
* If file is found using the given filename directly then look for the file in the datafiles/brushicons directory (local, user, or system).
* Note: This commit does not update the .blend to reference the default icons
* Note: This commit does not make sure that the build system copies the default icons to the 2.52/datafiles/brushicons directory
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 37 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 17 |
2 files changed, 36 insertions, 18 deletions
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 6d5a06d4f81..22f61c3efcd 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -104,6 +104,36 @@ static int rna_Brush_is_imapaint_brush(Brush *me, bContext *C) return 0; } +static void rna_Brush_image_icon_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Brush *br= (Brush*)ptr->data; + + if (br->image_icon) { + // store path to external image so it can be reloaded later + BLI_strncpy(br->image_icon_path, br->image_icon->name, sizeof(br->image_icon_path)); + + // setting or loading image_icon bumps its user count + // we do not want writefile to save the image if a brush is the only user, + // so decrement the user count by one + id_us_min((ID*)(br->image_icon)); + } + else { + memset(br->image_icon_path, 0, sizeof(br->image_icon_path)); + } + + WM_main_add_notifier(NC_BRUSH|NA_EDITED, br); +} + +static void rna_Brush_image_icon_path_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Brush *br= (Brush*)ptr->data; + + if (br->image_icon) + br->image_icon = NULL; + + WM_main_add_notifier(NC_BRUSH|NA_EDITED, br); +} + #else static void rna_def_brush_texture_slot(BlenderRNA *brna) @@ -642,7 +672,12 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Image"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Image Icon", ""); - RNA_def_property_update(prop, 0, "rna_Brush_update"); + RNA_def_property_update(prop, 0, "rna_Brush_image_icon_update"); + + prop= RNA_def_property(srna, "image_icon_path", PROP_STRING, PROP_FILEPATH); + RNA_def_property_string_sdna(prop, NULL, "image_icon_path"); + RNA_def_property_ui_text(prop, "Image Icon Filepath", "File path for brush icon"); + RNA_def_property_update(prop, 0, "rna_Brush_image_icon_path_update"); /* clone tool */ prop= RNA_def_property(srna, "clone_image", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 7144b409299..7d8248b58ed 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -213,12 +213,6 @@ static int rna_Image_depth_get(PointerRNA *ptr) return depth; } -static int rna_Image_is_image_icon(Image *me, bContext *C) -{ - const char prefix[] = ".imageicon."; - return strncmp(me->id.name+2, prefix, sizeof(prefix)-1) == 0; -} - #else static void rna_def_imageuser(BlenderRNA *brna) @@ -298,9 +292,6 @@ static void rna_def_image(BlenderRNA *brna) {IMA_STD_FIELD, "ODD", 0, "Lower First", "Lower field first"}, {0, NULL, 0, NULL, NULL}}; - FunctionRNA *func; - PropertyRNA *parm; - srna= RNA_def_struct(brna, "Image", "ID"); RNA_def_struct_ui_text(srna, "Image", "Image datablock referencing an external or packed image"); RNA_def_struct_ui_icon(srna, ICON_IMAGE_DATA); @@ -342,14 +333,6 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Field Order", "Order of video fields. Select which lines are displayed first"); RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); - /* functions */ - func= RNA_def_function(srna, "is_image_icon", "rna_Image_is_image_icon"); - RNA_def_function_ui_description(func, "Returns true if Image name is prefixed with .imageicon."); - parm= RNA_def_pointer(func, "context", "Context", "", ""); - RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_boolean(func, "ret", 0, "", ""); - RNA_def_function_return(func, parm); - /* booleans */ prop= RNA_def_property(srna, "fields", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS); |