diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-04 16:18:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-04 16:18:07 +0400 |
commit | 1f77f7b05af24d3117d76d8c2ec43dbee031ab6a (patch) | |
tree | c3262b326313bb4c1cdf0dc6894204e4eaf3bdd9 /source/blender/editors | |
parent | 2f8f86e4f6afe8ecdff5c57bdbcc1c0d9b18301e (diff) |
Brush/Paint internal changes
- remove brush array for each Paint struct, just use a single brush pointer.
- removed rna function based template filtering.
- filter brushes using a flag on the brush and the pointer poll function.
- set the brushes using a new operator WM_OT_context_set_id().
TODO
- remake startup.blend, currently brush groupings are lost.
- rewrite WM_OT_context_set_id() to use rna introspection.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_buttons.c | 2 | ||||
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 6 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 65 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 36 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 26 | ||||
-rw-r--r-- | source/blender/editors/space_image/Makefile | 4 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_logic/logic_window.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_buttons.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 10 |
10 files changed, 49 insertions, 106 deletions
diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index c1ac863b362..c051678b86b 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -243,7 +243,7 @@ static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, Poi col= uiLayoutColumn(layout, 0); /* current Grease Pencil block */ // TODO: show some info about who owns this? - uiTemplateID(col, C, ctx_ptr, "grease_pencil", "GPENCIL_OT_data_add", NULL, "GPENCIL_OT_data_unlink", NULL); + uiTemplateID(col, C, ctx_ptr, "grease_pencil", "GPENCIL_OT_data_add", NULL, "GPENCIL_OT_data_unlink"); /* add new layer button - can be used even when no data, since it can add a new block too */ uiItemO(col, NULL, 0, "GPENCIL_OT_layer_add"); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 4b6b396483d..93e91d02599 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -669,11 +669,11 @@ uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout); void uiTemplateHeader(uiLayout *layout, struct bContext *C, int menus); void uiTemplateDopeSheetFilter(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr); void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, - char *newop, char *openop, char *unlinkop, char *filterop); + char *newop, char *openop, char *unlinkop); void uiTemplateIDBrowse(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, - char *newop, char *openop, char *unlinkop, char *filterop); + char *newop, char *openop, char *unlinkop); void uiTemplateIDPreview(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, - char *newop, char *openop, char *unlinkop, char *filterop, int rows, int cols); + char *newop, char *openop, char *unlinkop, int rows, int cols); void uiTemplateAnyID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *proptypename, char *text); void uiTemplatePathBuilder(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index ec57c813e20..e2c033bd68d 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -142,8 +142,6 @@ typedef struct TemplateID { ListBase *idlb; int prv_rows, prv_cols; - - char filterop[64]; } TemplateID; /* Search browse menu, assign */ @@ -173,9 +171,6 @@ static void id_search_cb(const bContext *C, void *arg_template, char *str, uiSea /* ID listbase */ for(id= lb->first; id; id= id->next) { if(!((flag & PROP_ID_SELF_CHECK) && id == id_from)) { - int filter_yes; - - filter_yes= 0; /* use filter */ if(RNA_property_type(template->prop)==PROP_POINTER) { @@ -185,43 +180,8 @@ static void id_search_cb(const bContext *C, void *arg_template, char *str, uiSea continue; } - if (template->filterop[0] != 0) { - /* XXX, remove this, use pointer filtering */ - PointerRNA ptr; - ReportList reports; - FunctionRNA *func; - ParameterList parms; - - RNA_id_pointer_create(id, &ptr); - - BKE_reports_init(&reports, RPT_PRINT); - - func= RNA_struct_find_function(&ptr, template->filterop); - - if (func) { - RNA_parameter_list_create(&parms, &ptr, func); - - RNA_parameter_set_lookup(&parms, "context", &C); - - if (RNA_function_call((bContext *)C, &reports, &ptr, func, &parms) == 0) { - int* ret; - RNA_parameter_get_lookup(&parms, "ret", (void **)&ret); - - if (!(*ret)) { - RNA_parameter_list_free(&parms); - continue; - } - else { - filter_yes= 1; - } - } - - RNA_parameter_list_free(&parms); - } - } - /* hide dot-datablocks, but only if filter does not force it visible */ - if(!filter_yes && U.uiflag & USER_HIDE_DOT) + if(U.uiflag & USER_HIDE_DOT) if ((id->name[2]=='.') && (str[0] != '.')) continue; @@ -392,7 +352,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) } } -static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, int flag, char *newop, char *openop, char *unlinkop, char *filterop) +static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, int flag, char *newop, char *openop, char *unlinkop) { uiBut *but; uiBlock *block; @@ -536,7 +496,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str uiBlockEndAlign(block); } -static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, char* filterop, int flag, int prv_rows, int prv_cols) +static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, int flag, int prv_rows, int prv_cols) { TemplateID *template; PropertyRNA *prop; @@ -555,11 +515,6 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char template->prv_rows = prv_rows; template->prv_cols = prv_cols; - if (filterop) - BLI_strncpy(template->filterop, filterop, sizeof(template->filterop)); - else - template->filterop[0] = 0; - if(newop) flag |= UI_ID_ADD_NEW; if(openop) @@ -573,25 +528,25 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char */ if(template->idlb) { uiLayoutRow(layout, 1); - template_ID(C, layout, template, type, flag, newop, openop, unlinkop, filterop); + template_ID(C, layout, template, type, flag, newop, openop, unlinkop); } MEM_freeN(template); } -void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, char *filterop) +void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop) { - ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, filterop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE, 0, 0); + ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE, 0, 0); } -void uiTemplateIDBrowse(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, char *filterop) +void uiTemplateIDBrowse(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop) { - ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, filterop, UI_ID_BROWSE|UI_ID_RENAME, 0, 0); + ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME, 0, 0); } -void uiTemplateIDPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, char *filterop, int rows, int cols) +void uiTemplateIDPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, int rows, int cols) { - ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, filterop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE|UI_ID_PREVIEWS, rows, cols); + ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE|UI_ID_PREVIEWS, rows, cols); } /************************ ID Chooser Template ***************************/ diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 8c786483d9f..b5cadb9c484 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -350,40 +350,40 @@ void ED_keymap_paint(wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.use_airbrush"); /* brush switching */ - kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", DKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.active_brush_name"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_id", DKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush"); RNA_string_set(kmi->ptr, "value", "SculptDraw"); - kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", SKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.active_brush_name"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_id", SKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush"); RNA_string_set(kmi->ptr, "value", "Smooth"); - kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.active_brush_name"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_id", PKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush"); RNA_string_set(kmi->ptr, "value", "Pinch/Magnify"); - kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", GKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.active_brush_name"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_id", GKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush"); RNA_string_set(kmi->ptr, "value", "Grab"); - kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", LKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.active_brush_name"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_id", LKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush"); RNA_string_set(kmi->ptr, "value", "Layer"); - kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", CKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.active_brush_name"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_id", CKEY, KM_PRESS, KM_SHIFT, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush"); RNA_string_set(kmi->ptr, "value", "Crease"); - kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", CKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.active_brush_name"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_id", CKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush"); RNA_string_set(kmi->ptr, "value", "Clay"); - kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", IKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.active_brush_name"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_id", IKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush"); RNA_string_set(kmi->ptr, "value", "Inflate/Deflate"); - kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", TKEY, KM_PRESS, KM_SHIFT, 0); // was just T in 2.4x - RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.active_brush_name"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_id", TKEY, KM_PRESS, KM_SHIFT, 0); // was just T in 2.4x + RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush"); RNA_string_set(kmi->ptr, "value", "Flatten/Contrast"); /* Vertex Paint mode */ diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index a1e1d387e4a..e7ea298e58c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2860,18 +2860,13 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio if (ss->cache->alt_smooth) { Paint *p= &sd->paint; Brush *br; - int i; BLI_strncpy(cache->saved_active_brush_name, brush->id.name+2, sizeof(cache->saved_active_brush_name)); - for(i = 0; i < p->brush_count; ++i) { - br = p->brushes[i]; - - if (strcmp(br->id.name+2, "Smooth")==0) { - paint_brush_set(p, br); - brush = br; - break; - } + br= (Brush *)find_id("BR", "Smooth"); + if(br) { + paint_brush_set(p, br); + brush = br; } } @@ -3414,16 +3409,9 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *unused) /* Alt-Smooth */ if (ss->cache->alt_smooth) { Paint *p= &sd->paint; - Brush *br; - int i; - - for(i = 0; i < p->brush_count; ++i) { - br = p->brushes[i]; - - if (strcmp(br->id.name+2, ss->cache->saved_active_brush_name)==0) { - paint_brush_set(p, br); - break; - } + Brush *br= (Brush *)find_id("BR", ss->cache->saved_active_brush_name); + if(br) { + paint_brush_set(p, br); } } diff --git a/source/blender/editors/space_image/Makefile b/source/blender/editors/space_image/Makefile index 7267d1abb93..1838b9ce73d 100644 --- a/source/blender/editors/space_image/Makefile +++ b/source/blender/editors/space_image/Makefile @@ -66,11 +66,11 @@ ifeq ($(WITH_LCMS), true) CPPFLAGS += -I$(BF_LCMS_INC) endif -ifeq ($(WHITH_CINEON), true) +ifeq ($(WITH_CINEON), true) CPPFLAGS += -DWITH_CINEON endif -ifeq ($(WHITH_HDR), true) +ifeq ($(WITH_HDR), true) CPPFLAGS += -DWITH_HDR endif diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index f58326239ae..357aa9dacdf 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -792,7 +792,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn uiLayoutSetContextPointer(layout, "edit_image", &imaptr); if(!compact) - uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL, NULL); + uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL); // XXX missing: reload, pack diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index cdfac81b0fc..1387631870d 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -4275,7 +4275,7 @@ static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr, bContext *C) { uiLayout *row, *col; - uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL, NULL); + uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL); if (!RNA_pointer_get(ptr, "sound").data) { uiItemL(layout, "Select a sound from the list or load a new one", 0); diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 494e42ea2c8..ef46f8a274d 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -237,7 +237,7 @@ static void nla_panel_animdata (const bContext *C, Panel *pa) /* Active Action Properties ------------------------------------- */ /* action */ row= uiLayoutRow(layout, 1); - uiTemplateID(row, (bContext *)C, &adt_ptr, "action", "ACTION_OT_new", NULL, NULL /*"ACTION_OT_unlink"*/, NULL); // XXX: need to make these operators + uiTemplateID(row, (bContext *)C, &adt_ptr, "action", "ACTION_OT_new", NULL, NULL /*"ACTION_OT_unlink"*/); // XXX: need to make these operators /* extrapolation */ row= uiLayoutRow(layout, 1); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index ad21f9659af..171f56c63fb 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -81,7 +81,7 @@ void node_buts_group(uiLayout *layout, bContext *C, PointerRNA *ptr) { - uiTemplateIDBrowse(layout, C, ptr, "nodetree", NULL, NULL, "", NULL); + uiTemplateIDBrowse(layout, C, ptr, "nodetree", NULL, NULL, ""); } static void node_buts_value(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -309,7 +309,7 @@ static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA bNode *node= ptr->data; uiLayout *col; - uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL, NULL); + uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL); if(!node->id) return; @@ -471,7 +471,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * PointerRNA imaptr; PropertyRNA *prop; - uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL, NULL); + uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); if(!node->id) return; @@ -508,7 +508,7 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point const char *layer_name; char scene_name[19]; - uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL, NULL); + uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL); if(!node->id) return; @@ -1211,7 +1211,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *C, PointerRNA *pt static void node_texture_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr) { - uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL, NULL); + uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); } static void node_texture_buts_output(uiLayout *layout, bContext *C, PointerRNA *ptr) |