From: John Tsiombikas Date: Mon, 1 Aug 2016 23:44:00 +0000 (+0300) Subject: better icon placement X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrfileman;a=commitdiff_plain;h=eca943b2fb891a01cb4e883c07aad2167a8ac94b better icon placement --- diff --git a/src/app.cc b/src/app.cc index 617e6a1..9b83c21 100644 --- a/src/app.cc +++ b/src/app.cc @@ -147,7 +147,7 @@ void app_reshape(int x, int y) glViewport(0, 0, x, y); Mat4 mat; - mat.perspective(deg_to_rad(50), win_aspect, 0.5, 500.0); + mat.perspective(deg_to_rad(60), win_aspect, 0.5, 500.0); glMatrixMode(GL_PROJECTION); glLoadMatrixf(mat[0]); diff --git a/src/fs.cc b/src/fs.cc index b8f7420..0da07e5 100644 --- a/src/fs.cc +++ b/src/fs.cc @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -61,11 +62,22 @@ 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 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); @@ -75,8 +87,10 @@ void draw_fs() 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; itype) { + case FSTYPE_FILE: + ++nfiles; + break; + case FSTYPE_DIR: + ++ndirs; + default: + break; + } } printf("expanded %d children\n", (int)children.size()); diff --git a/src/fs.h b/src/fs.h index 6c7b406..0eb72ed 100644 --- a/src/fs.h +++ b/src/fs.h @@ -20,6 +20,7 @@ public: FSNode *parent; std::vector children; + int nfiles, ndirs; FSNode();