2.5 filebrowser
authorAndrea Weikert <elubie@gmx.net>
Tue, 6 Jan 2009 16:47:01 +0000 (16:47 +0000)
committerAndrea Weikert <elubie@gmx.net>
Tue, 6 Jan 2009 16:47:01 +0000 (16:47 +0000)
- some more cleanup, use UI_text functions for text output rather than BMF_ directly
- removed some debug prints and some unused variables

source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/file_header.c
source/blender/editors/space_file/file_ops.c

index 3cb659d5f419d3f276c673f77dbf83a4a0c77cb7..347cd6c747ef592634f0a0e8c78ccbed9e49dfc6 100644 (file)
 #include "BKE_global.h"
 #include "BKE_utildefines.h"
 
-#include "BMF_Api.h"
-
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_userdef_types.h"
+#include "DNA_windowmanager_types.h"
 
 #include "ED_fileselect.h"
 
@@ -148,7 +147,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
        */
 
        /* space available for load/save buttons? */
-       slen = BMF_GetStringWidth(G.font, sfile->params->title);
+       slen = UI_GetStringWidth(G.font, sfile->params->title, 0);
        loadbutton= slen > 60 ? slen + 20 : MAX2(80, 20+UI_GetStringWidth(G.font, params->title, 0));
        if(ar->v2d.mask.xmax-ar->v2d.mask.xmin > loadbutton+20) {
                /* XXX
@@ -194,7 +193,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
 }
 
 
-static void draw_tile(SpaceFile *sfile, short sx, short sy, short width, short height, int colorid)
+static void draw_tile(short sx, short sy, short width, short height, int colorid)
 {
        /* TODO: BIF_ThemeColor seems to need this to show the color, not sure why? - elubie */
        glEnable(GL_BLEND);
@@ -275,7 +274,6 @@ void file_calc_previews(const bContext *C, ARegion *ar)
        View2D *v2d= &ar->v2d;
        int width=0, height=0;
        int rows, columns;
-//     int linestep = U.fontsize*3/2;
 
        if (params->display) {
                sfile->prv_w = 96;
@@ -356,10 +354,10 @@ void file_draw_previews(const bContext *C, ARegion *ar)
 
                if (params->active_file == i) {
                        colorid = TH_ACTIVE;
-                       draw_tile(sfile, sx, sy, sfile->tile_w, sfile->tile_h, colorid);
+                       draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid);
                } else if (file->flags & ACTIVE) {
                        colorid = TH_HILITE;
-                       draw_tile(sfile, sx, sy+sfile->tile_border_y, sfile->tile_w, sfile->tile_h-sfile->tile_border_y, colorid);
+                       draw_tile(sx, sy+sfile->tile_border_y, sfile->tile_w, sfile->tile_h-sfile->tile_border_y, colorid);
                } else {
                        /*
                        colorid = TH_PANEL;
@@ -507,14 +505,14 @@ void file_draw_list(const bContext *C, ARegion *ar)
 
                if (params->active_file == i) {
                        colorid = TH_ACTIVE;
-                       draw_tile(sfile, sx, sy, sfile->tile_w, sfile->tile_h, colorid);
+                       draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid);
                } else if (file->flags & ACTIVE) {
                        colorid = TH_HILITE;
-                       draw_tile(sfile, sx, sy, sfile->tile_w, sfile->tile_h, colorid);
+                       draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid);
                } else {
                        /*
                        colorid = TH_PANEL;
-                       draw_tile(simasel, sx, sy, sfile->tile_w, sfile->tile_h, colorid);
+                       draw_tile(sx, sy, sfile->tile_w, sfile->tile_h, colorid);
                        */
                }
                if (type == FILE_MAIN) {
@@ -597,4 +595,4 @@ void file_draw_fsmenu(const bContext *C, ARegion *ar)
                        sy -= linestep;
                }
        }
-}
\ No newline at end of file
+}
index 21f81cd83a7d793002b850ff89e65c6344112881..5ed0504e69ec54e4d04f28cc7b0e23dce51ccf2c 100644 (file)
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
-#include "BMF_Api.h"
-
 #include "UI_interface.h"
 #include "UI_resources.h"
 #include "UI_view2d.h"
+#include "UI_text.h"
 
 #include "file_intern.h"
 #include "filelist.h"
@@ -156,7 +155,7 @@ void file_header_buttons(const bContext *C, ARegion *ar)
                xco+=XIC+10;
        } 
        xcotitle= xco;
-       xco+= BMF_GetStringWidth(G.font, params->title);
+       xco+= UI_GetStringWidth(G.font, params->title, 0);
 
        uiBlockSetEmboss(block, UI_EMBOSS);
 
index 4ca34f062ad144e06a4ace4a27c789cbd40165c3..3b5843f4c2862c28619e60807e0a78bbd0186146 100644 (file)
@@ -65,7 +65,6 @@ static void set_active_file_thumbs(SpaceFile *sfile, FileSelectParams* params, s
 {
        float x,y;
        int active_file = -1;
-//     int stridex, stridey;
        struct direntry* file;
        int offsetx, offsety;
        int numfiles = filelist_numfiles(params->files);
@@ -77,17 +76,13 @@ static void set_active_file_thumbs(SpaceFile *sfile, FileSelectParams* params, s
        offsetx = (x - (v2d->cur.xmin+sfile->tile_border_x))/(sfile->tile_w + sfile->tile_border_x);
        offsety = (-y+sfile->tile_border_y)/(sfile->tile_h + sfile->tile_border_y);
        columns = (v2d->cur.xmax - v2d->cur.xmin) / (sfile->tile_w+ sfile->tile_border_x);
-
-       printf("tile (%d, %d, %d)\n", offsetx, offsety, columns);
        active_file = offsetx + columns*offsety;
 
        if (active_file >= 0 && active_file < numfiles )
        {
-               printf("active file: %d\n", active_file);
                params->active_file = active_file;
                if (params->selstate & ACTIVATE) {
                        file = filelist_file(params->files, params->active_file);
-                       printf("active file: %s\n", file->relname);
                        file->flags |= ACTIVE;
                }                       
        }
@@ -110,8 +105,6 @@ static void set_active_file(SpaceFile *sfile, FileSelectParams* params, struct A
        offsety = (v2d->cur.ymax-y-sfile->tile_border_y)/(sfile->tile_h + sfile->tile_border_y);
        rows = (v2d->cur.ymax - v2d->cur.ymin - 2*sfile->tile_border_y) / (sfile->tile_h+sfile->tile_border_y);
        active_file = rows*offsetx + offsety;
-       printf("offsets (%d, %d)\n", offsetx, offsety);
-       printf("active_file (%d)\n", active_file);
        if ( (active_file >= 0) && (active_file < numfiles) )
        {
                params->active_file = active_file;
@@ -128,7 +121,6 @@ static void set_active_bookmark(SpaceFile *sfile, FileSelectParams* params, stru
        int nentries = fsmenu_get_nentries();
        short posy = ar->v2d.mask.ymax - TILE_BORDER_Y - y;
        params->active_bookmark = ((float)posy / (U.fontsize*3.0f/2.0f));
-       printf("active bookmark: %d\n", params->active_bookmark);
        if (params->active_bookmark < 0 || params->active_bookmark > nentries) {
                params->active_bookmark = -1;
        }
@@ -193,10 +185,8 @@ static void mouse_select(SpaceFile* sfile, FileSelectParams* params, ARegion* ar
 static void mouse_select_bookmark(SpaceFile* sfile, ARegion* ar, short *mval)
 {
        if(mval[0]>ar->v2d.mask.xmin && mval[0]<ar->v2d.mask.xmax
-       && mval[1]>ar->v2d.mask.ymin && mval[1]<ar->v2d.mask.ymax) {                    
-               //int nentries = fsmenu_get_nentries();
+       && mval[1]>ar->v2d.mask.ymin && mval[1]<ar->v2d.mask.ymax) {
                char *selected;
-               printf("selecting...\n");
                set_active_bookmark(sfile, sfile->params, ar, mval[1]);
                selected= fsmenu_get_entry(sfile->params->active_bookmark);                     
                /* which string */
@@ -214,7 +204,6 @@ static void mouse_select_bookmark(SpaceFile* sfile, ARegion* ar, short *mval)
 
 static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-//     ScrArea *sa= CTX_wm_area(C);
        ARegion *ar= CTX_wm_region(C);
        SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
        short mval[2];