[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18713] branches/blender2.5/blender/source /blender: 2.5
Ton Roosendaal
ton at blender.org
Wed Jan 28 12:27:26 CET 2009
Revision: 18713
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18713
Author: ton
Date: 2009-01-28 12:27:25 +0100 (Wed, 28 Jan 2009)
Log Message:
-----------
2.5
Filewindow: restored some usability issues :)
(Andrea: Hope you're OK, I needed to test stuff, and
file open was a pain!)
- F1: shows last saved/opened file now
- Enter key loads, ESC cancels
- Hilites on mousemove now show same theme colors as before
- Enabled intended roundbox draw (was added to UI api)
- Tweaked roundbox hilites to nicely surround text
- Text was drawing too close to collumn dividers
- Brought back missing glDisable(GL_BLEND), messed with draw
- On file-open, mouse position is used to show active file
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c
branches/blender2.5/blender/source/blender/editors/space_file/file_intern.h
branches/blender2.5/blender/source/blender/editors/space_file/file_ops.c
branches/blender2.5/blender/source/blender/editors/space_file/space_file.c
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c
Modified: branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c 2009-01-28 09:55:36 UTC (rev 18712)
+++ branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c 2009-01-28 11:27:25 UTC (rev 18713)
@@ -89,38 +89,12 @@
static void do_file_buttons(bContext *C, void *arg, int event)
{
- SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
switch(event) {
case B_FS_LOAD:
- {
- char name[FILE_MAX];
-
- ED_screen_full_prevspace(C);
- if(sfile->op) {
- wmOperator *op= sfile->op;
-
- /* if load .blend, all UI pointers after exec are invalid! */
- /* but, operator can be freed still */
-
- sfile->op = NULL;
- BLI_strncpy(name, sfile->params->dir, sizeof(name));
- strcat(name, sfile->params->file);
- RNA_string_set(op->ptr, "filename", name);
-
- op->type->exec(C, op);
-
- WM_operator_free(op);
- }
-
- }
+ file_load_exec(C, NULL); /* file_ops.c */
break;
case B_FS_CANCEL:
- if(sfile->op) {
- WM_operator_free(sfile->op);
- sfile->op = NULL;
- }
- ED_screen_full_prevspace(C);
-
+ file_cancel_exec(C, NULL); /* file_ops.c */
break;
}
}
@@ -203,15 +177,16 @@
static void draw_tile(short sx, short sy, short width, short height, int colorid, int shade)
{
/* TODO: BIF_ThemeColor seems to need this to show the color, not sure why? - elubie */
- glEnable(GL_BLEND);
- glColor4ub(0, 0, 0, 100);
- glDisable(GL_BLEND);
+ //glEnable(GL_BLEND);
+ //glColor4ub(0, 0, 0, 100);
+ //glDisable(GL_BLEND);
+ /* I think it was a missing glDisable() - ton */
UI_ThemeColorShade(colorid, shade);
uiSetRoundBox(15);
- glRecti(sx, sy - height, sx + width, sy);
+ // glRecti(sx, sy - height, sx + width, sy);
- // uiRoundBox(sx+TILE_BORDER_X, sy - sfile->prv_h - TILE_BORDER_Y*3 - U.fontsize, sx + sfile->prv_w + TILE_BORDER_X*3, sy, 6);
+ uiRoundBox(sx, sy - height, sx + width, sy, 6);
}
static float shorten_string(char* string, float w)
@@ -367,10 +342,10 @@
if (params->active_file == i) {
colorid = TH_ACTIVE;
- draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid,0);
+ draw_tile(sx - 1, sy, sfile->tile_w + 1, sfile->tile_h, colorid,0);
} else if (file->flags & ACTIVE) {
colorid = TH_HILITE;
- draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid,0);
+ draw_tile(sx - 1, sy, sfile->tile_w + 1, sfile->tile_h, colorid,0);
} else {
colorid = TH_BACK;
draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid, -5);
@@ -424,18 +399,18 @@
// glaDrawPixelsSafe((float)sx+8 + dx, (float)sy - imgwidth + dy - 8, imb->x, imb->y, imb->x, GL_RGBA, GL_UNSIGNED_BYTE, imb->rect);
glColor4f(1.0, 1.0, 1.0, 1.0);
glaDrawPixelsTex((float)sx + dx, (float)sy - sfile->prv_h + dy, imb->x, imb->y,GL_UNSIGNED_BYTE, imb->rect);
- // glDisable(GL_BLEND);
+ glDisable(GL_BLEND);
imb = 0;
}
#if 0
}
#endif
if (type == FILE_MAIN) {
- glColor3f(1.0f, 1.0f, 1.0f);
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
else {
if (S_ISDIR(file->type)) {
- glColor3f(1.0f, 1.0f, 0.9f);
+ glColor4f(1.0f, 1.0f, 0.9f, 1.0f);
}
else if (file->flags & IMAGEFILE) {
UI_ThemeColor(TH_SEQ_IMAGE);
@@ -506,16 +481,17 @@
for (i=offset; (i < numfiles); ++i)
{
sy = ar->v2d.tot.ymax-sfile->tile_border_y - (i%rows)*(sfile->tile_h+sfile->tile_border_y);
- sx = ar->v2d.tot.xmin +sfile->tile_border_x + (i/rows)*(sfile->tile_w+sfile->tile_border_x);
+ sx = 2 + ar->v2d.tot.xmin +sfile->tile_border_x + (i/rows)*(sfile->tile_w+sfile->tile_border_x);
file = filelist_file(files, i);
if (params->active_file == i) {
- colorid = TH_ACTIVE;
- draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid,0);
+ if (file->flags & ACTIVE) colorid= TH_HILITE;
+ else colorid = TH_BACK;
+ draw_tile(sx, sy-3, sfile->tile_w, sfile->tile_h, colorid,20);
} else if (file->flags & ACTIVE) {
colorid = TH_HILITE;
- draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid,0);
+ draw_tile(sx, sy-3, sfile->tile_w, sfile->tile_h, colorid,0);
} else {
/*
colorid = TH_PANEL;
@@ -523,11 +499,11 @@
*/
}
if (type == FILE_MAIN) {
- glColor3f(1.0f, 1.0f, 1.0f);
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
else {
if (S_ISDIR(file->type)) {
- glColor3f(1.0f, 1.0f, 0.9f);
+ glColor4f(1.0f, 1.0f, 0.9f, 1.0f);
}
else if (file->flags & IMAGEFILE) {
UI_ThemeColor(TH_SEQ_IMAGE);
@@ -550,7 +526,7 @@
}
sw = UI_GetStringWidth(G.font, file->size, 0);
- file_draw_string(sx, sy, file->relname, sfile->tile_w - sw - 2, sfile->tile_h);
+ file_draw_string(sx, sy, file->relname, sfile->tile_w - sw - 5, sfile->tile_h);
file_draw_string(sx + sfile->tile_w - sw, sy, file->size, sfile->tile_w - sw, sfile->tile_h);
}
}
@@ -584,9 +560,9 @@
if (params->active_bookmark == i ) {
glColor4ub(0, 0, 0, 100);
UI_ThemeColor(TH_HILITE);
- // uiSetRoundBox(15);
- // uiRoundBox(simasel->bookmarkrect.xmin + TILE_BORDER_X - 1, sy - linestep*0.25, simasel->bookmarkrect.xmax - TILE_BORDER_X + 1, sy + linestep*0.75, 6);
- glRecti(sx, sy - linestep, sx + bmwidth, sy);
+ uiSetRoundBox(15);
+ uiRoundBox(sx, sy - linestep, sx + bmwidth, sy, 6);
+ // glRecti(sx, sy - linestep, sx + bmwidth, sy);
UI_ThemeColor(TH_TEXT_HI);
} else {
UI_ThemeColor(TH_TEXT);
Modified: branches/blender2.5/blender/source/blender/editors/space_file/file_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_file/file_intern.h 2009-01-28 09:55:36 UTC (rev 18712)
+++ branches/blender2.5/blender/source/blender/editors/space_file/file_intern.h 2009-01-28 11:27:25 UTC (rev 18713)
@@ -47,12 +47,20 @@
/* file_ops.h */
struct wmOperatorType;
+struct wmOperator;
+struct wmEvent;
void ED_FILE_OT_highlight(struct wmOperatorType *ot);
void ED_FILE_OT_select(struct wmOperatorType *ot);
void ED_FILE_OT_select_all(struct wmOperatorType *ot);
void ED_FILE_OT_border_select(struct wmOperatorType *ot);
void ED_FILE_OT_select_bookmark(struct wmOperatorType *ot);
void ED_FILE_OT_loadimages(struct wmOperatorType *ot);
+void ED_FILE_OT_load(struct wmOperatorType *ot);
+void ED_FILE_OT_cancel(struct wmOperatorType *ot);
+int file_load_exec(bContext *C, struct wmOperator *unused);
+int file_cancel_exec(bContext *C, struct wmOperator *unused);
+int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my);
+
#endif /* ED_FILE_INTERN_H */
Modified: branches/blender2.5/blender/source/blender/editors/space_file/file_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_file/file_ops.c 2009-01-28 09:55:36 UTC (rev 18712)
+++ branches/blender2.5/blender/source/blender/editors/space_file/file_ops.c 2009-01-28 11:27:25 UTC (rev 18713)
@@ -398,40 +398,41 @@
/* api callbacks */
ot->invoke= loadimages_invoke;
- ot->poll= ED_operator_areaactive;
+ ot->poll= ED_operator_file_active;
}
-
-static int file_highlight_invoke(bContext *C, wmOperator *op, wmEvent *event)
+int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
{
- ScrArea *sa= CTX_wm_area(C);
- ARegion *ar= CTX_wm_region(C);
FileSelectParams* params;
- short x, y;
- int actfile;
- int numfiles;
- SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+ int numfiles, actfile;
- if (!sfile || !sfile->files) return OPERATOR_FINISHED;
-
+ if(sfile==NULL || sfile->files==NULL) return 0;
+
numfiles = filelist_numfiles(sfile->files);
-
- x = event->x - ar->winrct.xmin;
- y = event->y - ar->winrct.ymin;
-
params = ED_fileselect_get_params(sfile);
+
if (params->display) {
- actfile = find_file_mouse_hor(sfile, ar,x , y);
+ actfile = find_file_mouse_hor(sfile, ar, mx , my);
} else {
- actfile = find_file_mouse_vert(sfile, ar, x, y);
+ actfile = find_file_mouse_vert(sfile, ar, mx, my);
}
-
- if (actfile >= 0 && actfile < numfiles )
- {
+
+ if (actfile >= 0 && actfile < numfiles ) {
params->active_file=actfile;
- ED_area_tag_redraw(sa);
+ return 1;
}
+ return 0;
+}
+
+static int file_highlight_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ ARegion *ar= CTX_wm_region(C);
+ SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+ if( file_hilight_set(sfile, ar, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) {
+ ED_area_tag_redraw(CTX_wm_area(C));
+ }
+
return OPERATOR_FINISHED;
}
@@ -443,6 +444,70 @@
/* api callbacks */
ot->invoke= file_highlight_invoke;
- ot->poll= ED_operator_areaactive;
+ ot->poll= ED_operator_file_active;
}
+int file_cancel_exec(bContext *C, wmOperator *unused)
+{
+ SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+
+ if(sfile->op) {
+ WM_operator_free(sfile->op);
+ sfile->op = NULL;
+ }
+ ED_screen_full_prevspace(C);
+
+ return OPERATOR_FINISHED;
+}
+
+void ED_FILE_OT_cancel(struct wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Cancel File Load";
+ ot->idname= "ED_FILE_OT_cancel";
+
+ /* api callbacks */
+ ot->exec= file_cancel_exec;
+ ot->poll= ED_operator_file_active;
+}
+
+
+int file_load_exec(bContext *C, wmOperator *unused)
+{
+ SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+ char name[FILE_MAX];
+
+ ED_screen_full_prevspace(C);
+
+ if(sfile->op) {
+ wmOperator *op= sfile->op;
+
+ /* if load .blend, all UI pointers after exec are invalid! */
+ /* but, operator can be freed still */
+
+ sfile->op = NULL;
+ BLI_strncpy(name, sfile->params->dir, sizeof(name));
+ strcat(name, sfile->params->file);
+ RNA_string_set(op->ptr, "filename", name);
+
+ op->type->exec(C, op);
+
+ WM_operator_free(op);
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+void ED_FILE_OT_load(struct wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Load File";
+ ot->idname= "ED_FILE_OT_load";
+
+ /* api callbacks */
+ ot->exec= file_load_exec;
+ ot->poll= ED_operator_file_active;
+}
+
+
+
Modified: branches/blender2.5/blender/source/blender/editors/space_file/space_file.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_file/space_file.c 2009-01-28 09:55:36 UTC (rev 18712)
+++ branches/blender2.5/blender/source/blender/editors/space_file/space_file.c 2009-01-28 11:27:25 UTC (rev 18713)
@@ -195,6 +195,7 @@
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list