# HG changeset patch # User John Tsiombikas # Date 1422970923 -7200 # Node ID b041bc1c38adf0ca49ba1c0341c33f92ea673e42 # Parent d487181ee1d922e533698461464cde35abc45ec3 layout diff -r d487181ee1d9 -r b041bc1c38ad src/fs.cc --- a/src/fs.cc Tue Feb 03 03:35:14 2015 +0200 +++ b/src/fs.cc Tue Feb 03 15:42:03 2015 +0200 @@ -32,7 +32,6 @@ sorted = true; uid = gid = mode = 0; type = UNKNOWN; - data = 0; } void FSNode::destroy() @@ -228,16 +227,6 @@ return expanded; } -void FSNode::set_ext_data(void *data) -{ - this->data = data; -} - -void *FSNode::get_ext_data() const -{ - return data; -} - // ---- FSDir ---- FSDir::FSDir() diff -r d487181ee1d9 -r b041bc1c38ad src/fs.h --- a/src/fs.h Tue Feb 03 03:35:14 2015 +0200 +++ b/src/fs.h Tue Feb 03 15:42:03 2015 +0200 @@ -17,8 +17,6 @@ Type type; unsigned int uid, gid, mode; - void *data; - private: FSNode(const FSNode&); FSNode &operator =(const FSNode&); @@ -59,9 +57,6 @@ virtual bool expand(); virtual bool is_expanded() const; - - virtual void set_ext_data(void *data); - virtual void *get_ext_data() const; }; class FSDir : public FSNode { diff -r d487181ee1d9 -r b041bc1c38ad src/layout.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/layout.cc Tue Feb 03 15:42:03 2015 +0200 @@ -0,0 +1,81 @@ +#include "layout.h" + +Layout::Layout() +{ + init(); +} + +Layout::~Layout() +{ + destroy(); +} + +bool Layout::init() +{ + tree = 0; + return true; +} + +void Layout::destroy() +{ + std::map::iterator it = node_data.begin(); + while(it != node_data.end()) { + delete it->second; + ++it; + } + node_data.clear(); +} + +void Layout::clear() +{ + destroy(); + init(); +} + +void Layout::set_root(FSNode *root) +{ + clear(); + tree = root; +} + +Vector3 Layout::get_local_pos(const FSNode *node) const +{ + return Vector3(); +} + +Vector3 Layout::get_world_pos(const FSNode *node) const +{ + Vector3 pos; + + while(node) { + pos += get_local_pos(node); + node = node->get_parent(); + } + return pos; +} + + +// ---- PlanarLayout ---- + +void PlanarLayout::layout() +{ + clear(); + + if(!tree) return; + + PlanarLayoutData *root_data = new PlanarLayoutData; + root_data->width = root_data->height = 0; + root_data->sub_width = root_data->sub_width = 0; + node_data[tree] = root_data; + + layout_tree(tree); +} + +void PlanarLayout::layout_tree(FSNode *tree) +{ + +} + +Vector3 PlanarLayout::get_local_pos(const FSNode *node) const +{ +} diff -r d487181ee1d9 -r b041bc1c38ad src/layout.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/layout.h Tue Feb 03 15:42:03 2015 +0200 @@ -0,0 +1,46 @@ +#ifndef LAYOUT_H_ +#define LAYOUT_H_ + +#include +#include +#include "fs.h" + +struct LayoutData {}; + +class Layout { +protected: + FSNode *tree; + std::map node_data; + +public: + Layout(); + virtual ~Layout(); + + virtual bool init(); + virtual void destroy(); + virtual void clear(); + + virtual void set_root(FSNode *root); + + virtual void layout() = 0; + + virtual Vector3 get_local_pos(const FSNode *node) const; + virtual Vector3 get_world_pos(const FSNode *node) const; +}; + +struct PlanarLayoutData { + Vector2 pos; /* local pos, relative to parent */ + float width, height; + float sub_width, sub_height; +}; + +class PlanarLayout : public Layout { +private: + void layout_tree(FSNode *tree); + +public: + void layout(); +}; + + +#endif // LAYOUT_H_