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:
authorNicholas Bishop <nicholasbishop@gmail.com>2010-07-26 08:00:09 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2010-07-26 08:00:09 +0400
commitec19c7dffca92119c964dc18ef3af6efd1d8c0c9 (patch)
tree549f8b92d3badebd2a0e25710a86b639df9502c5 /source/blender/editors
parent6561da03ae1f0bd90b257c096f38c8432f413076 (diff)
== Sculpt ==
Fixed brush icons loading slowly * Changed brush icon property from an enum to a flag that toggles whether a custom file is used for the brush icon * Changed get_brush_icon to only handle loading external icons, built-ins are handled through the regular icon system * Modified preview icon drawing to allow built-in icons * When not using a custom icon, a default icon is selected based on the current tool TODO: * Allowing preview to show built-in icons makes the brush texture selector look ugly when nothing is selected. As discussed on IRC though, the nothing-selected state needs to be clarified anyway; I'll address this in another commit * Use image browser when selecting a custom icon * Selecting the default icon is ugly (uses the active object's mode), this can be fixed by making brushes know which paint mode they are part of
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/interface_icons.c47
-rw-r--r--source/blender/editors/interface/interface_widgets.c6
-rw-r--r--source/blender/editors/render/render_preview.c86
3 files changed, 50 insertions, 89 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 8db5724cf20..02586a86d1e 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -44,9 +44,13 @@
#include "BLI_blenlib.h"
#include "BLI_storage_types.h"
+#include "DNA_brush_types.h"
+#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_userdef_types.h"
-#include "DNA_brush_types.h"
+
+#include "RNA_access.h"
+#include "RNA_enum_types.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -1009,6 +1013,43 @@ void ui_id_icon_render(bContext *C, ID *id, int preview)
}
}
+static int ui_id_brush_get_icon(bContext *C, ID *id, int preview)
+{
+ Brush *br = (Brush*)id;
+
+ if(br->flag & BRUSH_CUSTOM_ICON) {
+ BKE_icon_getid(id);
+ ui_id_icon_render(C, id, preview);
+ }
+ else if(!id->icon_id) {
+ /* no icon found, reset it */
+
+ /* this is not nice, should probably make
+ brushes be strictly in one paint mode only
+ to avoid this kind of thing */
+ Object *ob = CTX_data_active_object(C);
+ EnumPropertyItem *items;
+ int tool;
+
+ if(ob->mode & OB_MODE_SCULPT) {
+ items = brush_sculpt_tool_items;
+ tool = br->sculpt_tool;
+ }
+ else if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT)) {
+ items = brush_vertexpaint_tool_items;
+ tool = br->vertexpaint_tool;
+ }
+ else {
+ items = brush_imagepaint_tool_items;
+ tool = br->imagepaint_tool;
+ }
+
+ RNA_enum_icon_from_value(items, tool, &id->icon_id);
+ }
+
+ return id->icon_id;
+}
+
int ui_id_icon_get(bContext *C, ID *id, int preview)
{
int iconid= 0;
@@ -1016,12 +1057,14 @@ int ui_id_icon_get(bContext *C, ID *id, int preview)
/* icon */
switch(GS(id->name))
{
+ case ID_BR:
+ iconid= ui_id_brush_get_icon(C, id, preview);
+ break;
case ID_MA: /* fall through */
case ID_TE: /* fall through */
case ID_IM: /* fall through */
case ID_WO: /* fall through */
case ID_LA: /* fall through */
- case ID_BR: /* fall through */
iconid= BKE_icon_getid(id);
/* checks if not exists, or changed */
ui_id_icon_render(C, id, preview);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index d2860adbf50..b457bf42ed1 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -747,11 +747,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
static void widget_draw_preview(BIFIconID icon, float aspect, float alpha, rcti *rect)
{
int w, h, x, y, size;
-
- /* only display previews for actual preview images .. ? */
- if (icon < BIFICONID_LAST)
- return;
-
+
w = rect->xmax - rect->xmin;
h = rect->ymax - rect->ymin;
size = MIN2(w, h);
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 2342d73768e..4bb1f630dad 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -104,83 +104,13 @@ static int qtest() {return 0;}
ImBuf* get_brush_icon(Brush *brush)
{
- 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,
-
- &datatoc_add_png,
- &datatoc_blur_png,
- &datatoc_clone_png,
- &datatoc_darken_png,
- &datatoc_lighten_png,
- &datatoc_mix_png,
- &datatoc_multiply_png,
- &datatoc_smear_png,
- &datatoc_soften_png,
- &datatoc_subtract_png,
- &datatoc_texdraw_png,
- &datatoc_vertexdraw_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,
-
- datatoc_add_png_size,
- datatoc_blur_png_size,
- datatoc_clone_png_size,
- datatoc_darken_png_size,
- datatoc_lighten_png_size,
- datatoc_mix_png_size,
- datatoc_multiply_png_size,
- datatoc_smear_png_size,
- datatoc_soften_png_size,
- datatoc_subtract_png_size,
- datatoc_texdraw_png_size,
- datatoc_vertexdraw_png_size,
- };
-
static const int flags = IB_rect|IB_multilayer|IB_metadata;
- static const int default_icon = BRUSH_ICON_SCULPTDRAW;
-
char path[240];
char *folder;
if (!(brush->icon_imbuf)) {
- if (brush->icon==BRUSH_ICON_FILE) {
+ if (brush->flag & BRUSH_CUSTOM_ICON) {
if (brush->icon_filepath[0]) {
// first use the path directly to try and load the file
@@ -202,21 +132,13 @@ ImBuf* get_brush_icon(Brush *brush)
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");
+ brush->id.icon_id = 0;
+ else
+ BKE_icon_changed(BKE_icon_getid(&(brush->id)));
return brush->icon_imbuf;
}