summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/tree.cpp17
-rw-r--r--scene/gui/tree.h3
-rw-r--r--scene/resources/default_theme/default_theme.cpp5
3 files changed, 19 insertions, 6 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 08fe847a33..f8516f8f5d 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -811,6 +811,8 @@ void Tree::update_cache() {
cache.item_margin=get_constant("item_margin");
cache.button_margin=get_constant("button_margin");
cache.guide_width=get_constant("guide_width");
+ cache.draw_relationship_lines=get_constant("draw_relationship_lines");
+ cache.relationship_line_color=get_color("relationship_line_color");
cache.title_button = get_stylebox("title_button_normal");
cache.title_button_pressed = get_stylebox("title_button_pressed");
@@ -1295,9 +1297,21 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
while (c) {
+ if (cache.draw_relationship_lines == 1){
+ int root_ofs = children_pos.x + (hide_folding?cache.hseparation:cache.item_margin);
+ int parent_ofs = p_pos.x + (hide_folding?cache.hseparation:cache.item_margin);
+ Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h/2)-cache.offset+p_draw_ofs;
+ if (c->get_children() > 0)
+ root_pos -= Point2i(cache.arrow->get_width(),0);
+
+ Point2i parent_pos = Point2i(parent_ofs - cache.arrow->get_width()/2, p_pos.y + label_h/2 + cache.arrow->get_height()/2)-cache.offset+p_draw_ofs;
+ VisualServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x, root_pos.y), cache.relationship_line_color);
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y), parent_pos, cache.relationship_line_color);
+ }
+
int child_h=draw_item(children_pos, p_draw_ofs, p_draw_size, c );
- if (child_h<0)
+ if (child_h<0 && cache.draw_relationship_lines == 0)
return -1; // break, stop drawing, no need to anymore
htotal+=child_h;
@@ -3674,4 +3688,3 @@ Tree::~Tree() {
}
}
-
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 1dad26dffe..0172546c1d 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -377,6 +377,7 @@ friend class TreeItem;
Color font_color_selected;
Color guide_color;
Color drop_position_color;
+ Color relationship_line_color;
int hseparation;
int vseparation;
@@ -384,6 +385,7 @@ friend class TreeItem;
int guide_width;
int button_margin;
Point2 offset;
+ int draw_relationship_lines;
enum ClickType {
CLICK_NONE,
@@ -532,4 +534,3 @@ public:
VARIANT_ENUM_CAST( Tree::SelectMode );
#endif
-
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 9ebb7e7561..58b1366e7c 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -661,12 +661,14 @@ void fill_default_theme(Ref<Theme>& t,const Ref<Font> & default_font,const Ref<F
t->set_color("cursor_color","Tree", Color(0,0,0) );
t->set_color("guide_color","Tree", Color(0,0,0,0.1) );
t->set_color("drop_position_color","Tree", Color(1,0.3,0.2) );
+ t->set_color("relationship_line_color", "Tree", Color::html("464646") );
t->set_constant("hseparation","Tree",4 *scale);
t->set_constant("vseparation","Tree",4 *scale);
t->set_constant("guide_width","Tree",2 *scale);
t->set_constant("item_margin","Tree",12 *scale);
t->set_constant("button_margin","Tree",4 *scale);
+ t->set_constant("draw_relationship_lines", "Tree", 0);
// ItemList
@@ -950,6 +952,3 @@ void clear_default_theme() {
Theme::set_default_font( Ref< Font >() );
}
-
-
-