adding fs and icon renderers
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Thu, 28 Jul 2016 14:09:56 +0000 (17:09 +0300)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Thu, 28 Jul 2016 14:09:56 +0000 (17:09 +0300)
src/fs.h [new file with mode: 0644]
src/icon.cc [new file with mode: 0644]
src/icon.h [new file with mode: 0644]

diff --git a/src/fs.h b/src/fs.h
new file mode 100644 (file)
index 0000000..d58c621
--- /dev/null
+++ b/src/fs.h
@@ -0,0 +1,20 @@
+#ifndef FS_H_
+#define FS_H_
+
+enum FSNodeType {
+       FSNODE_UNKNOWN,
+       FSNODE_FILE,
+       FSNODE_DIR,
+       FSNODE_DEV
+};
+
+class FSNode {
+public:
+       FSNodeType type;
+       char *abs_path;
+       char *name, *suffix;
+
+       void set_path(const char *s);
+};
+
+#endif // FS_H_
diff --git a/src/icon.cc b/src/icon.cc
new file mode 100644 (file)
index 0000000..a72a6d0
--- /dev/null
@@ -0,0 +1,69 @@
+#include <string.h>
+#include "icon.h"
+#include "fs.h"
+#include "meshgen.h"
+#include "mesh.h"
+
+IconRenderer::~IconRenderer()
+{
+}
+
+bool IconRenderer::init()
+{
+       return true;
+}
+
+void IconRenderer::shutdown()
+{
+}
+
+
+// Shapes icon renderer
+enum {
+       SHAPE_SPHERE,
+       SHAPE_BOX,
+       SHAPE_TORUS,
+       SHAPE_CONE,
+       NUM_SHAPES
+};
+
+struct ShapesIconsPriv {
+       Mesh *shape[NUM_SHAPES];
+};
+
+ShapesIcons::ShapesIcons()
+{
+       priv = new ShapesIconsPriv;
+       memset(priv, 0, sizeof *priv);
+}
+
+ShapesIcons::~ShapesIcons()
+{
+       shutdown();
+       delete priv;
+}
+
+bool ShapesIcons::init()
+{
+       for(int i=0; i<NUM_SHAPES; i++) {
+               priv->shape[i] = new Mesh;
+       }
+
+       gen_geosphere(priv->shape[SHAPE_SPHERE], 1.0, 2);
+       gen_box(priv->shape[SHAPE_BOX], 1, 1, 1);
+       gen_torus(priv->shape[SHAPE_TORUS], 0.9, 0.2, 16, 8);
+       gen_cone(priv->shape[SHAPE_CONE], 0.8, 1.0, 8, 2);
+
+       return true;
+}
+
+void ShapesIcons::shutdown()
+{
+       for(int i=0; i<NUM_SHAPES; i++) {
+               delete priv->shape[i];
+       }
+}
+
+void ShapesIcons::draw(FSNode *node) const
+{
+}
diff --git a/src/icon.h b/src/icon.h
new file mode 100644 (file)
index 0000000..e2b4fc1
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef ICON_H_
+#define ICON_H_
+
+class FSNode;
+
+class IconRenderer {
+public:
+       virtual ~IconRenderer();
+
+       virtual bool init();
+       virtual void shutdown();
+
+       virtual void draw(FSNode *node) const = 0;
+};
+
+struct ShapesIconsPriv;
+
+class ShapesIcons : public IconRenderer {
+private:
+       ShapesIconsPriv *priv;
+
+public:
+       ShapesIcons();
+       ~ShapesIcons();
+
+       bool init();
+       void shutdown();
+
+       void draw(FSNode *node) const;
+};
+
+#endif // ICON_H_