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/interface/interface_icons.c
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/interface/interface_icons.c')
-rw-r--r--source/blender/editors/interface/interface_icons.c47
1 files changed, 45 insertions, 2 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);