2.5
[blender.git] / source / blender / editors / space_info / info_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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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_space_types.h"
33 #include "DNA_scene_types.h"
34 #include "DNA_screen_types.h"
35 #include "DNA_windowmanager_types.h"
36
37 #include "MEM_guardedalloc.h"
38
39 #include "BLI_blenlib.h"
40
41 #include "BKE_global.h"
42 #include "BKE_screen.h"
43
44 #include "ED_screen.h"
45 #include "ED_util.h"
46
47 #include "WM_api.h"
48 #include "WM_types.h"
49
50 #include "BIF_gl.h"
51 #include "BIF_glutil.h"
52
53 #include "UI_interface.h"
54 #include "UI_resources.h"
55 #include "UI_view2d.h"
56
57 #include "info_intern.h"
58
59
60 /* ************************ header area region *********************** */
61
62 static void do_viewmenu(bContext *C, void *arg, int event)
63 {
64         
65 }
66
67 static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
68 {
69         ScrArea *curarea= C->area;
70         uiBlock *block;
71         short yco= 0, menuwidth=120;
72         
73         block= uiBeginBlock(C, handle->region, "dummy_viewmenu", UI_EMBOSSP, UI_HELV);
74         uiBlockSetButmFunc(block, do_viewmenu, NULL);
75         
76         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20, 
77                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
78         
79         if(curarea->headertype==HEADERTOP) {
80                 uiBlockSetDirection(block, UI_DOWN);
81         }
82         else {
83                 uiBlockSetDirection(block, UI_TOP);
84                 uiBlockFlipOrder(block);
85         }
86         
87         uiTextBoundsBlock(block, 50);
88         uiEndBlock(C, block);
89         
90         return block;
91 }
92
93 #define B_NEWSPACE              100
94
95 static void do_info_buttons(bContext *C, void *arg, int event)
96 {
97         switch(event) {
98                 case B_NEWSPACE:
99                         ED_newspace(C->area, C->area->butspacetype);
100                         WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
101                         break;
102                 }
103 }
104
105
106 void info_header_buttons(const bContext *C, ARegion *ar)
107 {
108         ScrArea *sa= C->area;
109         uiBlock *block;
110         int xco, yco= 3;
111         
112         block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
113         uiBlockSetHandleFunc(block, do_info_buttons, NULL);
114         
115         if(ED_screen_area_active(C)) uiBlockSetCol(block, TH_HEADER);
116         else uiBlockSetCol(block, TH_HEADERDESEL);
117
118         xco = 8;
119         
120         uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, 
121                                           windowtype_pup(), xco, yco, XIC+10, YIC, 
122                                           &(C->area->butspacetype), 1.0, SPACEICONMAX, 0, 0, 
123                                           "Displays Current Window Type. "
124                                           "Click for menu of available types.");
125         
126         xco += XIC + 14;
127         
128         uiBlockSetEmboss(block, UI_EMBOSSN);
129         if (sa->flag & HEADER_NO_PULLDOWN) {
130                 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, 
131                                                  ICON_DISCLOSURE_TRI_RIGHT,
132                                                  xco,yco,XIC,YIC-2,
133                                                  &(sa->flag), 0, 0, 0, 0, 
134                                                  "Show pulldown menus");
135         }
136         else {
137                 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, 
138                                                  ICON_DISCLOSURE_TRI_DOWN,
139                                                  xco,yco,XIC,YIC-2,
140                                                  &(sa->flag), 0, 0, 0, 0, 
141                                                  "Hide pulldown menus");
142         }
143         uiBlockSetEmboss(block, UI_EMBOSS);
144         xco+=XIC;
145         
146         if((sa->flag & HEADER_NO_PULLDOWN)==0) {
147                 int xmax;
148                 
149                 /* pull down menus */
150                 uiBlockSetEmboss(block, UI_EMBOSSP);
151                 
152                 xmax= GetButStringLength("File");
153                 uiDefPulldownBut(block, dummy_viewmenu, C->area, "File",        xco, yco, xmax-3, 22, "");
154                 xco+= xmax;
155                 
156                 xmax= GetButStringLength("Add");
157                 uiDefPulldownBut(block, dummy_viewmenu, C->area, "Add", xco, yco, xmax-3, 22, "");
158                 xco+= xmax;
159                 
160                 xmax= GetButStringLength("Timeline");
161                 uiDefPulldownBut(block, dummy_viewmenu, C->area, "Timeline",    xco, yco, xmax-3, 22, "");
162                 xco+= xmax;
163                 
164                 xmax= GetButStringLength("Game");
165                 uiDefPulldownBut(block, dummy_viewmenu, C->area, "Game",        xco, yco, xmax-3, 22, "");
166                 xco+= xmax;
167                 
168                 xmax= GetButStringLength("Render");
169                 uiDefPulldownBut(block, dummy_viewmenu, C->area, "Render",      xco, yco, xmax-3, 22, "");
170                 xco+= xmax;
171                 
172                 xmax= GetButStringLength("Help");
173                 uiDefPulldownBut(block, dummy_viewmenu, NULL, "Help",   xco, yco, xmax-3, 22, "");
174                 xco+= xmax;
175                 
176                 
177                 
178         }
179         
180         uiBlockSetEmboss(block, UI_EMBOSS);
181
182         /* always as last  */
183         sa->headbutlen= xco+XIC+80; // +80 because the last button is not an icon
184         
185         uiEndBlock(C, block);
186         uiDrawBlock(block);
187 }
188
189