Show visual notice for visibility on Scene Dock

This commit is contained in:
volzhs 2016-12-28 22:12:08 +09:00
parent 792ff11642
commit f33e21e7af
4 changed files with 28 additions and 3 deletions

View file

@ -569,6 +569,15 @@ void TreeItem::set_button(int p_column,int p_idx,const Ref<Texture>& p_button){
}
void TreeItem::set_button_color(int p_column,int p_idx,const Color& p_color) {
ERR_FAIL_INDEX( p_column, cells.size() );
ERR_FAIL_INDEX( p_idx, cells[p_column].buttons.size() );
cells[p_column].buttons[p_idx].color=p_color;
_changed_notify(p_column);
}
void TreeItem::set_editable(int p_column,bool p_editable) {
ERR_FAIL_INDEX( p_column, cells.size() );
@ -1061,7 +1070,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
o.y+=(label_h-s.height)/2;
o+=cache.button_pressed->get_offset();
b->draw(ci,o,p_item->cells[i].buttons[j].disabled?Color(1,1,1,0.5):Color(1,1,1,1));
b->draw(ci,o,p_item->cells[i].buttons[j].disabled?Color(1,1,1,0.5):p_item->cells[i].buttons[j].color);
w-=s.width+cache.button_margin;
bw+=s.width+cache.button_margin;
}

View file

@ -93,7 +93,8 @@ friend class Tree;
int id;
bool disabled;
Ref<Texture> texture;
Button() { id=0; disabled=false; }
Color color;
Button() { id=0; disabled=false; color=Color(1,1,1,1); }
};
Vector< Button > buttons;
@ -189,6 +190,7 @@ public:
int get_button_by_id(int p_column,int p_id) const;
bool is_button_disabled(int p_column,int p_idx) const;
void set_button(int p_column,int p_idx,const Ref<Texture>& p_button);
void set_button_color(int p_column,int p_idx,const Color& p_color);
/* range works for mode number or mode combo */

View file

@ -402,6 +402,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
if (!p_node->is_connected("visibility_changed",this,"_node_visibility_changed"))
p_node->connect("visibility_changed",this,"_node_visibility_changed",varray(p_node));
_update_visibility_color(p_node, item);
} else if (p_node->is_type("Spatial")) {
bool h = p_node->call("is_hidden");
@ -413,6 +414,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
if (!p_node->is_connected("visibility_changed",this,"_node_visibility_changed"))
p_node->connect("visibility_changed",this,"_node_visibility_changed",varray(p_node));
_update_visibility_color(p_node, item);
}
}
@ -478,9 +480,20 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) {
else
item->set_button(0,idx,get_icon("Visible","EditorIcons"));
_update_visibility_color(p_node, item);
}
void SceneTreeEditor::_update_visibility_color(Node *p_node, TreeItem *p_item) {
if (p_node->is_type("CanvasItem") || p_node->is_type("Spatial")) {
Color color(1,1,1,1);
bool visible_on_screen = p_node->call("is_visible");
if (!visible_on_screen) {
color = Color(0.6,0.6,0.6,1);
}
int idx=p_item->get_button_by_id(0,BUTTON_VISIBILITY);
p_item->set_button_color(0,idx,color);
}
}
void SceneTreeEditor::_node_script_changed(Node *p_node) {

View file

@ -117,6 +117,7 @@ class SceneTreeEditor : public Control {
void _update_selection(TreeItem *item);
void _node_script_changed(Node *p_node);
void _node_visibility_changed(Node *p_node);
void _update_visibility_color(Node *p_node, TreeItem *p_item);
void _subscene_option(int p_idx);
void _node_replace_owner(Node* p_base,Node* p_node,Node* p_root);