1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) 2008 Blender Foundation. 17 * All rights reserved. 18 */ 19 20 /** \file 21 * \ingroup editors 22 */ 23 24 #pragma once 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 struct ARegion; 31 struct FileSelectParams; 32 struct Scene; 33 struct ScrArea; 34 struct SpaceFile; 35 struct bContext; 36 struct bScreen; 37 struct uiBlock; 38 struct wmWindow; 39 struct wmWindowManager; 40 41 #define FILE_LAYOUT_HOR 1 42 #define FILE_LAYOUT_VER 2 43 44 typedef enum FileAttributeColumnType { 45 COLUMN_NONE = -1, 46 COLUMN_NAME = 0, 47 COLUMN_DATETIME, 48 COLUMN_SIZE, 49 50 ATTRIBUTE_COLUMN_MAX 51 } FileAttributeColumnType; 52 53 typedef struct FileAttributeColumn { 54 /** UI name for this column */ 55 const char *name; 56 57 float width; 58 /* The sort type to use when sorting by this column. */ 59 int sort_type; /* eFileSortType */ 60 61 /* Alignment of column texts, header text is always left aligned */ 62 int text_align; /* eFontStyle_Align */ 63 } FileAttributeColumn; 64 65 typedef struct FileLayout { 66 /* view settings - XXX - move into own struct */ 67 int offset_top; 68 /* Height of the header for the different FileAttributeColumn's. */ 69 int attribute_column_header_h; 70 int prv_w; 71 int prv_h; 72 int tile_w; 73 int tile_h; 74 int tile_border_x; 75 int tile_border_y; 76 int prv_border_x; 77 int prv_border_y; 78 int rows; 79 /* Those are the major layout columns the files are distributed across, not to be confused with 80 * 'attribute_columns' array below. */ 81 int flow_columns; 82 int width; 83 int height; 84 int flag; 85 int dirty; 86 int textheight; 87 /* The columns for each item (name, modification date/time, size). Not to be confused with the 88 * 'flow_columns' above. */ 89 FileAttributeColumn attribute_columns[ATTRIBUTE_COLUMN_MAX]; 90 91 /* When we change display size, we may have to update static strings like size of files... */ 92 short curr_size; 93 } FileLayout; 94 95 typedef struct FileSelection { 96 int first; 97 int last; 98 } FileSelection; 99 100 struct View2D; 101 struct rcti; 102 103 struct FileSelectParams *ED_fileselect_get_params(struct SpaceFile *sfile); 104 105 short ED_fileselect_set_params(struct SpaceFile *sfile); 106 void ED_fileselect_set_params_from_userdef(struct SpaceFile *sfile); 107 void ED_fileselect_params_to_userdef(struct SpaceFile *sfile, 108 const int temp_win_size[], 109 const bool is_maximized); 110 111 void ED_fileselect_reset_params(struct SpaceFile *sfile); 112 113 void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *region); 114 115 FileLayout *ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *region); 116 117 int ED_fileselect_layout_numfiles(FileLayout *layout, struct ARegion *region); 118 int ED_fileselect_layout_offset(FileLayout *layout, int x, int y); 119 FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const struct rcti *rect); 120 121 void ED_fileselect_layout_maskrect(const FileLayout *layout, 122 const struct View2D *v2d, 123 struct rcti *r_rect); 124 bool ED_fileselect_layout_is_inside_pt(const FileLayout *layout, 125 const struct View2D *v2d, 126 int x, 127 int y); 128 bool ED_fileselect_layout_isect_rect(const FileLayout *layout, 129 const struct View2D *v2d, 130 const struct rcti *rect, 131 struct rcti *r_dst); 132 void ED_fileselect_layout_tilepos(FileLayout *layout, int tile, int *x, int *y); 133 134 void ED_operatormacros_file(void); 135 136 void ED_fileselect_clear(struct wmWindowManager *wm, 137 struct Scene *owner_scene, 138 struct SpaceFile *sfile); 139 140 void ED_fileselect_exit(struct wmWindowManager *wm, 141 struct Scene *owner_scene, 142 struct SpaceFile *sfile); 143 144 void ED_fileselect_window_params_get(const struct wmWindow *win, 145 int win_size[2], 146 bool *is_maximized); 147 148 int ED_path_extension_type(const char *path); 149 int ED_file_extension_icon(const char *path); 150 151 void ED_file_read_bookmarks(void); 152 153 void ED_file_change_dir_ex(struct bContext *C, struct bScreen *screen, struct ScrArea *area); 154 void ED_file_change_dir(struct bContext *C); 155 156 void ED_file_path_button(struct bScreen *screen, 157 const struct SpaceFile *sfile, 158 struct FileSelectParams *params, 159 struct uiBlock *block); 160 161 /* File menu stuff */ 162 163 /* FSMenuEntry's without paths indicate separators */ 164 typedef struct FSMenuEntry { 165 struct FSMenuEntry *next; 166 167 char *path; 168 char name[256]; /* FILE_MAXFILE */ 169 short save; 170 short valid; 171 int icon; 172 } FSMenuEntry; 173 174 typedef enum FSMenuCategory { 175 FS_CATEGORY_SYSTEM, 176 FS_CATEGORY_SYSTEM_BOOKMARKS, 177 FS_CATEGORY_BOOKMARKS, 178 FS_CATEGORY_RECENT, 179 /* For internal use, a list of known paths that are used to match paths to icons and names. */ 180 FS_CATEGORY_OTHER, 181 } FSMenuCategory; 182 183 typedef enum FSMenuInsert { 184 FS_INSERT_SORTED = (1 << 0), 185 FS_INSERT_SAVE = (1 << 1), 186 /** moves the item to the front of the list when its not already there */ 187 FS_INSERT_FIRST = (1 << 2), 188 /** just append to preseve delivered order */ 189 FS_INSERT_LAST = (1 << 3), 190 } FSMenuInsert; 191 192 struct FSMenu; 193 struct FSMenuEntry; 194 195 struct FSMenu *ED_fsmenu_get(void); 196 struct FSMenuEntry *ED_fsmenu_get_category(struct FSMenu *fsmenu, FSMenuCategory category); 197 void ED_fsmenu_set_category(struct FSMenu *fsmenu, 198 FSMenuCategory category, 199 struct FSMenuEntry *fsm_head); 200 201 int ED_fsmenu_get_nentries(struct FSMenu *fsmenu, FSMenuCategory category); 202 203 struct FSMenuEntry *ED_fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx); 204 205 char *ED_fsmenu_entry_get_path(struct FSMenuEntry *fsentry); 206 void ED_fsmenu_entry_set_path(struct FSMenuEntry *fsentry, const char *path); 207 208 char *ED_fsmenu_entry_get_name(struct FSMenuEntry *fsentry); 209 void ED_fsmenu_entry_set_name(struct FSMenuEntry *fsentry, const char *name); 210 211 int ED_fsmenu_entry_get_icon(struct FSMenuEntry *fsentry); 212 void ED_fsmenu_entry_set_icon(struct FSMenuEntry *fsentry, const int icon); 213 214 #ifdef __cplusplus 215 } 216 #endif 217