diff options
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 36 | ||||
-rw-r--r-- | source/blender/editors/space_file/fsmenu.c | 43 |
2 files changed, 37 insertions, 42 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 06066372828..a1bd1f25427 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" @@ -71,8 +70,6 @@ #include "WM_api.h" #include "WM_types.h" -//#include "GPU_draw.h" -//#include "GPU_basic_shader.h" #include "GPU_immediate.h" #include "filelist.h" @@ -341,6 +338,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); @@ -387,12 +385,12 @@ static void file_draw_preview( /* the image */ if (!is_icon && typeflags & FILE_TYPE_FTFONT) { - UI_ThemeColor(TH_TEXT); + UI_GetThemeColor4fv(TH_TEXT, col); } - else { - 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); + + immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); + immDrawPixelsTexScaled((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); @@ -400,8 +398,8 @@ static void file_draw_preview( /* border */ if (use_dropshadow) { - VertexFormat* format = immVertexFormat(); - unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2,KEEP_FLOAT); + VertexFormat *format = immVertexFormat(); + unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 2,KEEP_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f); @@ -462,15 +460,18 @@ static void draw_background(FileLayout *layout, View2D *v2d) int i; int sy; - UI_ThemeColorShade(TH_BACK, -7); + unsigned int pos = add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_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) @@ -481,9 +482,9 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) unsigned int vertex_ct = 0; unsigned char col_hi[3], col_lo[3]; - VertexFormat* format = immVertexFormat(); - unsigned pos = add_attrib(format, "pos", GL_INT, 2, CONVERT_INT_TO_FLOAT); - unsigned color = add_attrib(format, "color", GL_UNSIGNED_BYTE, 3, NORMALIZE_INT_TO_FLOAT); + VertexFormat *format = immVertexFormat(); + unsigned int pos = add_attrib(format, "pos", GL_INT, 2, CONVERT_INT_TO_FLOAT); + unsigned int color = add_attrib(format, "color", GL_UNSIGNED_BYTE, 3, NORMALIZE_INT_TO_FLOAT); vertex_ct = (v2d->cur.xmax - v2d->tot.xmin) / step + 1; /* paint at least 1 divider */ vertex_ct *= 4; /* vertex_count = 2 points per divider * 2 lines per divider */ @@ -609,9 +610,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)) diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 631ff06a77a..71d49e0dc2e 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -169,12 +169,15 @@ void ED_fsmenu_entry_set_path(struct FSMenuEntry *fsentry, const char *path) static void fsmenu_entry_generate_name(struct FSMenuEntry *fsentry, char *name, size_t name_size) { - char temp[FILE_MAX]; + int offset = 0; + int len = name_size; - BLI_strncpy(temp, fsentry->path, FILE_MAX); - BLI_add_slash(temp); - BLI_getlastdir(temp, name, name_size); - BLI_del_slash(name); + if (BLI_path_name_at_index(fsentry->path, -1, &offset, &len)) { + /* use as size */ + len += 1; + } + + BLI_strncpy(name, &fsentry->path[offset], MIN2(len, name_size)); if (!name[0]) { name[0] = '/'; name[1] = '\0'; @@ -537,28 +540,22 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) /* Finally get user favorite places */ if (read_bookmarks) { UInt32 seed; - OSErr err = noErr; - CFArrayRef pathesArray; - LSSharedFileListRef list; - LSSharedFileListItemRef itemRef; - CFIndex i, pathesCount; - CFURLRef cfURL = NULL; - CFStringRef pathString = NULL; - list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL); - pathesArray = LSSharedFileListCopySnapshot(list, &seed); - pathesCount = CFArrayGetCount(pathesArray); + LSSharedFileListRef list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL); + CFArrayRef pathesArray = LSSharedFileListCopySnapshot(list, &seed); + CFIndex pathesCount = CFArrayGetCount(pathesArray); - for (i = 0; i < pathesCount; i++) { - itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); + for (CFIndex i = 0; i < pathesCount; i++) { + LSSharedFileListItemRef itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); - err = LSSharedFileListItemResolve(itemRef, - kLSSharedFileListNoUserInteraction | - kLSSharedFileListDoNotMountVolumes, - &cfURL, NULL); - if (err != noErr) + CFURLRef cfURL = NULL; + OSErr err = LSSharedFileListItemResolve(itemRef, + kLSSharedFileListNoUserInteraction | + kLSSharedFileListDoNotMountVolumes, + &cfURL, NULL); + if (err != noErr || !cfURL) continue; - pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle); + CFStringRef pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle); if (pathString == NULL || !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8)) continue; |