Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wilkins <Jason.A.Wilkins@gmail.com>2010-07-20 06:18:10 +0400
committerJason Wilkins <Jason.A.Wilkins@gmail.com>2010-07-20 06:18:10 +0400
commit80e63236464a7e864c45e163dd059ffe61735926 (patch)
tree4fb120608572fd4a3126838be24253e68bf1e693 /source/blender/makesrna/intern/rna_brush.c
parent1033b60824c291089e568e1b20b8b1a734cb28e1 (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/rna_brush.c')
-rw-r--r--source/blender/makesrna/intern/rna_brush.c37
1 files changed, 36 insertions, 1 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);