merge with trunk at r31523
[blender.git] / source / blender / editors / space_image / image_header.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. 
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * The Original Code is Copyright (C) 2008 Blender Foundation.
21  * All rights reserved.
22  *
23  * 
24  * Contributor(s): Blender Foundation
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #include <string.h>
30 #include <stdio.h>
31
32 #include "DNA_object_types.h"
33 #include "DNA_space_types.h"
34 #include "DNA_windowmanager_types.h"
35
36
37 #include "BLI_blenlib.h"
38 #include "BLI_editVert.h"
39
40 #include "BKE_context.h"
41 #include "BKE_mesh.h"
42
43
44 #include "ED_image.h"
45
46 #include "WM_types.h"
47
48
49 #include "UI_interface.h"
50
51
52
53 #include "image_intern.h"
54
55 /********************** toolbox operator *********************/
56
57 static int toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event)
58 {
59         SpaceImage *sima= CTX_wm_space_image(C);
60         Object *obedit= CTX_data_edit_object(C);
61         uiPopupMenu *pup;
62         uiLayout *layout;
63         int show_uvedit;
64
65         show_uvedit= ED_space_image_show_uvedit(sima, obedit);
66
67         pup= uiPupMenuBegin(C, "Toolbox", 0);
68         layout= uiPupMenuLayout(pup);
69
70         uiItemM(layout, C, "IMAGE_MT_view", NULL, 0);
71         if(show_uvedit) uiItemM(layout, C, "IMAGE_MT_select", NULL, 0);
72         uiItemM(layout, C, "IMAGE_MT_image", NULL, 0);
73         if(show_uvedit) uiItemM(layout, C, "IMAGE_MT_uvs", NULL, 0);
74
75         uiPupMenuEnd(C, pup);
76
77         return OPERATOR_CANCELLED;
78 }
79
80 void IMAGE_OT_toolbox(wmOperatorType *ot)
81 {
82         /* identifiers */
83         ot->name= "Toolbox";
84         ot->idname= "IMAGE_OT_toolbox";
85         
86         /* api callbacks */
87         ot->invoke= toolbox_invoke;
88         ot->poll= space_image_main_area_poll;
89 }
90