From 8d48cf95b9408a0a54bb741c6b795d2e5179503d Mon Sep 17 00:00:00 2001 From: Franklin Sobrinho Date: Thu, 5 Nov 2015 12:20:45 -0300 Subject: Add Tree checkbox check/uncheck behavior when pressing enter --- scene/gui/tree.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'scene/gui/tree.cpp') diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 5df6f2ced9..9789c83806 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2266,9 +2266,12 @@ bool Tree::edit_selected() { TreeItem::Cell &c = s->cells[col]; + if (c.mode==TreeItem::CELL_MODE_CHECK) { - - if (c.mode==TreeItem::CELL_MODE_CUSTOM) { + s->set_checked(col, !c.checked); + item_edited(col,s); + return true; + } else if (c.mode==TreeItem::CELL_MODE_CUSTOM) { edited_item=s; edited_col=col; -- cgit v1.2.3 From 8420c24f7f35cdd7adbc7d4595cb1756020ab127 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 13 Nov 2015 20:56:44 -0300 Subject: -better integration of ndee's theme --- scene/gui/tree.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'scene/gui/tree.cpp') diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 5df6f2ced9..a27918cf52 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -962,7 +962,9 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& Point2i guide_space=Point2i( cache.guide_width , height ); - if (p_item->childs) { //has childs, draw the guide box + + + if (!hide_folding && p_item->childs) { //has childs, draw the guide box Ref arrow; @@ -986,7 +988,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& int font_ascent=font->get_ascent(); - int ofs = p_pos.x + cache.item_margin; + int ofs = p_pos.x + (hide_folding?cache.hseparation:cache.item_margin); for (int i=0;icells[i].custom_bg_color) { - VisualServer::get_singleton()->canvas_item_add_rect(ci,cell_rect,p_item->cells[i].bg_color); + Rect2 r=cell_rect; + r.pos.x-=cache.hseparation; + r.size.x+=cache.hseparation; + VisualServer::get_singleton()->canvas_item_add_rect(ci,r,p_item->cells[i].bg_color); } Color col=p_item->cells[i].custom_color?p_item->cells[i].color:get_color( p_item->cells[i].selected?"font_color_selected":"font_color"); @@ -1376,7 +1381,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_ if (!skip && p_pos.y=x_ofs && p_pos.x < (x_ofs+cache.item_margin) ) { + if (!hide_folding && (p_pos.x >=x_ofs && p_pos.x < (x_ofs+cache.item_margin) )) { if (p_item->childs) @@ -3114,6 +3119,16 @@ bool Tree::can_cursor_exit_tree() const { return cursor_can_exit_tree; } +void Tree::set_hide_folding(bool p_hide) { + hide_folding=p_hide; + update(); +} + +bool Tree::is_folding_hidden() const { + + return hide_folding; +} + void Tree::_bind_methods() { @@ -3155,6 +3170,9 @@ void Tree::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_column_title","column"),&Tree::get_column_title); ObjectTypeDB::bind_method(_MD("get_scroll"),&Tree::get_scroll); + ObjectTypeDB::bind_method(_MD("set_hide_folding","hide"),&Tree::set_hide_folding); + ObjectTypeDB::bind_method(_MD("is_folding_hidden"),&Tree::is_folding_hidden); + ADD_SIGNAL( MethodInfo("item_selected")); ADD_SIGNAL( MethodInfo("cell_selected")); @@ -3242,6 +3260,8 @@ Tree::Tree() { pressing_for_editor=false; range_drag_enabled=false; + hide_folding=false; + } -- cgit v1.2.3