Merge pull request #10238 from Hinsbart/resource_rmb

Inspector: Right click on resource opens sub-menu.
This commit is contained in:
Rémi Verschelde 2017-08-11 10:42:29 +02:00 committed by GitHub
commit 066fb4d5f9
4 changed files with 17 additions and 5 deletions

View file

@ -3751,6 +3751,10 @@ void PropertyEditor::_item_selected() {
selected_property = item->get_metadata(1); selected_property = item->get_metadata(1);
} }
void PropertyEditor::_item_rmb_edited() {
_custom_editor_request(true);
}
void PropertyEditor::_edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field) { void PropertyEditor::_edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field) {
if (autoclear) { if (autoclear) {
@ -4247,6 +4251,7 @@ void PropertyEditor::_bind_methods() {
ClassDB::bind_method("_item_edited", &PropertyEditor::_item_edited); ClassDB::bind_method("_item_edited", &PropertyEditor::_item_edited);
ClassDB::bind_method("_item_selected", &PropertyEditor::_item_selected); ClassDB::bind_method("_item_selected", &PropertyEditor::_item_selected);
ClassDB::bind_method("_item_rmb_edited", &PropertyEditor::_item_rmb_edited);
ClassDB::bind_method("_item_folded", &PropertyEditor::_item_folded); ClassDB::bind_method("_item_folded", &PropertyEditor::_item_folded);
ClassDB::bind_method("_custom_editor_request", &PropertyEditor::_custom_editor_request); ClassDB::bind_method("_custom_editor_request", &PropertyEditor::_custom_editor_request);
ClassDB::bind_method("_custom_editor_edited", &PropertyEditor::_custom_editor_edited); ClassDB::bind_method("_custom_editor_edited", &PropertyEditor::_custom_editor_edited);
@ -4401,6 +4406,7 @@ PropertyEditor::PropertyEditor() {
add_child(tree); add_child(tree);
tree->connect("item_edited", this, "_item_edited", varray(), CONNECT_DEFERRED); tree->connect("item_edited", this, "_item_edited", varray(), CONNECT_DEFERRED);
tree->connect("item_rmb_edited", this, "_item_rmb_edited");
tree->connect("cell_selected", this, "_item_selected"); tree->connect("cell_selected", this, "_item_selected");
tree->connect("item_collapsed", this, "_item_folded"); tree->connect("item_collapsed", this, "_item_folded");

View file

@ -209,6 +209,7 @@ class PropertyEditor : public Control {
void _custom_editor_request(bool p_arrow); void _custom_editor_request(bool p_arrow);
void _item_selected(); void _item_selected();
void _item_rmb_edited();
void _item_edited(); void _item_edited();
TreeItem *get_parent_node(String p_path, HashMap<String, TreeItem *> &item_paths, TreeItem *root, TreeItem *category); TreeItem *get_parent_node(String p_path, HashMap<String, TreeItem *> &item_paths, TreeItem *root, TreeItem *category);

View file

@ -1856,13 +1856,14 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
bring_up_editor = false; bring_up_editor = false;
custom_popup_rect = Rect2i(get_global_position() + Point2i(col_ofs, _get_title_button_height() + y_ofs + item_h - cache.offset.y), Size2(get_column_width(col), item_h));
if (on_arrow || !p_item->cells[col].custom_button) { if (on_arrow || !p_item->cells[col].custom_button) {
custom_popup_rect = Rect2i(get_global_position() + Point2i(col_ofs, _get_title_button_height() + y_ofs + item_h - cache.offset.y), Size2(get_column_width(col), item_h));
emit_signal("custom_popup_edited", ((bool)(x >= (col_width - item_h / 2)))); emit_signal("custom_popup_edited", ((bool)(x >= (col_width - item_h / 2))));
} }
if (!p_item->cells[col].custom_button || !on_arrow) { if (!p_item->cells[col].custom_button || !on_arrow) {
item_edited(col, p_item); item_edited(col, p_item, p_button == BUTTON_LEFT);
} }
click_handled = true; click_handled = true;
return -1; return -1;
@ -2925,11 +2926,14 @@ TreeItem *Tree::get_last_item() {
return last; return last;
} }
void Tree::item_edited(int p_column, TreeItem *p_item) { void Tree::item_edited(int p_column, TreeItem *p_item, bool p_lmb) {
edited_item = p_item; edited_item = p_item;
edited_col = p_column; edited_col = p_column;
emit_signal("item_edited"); if (p_lmb)
emit_signal("item_edited");
else
emit_signal("item_rmb_edited");
} }
void Tree::item_changed(int p_column, TreeItem *p_item) { void Tree::item_changed(int p_column, TreeItem *p_item) {
@ -3645,6 +3649,7 @@ void Tree::_bind_methods() {
ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::VECTOR2, "pos"))); ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::VECTOR2, "pos")));
ADD_SIGNAL(MethodInfo("empty_tree_rmb_selected", PropertyInfo(Variant::VECTOR2, "pos"))); ADD_SIGNAL(MethodInfo("empty_tree_rmb_selected", PropertyInfo(Variant::VECTOR2, "pos")));
ADD_SIGNAL(MethodInfo("item_edited")); ADD_SIGNAL(MethodInfo("item_edited"));
ADD_SIGNAL(MethodInfo("item_rmb_edited"));
ADD_SIGNAL(MethodInfo("item_custom_button_pressed")); ADD_SIGNAL(MethodInfo("item_custom_button_pressed"));
ADD_SIGNAL(MethodInfo("item_double_clicked")); ADD_SIGNAL(MethodInfo("item_double_clicked"));
ADD_SIGNAL(MethodInfo("item_collapsed", PropertyInfo(Variant::OBJECT, "item"))); ADD_SIGNAL(MethodInfo("item_collapsed", PropertyInfo(Variant::OBJECT, "item")));

View file

@ -381,7 +381,7 @@ private:
Size2 get_minimum_size() const; Size2 get_minimum_size() const;
void item_edited(int p_column, TreeItem *p_item); void item_edited(int p_column, TreeItem *p_item, bool p_lmb = true);
void item_changed(int p_column, TreeItem *p_item); void item_changed(int p_column, TreeItem *p_item);
void item_selected(int p_column, TreeItem *p_item); void item_selected(int p_column, TreeItem *p_item);
void item_deselected(int p_column, TreeItem *p_item); void item_deselected(int p_column, TreeItem *p_item);