Merge pull request #14792 from Krakean/enh-1

A few small Debugger->Errors tab enhancements:
This commit is contained in:
Rémi Verschelde 2018-01-03 10:26:55 +01:00 committed by GitHub
commit 6cd33f17f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 89 additions and 1 deletions

View File

@ -1686,6 +1686,45 @@ void ScriptEditorDebugger::_clear_remote_objects() {
remote_objects.clear(); remote_objects.clear();
} }
void ScriptEditorDebugger::_clear_errors_list() {
error_list->clear();
error_count = 0;
_notification(NOTIFICATION_PROCESS);
}
// Right click on specific file(s) or folder(s).
void ScriptEditorDebugger::_error_list_item_rmb_selected(int p_item, const Vector2 &p_pos) {
item_menu->clear();
item_menu->set_size(Size2(1, 1));
// Allow specific actions only on one item.
bool single_item_selected = error_list->get_selected_items().size() == 1;
if (single_item_selected) {
item_menu->add_icon_item(get_icon("CopyNodePath", "EditorIcons"), TTR("Copy Error"), ITEM_MENU_COPY_ERROR);
}
if (item_menu->get_item_count() > 0) {
item_menu->set_position(error_list->get_global_position() + p_pos);
item_menu->popup();
}
}
void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) {
switch (p_option) {
case ITEM_MENU_COPY_ERROR: {
String title = error_list->get_item_text(error_list->get_current());
String desc = error_list->get_item_tooltip(error_list->get_current());
OS::get_singleton()->set_clipboard(title + "\n----------\n" + desc);
} break;
}
}
void ScriptEditorDebugger::_bind_methods() { void ScriptEditorDebugger::_bind_methods() {
ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"), &ScriptEditorDebugger::_stack_dump_frame_selected); ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"), &ScriptEditorDebugger::_stack_dump_frame_selected);
@ -1705,6 +1744,10 @@ void ScriptEditorDebugger::_bind_methods() {
ClassDB::bind_method(D_METHOD("_error_stack_selected"), &ScriptEditorDebugger::_error_stack_selected); ClassDB::bind_method(D_METHOD("_error_stack_selected"), &ScriptEditorDebugger::_error_stack_selected);
ClassDB::bind_method(D_METHOD("_profiler_activate"), &ScriptEditorDebugger::_profiler_activate); ClassDB::bind_method(D_METHOD("_profiler_activate"), &ScriptEditorDebugger::_profiler_activate);
ClassDB::bind_method(D_METHOD("_profiler_seeked"), &ScriptEditorDebugger::_profiler_seeked); ClassDB::bind_method(D_METHOD("_profiler_seeked"), &ScriptEditorDebugger::_profiler_seeked);
ClassDB::bind_method(D_METHOD("_clear_errors_list"), &ScriptEditorDebugger::_clear_errors_list);
ClassDB::bind_method(D_METHOD("_error_list_item_rmb_selected"), &ScriptEditorDebugger::_error_list_item_rmb_selected);
ClassDB::bind_method(D_METHOD("_item_menu_id_pressed"), &ScriptEditorDebugger::_item_menu_id_pressed);
ClassDB::bind_method(D_METHOD("_paused"), &ScriptEditorDebugger::_paused); ClassDB::bind_method(D_METHOD("_paused"), &ScriptEditorDebugger::_paused);
@ -1829,9 +1872,31 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
error_split = memnew(HSplitContainer); error_split = memnew(HSplitContainer);
VBoxContainer *errvb = memnew(VBoxContainer); VBoxContainer *errvb = memnew(VBoxContainer);
HBoxContainer *errhb = memnew(HBoxContainer);
errvb->set_h_size_flags(SIZE_EXPAND_FILL); errvb->set_h_size_flags(SIZE_EXPAND_FILL);
Label *velb = memnew(Label(TTR("Errors:")));
velb->set_h_size_flags(SIZE_EXPAND_FILL);
errhb->add_child(velb);
clearbutton = memnew(Button);
clearbutton->set_text(TTR("Clear"));
clearbutton->connect("pressed", this, "_clear_errors_list");
errhb->add_child(clearbutton);
errvb->add_child(errhb);
error_list = memnew(ItemList); error_list = memnew(ItemList);
errvb->add_margin_child(TTR("Errors:"), error_list, true); error_list->set_v_size_flags(SIZE_EXPAND_FILL);
error_list->set_h_size_flags(SIZE_EXPAND_FILL);
error_list->connect("item_rmb_selected", this, "_error_list_item_rmb_selected");
error_list->set_allow_rmb_select(true);
error_list->set_autoscroll_to_bottom(true);
item_menu = memnew(PopupMenu);
item_menu->connect("id_pressed", this, "_item_menu_id_pressed");
error_list->add_child(item_menu);
errvb->add_child(error_list);
error_split->add_child(errvb); error_split->add_child(errvb);
errvb = memnew(VBoxContainer); errvb = memnew(VBoxContainer);

View File

@ -62,6 +62,10 @@ class ScriptEditorDebugger : public Control {
MESSAGE_SUCCESS, MESSAGE_SUCCESS,
}; };
enum ItemMenu {
ITEM_MENU_COPY_ERROR,
};
AcceptDialog *msgdialog; AcceptDialog *msgdialog;
Button *debugger_button; Button *debugger_button;
@ -85,6 +89,8 @@ class ScriptEditorDebugger : public Control {
ItemList *error_list; ItemList *error_list;
ItemList *error_stack; ItemList *error_stack;
Tree *inspect_scene_tree; Tree *inspect_scene_tree;
Button *clearbutton;
PopupMenu *item_menu;
int error_count; int error_count;
int last_error_count; int last_error_count;
@ -175,6 +181,10 @@ class ScriptEditorDebugger : public Control {
void _set_remote_object(ObjectID p_id, ScriptEditorDebuggerInspectedObject *p_obj); void _set_remote_object(ObjectID p_id, ScriptEditorDebuggerInspectedObject *p_obj);
void _clear_remote_objects(); void _clear_remote_objects();
void _clear_errors_list();
void _error_list_item_rmb_selected(int p_item, const Vector2 &p_pos);
void _item_menu_id_pressed(int p_option);
protected: protected:
void _notification(int p_what); void _notification(int p_what);

View File

@ -930,6 +930,9 @@ void ItemList::_notification(int p_what) {
scroll_bar->hide(); scroll_bar->hide();
} else { } else {
scroll_bar->show(); scroll_bar->show();
if (do_autoscroll_to_bottom)
scroll_bar->set_value(max);
} }
break; break;
} }
@ -1313,6 +1316,11 @@ Size2 ItemList::get_minimum_size() const {
return Size2(); return Size2();
} }
void ItemList::set_autoscroll_to_bottom(const bool p_enable) {
do_autoscroll_to_bottom = p_enable;
}
void ItemList::set_auto_height(bool p_enable) { void ItemList::set_auto_height(bool p_enable) {
auto_height = p_enable; auto_height = p_enable;
@ -1466,6 +1474,7 @@ ItemList::ItemList() {
ensure_selected_visible = false; ensure_selected_visible = false;
defer_select_single = -1; defer_select_single = -1;
allow_rmb_select = false; allow_rmb_select = false;
do_autoscroll_to_bottom = false;
icon_scale = 1.0f; icon_scale = 1.0f;
set_clip_contents(true); set_clip_contents(true);

View File

@ -107,6 +107,8 @@ private:
real_t icon_scale; real_t icon_scale;
bool do_autoscroll_to_bottom;
Array _get_items() const; Array _get_items() const;
void _set_items(const Array &p_items); void _set_items(const Array &p_items);
@ -212,6 +214,8 @@ public:
Size2 get_minimum_size() const; Size2 get_minimum_size() const;
void set_autoscroll_to_bottom(const bool p_enable);
VScrollBar *get_v_scroll() { return scroll_bar; } VScrollBar *get_v_scroll() { return scroll_bar; }
ItemList(); ItemList();