[Bf-blender-cvs] [5a16f29] asset-experiments: Merge branch 'master' into asset-experiments
Bastien Montagne
noreply at git.blender.org
Sat Jul 11 22:52:01 CEST 2015
Commit: 5a16f297006b728f4e777f89fa73ee83d062ee1f
Author: Bastien Montagne
Date: Sat Jul 11 22:51:30 2015 +0200
Branches: asset-experiments
https://developer.blender.org/rB5a16f297006b728f4e777f89fa73ee83d062ee1f
Merge branch 'master' into asset-experiments
Conflicts:
source/blender/blenlib/intern/BLI_filelist.c
source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_file/filelist.c
===================================================================
===================================================================
diff --cc source/blender/blenlib/intern/BLI_filelist.c
index da605da,38a6781..62690ff
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@@ -378,21 -350,20 +378,21 @@@ void BLI_filelist_duplicate
*dest_filelist = MEM_mallocN(sizeof(**dest_filelist) * (size_t)(nrentries), __func__);
for (i = 0; i < nrentries; ++i) {
struct direntry * const src = &src_filelist[i];
- struct direntry *dest = &(*dest_filelist)[i];
- *dest = *src;
- if (dest->image) {
- dest->image = IMB_dupImBuf(src->image);
- }
- if (dest->relname) {
- dest->relname = MEM_dupallocN(src->relname);
- }
- if (dest->path) {
- dest->path = MEM_dupallocN(src->path);
- }
- if (dest->poin && dup_poin) {
- dest->poin = dup_poin(src->poin);
- }
+ struct direntry *dst = &(*dest_filelist)[i];
+ BLI_filelist_entry_duplicate(dst, src);
+ }
+}
+
+/**
+ * frees storage for a single direntry, not the direntry itself.
+ */
+void BLI_filelist_entry_free(struct direntry *entry)
+{
+ if (entry->relname) {
- MEM_freeN(entry->relname);
++ MEM_freeN((void *)entry->relname);
+ }
+ if (entry->path) {
- MEM_freeN(entry->path);
++ MEM_freeN((void *)entry->path);
}
}
diff --cc source/blender/editors/space_file/file_draw.c
index cba8754,be602e7..3a4e1f6
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@@ -168,7 -157,10 +168,10 @@@ void file_draw_buttons(const bContext *
/* Text input fields for directory and file. */
if (available_w > 0) {
- const struct direntry *file = sfile->files ? filelist_file(sfile->files, params->active_file) : NULL;
++ const struct FileDirEntry *file = sfile->files ? filelist_file(sfile->files, params->active_file) : NULL;
int overwrite_alert = file_draw_check_exists(sfile);
- const bool is_active_dir = file && file->path && BLI_is_dir(file->path);
++ const bool is_active_dir = file && (file->typeflag & FILE_TYPE_FOLDER);
+
/* callbacks for operator check functions */
UI_block_func_set(block, file_draw_check_cb, NULL, NULL);
@@@ -227,8 -220,12 +231,12 @@@
/* Execute / cancel buttons. */
if (loadbutton) {
- /* params->title is already translated! */
- uiDefButO(block, UI_BTYPE_BUT, "FILE_OT_execute", WM_OP_EXEC_REGION_WIN, params->title,
- const struct direntry *file = filelist_file(sfile->files, params->active_file);
- const char *str_exec = (file && file->path && BLI_is_dir(file->path)) ?
++ const struct FileDirEntry *file = sfile->files ? filelist_file(sfile->files, params->active_file) : NULL;
++ const char *str_exec = (file && (file->typeflag & FILE_TYPE_FOLDER)) ?
+ /* params->title is already translated! */
+ IFACE_("Open Directory") : params->title;
+
+ uiDefButO(block, UI_BTYPE_BUT, "FILE_OT_execute", WM_OP_EXEC_REGION_WIN, str_exec,
max_x - loadbutton, line1_y, loadbutton, btn_h, "");
uiDefButO(block, UI_BTYPE_BUT, "FILE_OT_cancel", WM_OP_EXEC_REGION_WIN, IFACE_("Cancel"),
max_x - loadbutton, line2_y, loadbutton, btn_h, "");
@@@ -247,7 -244,45 +255,7 @@@ static void draw_tile(int sx, int sy, i
}
- static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, int width, int height, bool drag)
-static int get_file_icon(struct direntry *file)
-{
- if (file->type & S_IFDIR) {
- if (FILENAME_IS_PARENT(file->relname)) {
- return ICON_FILE_PARENT;
- }
- if (file->flags & FILE_TYPE_APPLICATIONBUNDLE) {
- return ICON_UGLYPACKAGE;
- }
- if (file->flags & FILE_TYPE_BLENDER) {
- return ICON_FILE_BLEND;
- }
- return ICON_FILE_FOLDER;
- }
- else if (file->flags & FILE_TYPE_BLENDER)
- return ICON_FILE_BLEND;
- else if (file->flags & FILE_TYPE_BLENDER_BACKUP)
- return ICON_FILE_BACKUP;
- else if (file->flags & FILE_TYPE_IMAGE)
- return ICON_FILE_IMAGE;
- else if (file->flags & FILE_TYPE_MOVIE)
- return ICON_FILE_MOVIE;
- else if (file->flags & FILE_TYPE_PYSCRIPT)
- return ICON_FILE_SCRIPT;
- else if (file->flags & FILE_TYPE_SOUND)
- return ICON_FILE_SOUND;
- else if (file->flags & FILE_TYPE_FTFONT)
- return ICON_FILE_FONT;
- else if (file->flags & FILE_TYPE_BTX)
- return ICON_FILE_BLANK;
- else if (file->flags & FILE_TYPE_COLLADA)
- return ICON_FILE_BLANK;
- else if (file->flags & FILE_TYPE_TEXT)
- return ICON_FILE_TEXT;
- else
- return ICON_FILE_BLANK;
-}
-
+ static void file_draw_icon(uiBlock *block, const char *path, int sx, int sy, int icon, int width, int height, bool drag)
{
uiBut *but;
int x, y;
@@@ -562,17 -550,13 +570,15 @@@ void file_draw_list(const bContext *C,
UI_ThemeColor4(TH_TEXT);
- if (!(file->selflag & FILE_SEL_EDITING)) {
- if ((params->highlight_file == i) || (file->selflag & FILE_SEL_HIGHLIGHTED) || (file->selflag & FILE_SEL_SELECTED)) {
- int colorid = (file->selflag & FILE_SEL_SELECTED) ? TH_HILITE : TH_BACK;
- int shade = (params->highlight_file == i) || (file->selflag & FILE_SEL_HIGHLIGHTED) ? 35 : 0;
+ if (!(file_selflag & FILE_SEL_EDITING)) {
+ if ((params->highlight_file == i) || (file_selflag & FILE_SEL_HIGHLIGHTED) ||
+ (file_selflag & FILE_SEL_SELECTED))
+ {
+ int colorid = (file_selflag & FILE_SEL_SELECTED) ? TH_HILITE : TH_BACK;
+ int shade = (params->highlight_file == i) || (file_selflag & FILE_SEL_HIGHLIGHTED) ? 35 : 0;
- /* readonly files (".." and ".") must not be drawn as selected - set color back to normal */
- if (FILENAME_IS_CURRPAR(file->relpath)) {
- colorid = TH_BACK;
- }
- BLI_assert(i > 0 || FILENAME_IS_CURRPAR(file->relname));
++ BLI_assert(i > 0 || FILENAME_IS_CURRPAR(file->relpath));
+
draw_tile(sx, sy - 1, layout->tile_w + 4, sfile->layout->tile_h + layout->tile_border_y, colorid, shade);
}
}
diff --cc source/blender/editors/space_file/file_ops.c
index c7f861e,bfe8be9..fe58742
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@@ -323,15 -315,15 +321,15 @@@ static int file_border_select_modal(bCo
int idx;
file_deselect_all(sfile, FILE_SEL_HIGHLIGHTED);
- filelist_select(sfile->files, &sel, FILE_SEL_ADD, FILE_SEL_HIGHLIGHTED, CHECK_ALL);
+ filelist_entries_select_index_range_set(sfile->files, &sel, FILE_SEL_ADD, FILE_SEL_HIGHLIGHTED, CHECK_ALL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
- /* dont highlight readonly file (".." or ".") on border select */
for (idx = sel.last; idx >= 0; idx--) {
- struct direntry *file = filelist_file(sfile->files, idx);
+ const FileDirEntry *file = filelist_file(sfile->files, idx);
+ /* dont highlight readonly file (".." or ".") on border select */
- if (FILENAME_IS_CURRPAR(file->relname)) {
- file->selflag &= ~FILE_SEL_HIGHLIGHTED;
+ if (FILENAME_IS_CURRPAR(file->relpath)) {
+ filelist_entry_select_set(sfile->files, file, FILE_SEL_REMOVE, FILE_SEL_HIGHLIGHTED, CHECK_ALL);
}
/* make sure highlight_file is no readonly file */
@@@ -372,6 -364,10 +370,10 @@@ static int file_border_select_exec(bCon
BLI_rcti_isect(&(ar->v2d.mask), &rect, &rect);
ret = file_select(C, &rect, select ? FILE_SEL_ADD : FILE_SEL_REMOVE, false, false);
+
+ /* unselect '..' parent entry - it's not supposed to be selected if more than one file is selected */
- filelist_select_file(sfile->files, 0, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL);
++ filelist_entry_select_index_set(sfile->files, 0, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL);
+
if (FILE_SELECT_DIR == ret) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
}
@@@ -420,21 -416,22 +422,23 @@@ static int file_select_invoke(bContext
if (sfile && sfile->params) {
int idx = sfile->params->highlight_file;
+ int numfiles = filelist_files_ensure(sfile->files);
- if (idx >= 0) {
+ if ((idx >= 0) && (idx < numfiles)) {
- struct FileDirEntry *file = filelist_file(sfile->files, idx);
- if (FILENAME_IS_CURRPAR(file->relpath)) {
- /* skip - If a readonly file (".." or ".") is selected, skip deselect all! */
- }
- else {
- /* single select, deselect all selected first */
- if (!extend) file_deselect_all(sfile, FILE_SEL_SELECTED);
+ /* single select, deselect all selected first */
+ if (!extend) {
+ file_deselect_all(sfile, FILE_SEL_SELECTED);
}
}
}
ret = file_select(C, &rect, extend ? FILE_SEL_TOGGLE : FILE_SEL_ADD, fill, do_diropen);
+
+ if (extend) {
+ /* unselect '..' parent entry - it's not supposed to be selected if more than one file is selected */
- filelist_select_file(sfile->files, 0, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL);
++ filelist_entry_select_index_set(sfile->files, 0, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL);
+ }
+
if (FILE_SELECT_DIR == ret)
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
else if (FILE_SELECT_FILE == ret)
@@@ -492,10 -489,9 +496,10 @@@ static bool file_walk_select_selection_
{
/* conditions for deselecting: initial file is selected, new file is
* selected and either other_side isn't selected/found or we use fill */
- deselect = (fill || other_site == -1 || !filelist_is_selected(files, other_site, FILE_SEL_SELECTED));
+ deselect = (fill || other_site == -1 ||
+ !filelist_entry_select_index_get(files, other_site, FILE_SEL_SELECTED));
- /* don't change active here since we either want to deselect active or we want to
+ /* don't change highlight_file here since we either want to deselect active or we want to
* walk through a block of selected files without selecting/deselecting anything */
params->active_file = active_new;
/* but we want to change active if we use fill (needed to get correct selection bounds) */
@@@ -526,9 -522,12 +530,12 @@@
return false;
}
- /* highlight the active walker file for extended selection for better visual feedback */
if (extend) {
+ /* highlight the active walker file for extended selection for better visual feedback */
params->highlight_file = params
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list