vrfileman

view 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 source
1 #include "layout.h"
3 Layout::Layout()
4 {
5 init();
6 }
8 Layout::~Layout()
9 {
10 destroy();
11 }
13 bool Layout::init()
14 {
15 tree = 0;
16 return true;
17 }
19 void Layout::destroy()
20 {
21 std::map<FSNode*, LayoutData*>::iterator it = node_data.begin();
22 while(it != node_data.end()) {
23 delete it->second;
24 ++it;
25 }
26 node_data.clear();
27 }
29 void Layout::clear()
30 {
31 destroy();
32 init();
33 }
35 void Layout::set_root(FSNode *root)
36 {
37 clear();
38 tree = root;
39 }
41 Vector3 Layout::get_local_pos(const FSNode *node) const
42 {
43 return Vector3();
44 }
46 Vector3 Layout::get_world_pos(const FSNode *node) const
47 {
48 Vector3 pos;
50 while(node) {
51 pos += get_local_pos(node);
52 node = node->get_parent();
53 }
54 return pos;
55 }
58 // ---- PlanarLayout ----
60 void PlanarLayout::layout()
61 {
62 clear();
64 if(!tree) return;
66 PlanarLayoutData *root_data = new PlanarLayoutData;
67 root_data->width = root_data->height = 0;
68 root_data->sub_width = root_data->sub_width = 0;
69 node_data[tree] = root_data;
71 layout_tree(tree);
72 }
74 void PlanarLayout::layout_tree(FSNode *tree)
75 {
77 }
79 Vector3 PlanarLayout::get_local_pos(const FSNode *node) const
80 {
81 }