diff options
Diffstat (limited to 'source/blender/editors/space_file/file_draw.c')
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 112 |
1 files changed, 88 insertions, 24 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 6347ce7c4e8..9f66a22fbc1 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -35,6 +35,7 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BLI_fileops_types.h" +#include "BLI_math.h" #ifdef WIN32 # include "BLI_winstuff.h" @@ -64,6 +65,7 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "WM_api.h" #include "WM_types.h" #include "filelist.h" @@ -254,8 +256,13 @@ static int get_file_icon(struct direntry *file) 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_IMAGE) { + if (file->selflag & FILE_SEL_COLLAPSED) { + return ICON_FILE_MOVIE; + } + else + return ICON_FILE_IMAGE; + } else if (file->flags & FILE_TYPE_MOVIE) return ICON_FILE_MOVIE; else if (file->flags & FILE_TYPE_PYSCRIPT) @@ -330,7 +337,7 @@ void file_calc_previews(const bContext *C, ARegion *ar) UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height); } -static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int sy, ImBuf *imb, FileLayout *layout, bool is_icon, bool drag) +static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int sy, ImBuf *imb, FileLayout *layout, bool is_icon, bool drag, bool play) { uiBut *but; float fx, fy; @@ -406,6 +413,24 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int UI_but_drag_set_image(but, file->path, get_file_icon(file), imb, scale); } + if (play && !is_icon) { + float r = MIN2(ey, ex) / 6.0f; + float yr = sqrt(3) / 2 * r; + float xr = r / 2; + glPushMatrix(); + glTranslatef(xco + ex / 2.0f, yco + ey / 2.0f, 0.0); + glColor4f(1.0f, 1.0f, 1.0f, 0.8); + glutil_draw_filled_arc(0.0f, 2.0f * M_PI, ey / 4.0f, 32); + glColor4f(0.3f, 0.3f, 1.0f, 0.8f); + glutil_draw_filled_arc_part(0.0f, 2.0f * M_PI, ey / 4.0f, ey / 5.0f, 32); + glBegin(GL_TRIANGLES); + glVertex2f(-xr, yr); + glVertex2f(-xr, -yr); + glVertex2f(r, 0.0f); + glEnd(); + glPopMatrix(); + } + glDisable(GL_BLEND); } @@ -503,6 +528,7 @@ void file_draw_list(const bContext *C, ARegion *ar) bool is_icon; short align; bool do_drag; + bool do_play; int column_space = 0.6f * UI_UNIT_X; numfiles = filelist_numfiles(files); @@ -560,14 +586,24 @@ void file_draw_list(const bContext *C, ARegion *ar) do_drag = !(FILENAME_IS_CURRPAR(file->relname)); if (FILE_IMGDISPLAY == params->display) { - is_icon = 0; + is_icon = false; imb = filelist_getimage(files, i); if (!imb) { imb = filelist_geticon(files, i); - is_icon = 1; + is_icon = true; } - file_draw_preview(block, file, sx, sy, imb, layout, is_icon, do_drag); + do_play = (file->selflag & FILE_SEL_COLLAPSED) && !(file->selflag & FILE_SEL_PLAYING); + + file_draw_preview(block, file, sx, sy, imb, layout, is_icon, do_drag, do_play); + + if ((file->selflag & FILE_SEL_COLLAPSED) && (file->selflag & FILE_SEL_PLAYING)) { + /* refresh to keep movie playing */ + file->collapsed_info.curfra++; + file->collapsed_info.curfra %= file->collapsed_info.totfiles; + + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); + } } else { file_draw_icon(block, file->path, sx, sy - (UI_UNIT_Y / 6), get_file_icon(file), ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE, do_drag); @@ -605,43 +641,71 @@ void file_draw_list(const bContext *C, ARegion *ar) if (!(file->selflag & FILE_SEL_EDITING)) { int tpos = (FILE_IMGDISPLAY == params->display) ? sy - layout->tile_h + layout->textheight : sy; - file_draw_string(sx + 1, tpos, file->relname, (float)textwidth, textheight, align); + if (file->selflag & FILE_SEL_COLLAPSED) { + char fname[PATH_MAX]; + char finalname[PATH_MAX]; + char ext[PATH_MAX]; + CollapsedEntry *collapsed = &file->collapsed_info; + BLI_strncpy(fname, file->relname, sizeof(fname)); + BLI_path_frame_strip(fname, false, ext); + BLI_snprintf(finalname, sizeof(finalname), "%s%.*d-%.*d%s", + fname, collapsed->numdigits, collapsed->minframe, collapsed->numdigits, collapsed->maxframe, ext); + file_draw_string(sx + 1, tpos, finalname, (float)textwidth, textheight, align); + } + else + file_draw_string(sx + 1, tpos, file->relname, (float)textwidth, textheight, align); } if (params->display == FILE_SHORTDISPLAY) { sx += (int)layout->column_widths[COLUMN_NAME] + column_space; if (!(file->type & S_IFDIR)) { - file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); + if (file->selflag & FILE_SEL_COLLAPSED) { + CollapsedEntry *collapsed = &file->collapsed_info; + char sizestr[16]; + BLI_file_size_string(collapsed->totalsize, sizestr, sizeof(sizestr)); + file_draw_string(sx, sy, sizestr, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); + } + else + file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); sx += (int)layout->column_widths[COLUMN_SIZE] + column_space; } } else if (params->display == FILE_LONGDISPLAY) { sx += (int)layout->column_widths[COLUMN_NAME] + column_space; + /* for collapsed files it doesn't make sense to display all info */ + if (file->selflag & FILE_SEL_COLLAPSED) { + char sizestr[16]; + CollapsedEntry *collapsed = &file->collapsed_info; + BLI_file_size_string(collapsed->totalsize, sizestr, sizeof(sizestr)); + file_draw_string(sx, sy, sizestr, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); + } + else { #ifndef WIN32 - /* rwx rwx rwx */ - file_draw_string(sx, sy, file->mode1, layout->column_widths[COLUMN_MODE1], layout->tile_h, align); - sx += layout->column_widths[COLUMN_MODE1] + column_space; + /* rwx rwx rwx */ + file_draw_string(sx, sy, file->mode1, layout->column_widths[COLUMN_MODE1], layout->tile_h, align); + sx += layout->column_widths[COLUMN_MODE1] + column_space; - file_draw_string(sx, sy, file->mode2, layout->column_widths[COLUMN_MODE2], layout->tile_h, align); - sx += layout->column_widths[COLUMN_MODE2] + column_space; + file_draw_string(sx, sy, file->mode2, layout->column_widths[COLUMN_MODE2], layout->tile_h, align); + sx += layout->column_widths[COLUMN_MODE2] + column_space; - file_draw_string(sx, sy, file->mode3, layout->column_widths[COLUMN_MODE3], layout->tile_h, align); - sx += layout->column_widths[COLUMN_MODE3] + column_space; + file_draw_string(sx, sy, file->mode3, layout->column_widths[COLUMN_MODE3], layout->tile_h, align); + sx += layout->column_widths[COLUMN_MODE3] + column_space; - file_draw_string(sx, sy, file->owner, layout->column_widths[COLUMN_OWNER], layout->tile_h, align); - sx += layout->column_widths[COLUMN_OWNER] + column_space; + file_draw_string(sx, sy, file->owner, layout->column_widths[COLUMN_OWNER], layout->tile_h, align); + sx += layout->column_widths[COLUMN_OWNER] + column_space; #endif - file_draw_string(sx, sy, file->date, layout->column_widths[COLUMN_DATE], layout->tile_h, align); - sx += (int)layout->column_widths[COLUMN_DATE] + column_space; + file_draw_string(sx, sy, file->date, layout->column_widths[COLUMN_DATE], layout->tile_h, align); + sx += (int)layout->column_widths[COLUMN_DATE] + column_space; - file_draw_string(sx, sy, file->time, layout->column_widths[COLUMN_TIME], layout->tile_h, align); - sx += (int)layout->column_widths[COLUMN_TIME] + column_space; + file_draw_string(sx, sy, file->time, layout->column_widths[COLUMN_TIME], layout->tile_h, align); + sx += (int)layout->column_widths[COLUMN_TIME] + column_space; - if (!(file->type & S_IFDIR)) { - file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); - sx += (int)layout->column_widths[COLUMN_SIZE] + column_space; + if (!(file->type & S_IFDIR)) { + file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); + sx += (int)layout->column_widths[COLUMN_SIZE] + column_space; + } } } } |