4 * ***** BEGIN GPL LICENSE BLOCK *****
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.
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.
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.
20 * The Original Code is Copyright (C) 2008 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation
26 * ***** END GPL LICENSE BLOCK *****
33 #include "DNA_anim_types.h"
34 #include "DNA_space_types.h"
35 #include "DNA_scene_types.h"
36 #include "DNA_screen_types.h"
37 #include "DNA_windowmanager_types.h"
39 #include "MEM_guardedalloc.h"
41 #include "BLI_blenlib.h"
43 #include "BKE_animsys.h"
44 #include "BKE_context.h"
45 #include "BKE_global.h"
47 #include "BKE_screen.h"
49 #include "ED_keyframing.h"
50 #include "ED_screen.h"
58 #include "BIF_glutil.h"
60 #include "UI_interface.h"
61 #include "UI_resources.h"
62 #include "UI_view2d.h"
64 #include "outliner_intern.h"
67 /* ************************ header area region *********************** */
69 static void do_viewmenu(bContext *C, void *arg, int event)
71 ScrArea *curarea= CTX_wm_area(C);
72 SpaceOops *soops= curarea->spacedata.first;
75 case 0: /* Shuffle Selected Blocks */
78 case 1: /* Shrink Selected Blocks */
81 case 2: /* View All */
82 //do_oops_buttons(B_OOPSHOME);
84 case 3: /* View All */
85 //do_oops_buttons(B_OOPSVIEWSEL);
87 case 4: /* Maximize Window */
88 /* using event B_FULL */
91 case 14: /* show outliner viewer */
92 soops->type= SO_OUTLINER;
95 //outliner_toggle_visible(curarea);
98 //outliner_show_hierarchy(curarea);
101 //outliner_show_active(curarea);
104 //outliner_one_level(curarea, 1);
107 //outliner_one_level(curarea, -1);
110 if (soops->flag & SO_HIDE_RESTRICTCOLS) soops->flag &= ~SO_HIDE_RESTRICTCOLS;
111 else soops->flag |= SO_HIDE_RESTRICTCOLS;
114 ED_area_tag_redraw(curarea);
117 static uiBlock *outliner_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
119 ScrArea *curarea= CTX_wm_area(C);
120 SpaceOops *soops= curarea->spacedata.first;
122 short yco= 0, menuwidth=120;
124 block= uiBeginBlock(C, ar, "outliner_viewmenu", UI_EMBOSSP, UI_HELV);
125 uiBlockSetButmFunc(block, do_viewmenu, NULL);
127 if(soops->type==SO_OUTLINER) {
128 if (soops->flag & SO_HIDE_RESTRICTCOLS)
129 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Show Restriction Columns", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
131 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Show Restriction Columns", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
133 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
135 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Expand One Level|NumPad +", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
136 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Collapse One Level|NumPad -", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
138 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
140 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show/Hide All", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
141 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Hierarchy|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
142 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Active|NumPad .", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, "");
145 // uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
146 // if(!curarea->full) uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
147 // else uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
150 if(curarea->headertype==HEADERTOP) {
151 uiBlockSetDirection(block, UI_DOWN);
154 uiBlockSetDirection(block, UI_TOP);
155 uiBlockFlipOrder(block);
158 uiTextBoundsBlock(block, 50);
159 uiEndBlock(C, block);
169 } eOutlinerHeader_Events;
171 static void do_outliner_buttons(bContext *C, void *arg, int event)
173 ScrArea *sa= CTX_wm_area(C);
174 Scene *scene= CTX_data_scene(C);
178 ED_area_tag_redraw(sa);
181 case B_KEYINGSET_CHANGE:
182 /* add a new KeyingSet if active is -1 */
183 if (scene->active_keyingset == -1) {
184 // XXX the default settings have yet to evolve... need to keep this in sync with the
185 BKE_keyingset_add(&scene->keyingsets, "KeyingSet", KEYINGSET_ABSOLUTE, 0);
186 scene->active_keyingset= BLI_countlist(&scene->keyingsets);
189 /* redraw regions with KeyingSet info */
190 WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, scene);
193 case B_KEYINGSET_REMOVE:
194 /* remove the active KeyingSet */
195 if (scene->active_keyingset) {
196 KeyingSet *ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
198 /* firstly free KeyingSet's data, then free the KeyingSet itself */
200 BKE_keyingset_free(ks);
201 BLI_freelinkN(&scene->keyingsets, ks);
202 scene->active_keyingset= 0;
206 /* redraw regions with KeyingSet info */
207 WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, scene);
213 void outliner_header_buttons(const bContext *C, ARegion *ar)
215 ScrArea *sa= CTX_wm_area(C);
216 Scene *scene= CTX_data_scene(C);
217 SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
219 int xco, yco= 3, xmax;
221 block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
222 uiBlockSetHandleFunc(block, do_outliner_buttons, NULL);
224 xco= ED_area_header_standardbuttons(C, block, yco);
226 if((sa->flag & HEADER_NO_PULLDOWN)==0) {
228 /* pull down menus */
229 uiBlockSetEmboss(block, UI_EMBOSSP);
231 xmax= GetButStringLength("View");
232 uiDefPulldownBut(block, outliner_viewmenu, CTX_wm_area(C),
233 "View", xco, yco-2, xmax-3, 24, "");
239 uiBlockSetEmboss(block, UI_EMBOSS);
242 //if (outliner->type==SO_OUTLINER) {
244 if(G.main->library.first)
245 uiDefButS(block, MENU, B_REDR, "Outliner Display%t|Libraries %x7|All Scenes %x0|Current Scene %x1|Visible Layers %x2|Groups %x6|Same Types %x5|Selected %x3|Active %x4|Sequence %x10|Datablocks %x11|User Preferences %x12", xco, yco, 120, 20, &soutliner->outlinevis, 0, 0, 0, 0, "");
247 uiDefButS(block, MENU, B_REDR, "Outliner Display%t|All Scenes %x0|Current Scene %x1|Visible Layers %x2|Groups %x6|Same Types %x5|Selected %x3|Active %x4|Sequence %x10|Datablocks %x11|User Preferences %x12", xco, yco, 120, 20, &soutliner->outlinevis, 0, 0, 0, 0, "");
250 /* KeyingSet editing buttons */
251 if ((soutliner->flag & SO_HIDE_KEYINGSETINFO)==0 && (soutliner->outlinevis==SO_DATABLOCKS)) {
255 xco+= (int)(XIC*1.5);
257 if (scene->active_keyingset)
258 ks= (KeyingSet *)BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
260 uiBlockBeginAlign(block);
261 /* currently 'active' KeyingSet */
262 menustr= ANIM_build_keyingsets_menu(&scene->keyingsets, 1);
263 uiDefButI(block, MENU, B_KEYINGSET_CHANGE, menustr, xco,yco, 18,20, &scene->active_keyingset, 0, 0, 0, 0, "Browse Keying Sets");
267 /* currently 'active' KeyingSet - change name */
269 /* active KeyingSet */
270 uiDefBut(block, TEX, B_KEYINGSET_CHANGE,"", xco,yco,120,20, ks->name, 0, 63, 0, 0, "Name of Active Keying Set");
272 uiDefIconBut(block, BUT, B_KEYINGSET_REMOVE, VICON_X, xco, yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Remove this Keying Set");
276 /* no active KeyingSet... so placeholder instead */
277 uiDefBut(block, LABEL, 0,"<No Keying Set Active>", xco,yco,140,20, NULL, 0, 63, 0, 0, "Name of Active Keying Set");
280 uiBlockEndAlign(block);
282 /* current 'active' KeyingSet */
286 /* operator buttons to add/remove selected items from set */
287 uiBlockBeginAlign(block);
288 // XXX the icons here are temporary
289 uiDefIconButO(block, BUT, "OUTLINER_OT_keyingset_remove_selected", WM_OP_INVOKE_REGION_WIN, ICON_ZOOMOUT, xco,yco,XIC,YIC, "Remove selected properties from active Keying Set (Alt-K)");
291 uiDefIconButO(block, BUT, "OUTLINER_OT_keyingset_add_selected", WM_OP_INVOKE_REGION_WIN, ICON_ZOOMIN, xco,yco,XIC,YIC, "Add selected properties to active Keying Set (K)");
293 uiBlockEndAlign(block);
297 /* operator buttons to insert/delete keyframes for the active set */
298 uiBlockBeginAlign(block);
299 uiDefIconButO(block, BUT, "ANIM_OT_delete_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_DEHLT, xco,yco,XIC,YIC, "Delete Keyframes for the Active Keying Set (Alt-I)");
301 uiDefIconButO(block, BUT, "ANIM_OT_insert_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_HLT, xco,yco,XIC,YIC, "Insert Keyframes for the Active Keying Set (I)");
303 uiBlockEndAlign(block);
311 UI_view2d_totRect_set(&ar->v2d, xco+XIC+100, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin));
313 uiEndBlock(C, block);
314 uiDrawBlock(C, block);