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]);
#include <errno.h>
#include <string>
#include <map>
+#include <algorithm>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
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<int>(1, umax * 16);
Mat4 base_xform;
base_xform.rotate(time_sec, 0, 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; i<nchildren; i++) {
continue;
}
- float angle = -2.0 * M_PI * (float)col / (float)ncols;
+ float angle = icon_angle(col, ncols, max_icon_angle);
Mat4 xform = base_xform;
xform.translate(0, row * row_spacing, -radius);
type = FSTYPE_UNKNOWN;
size = 0;
parent = 0;
+ nfiles = ndirs = 0;
}
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());