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:
authorBastien Montagne <montagne29@wanadoo.fr>2013-08-22 01:35:45 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2013-08-22 01:35:45 +0400
commitc26a4be5c013650f339f446185339aa71f2b88c4 (patch)
tree6879a4f3030d1e75206a4cb50ed4c00343b91247 /source/blender/editors/space_buttons
parent2a5b6d9c8f167724d2ddd2bf1a2b59036121ac81 (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/editors/space_buttons')
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c37
1 files changed, 25 insertions, 12 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;
+ }
}
}
}