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 *****
32 #include "DNA_space_types.h"
33 #include "DNA_scene_types.h"
34 #include "DNA_screen_types.h"
35 #include "DNA_windowmanager_types.h"
37 #include "MEM_guardedalloc.h"
39 #include "BLI_blenlib.h"
41 #include "BKE_context.h"
42 #include "BKE_screen.h"
43 #include "BKE_global.h"
45 #include "ED_screen.h"
48 #include "ED_fileselect.h"
54 #include "BIF_glutil.h"
56 #include "UI_interface.h"
57 #include "UI_resources.h"
58 #include "UI_view2d.h"
61 #include "file_intern.h"
64 #define B_SORTIMASELLIST 1
65 #define B_RELOADIMASELDIR 2
68 /* ************************ header area region *********************** */
70 static void do_viewmenu(bContext *C, void *arg, int event)
74 static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
76 ScrArea *curarea= CTX_wm_area(C);
78 short yco= 0, menuwidth=120;
80 block= uiBeginBlock(C, ar, "dummy_viewmenu", UI_EMBOSSP, UI_HELV);
81 uiBlockSetButmFunc(block, do_viewmenu, NULL);
83 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
84 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
86 if(curarea->headertype==HEADERTOP) {
87 uiBlockSetDirection(block, UI_DOWN);
90 uiBlockSetDirection(block, UI_TOP);
91 uiBlockFlipOrder(block);
94 uiTextBoundsBlock(block, 50);
100 static void do_file_header_buttons(bContext *C, void *arg, int event)
102 SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
104 case B_SORTIMASELLIST:
105 filelist_sort(sfile->files, sfile->params->sort);
106 WM_event_add_notifier(C, NC_WINDOW, NULL);
108 case B_RELOADIMASELDIR:
109 WM_event_add_notifier(C, NC_WINDOW, NULL);
115 void file_header_buttons(const bContext *C, ARegion *ar)
117 SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
118 FileSelectParams* params = ED_fileselect_get_params(sfile);
124 block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
125 uiBlockSetHandleFunc(block, do_file_header_buttons, NULL);
127 xco= ED_area_header_standardbuttons(C, block, yco);
130 if((sa->flag & HEADER_NO_PULLDOWN)==0) {
133 uiBlockSetEmboss(block, UI_EMBOSSP);
135 xmax= GetButStringLength("View");
136 uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
137 "View", xco, yco-2, xmax-3, 24, "");
143 uiBlockSetEmboss(block, UI_EMBOSSX);
147 uiDefIconButO(block, BUT, "FILE_OT_parent", WM_OP_INVOKE_DEFAULT, ICON_FILE_PARENT, xco, yco, 20, 20, "Navigate to Parent Folder");
151 if (sfile->params->type != FILE_MAIN) {
152 uiBlockBeginAlign(block);
153 uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_SHORTDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_SHORTDISPLAY, 0, 0, "Displays short file description");
154 uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_LONGDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_LONGDISPLAY, 0, 0, "Displays long file description");
155 uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_IMGDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_IMGDISPLAY, 0, 0, "Displays files as thumbnails");
156 uiBlockEndAlign(block);
161 uiBlockBeginAlign(block);
162 uiDefIconButS(block, ROW, B_SORTIMASELLIST, ICON_SORTALPHA, xco+=XIC, yco, XIC,YIC, ¶ms->sort, 1.0, 0.0, 0, 0, "Sorts files alphabetically");
163 uiDefIconButS(block, ROW, B_SORTIMASELLIST, ICON_SORTBYEXT, xco+=XIC, yco, XIC,YIC, ¶ms->sort, 1.0, 3.0, 0, 0, "Sorts files by extension");
164 uiDefIconButS(block, ROW, B_SORTIMASELLIST, ICON_SORTTIME, xco+=XIC, yco, XIC,YIC, ¶ms->sort, 1.0, 1.0, 0, 0, "Sorts files by time");
165 uiDefIconButS(block, ROW, B_SORTIMASELLIST, ICON_SORTSIZE, xco+=XIC, yco, XIC,YIC, ¶ms->sort, 1.0, 2.0, 0, 0, "Sorts files by size");
166 uiBlockEndAlign(block);
170 /* replace with consistent sub-region collapsing
171 if (sfile->params->type != FILE_MAIN) {
172 uiBlockBeginAlign(block);
173 // uiDefIconButBitS(block, TOG, FILE_BOOKMARKS, B_RELOADIMASELDIR, ICON_BOOKMARKS,xco+=XIC,0,XIC,YIC, ¶ms->flag, 0, 0, 0, 0, "Toggles Bookmarks on/off");
174 uiDefIconButO(block, TOG, "FILE_OT_bookmark_toggle", WM_OP_INVOKE_DEFAULT, ICON_BOOKMARKS, xco+XIC,yco,20,20, "Toggle Bookmarks");
175 uiBlockEndAlign(block);
181 xco+= UI_GetStringWidth(G.font, params->title, 0);
183 uiBlockSetEmboss(block, UI_EMBOSS);
186 UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
188 uiEndBlock(C, block);
189 uiDrawBlock(C, block);