Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_file/file_draw.c
| Show All 29 Lines | |||||
| #include <math.h> | #include <math.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_fileops_types.h" | #include "BLI_fileops_types.h" | ||||
| #include "BLI_math.h" | |||||
| #ifdef WIN32 | #ifdef WIN32 | ||||
| # include "BLI_winstuff.h" | # include "BLI_winstuff.h" | ||||
| #endif | #endif | ||||
| #include "BIF_gl.h" | #include "BIF_gl.h" | ||||
| #include "BIF_glutil.h" | #include "BIF_glutil.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BLO_readfile.h" | |||||
| #include "BLF_translation.h" | #include "BLF_translation.h" | ||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "DNA_userdef_types.h" | #include "DNA_userdef_types.h" | ||||
| #include "DNA_windowmanager_types.h" | #include "DNA_windowmanager_types.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "ED_fileselect.h" | #include "ED_fileselect.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_interface_icons.h" | #include "UI_interface_icons.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "WM_api.h" | |||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "filelist.h" | #include "filelist.h" | ||||
| #include "file_intern.h" // own include | #include "file_intern.h" // own include | ||||
| /* Dummy helper - we need dynamic tooltips here. */ | |||||
| static char *file_draw_tooltip_func(bContext *UNUSED(C), void *argN, const char *UNUSED(tip)) | |||||
| { | |||||
| char *dyn_tooltip = argN; | |||||
| return BLI_strdup(dyn_tooltip); | |||||
| } | |||||
| /* Note: This function uses pixelspace (0, 0, winx, winy), not view2d. | /* Note: This function uses pixelspace (0, 0, winx, winy), not view2d. | ||||
| * The controls are laid out as follows: | * The controls are laid out as follows: | ||||
| * | * | ||||
| * ------------------------------------------- | * ------------------------------------------- | ||||
| * | Directory input | execute | | * | Directory input | execute | | ||||
| * ------------------------------------------- | * ------------------------------------------- | ||||
| * | Filename input | + | - | cancel | | * | Filename input | + | - | cancel | | ||||
| * ------------------------------------------- | * ------------------------------------------- | ||||
| ▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | |||||
| static void draw_tile(int sx, int sy, int width, int height, int colorid, int shade) | static void draw_tile(int sx, int sy, int width, int height, int colorid, int shade) | ||||
| { | { | ||||
| UI_ThemeColorShade(colorid, shade); | UI_ThemeColorShade(colorid, shade); | ||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| UI_draw_roundbox((float)sx, (float)(sy - height), (float)(sx + width), (float)sy, 5.0f); | UI_draw_roundbox((float)sx, (float)(sy - height), (float)(sx + width), (float)sy, 5.0f); | ||||
| } | } | ||||
| 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, char *path, int sx, int sy, int icon, int width, int height, bool drag) | static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, int width, int height, bool drag) | ||||
| { | { | ||||
| uiBut *but; | uiBut *but; | ||||
| int x, y; | int x, y; | ||||
| // float alpha = 1.0f; | // float alpha = 1.0f; | ||||
| x = sx; | x = sx; | ||||
| y = sy - height; | y = sy - height; | ||||
| /*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/ | /*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/ | ||||
| but = uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, ""); | but = uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, NULL); | ||||
| UI_but_func_tooltip_set(but, file_draw_tooltip_func, BLI_strdup(path)); | |||||
| if (drag) { | if (drag) { | ||||
| UI_but_drag_set_path(but, path); | /* path is no more static, cannot give it directly to but... */ | ||||
| UI_but_drag_set_path(but, BLI_strdup(path), true); | |||||
sergey: Not totally clear why do we need to duplicate path now actually Worth mentioning this somewhere. | |||||
Not Done Inline ActionsPath is now generated from root + relpath, no more static in filelist. Added some comment about it. mont29: Path is now generated from root + relpath, no more static in filelist. Added some comment about… | |||||
| } | } | ||||
| } | } | ||||
| static void file_draw_string(int sx, int sy, const char *string, float width, int height, short align) | static void file_draw_string(int sx, int sy, const char *string, float width, int height, short align) | ||||
| { | { | ||||
| uiStyle *style; | uiStyle *style; | ||||
| uiFontStyle fs; | uiFontStyle fs; | ||||
| Show All 25 Lines | |||||
| { | { | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| ED_fileselect_init_layout(sfile, ar); | ED_fileselect_init_layout(sfile, ar); | ||||
| UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height); | 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, const char *path, int sx, int sy, | |||||
| ImBuf *imb, const int icon, FileLayout *layout, const bool is_icon, const int typeflags, const bool drag) | |||||
| { | { | ||||
| uiBut *but; | uiBut *but; | ||||
| float fx, fy; | float fx, fy; | ||||
| float dx, dy; | float dx, dy; | ||||
| int xco, yco; | int xco, yco; | ||||
| float ui_imbx, ui_imby; | float ui_imbx, ui_imby; | ||||
| float scaledx, scaledy; | float scaledx, scaledy; | ||||
| float scale; | float scale; | ||||
| int ex, ey; | int ex, ey; | ||||
| bool use_dropshadow = !is_icon && (file->flags & FILE_TYPE_IMAGE); | bool use_dropshadow = !is_icon && (typeflags & FILE_TYPE_IMAGE); | ||||
| BLI_assert(imb != NULL); | BLI_assert(imb != NULL); | ||||
| ui_imbx = imb->x * UI_DPI_FAC; | ui_imbx = imb->x * UI_DPI_FAC; | ||||
| ui_imby = imb->y * UI_DPI_FAC; | ui_imby = imb->y * UI_DPI_FAC; | ||||
| /* Unlike thumbnails, icons are not scaled up. */ | /* Unlike thumbnails, icons are not scaled up. */ | ||||
| if (((ui_imbx > layout->prv_w) || (ui_imby > layout->prv_h)) || | if (((ui_imbx > layout->prv_w) || (ui_imby > layout->prv_h)) || | ||||
| (!is_icon && ((ui_imbx < layout->prv_w) || (ui_imby < layout->prv_h)))) | (!is_icon && ((ui_imbx < layout->prv_w) || (ui_imby < layout->prv_h)))) | ||||
| Show All 29 Lines | static void file_draw_preview( | ||||
| /* shadow */ | /* shadow */ | ||||
| if (use_dropshadow) { | if (use_dropshadow) { | ||||
| UI_draw_box_shadow(220, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); | UI_draw_box_shadow(220, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); | ||||
| } | } | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| /* the image */ | /* the image */ | ||||
| if (!is_icon && file->flags & FILE_TYPE_FTFONT) { | if (!is_icon && typeflags & FILE_TYPE_FTFONT) { | ||||
| UI_ThemeColor(TH_TEXT); | UI_ThemeColor(TH_TEXT); | ||||
| } | } | ||||
| else { | else { | ||||
| glColor4f(1.0, 1.0, 1.0, 1.0); | glColor4f(1.0, 1.0, 1.0, 1.0); | ||||
| } | } | ||||
| glaDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect, scale, scale); | glaDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect, scale, scale); | ||||
| if (icon) { | |||||
| UI_icon_draw((float)xco, (float)yco, icon); | |||||
| } | |||||
| /* border */ | /* border */ | ||||
| if (use_dropshadow) { | if (use_dropshadow) { | ||||
| glColor4f(0.0f, 0.0f, 0.0f, 0.4f); | glColor4f(0.0f, 0.0f, 0.0f, 0.4f); | ||||
| fdrawbox((float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); | fdrawbox((float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); | ||||
| } | } | ||||
| but = uiDefBut(block, UI_BTYPE_LABEL, 0, "", xco, yco, ex, ey, NULL, 0.0, 0.0, 0, 0, NULL); | |||||
| UI_but_func_tooltip_set(but, file_draw_tooltip_func, BLI_strdup(path)); | |||||
| /* dragregion */ | /* dragregion */ | ||||
| if (drag) { | if (drag) { | ||||
| but = uiDefBut(block, UI_BTYPE_LABEL, 0, "", xco, yco, ex, ey, NULL, 0.0, 0.0, 0, 0, ""); | /* path is no more static, cannot give it directly to but... */ | ||||
| UI_but_drag_set_image(but, file->path, get_file_icon(file), imb, scale); | UI_but_drag_set_image(but, BLI_strdup(path), icon, imb, scale, true); | ||||
| } | } | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) | static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) | ||||
| { | { | ||||
| char newname[FILE_MAX + 12]; | char newname[FILE_MAX + 12]; | ||||
| char orgname[FILE_MAX + 12]; | char orgname[FILE_MAX + 12]; | ||||
| char filename[FILE_MAX + 12]; | char filename[FILE_MAX + 12]; | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); | SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); | ||||
| ScrArea *sa = CTX_wm_area(C); | |||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| BLI_make_file_string(G.main->name, orgname, sfile->params->dir, oldname); | BLI_make_file_string(G.main->name, orgname, sfile->params->dir, oldname); | ||||
| BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename)); | BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename)); | ||||
| BLI_make_file_string(G.main->name, newname, sfile->params->dir, filename); | BLI_make_file_string(G.main->name, newname, sfile->params->dir, filename); | ||||
| if (!STREQ(orgname, newname)) { | if (!STREQ(orgname, newname)) { | ||||
| if (!BLI_exists(newname)) { | if (!BLI_exists(newname)) { | ||||
| BLI_rename(orgname, newname); | BLI_rename(orgname, newname); | ||||
| /* to make sure we show what is on disk */ | /* to make sure we show what is on disk */ | ||||
| ED_fileselect_clear(wm, sfile); | ED_fileselect_clear(wm, sa, sfile); | ||||
| } | } | ||||
| ED_region_tag_redraw(ar); | ED_region_tag_redraw(ar); | ||||
| } | } | ||||
| } | } | ||||
| static void draw_background(FileLayout *layout, View2D *v2d) | static void draw_background(FileLayout *layout, View2D *v2d) | ||||
| ▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
| void file_draw_list(const bContext *C, ARegion *ar) | void file_draw_list(const bContext *C, ARegion *ar) | ||||
| { | { | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| FileSelectParams *params = ED_fileselect_get_params(sfile); | FileSelectParams *params = ED_fileselect_get_params(sfile); | ||||
| FileLayout *layout = ED_fileselect_get_layout(sfile, ar); | FileLayout *layout = ED_fileselect_get_layout(sfile, ar); | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| struct FileList *files = sfile->files; | struct FileList *files = sfile->files; | ||||
| struct direntry *file; | struct FileDirEntry *file; | ||||
| const char *root = filelist_dir(files); | |||||
| ImBuf *imb; | ImBuf *imb; | ||||
| uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS); | uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS); | ||||
| int numfiles; | int numfiles; | ||||
| int numfiles_layout; | int numfiles_layout; | ||||
| int sx, sy; | int sx, sy; | ||||
| int offset; | int offset; | ||||
| int textwidth, textheight; | int textwidth, textheight; | ||||
| int i; | int i; | ||||
| bool is_icon; | bool is_icon; | ||||
| short align; | short align; | ||||
| bool do_drag; | bool do_drag; | ||||
| int column_space = 0.6f * UI_UNIT_X; | int column_space = 0.6f * UI_UNIT_X; | ||||
| const bool small_size = SMALL_SIZE_CHECK(params->thumbnail_size); | |||||
| const bool update_stat_strings = small_size != SMALL_SIZE_CHECK(layout->curr_size); | |||||
| numfiles = filelist_numfiles(files); | numfiles = filelist_files_ensure(files); | ||||
| if (params->display != FILE_IMGDISPLAY) { | if (params->display != FILE_IMGDISPLAY) { | ||||
| draw_background(layout, v2d); | draw_background(layout, v2d); | ||||
| draw_dividers(layout, v2d); | draw_dividers(layout, v2d); | ||||
| } | } | ||||
| offset = ED_fileselect_layout_offset(layout, (int)ar->v2d.cur.xmin, (int)-ar->v2d.cur.ymax); | offset = ED_fileselect_layout_offset(layout, (int)ar->v2d.cur.xmin, (int)-ar->v2d.cur.ymax); | ||||
| if (offset < 0) offset = 0; | if (offset < 0) offset = 0; | ||||
| numfiles_layout = ED_fileselect_layout_numfiles(layout, ar); | numfiles_layout = ED_fileselect_layout_numfiles(layout, ar); | ||||
| /* adjust, so the next row is already drawn when scrolling */ | /* adjust, so the next row is already drawn when scrolling */ | ||||
| if (layout->flag & FILE_LAYOUT_HOR) { | if (layout->flag & FILE_LAYOUT_HOR) { | ||||
| numfiles_layout += layout->rows; | numfiles_layout += layout->rows; | ||||
| } | } | ||||
| else { | else { | ||||
| numfiles_layout += layout->columns; | numfiles_layout += layout->columns; | ||||
| } | } | ||||
| filelist_file_cache_slidingwindow_set(files, numfiles_layout); | |||||
| textwidth = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : (int)layout->column_widths[COLUMN_NAME]; | textwidth = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : (int)layout->column_widths[COLUMN_NAME]; | ||||
| textheight = (int)(layout->textheight * 3.0 / 2.0 + 0.5); | textheight = (int)(layout->textheight * 3.0 / 2.0 + 0.5); | ||||
| align = (FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT; | align = (FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT; | ||||
| if (numfiles > 0) { | |||||
| const bool success = filelist_file_cache_block(files, min_ii(offset + (numfiles_layout / 2), numfiles - 1)); | |||||
| BLI_assert(success); | |||||
| UNUSED_VARS_NDEBUG(success); | |||||
| filelist_cache_previews_update(files); | |||||
| /* Handle preview timer here, since it's filelist_file_cache_block() and filelist_cache_previews_update() | |||||
| * which controlls previews task. */ | |||||
| { | |||||
| const bool previews_running = filelist_cache_previews_running(files); | |||||
| // printf("%s: preview task: %d\n", __func__, previews_running); | |||||
| if (previews_running && !sfile->previews_timer) { | |||||
| sfile->previews_timer = WM_event_add_timer_notifier(CTX_wm_manager(C), CTX_wm_window(C), | |||||
| NC_SPACE | ND_SPACE_FILE_PREVIEW, 0.01); | |||||
| } | |||||
| if (!previews_running && sfile->previews_timer) { | |||||
| /* Preview is not running, no need to keep generating update events! */ | |||||
| // printf("%s: Inactive preview task, sleeping!\n", __func__); | |||||
| WM_event_remove_timer_notifier(CTX_wm_manager(C), CTX_wm_window(C), sfile->previews_timer); | |||||
| sfile->previews_timer = NULL; | |||||
| } | |||||
| } | |||||
| } | |||||
| for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) { | for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) { | ||||
| unsigned int file_selflag; | |||||
| char path[FILE_MAX_LIBEXTRA]; | |||||
| ED_fileselect_layout_tilepos(layout, i, &sx, &sy); | ED_fileselect_layout_tilepos(layout, i, &sx, &sy); | ||||
| sx += (int)(v2d->tot.xmin + 0.1f * UI_UNIT_X); | sx += (int)(v2d->tot.xmin + 0.1f * UI_UNIT_X); | ||||
| sy = (int)(v2d->tot.ymax - sy); | sy = (int)(v2d->tot.ymax - sy); | ||||
| file = filelist_file(files, i); | file = filelist_file(files, i); | ||||
| file_selflag = filelist_entry_select_get(sfile->files, file, CHECK_ALL); | |||||
| BLI_join_dirfile(path, sizeof(path), root, file->relpath); | |||||
| UI_ThemeColor4(TH_TEXT); | UI_ThemeColor4(TH_TEXT); | ||||
| if (!(file->selflag & FILE_SEL_EDITING)) { | if (!(file_selflag & FILE_SEL_EDITING)) { | ||||
| if ((params->highlight_file == i) || (file->selflag & FILE_SEL_HIGHLIGHTED) || (file->selflag & FILE_SEL_SELECTED)) { | if ((params->highlight_file == i) || (file_selflag & FILE_SEL_HIGHLIGHTED) || | ||||
| int colorid = (file->selflag & FILE_SEL_SELECTED) ? TH_HILITE : TH_BACK; | (file_selflag & FILE_SEL_SELECTED)) | ||||
| int shade = (params->highlight_file == i) || (file->selflag & FILE_SEL_HIGHLIGHTED) ? 35 : 0; | { | ||||
| 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 */ | /* 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; | colorid = TH_BACK; | ||||
| } | } | ||||
| draw_tile(sx, sy - 1, layout->tile_w + 4, sfile->layout->tile_h + layout->tile_border_y, colorid, shade); | draw_tile(sx, sy - 1, layout->tile_w + 4, sfile->layout->tile_h + layout->tile_border_y, colorid, shade); | ||||
| } | } | ||||
| } | } | ||||
| UI_draw_roundbox_corner_set(UI_CNR_NONE); | UI_draw_roundbox_corner_set(UI_CNR_NONE); | ||||
| /* don't drag parent or refresh items */ | /* don't drag parent or refresh items */ | ||||
| do_drag = !(FILENAME_IS_CURRPAR(file->relname)); | do_drag = !(FILENAME_IS_CURRPAR(file->relpath)); | ||||
| if (FILE_IMGDISPLAY == params->display) { | if (FILE_IMGDISPLAY == params->display) { | ||||
| const int icon = filelist_geticon(files, i, false); | |||||
| is_icon = 0; | is_icon = 0; | ||||
| imb = filelist_getimage(files, i); | imb = filelist_getimage(files, i); | ||||
| if (!imb) { | if (!imb) { | ||||
| imb = filelist_geticon(files, i); | imb = filelist_geticon_image(files, i); | ||||
| is_icon = 1; | is_icon = 1; | ||||
| } | } | ||||
| file_draw_preview(block, file, sx, sy, imb, layout, is_icon, do_drag); | file_draw_preview(block, path, sx, sy, imb, icon, layout, is_icon, file->typeflag, do_drag); | ||||
| } | } | ||||
| else { | 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); | file_draw_icon(block, path, sx, sy - (UI_UNIT_Y / 6), filelist_geticon(files, i, true), | ||||
| ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE, do_drag); | |||||
| sx += ICON_DEFAULT_WIDTH_SCALE + 0.2f * UI_UNIT_X; | sx += ICON_DEFAULT_WIDTH_SCALE + 0.2f * UI_UNIT_X; | ||||
| } | } | ||||
| UI_ThemeColor4(TH_TEXT); | UI_ThemeColor4(TH_TEXT); | ||||
| if (file->selflag & FILE_SEL_EDITING) { | if (file_selflag & FILE_SEL_EDITING) { | ||||
| uiBut *but; | uiBut *but; | ||||
| short width; | short width; | ||||
| if (params->display == FILE_SHORTDISPLAY) { | if (params->display == FILE_SHORTDISPLAY) { | ||||
| width = layout->tile_w - (ICON_DEFAULT_WIDTH_SCALE + 0.2f * UI_UNIT_X); | width = layout->tile_w - (ICON_DEFAULT_WIDTH_SCALE + 0.2f * UI_UNIT_X); | ||||
| } | } | ||||
| else if (params->display == FILE_LONGDISPLAY) { | else if (params->display == FILE_LONGDISPLAY) { | ||||
| width = layout->column_widths[COLUMN_NAME] + layout->column_widths[COLUMN_MODE1] + | width = layout->column_widths[COLUMN_NAME] + (column_space * 3.5f); | ||||
| layout->column_widths[COLUMN_MODE2] + layout->column_widths[COLUMN_MODE3] + | |||||
| (column_space * 3.5f); | |||||
| } | } | ||||
| else { | else { | ||||
| BLI_assert(params->display == FILE_IMGDISPLAY); | BLI_assert(params->display == FILE_IMGDISPLAY); | ||||
| width = textwidth; | width = textwidth; | ||||
| } | } | ||||
| but = uiDefBut(block, UI_BTYPE_TEXT, 1, "", sx, sy - layout->tile_h - 0.15f * UI_UNIT_X, | but = uiDefBut(block, UI_BTYPE_TEXT, 1, "", sx, sy - layout->tile_h - 0.15f * UI_UNIT_X, | ||||
| width, textheight, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit), 0, 0, ""); | width, textheight, sfile->params->renameedit, 1.0f, | ||||
| (float)sizeof(sfile->params->renameedit), 0, 0, ""); | |||||
| UI_but_func_rename_set(but, renamebutton_cb, file); | UI_but_func_rename_set(but, renamebutton_cb, file); | ||||
| UI_but_flag_enable(but, UI_BUT_NO_UTF8); /* allow non utf8 names */ | UI_but_flag_enable(but, UI_BUT_NO_UTF8); /* allow non utf8 names */ | ||||
| UI_but_flag_disable(but, UI_BUT_UNDO); | UI_but_flag_disable(but, UI_BUT_UNDO); | ||||
| if (false == UI_but_active_only(C, ar, block, but)) { | if (false == UI_but_active_only(C, ar, block, but)) { | ||||
| file->selflag &= ~FILE_SEL_EDITING; | file_selflag = filelist_entry_select_set( | ||||
| sfile->files, file, FILE_SEL_REMOVE, FILE_SEL_EDITING, CHECK_ALL); | |||||
| } | } | ||||
| } | } | ||||
| if (!(file->selflag & FILE_SEL_EDITING)) { | if (!(file_selflag& FILE_SEL_EDITING)) { | ||||
| int tpos = (FILE_IMGDISPLAY == params->display) ? sy - layout->tile_h + layout->textheight : sy; | 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); | file_draw_string(sx + 1, tpos, file->name, (float)textwidth, textheight, align); | ||||
| } | } | ||||
| if (params->display == FILE_SHORTDISPLAY) { | if (params->display == FILE_SHORTDISPLAY) { | ||||
| sx += (int)layout->column_widths[COLUMN_NAME] + column_space; | sx += (int)layout->column_widths[COLUMN_NAME] + column_space; | ||||
| if (!(file->type & S_IFDIR)) { | if (!(file->typeflag & FILE_TYPE_DIR)) { | ||||
| file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); | if ((file->entry->size_str[0] == '\0') || update_stat_strings) { | ||||
| BLI_filelist_entry_size_to_string(NULL, file->entry->size, small_size, file->entry->size_str); | |||||
| } | |||||
| file_draw_string( | |||||
| sx, sy, file->entry->size_str, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); | |||||
| sx += (int)layout->column_widths[COLUMN_SIZE] + column_space; | sx += (int)layout->column_widths[COLUMN_SIZE] + column_space; | ||||
| } | } | ||||
| } | } | ||||
| else if (params->display == FILE_LONGDISPLAY) { | else if (params->display == FILE_LONGDISPLAY) { | ||||
| sx += (int)layout->column_widths[COLUMN_NAME] + column_space; | sx += (int)layout->column_widths[COLUMN_NAME] + column_space; | ||||
| #ifndef WIN32 | if ((file->entry->date_str[0] == '\0') || update_stat_strings) { | ||||
| /* rwx rwx rwx */ | BLI_filelist_entry_datetime_to_string( | ||||
| file_draw_string(sx, sy, file->mode1, layout->column_widths[COLUMN_MODE1], layout->tile_h, align); | NULL, file->entry->time, small_size, file->entry->time_str, file->entry->date_str); | ||||
| sx += layout->column_widths[COLUMN_MODE1] + column_space; | } | ||||
| file_draw_string(sx, sy, file->entry->date_str, layout->column_widths[COLUMN_DATE], layout->tile_h, align); | |||||
| 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->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; | sx += (int)layout->column_widths[COLUMN_DATE] + column_space; | ||||
| file_draw_string(sx, sy, file->entry->time_str, layout->column_widths[COLUMN_TIME], layout->tile_h, align); | |||||
| 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; | sx += (int)layout->column_widths[COLUMN_TIME] + column_space; | ||||
| if (!(file->type & S_IFDIR)) { | if (!(file->typeflag & FILE_TYPE_DIR)) { | ||||
| file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); | if ((file->entry->size_str[0] == '\0') || update_stat_strings) { | ||||
| BLI_filelist_entry_size_to_string(NULL, file->entry->size, small_size, file->entry->size_str); | |||||
| } | |||||
| file_draw_string( | |||||
| sx, sy, file->entry->size_str, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); | |||||
| sx += (int)layout->column_widths[COLUMN_SIZE] + column_space; | sx += (int)layout->column_widths[COLUMN_SIZE] + column_space; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| UI_block_end(C, block); | UI_block_end(C, block); | ||||
| UI_block_draw(C, block); | UI_block_draw(C, block); | ||||
| layout->curr_size = params->thumbnail_size; | |||||
| } | } | ||||
Not totally clear why do we need to duplicate path now actually Worth mentioning this somewhere.