Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2008 Blender Foundation. 00019 * All rights reserved. 00020 * 00021 * 00022 * Contributor(s): Blender Foundation 00023 * 00024 * ***** END GPL LICENSE BLOCK ***** 00025 */ 00026 00032 #include <string.h> 00033 #include <stdio.h> 00034 00035 #include "BLI_blenlib.h" 00036 #include "BLI_utildefines.h" 00037 00038 #include "BLF_translation.h" 00039 00040 #include "BKE_context.h" 00041 00042 #include "ED_screen.h" 00043 #include "ED_types.h" 00044 00045 #include "DNA_object_types.h" 00046 00047 #include "UI_interface.h" 00048 #include "UI_resources.h" 00049 #include "UI_view2d.h" 00050 00051 #include "buttons_intern.h" 00052 00053 00054 #define B_CONTEXT_SWITCH 101 00055 #define B_BUTSPREVIEW 102 00056 00057 static void set_texture_context(bContext *C, SpaceButs *sbuts) 00058 { 00059 switch(sbuts->mainb) { 00060 case BCONTEXT_MATERIAL: 00061 sbuts->texture_context = SB_TEXC_MAT_OR_LAMP; 00062 break; 00063 case BCONTEXT_DATA: 00064 { 00065 Object *ob = CTX_data_active_object(C); 00066 if(ob && ob->type==OB_LAMP) 00067 sbuts->texture_context = SB_TEXC_MAT_OR_LAMP; 00068 break; 00069 } 00070 case BCONTEXT_WORLD: 00071 sbuts->texture_context = SB_TEXC_WORLD; 00072 break; 00073 case BCONTEXT_PARTICLE: 00074 sbuts->texture_context = SB_TEXC_PARTICLES; 00075 break; 00076 } 00077 } 00078 00079 static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event) 00080 { 00081 SpaceButs *sbuts= CTX_wm_space_buts(C); 00082 00083 if(!sbuts) /* editor type switch */ 00084 return; 00085 00086 switch(event) { 00087 case B_CONTEXT_SWITCH: 00088 case B_BUTSPREVIEW: 00089 ED_area_tag_redraw(CTX_wm_area(C)); 00090 00091 set_texture_context(C, sbuts); 00092 00093 sbuts->preview= 1; 00094 break; 00095 } 00096 00097 sbuts->mainbuser= sbuts->mainb; 00098 } 00099 00100 #define BUT_UNIT_X (UI_UNIT_X+2) 00101 00102 void buttons_header_buttons(const bContext *C, ARegion *ar) 00103 { 00104 SpaceButs *sbuts= CTX_wm_space_buts(C); 00105 uiBlock *block; 00106 uiBut *but; 00107 int xco, yco= 2; 00108 00109 buttons_context_compute(C, sbuts); 00110 00111 block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); 00112 uiBlockSetHandleFunc(block, do_buttons_buttons, NULL); 00113 00114 xco= ED_area_header_switchbutton(C, block, yco); 00115 00116 uiBlockSetEmboss(block, UI_EMBOSS); 00117 00118 xco -= UI_UNIT_X; 00119 00120 // Default panels 00121 00122 uiBlockBeginAlign(block); 00123 00124 #define BUTTON_HEADER_CTX(_ctx, _icon, _tip) \ 00125 if(sbuts->pathflag & (1<<_ctx)) { \ 00126 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)); \ 00127 uiButClearFlag(but, UI_BUT_UNDO); \ 00128 } \ 00129 00130 BUTTON_HEADER_CTX(BCONTEXT_RENDER, ICON_SCENE, N_("Render")) 00131 BUTTON_HEADER_CTX(BCONTEXT_SCENE, ICON_SCENE_DATA, N_("Scene")); 00132 BUTTON_HEADER_CTX(BCONTEXT_WORLD, ICON_WORLD, N_("World")); 00133 BUTTON_HEADER_CTX(BCONTEXT_OBJECT, ICON_OBJECT_DATA, N_("Object")); 00134 BUTTON_HEADER_CTX(BCONTEXT_CONSTRAINT, ICON_CONSTRAINT, N_("Object Constraints")); 00135 BUTTON_HEADER_CTX(BCONTEXT_MODIFIER, ICON_MODIFIER, N_("Object Modifiers")); 00136 BUTTON_HEADER_CTX(BCONTEXT_DATA, sbuts->dataicon, N_("Object Data")); 00137 BUTTON_HEADER_CTX(BCONTEXT_BONE, ICON_BONE_DATA, N_("Bone")); 00138 BUTTON_HEADER_CTX(BCONTEXT_BONE_CONSTRAINT, ICON_CONSTRAINT_BONE, N_("Bone Constraints")); 00139 BUTTON_HEADER_CTX(BCONTEXT_MATERIAL, ICON_MATERIAL, N_("Material")); 00140 BUTTON_HEADER_CTX(BCONTEXT_TEXTURE, ICON_TEXTURE, N_("Textures")); 00141 BUTTON_HEADER_CTX(BCONTEXT_PARTICLE, ICON_PARTICLES, N_("Particles")); 00142 BUTTON_HEADER_CTX(BCONTEXT_PHYSICS, ICON_PHYSICS, N_("Physics")); 00143 00144 #undef BUTTON_HEADER_CTX 00145 00146 xco+= BUT_UNIT_X; 00147 00148 uiBlockEndAlign(block); 00149 00150 /* always as last */ 00151 UI_view2d_totRect_set(&ar->v2d, xco+(UI_UNIT_X/2), ar->v2d.tot.ymax-ar->v2d.tot.ymin); 00152 00153 uiEndBlock(C, block); 00154 uiDrawBlock(C, block); 00155 } 00156 00157