[Bf-blender-cvs] [a496503] asset-experiments: Merge branch 'master' into asset-experiments
Bastien Montagne
noreply at git.blender.org
Thu Jun 11 19:59:10 CEST 2015
Commit: a4965036a741bd06a33fc4f3f7708fb1a497ac17
Author: Bastien Montagne
Date: Thu Jun 11 18:16:43 2015 +0200
Branches: asset-experiments
https://developer.blender.org/rBa4965036a741bd06a33fc4f3f7708fb1a497ac17
Merge branch 'master' into asset-experiments
Conflicts:
source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_file/space_file.c
NOTE: Tagged some parts in new code to be fixed, rather do that in a separate commit.
This means this commit is broken and won't compile.
===================================================================
===================================================================
diff --cc source/blender/editors/space_file/file_draw.c
index 9f7ae93,6347ce7..aa8fa7a
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@@ -542,15 -542,13 +542,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->active_file == i) || (file_selflag & FILE_SEL_HIGHLIGHTED) ||
++ 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->active_file == i) || (file_selflag & FILE_SEL_HIGHLIGHTED) ? 20 : 0;
++ 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->relname)) {
+ if (FILENAME_IS_CURRPAR(file->relpath)) {
colorid = TH_BACK;
}
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 317a336,680a28f..acdb044
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@@ -176,10 -176,11 +176,11 @@@ static FileSelect file_select_do(bConte
(selected_idx < numfiles) &&
(file = filelist_file(sfile->files, selected_idx)))
{
+ params->highlight_file = selected_idx;
- sfile->params->active_file = selected_idx;
+ params->active_file = selected_idx;
- if (S_ISDIR(file->type)) {
- const bool is_parent_dir = FILENAME_IS_PARENT(file->relname);
+ if (file->typeflag & FILE_TYPE_DIR) {
+ const bool is_parent_dir = FILENAME_IS_PARENT(file->relpath);
if (do_diropen == false) {
params->file[0] = '\0';
@@@ -248,6 -243,53 +249,56 @@@ static FileSelect file_select(bContext
return retval;
}
++/* START XXX TODO!!!!!! */
+ /**
+ * \warning: loops over all files so better use cautiously
+ */
+ static bool file_is_any_selected(struct FileList *files)
+ {
+ const int numfiles = filelist_numfiles(files);
+ int i;
+
+ for (i = 0; i < numfiles; ++i) {
+ if (filelist_is_selected(files, i, CHECK_ALL)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ static int file_border_select_find_last_selected(
+ SpaceFile *sfile, ARegion *ar, const FileSelection *sel,
+ const int mouse_xy[2])
+ {
+ FileLayout *layout = ED_fileselect_get_layout(sfile, ar);
+ rcti bounds_first, bounds_last;
+ int dist_first, dist_last;
+
+ file_tile_boundbox(ar, layout, sel->first, &bounds_first);
+ file_tile_boundbox(ar, layout, sel->last, &bounds_last);
+
+ /* are first and last in the same column (horizontal layout)/row (vertical layout)? */
+ if ((layout->flag & FILE_LAYOUT_HOR && bounds_first.xmin == bounds_last.xmin) ||
+ (layout->flag & FILE_LAYOUT_VER && bounds_first.ymin != bounds_last.ymin))
+ {
+ /* use vertical distance */
+ const int my_loc = mouse_xy[1] - ar->winrct.ymin;
+ dist_first = BLI_rcti_length_y(&bounds_first, my_loc);
+ dist_last = BLI_rcti_length_y(&bounds_last, my_loc);
+ }
+ else {
+ /* use horizontal distance */
+ const int mx_loc = mouse_xy[0] - ar->winrct.xmin;
+ dist_first = BLI_rcti_length_x(&bounds_first, mx_loc);
+ dist_last = BLI_rcti_length_x(&bounds_last, mx_loc);
+ }
+
+ return dist_first < dist_last ? sel->first : sel->last;
+ }
+
++/* END XXX TODO!!!!!! */
++
static int file_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *ar = CTX_wm_region(C);
@@@ -276,15 -318,15 +327,15 @@@
/* 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);
- 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);
}
- /* active_file gets highlighted as well - make sure it is no readonly file */
+ /* make sure highlight_file is no readonly file */
if (sel.last == idx) {
- params->active_file = idx;
+ params->highlight_file = idx;
}
}
}
@@@ -367,11 -409,11 +418,11 @@@ static int file_select_invoke(bContext
return OPERATOR_CANCELLED;
if (sfile && sfile->params) {
- int idx = sfile->params->active_file;
+ int idx = sfile->params->highlight_file;
if (idx >= 0) {
- struct direntry *file = filelist_file(sfile->files, idx);
- if (FILENAME_IS_CURRPAR(file->relname)) {
+ 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 {
@@@ -415,6 -457,206 +466,208 @@@ void FILE_OT_select(wmOperatorType *ot
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
++/* START XXX TODO!!! */
+ /**
+ * \returns true if selection has changed
+ */
+ static bool file_walk_select_selection_set(
+ bContext *C, SpaceFile *sfile,
+ const int direction, const int numfiles,
+ const int active_old, const int active_new, const int other_site,
+ const bool has_selection, const bool extend, const bool fill)
+ {
+ FileSelectParams *params = sfile->params;
+ struct FileList *files = sfile->files;
+ const int last_sel = params->active_file; /* store old value */
+ int active = active_old; /* could use active_old instead, just for readability */
+ bool deselect = false;
+
+ if (has_selection) {
+ if (extend &&
+ filelist_is_selected(files, active_old, FILE_SEL_SELECTED) &&
+ filelist_is_selected(files, active_new, FILE_SEL_SELECTED))
+ {
+ /* 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));
+
+ /* don't change active 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) */
+ if (deselect && fill) active = active_new;
+ }
+ else {
+ /* regular selection change */
+ params->active_file = active = active_new;
+ }
+ }
+ else {
+ /* select last file */
+ if (ELEM(direction, FILE_SELECT_WALK_UP, FILE_SELECT_WALK_LEFT)) {
+ params->active_file = active = numfiles - 1;
+ }
+ /* select first file */
+ else if (ELEM(direction, FILE_SELECT_WALK_DOWN, FILE_SELECT_WALK_RIGHT)) {
+ params->active_file = active = 1;
+ }
+ else {
+ BLI_assert(0);
+ }
+ }
+
+ if (!params || active < 0) return false;
+
+ /* highlight the active walker file for extended selection for better visual feedback */
+ if (extend) {
+ params->highlight_file = params->active_file;
+ }
+ else {
+ /* deselect all first */
+ file_deselect_all(sfile, FILE_SEL_SELECTED);
+
+ /* highlight file under mouse pos */
+ params->highlight_file = -1;
+ WM_event_add_mousemove(C);
+ }
+
+ /* do the actual selection */
+ if (fill) {
+ FileSelection sel = { MIN2(active, last_sel), MAX2(active, last_sel) };
+
+ /* fill selection between last and first selected file */
+ filelist_select(sfile->files, &sel, deselect ? FILE_SEL_REMOVE : FILE_SEL_ADD,
+ FILE_SEL_SELECTED, CHECK_ALL);
+ /* entire sel is cleared here, so select active again */
+ if (deselect) {
+ filelist_select_file(sfile->files, active, FILE_SEL_ADD, FILE_SEL_SELECTED, CHECK_ALL);
+ }
+ }
+ else {
+ filelist_select_file(sfile->files, active, deselect ? FILE_SEL_REMOVE : FILE_SEL_ADD,
+ FILE_SEL_SELECTED, CHECK_ALL);
+ }
+
+ BLI_assert(IN_RANGE(active, 0, numfiles));
+
+ /* selection changed */
+ return true;
+ }
+
+ /**
+ * \returns true if selection has changed
+ */
+ static bool file_walk_select_do(
+ bContext *C, SpaceFile *sfile,
+ FileSelectParams *params, const int direction,
+ const bool extend, const bool fill)
+ {
+ const int numfiles = filelist_numfiles(sfile->files);
+ const bool has_selection = file_is_any_selected(sfile->files);
+ const int active_old = params->active_file;
+ int active_new = -1;
+ int other_site = -1; /* file on the other site of active_old */
+
+
+ /* *** get all needed files for handling selection *** */
+
+ if (has_selection) {
+ ARegion *ar = CTX_wm_region(C);
+ FileLayout *layout = ED_fileselect_get_layout(sfile, ar);
+ const int idx_shift = (layout->flag & FILE_LAYOUT_HOR) ? layout->rows : layout->columns;
+
+ if ((layout->flag & FILE_LAYOUT_HOR && direction == FILE_SELECT_WALK_UP) ||
+ (layout->flag & FILE_LAYOUT_VER && direction == FILE_SELECT_WALK_LEFT))
+ {
+ active_new = active_old - 1;
+ other_site = active_old + 1;
+ }
+ else if ((layout->flag & FILE_LAYOUT_HOR && direction == FILE_SELECT_WALK_DOWN) ||
+ (layout->flag & FILE_LAYOUT_VER && direction == FILE_SELECT_WALK_RIGHT))
+ {
+ active_new = active_old + 1;
+ other_site = active_old - 1;
+ }
+ else if ((layout->flag & FILE_LAYOUT_HOR && direction == FILE_SELECT_WALK_LEFT) ||
+ (layout->flag & FILE_LAYOUT_VER && direction == FILE_SELECT_WALK_UP))
+ {
+ active_new = active_old - idx_shift;
+ other_site = active_old + idx_s
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list