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