doxygen: blender/blenkernel tagged.
[blender.git] / source / blender / blenkernel / intern / icons.c
index 29314fb486503aa0a9daae169118559b19d0c748..09c189a8847d8e9c2554f6fbb1384c9de856cae5 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
 * $Id$
 *
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 */
 
+/** \file blender/blenkernel/intern/icons.c
+ *  \ingroup bke
+ */
+
+
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
@@ -38,7 +43,9 @@
 #include "DNA_material_types.h"
 #include "DNA_texture_types.h"
 #include "DNA_world_types.h"
+#include "DNA_brush_types.h"
 
+#include "BLI_utildefines.h"
 #include "BLI_ghash.h"
 
 #include "BKE_icons.h"
@@ -75,7 +82,7 @@ static void icon_free(void *val)
 
 /* create an id for a new icon and make sure that ids from deleted icons get reused
    after the integer number range is used up */
-static int get_next_free_id()
+static int get_next_free_id(void)
 {
        int startId = gFirstIconId;
 
@@ -104,14 +111,14 @@ void BKE_icons_init(int first_dyn_id)
                gIcons = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "icons_init gh");
 }
 
-void BKE_icons_free()
+void BKE_icons_free(void)
 {
        if(gIcons)
-               BLI_ghash_free(gIcons, 0, icon_free);
+               BLI_ghash_free(gIcons, NULL, icon_free);
        gIcons = NULL;
 }
 
-struct PreviewImage* BKE_previewimg_create() 
+struct PreviewImage* BKE_previewimg_create(void
 {
        PreviewImage* prv_img = NULL;
        int i;
@@ -120,6 +127,7 @@ struct PreviewImage* BKE_previewimg_create()
 
        for (i=0; i<PREVIEW_MIPMAPS; ++i) {
                prv_img->changed[i] = 1;
+               prv_img->changed_timestamp[i] = 0;
        }
        return prv_img;
 }
@@ -175,6 +183,9 @@ void BKE_previewimg_free_id(ID *id)
        } else if (GS(id->name) == ID_IM) {
                Image *img  = (Image*)id;
                BKE_previewimg_free(&img->preview);
+       } else if (GS(id->name) == ID_BR) {
+               Brush *br  = (Brush*)id;
+               BKE_previewimg_free(&br->preview);
        }
 }
 
@@ -202,14 +213,18 @@ PreviewImage* BKE_previewimg_get(ID *id)
                Image *img  = (Image*)id;
                if (!img->preview) img->preview = BKE_previewimg_create();
                prv_img = img->preview;
-       } 
+       } else if (GS(id->name) == ID_BR) {
+               Brush *br  = (Brush*)id;
+               if (!br->preview) br->preview = BKE_previewimg_create();
+               prv_img = br->preview;
+       }
 
        return prv_img;
 }
 
 void BKE_icon_changed(int id)
 {
-       Icon* icon = 0;
+       Icon* icon = NULL;
        
        if (!id || G.background) return;
 
@@ -224,6 +239,7 @@ void BKE_icon_changed(int id)
                        int i;
                        for (i=0; i<PREVIEW_MIPMAPS; ++i) {
                                prv->changed[i] = 1;
+                               prv->changed_timestamp[i]++;
                        }
                }
        }       
@@ -231,7 +247,7 @@ void BKE_icon_changed(int id)
 
 int BKE_icon_getid(struct ID* id)
 {
-       Icon* new_icon = 0;
+       Icon* new_icon = NULL;
 
        if (!id || G.background)
                return 0;
@@ -252,8 +268,8 @@ int BKE_icon_getid(struct ID* id)
        new_icon->type = GS(id->name);
        
        /* next two lines make sure image gets created */
-       new_icon->drawinfo = 0;
-       new_icon->drawinfo_free = 0;
+       new_icon->drawinfo = NULL;
+       new_icon->drawinfo_free = NULL;
 
        BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(id->icon_id), new_icon);
        
@@ -262,13 +278,13 @@ int BKE_icon_getid(struct ID* id)
 
 Icon* BKE_icon_get(int icon_id)
 {
-       Icon* icon = 0;
+       Icon* icon = NULL;
 
        icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id));
        
        if (!icon) {
                printf("BKE_icon_get: Internal error, no icon for icon ID: %d\n", icon_id);
-               return 0;
+               return NULL;
        }
 
        return icon;
@@ -276,7 +292,7 @@ Icon* BKE_icon_get(int icon_id)
 
 void BKE_icon_set(int icon_id, struct Icon* icon)
 {
-       Icon* old_icon = 0;
+       Icon* old_icon = NULL;
 
        old_icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id));
 
@@ -294,6 +310,6 @@ void BKE_icon_delete(struct ID* id)
 
        if (!id->icon_id) return; /* no icon defined for library object */
 
-       BLI_ghash_remove(gIcons, SET_INT_IN_POINTER(id->icon_id), 0, icon_free);
+       BLI_ghash_remove(gIcons, SET_INT_IN_POINTER(id->icon_id), NULL, icon_free);
        id->icon_id = 0;
 }