vrfileman
diff src/layout.cc @ 6:b041bc1c38ad
layout
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 03 Feb 2015 15:42:03 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/layout.cc Tue Feb 03 15:42:03 2015 +0200 1.3 @@ -0,0 +1,81 @@ 1.4 +#include "layout.h" 1.5 + 1.6 +Layout::Layout() 1.7 +{ 1.8 + init(); 1.9 +} 1.10 + 1.11 +Layout::~Layout() 1.12 +{ 1.13 + destroy(); 1.14 +} 1.15 + 1.16 +bool Layout::init() 1.17 +{ 1.18 + tree = 0; 1.19 + return true; 1.20 +} 1.21 + 1.22 +void Layout::destroy() 1.23 +{ 1.24 + std::map<FSNode*, LayoutData*>::iterator it = node_data.begin(); 1.25 + while(it != node_data.end()) { 1.26 + delete it->second; 1.27 + ++it; 1.28 + } 1.29 + node_data.clear(); 1.30 +} 1.31 + 1.32 +void Layout::clear() 1.33 +{ 1.34 + destroy(); 1.35 + init(); 1.36 +} 1.37 + 1.38 +void Layout::set_root(FSNode *root) 1.39 +{ 1.40 + clear(); 1.41 + tree = root; 1.42 +} 1.43 + 1.44 +Vector3 Layout::get_local_pos(const FSNode *node) const 1.45 +{ 1.46 + return Vector3(); 1.47 +} 1.48 + 1.49 +Vector3 Layout::get_world_pos(const FSNode *node) const 1.50 +{ 1.51 + Vector3 pos; 1.52 + 1.53 + while(node) { 1.54 + pos += get_local_pos(node); 1.55 + node = node->get_parent(); 1.56 + } 1.57 + return pos; 1.58 +} 1.59 + 1.60 + 1.61 +// ---- PlanarLayout ---- 1.62 + 1.63 +void PlanarLayout::layout() 1.64 +{ 1.65 + clear(); 1.66 + 1.67 + if(!tree) return; 1.68 + 1.69 + PlanarLayoutData *root_data = new PlanarLayoutData; 1.70 + root_data->width = root_data->height = 0; 1.71 + root_data->sub_width = root_data->sub_width = 0; 1.72 + node_data[tree] = root_data; 1.73 + 1.74 + layout_tree(tree); 1.75 +} 1.76 + 1.77 +void PlanarLayout::layout_tree(FSNode *tree) 1.78 +{ 1.79 + 1.80 +} 1.81 + 1.82 +Vector3 PlanarLayout::get_local_pos(const FSNode *node) const 1.83 +{ 1.84 +}