diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-08-17 11:35:57 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-08-17 11:50:45 +0400 |
commit | e85bcfab044f0bee9819608bab8ca95f09809ff6 (patch) | |
tree | fb595e5903b6499eeb8e4db1edcb5a6edb5b60fc /source/blender | |
parent | ed26d9dd90cd67c0ee4d88e1b4da9f2e6ac963d0 (diff) |
Fix T41467: Modifier view buttons changing positions.
Commits early in this year (to save some space) broke this. Hopefully this time
it works in all cases - lastCageIndex is no more influenced by realtime/edit active states.
Also, inactivate buttons instead of hiding them, can be useful to set those data
even though it does not have any immediate effect.
Took the opportunity to switch cage buttons to RNA, btw.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 12 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 59 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 3 |
3 files changed, 24 insertions, 50 deletions
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 074a91ea2cf..b4d9561ec5d 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -353,6 +353,7 @@ int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *r_lastPossibleC /* Find the last modifier acting on the cage. */ for (i = 0; md; i++, md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); + bool supports_mapping; md->scene = scene; @@ -360,16 +361,17 @@ int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *r_lastPossibleC if (!(mti->flags & eModifierTypeFlag_SupportsEditmode)) continue; if (md->mode & eModifierMode_DisableTemporary) continue; + supports_mapping = modifier_supportsMapping(md); + if (r_lastPossibleCageIndex && supports_mapping) { + *r_lastPossibleCageIndex = i; + } + if (!(md->mode & eModifierMode_Realtime)) continue; if (!(md->mode & eModifierMode_Editmode)) continue; - if (!modifier_supportsMapping(md)) + if (!supports_mapping) break; - if (r_lastPossibleCageIndex) { - *r_lastPossibleCageIndex = i; - } - if (md->mode & eModifierMode_OnCage) cageIndex = i; } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 7f85a2314ca..028d34d1f80 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -756,28 +756,6 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna #define ERROR_LIBDATA_MESSAGE IFACE_("Can't edit external libdata") -static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v) -{ - Scene *scene = CTX_data_scene(C); - Object *ob = ob_v; - ModifierData *md = md_v; - int i, cageIndex = modifiers_getCageIndex(scene, ob, NULL, 0); - - /* undo button operation */ - md->mode ^= eModifierMode_OnCage; - - for (i = 0, md = ob->modifiers.first; md; ++i, md = md->next) { - if (md == md_v) { - if (i >= cageIndex) - md->mode ^= eModifierMode_OnCage; - break; - } - } - - WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); -} - static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v) { Object *ob = ob_v; @@ -834,7 +812,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, PointerRNA ptr; uiBut *but; uiBlock *block; - uiLayout *box, *column, *row; + uiLayout *box, *column, *row, *sub; uiLayout *result = NULL; int isVirtual = (md->mode & eModifierMode_Virtual); char str[128]; @@ -886,29 +864,22 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE); uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE); - if (mti->flags & eModifierTypeFlag_SupportsEditmode) - uiItemR(row, &ptr, "show_in_editmode", 0, "", ICON_NONE); + if (mti->flags & eModifierTypeFlag_SupportsEditmode) { + sub = uiLayoutRow(row, true); + if (!(md->mode & eModifierMode_Realtime)) { + uiLayoutSetActive(sub, false); + } + uiItemR(sub, &ptr, "show_in_editmode", 0, "", ICON_NONE); + } } if (ob->type == OB_MESH) { - if (modifier_couldBeCage(scene, md) && (index <= lastCageIndex)) { - /* -- convert to rna ? */ - but = uiDefIconButBitI(block, TOG, eModifierMode_OnCage, 0, ICON_MESH_DATA, 0, 0, - UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, - TIP_("Adjust edit cage to modifier result")); - if (index < cageIndex) - uiButSetFlag(but, UI_BUT_DISABLED); - uiButSetFunc(but, modifiers_setOnCage, ob, md); - } - else if (modifier_supportsCage(scene, md) && (index <= lastCageIndex)) { - uiBlockEndAlign(block); - - /* place holder button */ - uiBlockSetEmboss(block, UI_EMBOSSN); - but = uiDefIconBut(block, BUT, 0, ICON_NONE, 0, 0, UI_UNIT_X - 2, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, NULL); - uiButSetFlag(but, UI_BUT_DISABLED); - uiBlockSetEmboss(block, UI_EMBOSS); + if (modifier_supportsCage(scene, md) && (index <= lastCageIndex)) { + sub = uiLayoutRow(row, true); + if (index < cageIndex || !modifier_couldBeCage(scene, md)) { + uiLayoutSetActive(sub, false); + } + uiItemR(sub, &ptr, "show_on_cage", 0, "", ICON_NONE); } } /* tessellation point for curve-typed objects */ else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { @@ -918,7 +889,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, * message for this modifiers */ but = uiDefIconButBitI(block, TOG, eModifierMode_ApplyOnSpline, 0, ICON_SURFACE_DATA, 0, 0, UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, - TIP_("This modifier could be applied on splines' points only")); + TIP_("This modifier can only be applied on splines' points")); uiButSetFlag(but, UI_BUT_DISABLED); } else if (mti->type != eModifierTypeType_Constructive) { diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 6fd89e53b43..4911c106f53 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -3712,7 +3712,8 @@ void RNA_def_modifier(BlenderRNA *brna) prop = RNA_def_property(srna, "show_on_cage", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_OnCage); - RNA_def_property_ui_text(prop, "On Cage", "Enable direct editing of modifier control cage"); + RNA_def_property_ui_text(prop, "On Cage", "Adjust edit cage to modifier result"); + RNA_def_property_ui_icon(prop, ICON_MESH_DATA, 0); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); |