diff options
Diffstat (limited to 'source/blender/editors/space_buttons/buttons_header.c')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_header.c | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index 19bfe05e8a4..95f0b723828 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -38,10 +38,16 @@ #include "BLF_translation.h" #include "BKE_context.h" +#include "BKE_modifier.h" +#include "BKE_paint.h" +#include "BKE_scene.h" +#include "ED_buttons.h" #include "ED_screen.h" #include "ED_types.h" +#include "DNA_brush_types.h" +#include "DNA_object_force.h" #include "DNA_object_types.h" #include "UI_interface.h" @@ -54,25 +60,29 @@ #define B_CONTEXT_SWITCH 101 #define B_BUTSPREVIEW 102 -static void set_texture_context(bContext *C, SpaceButs *sbuts) +static void set_texture_context(const bContext *C, SpaceButs *sbuts) { - switch (sbuts->mainb) { - case BCONTEXT_MATERIAL: - sbuts->texture_context = SB_TEXC_MAT_OR_LAMP; - break; - case BCONTEXT_DATA: - { - Object *ob = CTX_data_active_object(C); - if (ob && ob->type == OB_LAMP) - sbuts->texture_context = SB_TEXC_MAT_OR_LAMP; - break; - } - case BCONTEXT_WORLD: - sbuts->texture_context = SB_TEXC_WORLD; - break; - case BCONTEXT_PARTICLE: - sbuts->texture_context = SB_TEXC_PARTICLES; - break; + Scene *scene = CTX_data_scene(C); + + if (BKE_scene_use_new_shading_nodes(scene)) { + return; /* No texture context in new shading mode */ + } + + if ((sbuts->mainb == BCONTEXT_WORLD) && ED_texture_context_check_world(C)) { + sbuts->texture_context = SB_TEXC_WORLD; + } + else if ((sbuts->mainb == BCONTEXT_MATERIAL) && ED_texture_context_check_material(C)) { + sbuts->texture_context = SB_TEXC_MATERIAL; + } + else if ((sbuts->mainb == BCONTEXT_DATA) && ED_texture_context_check_lamp(C)) { + sbuts->texture_context = SB_TEXC_LAMP; + } + else if ((sbuts->mainb == BCONTEXT_PARTICLE) && ED_texture_context_check_particles(C)) { + sbuts->texture_context = SB_TEXC_PARTICLES; + } + /* Else, just be sure that current context is valid! */ + else { + buttons_check_texture_context(C, sbuts); } } @@ -124,7 +134,8 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) #define BUTTON_HEADER_CTX(_ctx, _icon, _tip) \ if (sbuts->pathflag & (1 << _ctx)) { \ - but = uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, _icon, xco += BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)_ctx, 0, 0, TIP_(_tip)); \ + but = uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, _icon, xco += BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, \ + &(sbuts->mainb), 0.0, (float)_ctx, 0, 0, TIP_(_tip)); \ uiButClearFlag(but, UI_BUT_UNDO); \ } (void)0 |