Merge branch 'blender-v2.81-release'
[blender.git] / source / blender / editors / space_file / filelist.h
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) 2007 Blender Foundation.
17  * All rights reserved.
18  */
19
20 /** \file
21  * \ingroup spfile
22  */
23
24 #ifndef __FILELIST_H__
25 #define __FILELIST_H__
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 struct BlendHandle;
32 struct FileList;
33 struct FileSelection;
34 struct wmWindowManager;
35
36 struct FileDirEntry;
37
38 typedef enum FileSelType {
39   FILE_SEL_REMOVE = 0,
40   FILE_SEL_ADD = 1,
41   FILE_SEL_TOGGLE = 2,
42 } FileSelType;
43
44 typedef enum FileCheckType {
45   CHECK_DIRS = 1,
46   CHECK_FILES = 2,
47   CHECK_ALL = 3,
48 } FileCheckType;
49
50 struct ListBase *folderlist_new(void);
51 void folderlist_free(struct ListBase *folderlist);
52 struct ListBase *folderlist_duplicate(ListBase *folderlist);
53 void folderlist_popdir(struct ListBase *folderlist, char *dir);
54 void folderlist_pushdir(struct ListBase *folderlist, const char *dir);
55 const char *folderlist_peeklastdir(struct ListBase *folderdist);
56 int folderlist_clear_next(struct SpaceFile *sfile);
57
58 void filelist_setsorting(struct FileList *filelist, const short sort, bool invert_sort);
59 void filelist_sort(struct FileList *filelist);
60
61 void filelist_setfilter_options(struct FileList *filelist,
62                                 const bool do_filter,
63                                 const bool hide_dot,
64                                 const bool hide_parent,
65                                 const unsigned int filter,
66                                 const unsigned int filter_id,
67                                 const char *filter_glob,
68                                 const char *filter_search);
69 void filelist_filter(struct FileList *filelist);
70
71 void filelist_init_icons(void);
72 void filelist_free_icons(void);
73 void filelist_imgsize(struct FileList *filelist, short w, short h);
74 struct ImBuf *filelist_getimage(struct FileList *filelist, const int index);
75 struct ImBuf *filelist_geticon_image(struct FileList *filelist, const int index);
76 int filelist_geticon(struct FileList *filelist, const int index, const bool is_main);
77
78 struct FileList *filelist_new(short type);
79 void filelist_clear(struct FileList *filelist);
80 void filelist_clear_ex(struct FileList *filelist, const bool do_cache, const bool do_selection);
81 void filelist_free(struct FileList *filelist);
82
83 const char *filelist_dir(struct FileList *filelist);
84 bool filelist_is_dir(struct FileList *filelist, const char *path);
85 void filelist_setdir(struct FileList *filelist, char *r_dir);
86
87 int filelist_files_ensure(struct FileList *filelist);
88 int filelist_empty(struct FileList *filelist);
89 FileDirEntry *filelist_file(struct FileList *filelist, int index);
90 int filelist_file_findpath(struct FileList *filelist, const char *file);
91 FileDirEntry *filelist_entry_find_uuid(struct FileList *filelist, const int uuid[4]);
92 void filelist_file_cache_slidingwindow_set(struct FileList *filelist, size_t window_size);
93 bool filelist_file_cache_block(struct FileList *filelist, const int index);
94
95 bool filelist_force_reset(struct FileList *filelist);
96 bool filelist_pending(struct FileList *filelist);
97 bool filelist_is_ready(struct FileList *filelist);
98
99 unsigned int filelist_entry_select_set(const struct FileList *filelist,
100                                        const struct FileDirEntry *entry,
101                                        FileSelType select,
102                                        unsigned int flag,
103                                        FileCheckType check);
104 void filelist_entry_select_index_set(struct FileList *filelist,
105                                      const int index,
106                                      FileSelType select,
107                                      unsigned int flag,
108                                      FileCheckType check);
109 void filelist_entries_select_index_range_set(struct FileList *filelist,
110                                              FileSelection *sel,
111                                              FileSelType select,
112                                              unsigned int flag,
113                                              FileCheckType check);
114 unsigned int filelist_entry_select_get(struct FileList *filelist,
115                                        struct FileDirEntry *entry,
116                                        FileCheckType check);
117 unsigned int filelist_entry_select_index_get(struct FileList *filelist,
118                                              const int index,
119                                              FileCheckType check);
120 void filelist_entry_parent_select_set(struct FileList *filelist,
121                                       FileSelType select,
122                                       unsigned int flag,
123                                       FileCheckType check);
124
125 void filelist_setrecursion(struct FileList *filelist, const int recursion_level);
126
127 struct BlendHandle *filelist_lib(struct FileList *filelist);
128 bool filelist_islibrary(struct FileList *filelist, char *dir, char **group);
129 void filelist_freelib(struct FileList *filelist);
130
131 void filelist_readjob_start(struct FileList *filelist, const struct bContext *C);
132 void filelist_readjob_stop(struct wmWindowManager *wm, struct ScrArea *sa);
133 int filelist_readjob_running(struct wmWindowManager *wm, struct ScrArea *sa);
134
135 bool filelist_cache_previews_update(struct FileList *filelist);
136 void filelist_cache_previews_set(struct FileList *filelist, const bool use_previews);
137 bool filelist_cache_previews_running(struct FileList *filelist);
138
139 #ifdef __cplusplus
140 }
141 #endif
142
143 #endif