diff options
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 144 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_intern.h | 4 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 44 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_panels.c | 7 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_utils.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_file/fsmenu.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 207 |
9 files changed, 190 insertions, 227 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index f407d82aa5e..2ae432fbc4e 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -42,7 +42,6 @@ # include "BLI_winstuff.h" #endif -#include "BIF_gl.h" #include "BIF_glutil.h" #include "BKE_context.h" @@ -53,6 +52,8 @@ #include "BLT_translation.h" +#include "BLF_api.h" + #include "IMB_imbuf_types.h" #include "DNA_userdef_types.h" @@ -71,6 +72,10 @@ #include "WM_api.h" #include "WM_types.h" +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_state.h" + #include "filelist.h" #include "file_intern.h" // own include @@ -216,13 +221,13 @@ void file_draw_buttons(const bContext *C, ARegion *ar) /* Filename number increment / decrement buttons. */ if (fnumbuttons && (params->flag & FILE_DIRSEL_ONLY) == 0) { UI_block_align_begin(block); - but = uiDefIconButO(block, UI_BTYPE_BUT, "FILE_OT_filenum", 0, ICON_ZOOMOUT, + but = uiDefIconButO(block, UI_BTYPE_BUT, "FILE_OT_filenum", 0, ICON_REMOVE, min_x + line2_w + separator - chan_offs, line2_y, btn_fn_w, btn_h, TIP_("Decrement the filename number")); RNA_int_set(UI_but_operator_ptr_get(but), "increment", -1); - but = uiDefIconButO(block, UI_BTYPE_BUT, "FILE_OT_filenum", 0, ICON_ZOOMIN, + but = uiDefIconButO(block, UI_BTYPE_BUT, "FILE_OT_filenum", 0, ICON_ADD, min_x + line2_w + separator + btn_fn_w - chan_offs, line2_y, btn_fn_w, btn_h, TIP_("Increment the filename number")); @@ -258,9 +263,10 @@ void file_draw_buttons(const bContext *C, ARegion *ar) static void draw_tile(int sx, int sy, int width, int height, int colorid, int shade) { - UI_ThemeColorShade(colorid, shade); + float color[4]; + UI_GetThemeColorShade4fv(colorid, shade, color); 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_aa(true, (float)sx, (float)(sy - height), (float)(sx + width), (float)sy, 5.0f, color); } @@ -285,7 +291,8 @@ static void file_draw_icon(uiBlock *block, const char *path, int sx, int sy, int } -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, + const unsigned char col[4]) { uiStyle *style; uiFontStyle fs; @@ -310,7 +317,7 @@ static void file_draw_string(int sx, int sy, const char *string, float width, in rect.ymin = sy - height; rect.ymax = sy; - UI_fontstyle_draw(&fs, &rect, fname); + UI_fontstyle_draw(&fs, &rect, fname, col); } void file_calc_previews(const bContext *C, ARegion *ar) @@ -335,6 +342,7 @@ static void file_draw_preview( float scale; int ex, ey; bool use_dropshadow = !is_icon && (typeflags & FILE_TYPE_IMAGE); + float col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; BLI_assert(imb != NULL); @@ -370,32 +378,37 @@ static void file_draw_preview( xco = sx + (int)dx; yco = sy - layout->prv_h + (int)dy; - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* shadow */ if (use_dropshadow) { UI_draw_box_shadow(220, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); } - glEnable(GL_BLEND); + GPU_blend(true); /* the image */ if (!is_icon && typeflags & FILE_TYPE_FTFONT) { - UI_ThemeColor(TH_TEXT); - } - else { - glColor4f(1.0, 1.0, 1.0, 1.0); + UI_GetThemeColor4fv(TH_TEXT, col); } - glaDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect, scale, scale); + + IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); + immDrawPixelsTexScaled(&state, (float)xco, (float)yco, imb->x, imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect, + scale, scale, 1.0f, 1.0f, col); if (icon) { - UI_icon_draw_aspect((float)xco, (float)yco, icon, icon_aspect, 1.0f); + UI_icon_draw_aspect((float)xco, (float)yco, icon, icon_aspect, 1.0f, NULL); } /* border */ if (use_dropshadow) { - glColor4f(0.0f, 0.0f, 0.0f, 0.4f); - fdrawbox((float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f); + imm_draw_box_wire_2d(pos, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); + immUnbindProgram(); } but = uiDefBut(block, UI_BTYPE_LABEL, 0, "", xco, yco, ex, ey, NULL, 0.0, 0.0, 0, 0, NULL); @@ -407,7 +420,7 @@ static void file_draw_preview( UI_but_drag_set_image(but, BLI_strdup(path), icon, imb, scale, true); } - glDisable(GL_BLEND); + GPU_blend(false); } static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) @@ -453,49 +466,70 @@ static void draw_background(FileLayout *layout, View2D *v2d) int i; int sy; - UI_ThemeColorShade(TH_BACK, -7); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformThemeColorShade(TH_BACK, -7); /* alternating flat shade background */ for (i = 0; (i <= layout->rows); i += 2) { sy = (int)v2d->cur.ymax - i * (layout->tile_h + 2 * layout->tile_border_y) - layout->tile_border_y; - glRectf(v2d->cur.xmin, (float)sy, v2d->cur.xmax, (float)(sy + layout->tile_h + 2 * layout->tile_border_y)); - + immRectf(pos, v2d->cur.xmin, (float)sy, v2d->cur.xmax, (float)(sy + layout->tile_h + 2 * layout->tile_border_y)); } + + immUnbindProgram(); } static void draw_dividers(FileLayout *layout, View2D *v2d) { + /* vertical column dividers */ + const int step = (layout->tile_w + 2 * layout->tile_border_x); - int v1[2], v2[2]; - int sx; - unsigned char col_hi[3], col_lo[3]; - UI_GetThemeColorShade3ubv(TH_BACK, 30, col_hi); - UI_GetThemeColorShade3ubv(TH_BACK, -30, col_lo); + unsigned int vertex_len = 0; + int sx = (int)v2d->tot.xmin; + while (sx < v2d->cur.xmax) { + sx += step; + vertex_len += 4; /* vertex_count = 2 points per line * 2 lines per divider */ + } + + if (vertex_len > 0) { + int v1[2], v2[2]; + unsigned char col_hi[3], col_lo[3]; - v1[1] = v2d->cur.ymax - layout->tile_border_y; - v2[1] = v2d->cur.ymin; + UI_GetThemeColorShade3ubv(TH_BACK, 30, col_hi); + UI_GetThemeColorShade3ubv(TH_BACK, -30, col_lo); - glBegin(GL_LINES); + v1[1] = v2d->cur.ymax - layout->tile_border_y; + v2[1] = v2d->cur.ymin; - /* vertical column dividers */ - sx = (int)v2d->tot.xmin; - while (sx < v2d->cur.xmax) { - sx += step; + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); - glColor3ubv(col_lo); - v1[0] = v2[0] = sx; - glVertex2iv(v1); - glVertex2iv(v2); + immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); + immBegin(GPU_PRIM_LINES, vertex_len); - glColor3ubv(col_hi); - v1[0] = v2[0] = sx + 1; - glVertex2iv(v1); - glVertex2iv(v2); - } + sx = (int)v2d->tot.xmin; + while (sx < v2d->cur.xmax) { + sx += step; + + v1[0] = v2[0] = sx; + immAttrSkip(color); + immVertex2iv(pos, v1); + immAttr3ubv(color, col_lo); + immVertex2iv(pos, v2); - glEnd(); + v1[0] = v2[0] = sx + 1; + immAttrSkip(color); + immVertex2iv(pos, v1); + immAttr3ubv(color, col_hi); + immVertex2iv(pos, v2); + } + + immEnd(); + immUnbindProgram(); + } } void file_draw_list(const bContext *C, ARegion *ar) @@ -519,6 +553,7 @@ void file_draw_list(const bContext *C, ARegion *ar) short align; bool do_drag; int column_space = 0.6f * UI_UNIT_X; + unsigned char text_col[4]; const bool small_size = SMALL_SIZE_CHECK(params->thumbnail_size); const bool update_stat_strings = small_size != SMALL_SIZE_CHECK(layout->curr_size); const float thumb_icon_aspect = sqrtf(64.0f / (float)(params->thumbnail_size)); @@ -577,6 +612,8 @@ void file_draw_list(const bContext *C, ARegion *ar) } } + BLF_batch_draw_begin(); + for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) { unsigned int file_selflag; char path[FILE_MAX_LIBEXTRA]; @@ -589,9 +626,6 @@ void file_draw_list(const bContext *C, ARegion *ar) BLI_join_dirfile(path, sizeof(path), root, file->relpath); - 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)) @@ -627,7 +661,7 @@ void file_draw_list(const bContext *C, ARegion *ar) sx += ICON_DEFAULT_WIDTH_SCALE + 0.2f * UI_UNIT_X; } - UI_ThemeColor4(TH_TEXT); + UI_GetThemeColor4ubv(TH_TEXT, text_col); if (file_selflag & FILE_SEL_EDITING) { uiBut *but; @@ -658,7 +692,7 @@ 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->name, (float)textwidth, textheight, align); + file_draw_string(sx + 1, tpos, file->name, (float)textwidth, textheight, align, text_col); } sx += (int)layout->column_widths[COLUMN_NAME] + column_space; @@ -670,7 +704,8 @@ void file_draw_list(const bContext *C, ARegion *ar) 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, sy, file->entry->size_str, layout->column_widths[COLUMN_SIZE], layout->tile_h, + align, text_col); } sx += (int)layout->column_widths[COLUMN_SIZE] + column_space; } @@ -681,10 +716,12 @@ void file_draw_list(const bContext *C, ARegion *ar) NULL, file->entry->time, small_size, file->entry->time_str, file->entry->date_str); } file_draw_string( - sx, sy, file->entry->date_str, layout->column_widths[COLUMN_DATE], layout->tile_h, align); + sx, sy, file->entry->date_str, layout->column_widths[COLUMN_DATE], layout->tile_h, + align, text_col); 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); + sx, sy, file->entry->time_str, layout->column_widths[COLUMN_TIME], layout->tile_h, + align, text_col); sx += (int)layout->column_widths[COLUMN_TIME] + column_space; } else { @@ -699,12 +736,15 @@ void file_draw_list(const bContext *C, ARegion *ar) 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, sy, file->entry->size_str, layout->column_widths[COLUMN_SIZE], layout->tile_h, + align, text_col); } sx += (int)layout->column_widths[COLUMN_SIZE] + column_space; } } + BLF_batch_draw_end(); + UI_block_end(C, block); UI_block_draw(C, block); diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index 6eaf2dda084..710aa472a8b 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -72,8 +72,8 @@ typedef enum WalkSelectDirection { void FILE_OT_highlight(struct wmOperatorType *ot); void FILE_OT_select(struct wmOperatorType *ot); void FILE_OT_select_walk(struct wmOperatorType *ot); -void FILE_OT_select_all_toggle(struct wmOperatorType *ot); -void FILE_OT_select_border(struct wmOperatorType *ot); +void FILE_OT_select_all(struct wmOperatorType *ot); +void FILE_OT_select_box(struct wmOperatorType *ot); void FILE_OT_select_bookmark(struct wmOperatorType *ot); void FILE_OT_bookmark_add(struct wmOperatorType *ot); void FILE_OT_bookmark_delete(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 429b643a807..ea73026020d 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -37,10 +37,10 @@ #include "BKE_appdir.h" #include "BKE_context.h" -#include "BKE_screen.h" #include "BKE_global.h" -#include "BKE_report.h" #include "BKE_main.h" +#include "BKE_report.h" +#include "BKE_screen.h" #ifdef WIN32 # include "BLI_winstuff.h" @@ -113,7 +113,7 @@ typedef enum FileSelect { static void clamp_to_filelist(int numfiles, FileSelection *sel) { - /* border select before the first file */ + /* box select before the first file */ if ( (sel->first < 0) && (sel->last >= 0) ) { sel->first = 0; } @@ -338,7 +338,7 @@ static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, return retval; } -static int file_border_select_find_last_selected( +static int file_box_select_find_last_selected( SpaceFile *sfile, ARegion *ar, const FileSelection *sel, const int mouse_xy[2]) { @@ -371,7 +371,7 @@ static int file_border_select_find_last_selected( return (dist_first < dist_last) ? sel->first : sel->last; } -static int file_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event) +static int file_box_select_modal(bContext *C, wmOperator *op, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); SpaceFile *sfile = CTX_wm_space_file(C); @@ -381,7 +381,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, const wmEvent * int result; - result = WM_gesture_border_modal(C, op, event); + result = WM_gesture_box_modal(C, op, event); if (result == OPERATOR_RUNNING_MODAL) { WM_operator_properties_border_to_rcti(op, &rect); @@ -399,7 +399,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, const wmEvent * for (idx = sel.last; idx >= 0; idx--) { const FileDirEntry *file = filelist_file(sfile->files, idx); - /* dont highlight readonly file (".." or ".") on border select */ + /* dont highlight readonly file (".." or ".") on box select */ if (FILENAME_IS_CURRPAR(file->relpath)) { filelist_entry_select_set(sfile->files, file, FILE_SEL_REMOVE, FILE_SEL_HIGHLIGHTED, CHECK_ALL); } @@ -411,7 +411,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, const wmEvent * } } params->sel_first = sel.first; params->sel_last = sel.last; - params->active_file = file_border_select_find_last_selected(sfile, ar, &sel, event->mval); + params->active_file = file_box_select_find_last_selected(sfile, ar, &sel, event->mval); } else { params->highlight_file = -1; @@ -424,7 +424,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, const wmEvent * return result; } -static int file_border_select_exec(bContext *C, wmOperator *op) +static int file_box_select_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); SpaceFile *sfile = CTX_wm_space_file(C); @@ -455,22 +455,22 @@ static int file_border_select_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void FILE_OT_select_border(wmOperatorType *ot) +void FILE_OT_select_box(wmOperatorType *ot) { /* identifiers */ - ot->name = "Activate/Select File"; + ot->name = "Box Select"; ot->description = "Activate/select the file(s) contained in the border"; - ot->idname = "FILE_OT_select_border"; + ot->idname = "FILE_OT_select_box"; /* api callbacks */ - ot->invoke = WM_gesture_border_invoke; - ot->exec = file_border_select_exec; - ot->modal = file_border_select_modal; + ot->invoke = WM_gesture_box_invoke; + ot->exec = file_box_select_exec; + ot->modal = file_box_select_modal; ot->poll = ED_operator_file_active; - ot->cancel = WM_gesture_border_cancel; + ot->cancel = WM_gesture_box_cancel; /* properties */ - WM_operator_properties_gesture_border_select(ot); + WM_operator_properties_gesture_box_select(ot); } static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -527,7 +527,7 @@ void FILE_OT_select(wmOperatorType *ot) PropertyRNA *prop; /* identifiers */ - ot->name = "Activate/Select File"; + ot->name = "Select"; ot->description = "Activate/select file"; ot->idname = "FILE_OT_select"; @@ -808,12 +808,12 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void FILE_OT_select_all_toggle(wmOperatorType *ot) +void FILE_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name = "(De)select All Files"; ot->description = "Select or deselect all files"; - ot->idname = "FILE_OT_select_all_toggle"; + ot->idname = "FILE_OT_select_all"; /* api callbacks */ ot->exec = file_select_all_exec; @@ -1147,11 +1147,11 @@ static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv SpaceFile *sfile = CTX_wm_space_file(C); if (!file_highlight_set(sfile, ar, event->x, event->y)) - return OPERATOR_CANCELLED; + return OPERATOR_PASS_THROUGH; ED_area_tag_redraw(CTX_wm_area(C)); - return OPERATOR_FINISHED; + return OPERATOR_PASS_THROUGH; } void FILE_OT_highlight(struct wmOperatorType *ot) diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index a40334098d7..cbf685e6ed8 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -80,7 +80,7 @@ static void file_panel_operator(const bContext *C, Panel *pa) UI_block_func_set(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL); /* Hack: temporary hide.*/ - const char *hide[] = {"filepath", "directory", "filename", "files"}; + const char *hide[] = {"filepath", "files", "directory", "filename"}; for (int i = 0; i < ARRAY_SIZE(hide); i++) { PropertyRNA *prop = RNA_struct_find_property(op->ptr, hide[i]); if (prop) { @@ -88,8 +88,11 @@ static void file_panel_operator(const bContext *C, Panel *pa) } } - uiTemplateOperatorPropertyButs(C, pa->layout, op, '\0', UI_TEMPLATE_OP_PROPS_SHOW_EMPTY); + uiTemplateOperatorPropertyButs( + C, pa->layout, op, UI_BUT_LABEL_ALIGN_NONE, + UI_TEMPLATE_OP_PROPS_SHOW_EMPTY); + /* Hack: temporary hide.*/ for (int i = 0; i < ARRAY_SIZE(hide); i++) { PropertyRNA *prop = RNA_struct_find_property(op->ptr, hide[i]); if (prop) { diff --git a/source/blender/editors/space_file/file_utils.c b/source/blender/editors/space_file/file_utils.c index c1caf5ae8ac..fc870399696 100644 --- a/source/blender/editors/space_file/file_utils.c +++ b/source/blender/editors/space_file/file_utils.c @@ -26,6 +26,7 @@ #include "BLI_rect.h" #include "BLI_fileops.h" +#include "BLI_listbase.h" #include "BLO_readfile.h" diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 368fc8be35c..218c7dcdb42 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -65,7 +65,6 @@ #include "BKE_context.h" #include "BKE_global.h" -#include "BKE_library.h" #include "BKE_icons.h" #include "BKE_idcode.h" #include "BKE_main.h" @@ -2357,7 +2356,7 @@ static void filelist_readjob_main_rec(Main *bmain, FileList *filelist) filelist->filelist.entries[9].entry->relpath = BLI_strdup("Ika"); filelist->filelist.entries[10].entry->relpath = BLI_strdup("Wave"); filelist->filelist.entries[11].entry->relpath = BLI_strdup("Lattice"); - filelist->filelist.entries[12].entry->relpath = BLI_strdup("Lamp"); + filelist->filelist.entries[12].entry->relpath = BLI_strdup("Light"); filelist->filelist.entries[13].entry->relpath = BLI_strdup("Camera"); filelist->filelist.entries[14].entry->relpath = BLI_strdup("Ipo"); filelist->filelist.entries[15].entry->relpath = BLI_strdup("World"); diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 1c86ecc327b..cb014f30d95 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -221,7 +221,8 @@ short ED_fileselect_set_params(SpaceFile *sfile) FILTER_ID_GR | FILTER_ID_IM | FILTER_ID_LA | FILTER_ID_LS | FILTER_ID_LT | FILTER_ID_MA | FILTER_ID_MB | FILTER_ID_MC | FILTER_ID_ME | FILTER_ID_MSK | FILTER_ID_NT | FILTER_ID_OB | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_SCE | FILTER_ID_SPK | FILTER_ID_SO | - FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_WO | FILTER_ID_CF; + FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_WO | FILTER_ID_CF | FILTER_ID_WS | + FILTER_ID_LP; if (U.uiflag & USER_HIDE_DOT) { params->flag |= FILE_HIDE_DOT; @@ -234,7 +235,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) if (params->type == FILE_LOADLIB) { params->flag |= RNA_boolean_get(op->ptr, "link") ? FILE_LINK : 0; params->flag |= RNA_boolean_get(op->ptr, "autoselect") ? FILE_AUTOSELECT : 0; - params->flag |= RNA_boolean_get(op->ptr, "active_layer") ? FILE_ACTIVELAY : 0; + params->flag |= RNA_boolean_get(op->ptr, "active_collection") ? FILE_ACTIVE_COLLECTION : 0; } if ((prop = RNA_struct_find_property(op->ptr, "display_type"))) { diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 359cce45baa..9b1aae03219 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -42,8 +42,6 @@ #include "BKE_appdir.h" -#include "DNA_space_types.h" - #include "ED_fileselect.h" #ifdef WIN32 diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index b0dea1eb31b..e0413e48346 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -49,6 +49,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "WM_message.h" #include "ED_space_api.h" #include "ED_screen.h" @@ -64,10 +65,11 @@ #include "file_intern.h" // own include #include "fsmenu.h" #include "filelist.h" +#include "GPU_framebuffer.h" /* ******************** default callbacks for file space ***************** */ -static SpaceLink *file_new(const bContext *UNUSED(C)) +static SpaceLink *file_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene)) { ARegion *ar; SpaceFile *sfile; @@ -291,11 +293,12 @@ static void file_refresh(const bContext *C, ScrArea *sa) file_tools_region(sa); ED_area_initialize(wm, CTX_wm_window(C), sa); - ED_area_tag_redraw(sa); } + + ED_area_tag_redraw(sa); } -static void file_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) +static void file_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene)) { SpaceFile *sfile = (SpaceFile *)sa->spacedata.first; @@ -305,16 +308,13 @@ static void file_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) switch (wmn->data) { case ND_SPACE_FILE_LIST: ED_area_tag_refresh(sa); - ED_area_tag_redraw(sa); break; case ND_SPACE_FILE_PARAMS: ED_area_tag_refresh(sa); - ED_area_tag_redraw(sa); break; case ND_SPACE_FILE_PREVIEW: if (sfile->files && filelist_cache_previews_update(sfile->files)) { ED_area_tag_refresh(sa); - ED_area_tag_redraw(sa); } break; } @@ -337,7 +337,9 @@ static void file_main_region_init(wmWindowManager *wm, ARegion *ar) WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } -static void file_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) +static void file_main_region_listener( + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, + wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ switch (wmn->category) { @@ -354,6 +356,42 @@ static void file_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), } } +static void file_main_region_message_subscribe( + const struct bContext *UNUSED(C), + struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene), + struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar, + struct wmMsgBus *mbus) +{ + SpaceFile *sfile = sa->spacedata.first; + FileSelectParams *params = ED_fileselect_get_params(sfile); + /* This is a bit odd that a region owns the subscriber for an area, + * keep for now since all subscribers for WM are regions. + * May be worth re-visiting later. */ + wmMsgSubscribeValue msg_sub_value_area_tag_refresh = { + .owner = ar, + .user_data = sa, + .notify = ED_area_do_msg_notify_tag_refresh, + }; + + /* SpaceFile itself. */ + { + PointerRNA ptr; + RNA_pointer_create(&screen->id, &RNA_SpaceFileBrowser, sfile, &ptr); + + /* All properties for this space type. */ + WM_msg_subscribe_rna(mbus, &ptr, NULL, &msg_sub_value_area_tag_refresh, __func__); + } + + /* FileSelectParams */ + { + PointerRNA ptr; + RNA_pointer_create(&screen->id, &RNA_FileSelectParams, params, &ptr); + + /* All properties for this space type. */ + WM_msg_subscribe_rna(mbus, &ptr, NULL, &msg_sub_value_area_tag_refresh, __func__); + } +} + static void file_main_region_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ @@ -370,8 +408,8 @@ static void file_main_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(col[0], col[1], col[2], 0.0); + GPU_clear(GPU_COLOR_BIT); /* Allow dynamically sliders to be set, saves notifiers etc. */ @@ -413,7 +451,7 @@ static void file_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); @@ -423,8 +461,8 @@ static void file_operatortypes(void) { WM_operatortype_append(FILE_OT_select); WM_operatortype_append(FILE_OT_select_walk); - WM_operatortype_append(FILE_OT_select_all_toggle); - WM_operatortype_append(FILE_OT_select_border); + WM_operatortype_append(FILE_OT_select_all); + WM_operatortype_append(FILE_OT_select_box); WM_operatortype_append(FILE_OT_select_bookmark); WM_operatortype_append(FILE_OT_highlight); WM_operatortype_append(FILE_OT_execute); @@ -451,136 +489,14 @@ static void file_operatortypes(void) /* NOTE: do not add .blend file reading on this level */ static void file_keymap(struct wmKeyConfig *keyconf) { - wmKeyMapItem *kmi; /* keys for all regions */ - wmKeyMap *keymap = WM_keymap_ensure(keyconf, "File Browser", SPACE_FILE, 0); - - /* More common 'fliebrowser-like navigation' shortcuts. */ - WM_keymap_add_item(keymap, "FILE_OT_parent", UPARROWKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "FILE_OT_previous", LEFTARROWKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "FILE_OT_next", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "FILE_OT_refresh", RKEY, KM_PRESS, 0, 0); - - WM_keymap_add_item(keymap, "FILE_OT_parent", PKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "FILE_OT_previous", BACKSPACEKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "FILE_OT_next", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0); - kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", HKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", "space_data.params.show_hidden"); - WM_keymap_add_item(keymap, "FILE_OT_directory_new", IKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "FILE_OT_delete", XKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "FILE_OT_delete", DELKEY, KM_PRESS, 0, 0); - - WM_keymap_verify_item(keymap, "FILE_OT_smoothscroll", TIMER1, KM_ANY, KM_ANY, 0); - - WM_keymap_add_item(keymap, "FILE_OT_bookmark_toggle", TKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "FILE_OT_bookmark_add", BKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_ensure(keyconf, "File Browser", SPACE_FILE, 0); /* keys for main region */ - keymap = WM_keymap_ensure(keyconf, "File Browser Main", SPACE_FILE, 0); - kmi = WM_keymap_add_item(keymap, "FILE_OT_execute", LEFTMOUSE, KM_DBL_CLICK, 0, 0); - RNA_boolean_set(kmi->ptr, "need_active", true); - - WM_keymap_add_item(keymap, "FILE_OT_refresh", PADPERIOD, KM_PRESS, 0, 0); - - /* left mouse selects and opens */ - WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, 0, 0); - kmi = WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", true); - kmi = WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, KM_CTRL | KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", true); - RNA_boolean_set(kmi->ptr, "fill", true); - - /* right mouse selects without opening */ - kmi = WM_keymap_add_item(keymap, "FILE_OT_select", RIGHTMOUSE, KM_CLICK, 0, 0); - RNA_boolean_set(kmi->ptr, "open", false); - kmi = WM_keymap_add_item(keymap, "FILE_OT_select", RIGHTMOUSE, KM_CLICK, KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", true); - RNA_boolean_set(kmi->ptr, "open", false); - kmi = WM_keymap_add_item(keymap, "FILE_OT_select", RIGHTMOUSE, KM_CLICK, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "extend", true); - RNA_boolean_set(kmi->ptr, "fill", true); - RNA_boolean_set(kmi->ptr, "open", false); - - - /* arrow keys navigation (walk selecting) */ - kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", UPARROWKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_UP); - kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", UPARROWKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_UP); - RNA_boolean_set(kmi->ptr, "extend", true); - kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", UPARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_UP); - RNA_boolean_set(kmi->ptr, "extend", true); - RNA_boolean_set(kmi->ptr, "fill", true); - - kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", DOWNARROWKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_DOWN); - kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_DOWN); - RNA_boolean_set(kmi->ptr, "extend", true); - kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", DOWNARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_DOWN); - RNA_boolean_set(kmi->ptr, "extend", true); - RNA_boolean_set(kmi->ptr, "fill", true); - - kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", LEFTARROWKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_LEFT); - kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_LEFT); - RNA_boolean_set(kmi->ptr, "extend", true); - kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", LEFTARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_LEFT); - RNA_boolean_set(kmi->ptr, "extend", true); - RNA_boolean_set(kmi->ptr, "fill", true); - - kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", RIGHTARROWKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_RIGHT); - kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_RIGHT); - RNA_boolean_set(kmi->ptr, "extend", true); - kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", RIGHTARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_RIGHT); - RNA_boolean_set(kmi->ptr, "extend", true); - RNA_boolean_set(kmi->ptr, "fill", true); - - - /* front and back mouse folder navigation */ - WM_keymap_add_item(keymap, "FILE_OT_previous", BUTTON4MOUSE, KM_CLICK, 0, 0); - WM_keymap_add_item(keymap, "FILE_OT_next", BUTTON5MOUSE, KM_CLICK, 0, 0); - - WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "FILE_OT_select_border", EVT_TWEAK_L, KM_ANY, 0, 0); - WM_keymap_add_item(keymap, "FILE_OT_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "FILE_OT_highlight", MOUSEMOVE, KM_ANY, KM_ANY, 0); - kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0); - RNA_int_set(kmi->ptr, "increment", 1); - kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_SHIFT, 0); - RNA_int_set(kmi->ptr, "increment", 10); - kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); - RNA_int_set(kmi->ptr, "increment", 100); - kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, 0, 0); - RNA_int_set(kmi->ptr, "increment", -1); - kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_SHIFT, 0); - RNA_int_set(kmi->ptr, "increment", -10); - kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL, 0); - RNA_int_set(kmi->ptr, "increment", -100); - + WM_keymap_ensure(keyconf, "File Browser Main", SPACE_FILE, 0); /* keys for button region (top) */ - keymap = WM_keymap_ensure(keyconf, "File Browser Buttons", SPACE_FILE, 0); - kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0); - RNA_int_set(kmi->ptr, "increment", 1); - kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_SHIFT, 0); - RNA_int_set(kmi->ptr, "increment", 10); - kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); - RNA_int_set(kmi->ptr, "increment", 100); - kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, 0, 0); - RNA_int_set(kmi->ptr, "increment", -1); - kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_SHIFT, 0); - RNA_int_set(kmi->ptr, "increment", -10); - kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL, 0); - RNA_int_set(kmi->ptr, "increment", -100); + WM_keymap_ensure(keyconf, "File Browser Buttons", SPACE_FILE, 0); } @@ -598,10 +514,12 @@ static void file_tools_region_init(wmWindowManager *wm, ARegion *ar) static void file_tools_region_draw(const bContext *C, ARegion *ar) { - ED_region_panels(C, ar, NULL, -1, true); + ED_region_panels(C, ar); } -static void file_tools_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn)) +static void file_tools_region_listener( + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), + wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) { #if 0 /* context changes */ @@ -647,8 +565,8 @@ static void file_ui_region_draw(const bContext *C, ARegion *ar) float col[3]; /* clear */ UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(col[0], col[1], col[2], 0.0); + GPU_clear(GPU_COLOR_BIT); /* scrolling here is just annoying, disable it */ ar->v2d.cur.ymax = BLI_rctf_size_y(&ar->v2d.cur); @@ -663,7 +581,9 @@ static void file_ui_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); } -static void file_ui_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) +static void file_ui_region_listener( + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, + wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ switch (wmn->category) { @@ -677,7 +597,7 @@ static void file_ui_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), AR } } -static bool filepath_drop_poll(bContext *C, wmDrag *drag, const wmEvent *UNUSED(event)) +static bool filepath_drop_poll(bContext *C, wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { if (drag->type == WM_DRAG_PATH) { SpaceFile *sfile = CTX_wm_space_file(C); @@ -727,6 +647,7 @@ void ED_spacetype_file(void) art->init = file_main_region_init; art->draw = file_main_region_draw; art->listener = file_main_region_listener; + art->message_subscribe = file_main_region_message_subscribe; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; BLI_addhead(&st->regiontypes, art); |