From f6a327e85904bea1ab1ae49ccd521de3a372b68b Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Mon, 1 Aug 2016 06:37:22 +0300 Subject: [PATCH] rough filenames --- Makefile | 2 +- src/fs.cc | 31 +++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c3de574..a9b2486 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ warn = -pedantic -Wall CFLAGS = $(warn) $(opt) $(dbg) $(inc) `pkg-config --cflags sdl2` CXXFLAGS = -std=c++11 $(warn) $(opt) $(dbg) $(inc) `pkg-config --cflags sdl2` -LDFLAGS = $(libgl) -lgmath -limago -lgoatvr -loptcfg `pkg-config --libs sdl2` +LDFLAGS = $(libgl) -lgmath -limago -lgoatvr -loptcfg -ldrawtext `pkg-config --libs sdl2` ifeq ($(shell uname -s), Darwin) diff --git a/src/fs.cc b/src/fs.cc index d038546..b8f7420 100644 --- a/src/fs.cc +++ b/src/fs.cc @@ -12,6 +12,7 @@ #include "gmath/gmath.h" #include "opengl.h" #include "app.h" +#include "drawtext.h" static IconRenderer *iconrend; @@ -19,6 +20,10 @@ static std::map node_cache; static FSNode *cur_node; static int start_child; +static dtx_font *fat_font; +#define FAT_FONT_SZ 32 + + bool init_fs() { iconrend = new ShapesIcons; @@ -26,6 +31,11 @@ bool init_fs() return false; } + if(!(fat_font = dtx_open_font("data/fat.font", FAT_FONT_SZ))) { + fprintf(stderr, "failed to open font file data/fat.font\n"); + return false; + } + cur_node = get_fsnode(0); cur_node->expand(); return true; @@ -71,19 +81,32 @@ void draw_fs() for(int i=0; ichildren[idx]; - if(cur_node->children[idx]->type == FSTYPE_DIR) { + if(node->type == FSTYPE_DIR) { continue; } - Vec3 pos = icon_pos(row, col, ncols, row_spacing, radius); + float angle = -2.0 * M_PI * (float)col / (float)ncols; Mat4 xform = base_xform; - xform.translate(pos); + xform.translate(0, row * row_spacing, -radius); + xform.rotate_y(angle); glPushMatrix(); glMultMatrixf(xform[0]); - iconrend->draw(cur_node->children[idx]); + iconrend->draw(node); + glPopMatrix(); + + glPushMatrix(); + xform = Mat4::identity; + xform.translate(-dtx_string_width(node->path.get_name()) / 2.0, 0, 0); + xform.scale(0.01); + xform.translate(0, 1 + row * row_spacing, -radius); + xform.rotate_y(angle); + glMultMatrixf(xform[0]); + + dtx_string(node->path.get_name()); glPopMatrix(); if(++col >= ncols) { -- 1.7.10.4