diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2013-08-22 01:35:45 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2013-08-22 01:35:45 +0400 |
commit | c26a4be5c013650f339f446185339aa71f2b88c4 (patch) | |
tree | 6879a4f3030d1e75206a4cb50ed4c00343b91247 /source/blender | |
parent | 2a5b6d9c8f167724d2ddd2bf1a2b59036121ac81 (diff) |
Fix [#36530] Texture tab refreshing problem
That was not really a bug (code working as expected), but the way tex context was handled was a bit raw, now it is much smarter:
* Default fallback context (when current one is no more valid) will now choose "most specific" ones first (i.e. material/lamp/particules before world and "others").
* When using that default fallback context, previous one is stored and we try to revive it later, if possible. Thus e.g. object[mat tex ctxt] -> empty[default world ctxt] -> object[mat tex ctxt] is now working as expected.
* However, when user explicitely or implicitely (through e.g. going to Material context...) sets a tex context, previous one is not stored, so that only default fallback context switch may later automatically revive a previous (presumably user-set) context.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_texture.c | 37 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 11 |
3 files changed, 38 insertions, 15 deletions
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index 51e740e539f..8508123f942 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -150,20 +150,31 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts) bool valid_particles = ED_texture_context_check_particles(C); bool valid_others = ED_texture_context_check_others(C); + /* this is similar to direct user action, no need to keep "better" ctxt in _prev */ if ((sbuts->mainb == BCONTEXT_WORLD) && valid_world) { - sbuts->texture_context = SB_TEXC_WORLD; + sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_WORLD; } else if ((sbuts->mainb == BCONTEXT_MATERIAL) && valid_material) { - sbuts->texture_context = SB_TEXC_MATERIAL; + sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_MATERIAL; } else if ((sbuts->mainb == BCONTEXT_DATA) && valid_lamp) { - sbuts->texture_context = SB_TEXC_LAMP; + sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_LAMP; } else if ((sbuts->mainb == BCONTEXT_PARTICLE) && valid_particles) { - sbuts->texture_context = SB_TEXC_PARTICLES; + sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_PARTICLES; } else if ((ELEM(sbuts->mainb, BCONTEXT_MODIFIER, BCONTEXT_PHYSICS)) && valid_others) { - sbuts->texture_context = SB_TEXC_OTHER; + sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_OTHER; + } + /* Else, try to revive a previous "better" ctxt... */ + else if ((sbuts->texture_context_prev != sbuts->texture_context) && + (((sbuts->texture_context_prev == SB_TEXC_WORLD) && valid_world) || + ((sbuts->texture_context_prev == SB_TEXC_MATERIAL) && valid_material) || + ((sbuts->texture_context_prev == SB_TEXC_LAMP) && valid_lamp) || + ((sbuts->texture_context_prev == SB_TEXC_PARTICLES) && valid_particles) || + ((sbuts->texture_context_prev == SB_TEXC_OTHER) && valid_others))) + { + sbuts->texture_context = sbuts->texture_context_prev; } /* Else, just be sure that current context is valid! */ else if (((sbuts->texture_context == SB_TEXC_WORLD) && !valid_world) || @@ -172,13 +183,9 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts) ((sbuts->texture_context == SB_TEXC_PARTICLES) && !valid_particles) || ((sbuts->texture_context == SB_TEXC_OTHER) && !valid_others)) { - if (valid_others) { - sbuts->texture_context = SB_TEXC_OTHER; - } - else if (valid_world) { - sbuts->texture_context = SB_TEXC_WORLD; - } - else if (valid_material) { + /* this is default fallback, do keep "better" ctxt in _prev */ + sbuts->texture_context_prev = sbuts->texture_context; + if (valid_material) { sbuts->texture_context = SB_TEXC_MATERIAL; } else if (valid_lamp) { @@ -187,6 +194,12 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts) else if (valid_particles) { sbuts->texture_context = SB_TEXC_PARTICLES; } + else if (valid_world) { + sbuts->texture_context = SB_TEXC_WORLD; + } + else if (valid_others) { + sbuts->texture_context = SB_TEXC_OTHER; + } } } } diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 3e1196fb45a..5c308083f3c 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -132,8 +132,9 @@ typedef struct SpaceButs { short mainb, mainbo, mainbuser; /* context tabs */ short re_align, align; /* align for panels */ short preview; /* preview is signal to refresh */ - short texture_context; /* texture context selector (material, world, brush)*/ - char flag, pad; + /* texture context selector (material, lamp, particles, world, other)*/ + short texture_context, texture_context_prev; + char flag, pad[7]; void *path; /* runtime */ int pathflag, dataicon; /* runtime */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index f7a0d865274..7b72a29e3bf 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -959,6 +959,14 @@ static EnumPropertyItem *rna_SpaceProperties_texture_context_itemf(bContext *C, return item; } +static void rna_SpaceProperties_texture_context_set(PointerRNA *ptr, int value) +{ + SpaceButs *sbuts = (SpaceButs *)(ptr->data); + + /* User action, no need to keep "better" value in prev here! */ + sbuts->texture_context = sbuts->texture_context_prev = value; +} + /* Space Console */ static void rna_ConsoleLine_body_get(PointerRNA *ptr, char *value) { @@ -2194,7 +2202,8 @@ static void rna_def_space_buttons(BlenderRNA *brna) prop = RNA_def_property(srna, "texture_context", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, buttons_texture_context_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_SpaceProperties_texture_context_itemf"); + RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceProperties_texture_context_set", + "rna_SpaceProperties_texture_context_itemf"); RNA_def_property_ui_text(prop, "Texture Context", "Type of texture data to display and edit"); RNA_def_property_update(prop, NC_TEXTURE, NULL); |