Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_file/file_draw.c')
-rw-r--r--source/blender/editors/space_file/file_draw.c136
1 files changed, 72 insertions, 64 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index af0bf9413df..5db17d8bc7c 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -320,8 +320,9 @@ static int get_file_icon(struct direntry *file)
return ICON_FILE_BLANK;
}
-static void file_draw_icon(int sx, int sy, int icon, int width, int height)
+static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, int width, int height)
{
+ uiBut *but;
float x,y;
float alpha=1.0f;
@@ -329,10 +330,9 @@ static void file_draw_icon(int sx, int sy, int icon, int width, int height)
y = (float)(sy-height);
if (icon == ICON_FILE_BLANK) alpha = 0.375f;
-
- glEnable(GL_BLEND);
-
- UI_icon_draw_aspect(x, y, icon, 1.f, alpha);
+
+ but= uiDefIconBut(block, LABEL, 0, icon, x, y, width, height, NULL, 0.0, 0.0, 0, 0, "");
+ uiButSetDragPath(but, path);
}
@@ -364,62 +364,67 @@ void file_calc_previews(const bContext *C, ARegion *ar)
UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height+V2D_SCROLL_HEIGHT);
}
-static void file_draw_preview(int sx, int sy, ImBuf *imb, FileLayout *layout, short dropshadow)
+static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int sy, ImBuf *imb, FileLayout *layout, short dropshadow)
{
if (imb) {
- float fx, fy;
- float dx, dy;
- int xco, yco;
- float scaledx, scaledy;
- float scale;
- int ex, ey;
-
- if ( (imb->x > layout->prv_w) || (imb->y > layout->prv_h) ) {
- if (imb->x > imb->y) {
- scaledx = (float)layout->prv_w;
- scaledy = ( (float)imb->y/(float)imb->x )*layout->prv_w;
- scale = scaledx/imb->x;
- }
- else {
- scaledy = (float)layout->prv_h;
- scaledx = ( (float)imb->x/(float)imb->y )*layout->prv_h;
- scale = scaledy/imb->y;
- }
- } else {
- scaledx = (float)imb->x;
- scaledy = (float)imb->y;
- scale = 1.0;
+ uiBut *but;
+ float fx, fy;
+ float dx, dy;
+ int xco, yco;
+ float scaledx, scaledy;
+ float scale;
+ int ex, ey;
+
+ if ( (imb->x > layout->prv_w) || (imb->y > layout->prv_h) ) {
+ if (imb->x > imb->y) {
+ scaledx = (float)layout->prv_w;
+ scaledy = ( (float)imb->y/(float)imb->x )*layout->prv_w;
+ scale = scaledx/imb->x;
}
- ex = (int)scaledx;
- ey = (int)scaledy;
- fx = ((float)layout->prv_w - (float)ex)/2.0f;
- fy = ((float)layout->prv_h - (float)ey)/2.0f;
- dx = (fx + 0.5f + layout->prv_border_x);
- dy = (fy + 0.5f - layout->prv_border_y);
- xco = (float)sx + dx;
- yco = (float)sy - layout->prv_h + dy;
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- /* shadow */
- if (dropshadow)
- uiDrawBoxShadow(220, xco, yco, xco + ex, yco + ey);
-
- glEnable(GL_BLEND);
-
- /* the image */
- glColor4f(1.0, 1.0, 1.0, 1.0);
- glaDrawPixelsTexScaled(xco, yco, imb->x, imb->y, GL_UNSIGNED_BYTE, imb->rect, scale, scale);
-
- /* border */
- if (dropshadow) {
- glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
- fdrawbox(xco, yco, xco + ex, yco + ey);
+ else {
+ scaledy = (float)layout->prv_h;
+ scaledx = ( (float)imb->x/(float)imb->y )*layout->prv_h;
+ scale = scaledy/imb->y;
}
-
- glDisable(GL_BLEND);
- imb = 0;
+ } else {
+ scaledx = (float)imb->x;
+ scaledy = (float)imb->y;
+ scale = 1.0;
+ }
+ ex = (int)scaledx;
+ ey = (int)scaledy;
+ fx = ((float)layout->prv_w - (float)ex)/2.0f;
+ fy = ((float)layout->prv_h - (float)ey)/2.0f;
+ dx = (fx + 0.5f + layout->prv_border_x);
+ dy = (fy + 0.5f - layout->prv_border_y);
+ xco = (float)sx + dx;
+ yco = (float)sy - layout->prv_h + dy;
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ /* shadow */
+ if (dropshadow)
+ uiDrawBoxShadow(220, xco, yco, xco + ex, yco + ey);
+
+ glEnable(GL_BLEND);
+
+ /* the image */
+ glColor4f(1.0, 1.0, 1.0, 1.0);
+ glaDrawPixelsTexScaled(xco, yco, imb->x, imb->y, GL_UNSIGNED_BYTE, imb->rect, scale, scale);
+
+ /* border */
+ if (dropshadow) {
+ glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
+ fdrawbox(xco, yco, xco + ex, yco + ey);
}
+
+ /* dragregion */
+ but= uiDefBut(block, LABEL, 0, "", xco, yco, ex, ey, NULL, 0.0, 0.0, 0, 0, "");
+ uiButSetDragImage(but, file->path, get_file_icon(file), imb, scale);
+
+ glDisable(GL_BLEND);
+ imb = 0;
+ }
}
static void renamebutton_cb(bContext *C, void *arg1, char *oldname)
@@ -491,6 +496,7 @@ void file_draw_list(const bContext *C, ARegion *ar)
struct FileList* files = sfile->files;
struct direntry *file;
ImBuf *imb;
+ uiBlock *block = uiBeginBlock(C, ar, "FileNames", UI_EMBOSS);
int numfiles;
int numfiles_layout;
int colorid = 0;
@@ -526,10 +532,10 @@ void file_draw_list(const bContext *C, ARegion *ar)
if (params->active_file == i) {
if (file->flags & ACTIVE) colorid= TH_HILITE;
else colorid = TH_BACK;
- draw_tile(sx-2, sy-3, layout->tile_w+2, sfile->layout->tile_h+layout->tile_border_y, colorid,20);
+ draw_tile(sx, sy-3, layout->tile_w+4, sfile->layout->tile_h+layout->tile_border_y, colorid,20);
} else if (file->flags & ACTIVE) {
colorid = TH_HILITE;
- draw_tile(sx-2, sy-3, layout->tile_w+2, sfile->layout->tile_h+layout->tile_border_y, colorid,0);
+ draw_tile(sx, sy-3, layout->tile_w+4, sfile->layout->tile_h+layout->tile_border_y, colorid,0);
}
}
@@ -546,11 +552,11 @@ void file_draw_list(const bContext *C, ARegion *ar)
is_icon = 1;
}
- file_draw_preview(sx, sy, imb, layout, !is_icon && (file->flags & IMAGEFILE));
+ file_draw_preview(block, file, sx, sy, imb, layout, !is_icon && (file->flags & IMAGEFILE));
} else {
- file_draw_icon(spos, sy-3, get_file_icon(file), ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH);
- spos += ICON_DEFAULT_WIDTH + 4;
+ file_draw_icon(block, file->path, spos, sy-3, get_file_icon(file), ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH);
+ spos += ICON_DEFAULT_WIDTH + 4;
}
UI_ThemeColor4(TH_TEXT);
@@ -558,15 +564,13 @@ void file_draw_list(const bContext *C, ARegion *ar)
sw = file_string_width(file->relname);
if (file->flags & EDITING) {
int but_width = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : layout->column_widths[COLUMN_NAME];
- uiBlock *block = uiBeginBlock(C, ar, "FileName", UI_EMBOSS);
+
uiBut *but = uiDefBut(block, TEX, 1, "", spos, sy-layout->tile_h-3,
but_width, layout->textheight*2, file->relname, 1.0f, (float)FILE_MAX,0,0,"");
uiButSetRenameFunc(but, renamebutton_cb, file);
if ( 0 == uiButActiveOnly(C, block, but)) {
file->flags &= ~EDITING;
}
- uiEndBlock(C, block);
- uiDrawBlock(C, block);
} else {
float name_width = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : sw;
file_draw_string(spos, sy, file->relname, name_width, layout->tile_h, FILE_SHORTEN_END);
@@ -621,6 +625,10 @@ void file_draw_list(const bContext *C, ARegion *ar)
if (!sfile->loadimage_timer)
sfile->loadimage_timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER1, 1.0/30.0); /* max 30 frames/sec. */
+
+ uiEndBlock(C, block);
+ uiDrawBlock(C, block);
+
}