X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrfileman;a=blobdiff_plain;f=src%2Ffs.cc;h=a3e5b810533c48146733ce398c033a6e298c5131;hp=b8f7420d75717af9be87e221e6e3360b8043fec1;hb=f737a4688a44fa05c9a5ea7919819437fae85ae1;hpb=f6a327e85904bea1ab1ae49ccd521de3a372b68b diff --git a/src/fs.cc b/src/fs.cc index b8f7420..a3e5b81 100644 --- a/src/fs.cc +++ b/src/fs.cc @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -24,7 +25,7 @@ static dtx_font *fat_font; #define FAT_FONT_SZ 32 -bool init_fs() +bool init_fs(const char *path) { iconrend = new ShapesIcons; if(!iconrend->init()) { @@ -36,7 +37,7 @@ bool init_fs() return false; } - cur_node = get_fsnode(0); + cur_node = get_fsnode(path); cur_node->expand(); return true; } @@ -61,22 +62,35 @@ static Vec3 icon_pos(int row, int col, int ncols, float row_spacing, float radiu return Vec3(x, y, z); } +static float icon_angle(int col, int ncols, float max_angle = 0.0f) +{ + if(max_angle > 0) { + return max_angle * ((float)col / (float)(ncols - 1) - 0.5); + } + return 2.0 * M_PI * (float)col / (float)ncols; +} + void draw_fs() { - static const int ncols = 8; static const float row_spacing = 2.0; - static const float radius = 5; + static const float radius = 0.6; + static const float umax = 0.42; + static const float max_icon_angle = M_PI * 2.0 * umax; + + int max_ncols = std::max(1, umax * 16); Mat4 base_xform; base_xform.rotate(time_sec, 0, 0); base_xform.rotate(0, 0, time_sec * 0.5); - base_xform.translate(0, 2, 0); + base_xform.translate(0, 1.65, 0); glUseProgram(0); glDisable(GL_TEXTURE_2D); - int first = start_child % ncols; int nchildren = (int)cur_node->children.size(); + int ncols = std::min(cur_node->nfiles, max_ncols); + + int first = start_child % ncols; int col = 0, row = 0; for(int i=0; ipath.get_name()) / 2.0, 0, 0); - xform.scale(0.01); - xform.translate(0, 1 + row * row_spacing, -radius); + xform.scale(0.001); + xform.translate(0, 1.54 + row * row_spacing, -radius); xform.rotate_y(angle); glMultMatrixf(xform[0]); @@ -179,6 +193,7 @@ FSNode::FSNode() type = FSTYPE_UNKNOWN; size = 0; parent = 0; + nfiles = ndirs = 0; } bool FSNode::expand() @@ -203,6 +218,15 @@ bool FSNode::expand() if(!node) continue; children.push_back(node); + switch(node->type) { + case FSTYPE_FILE: + ++nfiles; + break; + case FSTYPE_DIR: + ++ndirs; + default: + break; + } } printf("expanded %d children\n", (int)children.size());