From 23c659fc4799a880997e1a0e8f5a75efea9613c4 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 4 May 2016 17:41:58 -0300 Subject: [PATCH] -make sure single select after multi select works better -fixed some warnings for OSX (cherry picked from commit f909634832a72cfc669fd1b6281c8a960ea3d40f) --- scene/gui/item_list.cpp | 23 +++++++++++++++++++++++ scene/gui/item_list.h | 2 ++ tools/editor/editor_file_system.h | 2 +- tools/editor/editor_import_export.h | 2 +- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 462423d30b6..51d89e3da3e 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -278,6 +278,7 @@ void ItemList::remove_item(int p_idx){ items.remove(p_idx); update(); shape_changed=true; + defer_select_single=-1; } @@ -288,6 +289,7 @@ void ItemList::clear(){ current=-1; ensure_selected_visible=false; update(); + defer_select_single=-1; } @@ -365,6 +367,20 @@ Size2 ItemList::get_min_icon_size() const { void ItemList::_input_event(const InputEvent& p_event) { + + if (defer_select_single>=0 && p_event.type==InputEvent::MOUSE_MOTION) { + defer_select_single=-1; + return; + } + if (defer_select_single>=0 && p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT && !p_event.mouse_button.pressed) { + + select(defer_select_single,true); + + emit_signal("multi_selected",defer_select_single,true); + defer_select_single=-1; + return; + } + if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT && p_event.mouse_button.pressed) { const InputEventMouseButton &mb = p_event.mouse_button; @@ -418,7 +434,13 @@ void ItemList::_input_event(const InputEvent& p_event) { emit_signal("multi_selected",i,true); } } else { + + if (!mb.mod.command && select_mode==SELECT_MULTI && items[i].selectable && items[i].selected) { + defer_select_single=i; + return; + } bool selected = !items[i].selected; + select(i,select_mode==SELECT_SINGLE || !mb.mod.command); if (selected) { if (select_mode==SELECT_SINGLE) { @@ -1142,6 +1164,7 @@ ItemList::ItemList() { current_columns=1; search_time_msec=0; ensure_selected_visible=false; + defer_select_single=-1; } diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index bd3cf6484e5..850bf335fc2 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -59,6 +59,8 @@ private: int max_columns; Size2 min_icon_size; + int defer_select_single; + void _scroll_changed(double); void _input_event(const InputEvent& p_event); protected: diff --git a/tools/editor/editor_file_system.h b/tools/editor/editor_file_system.h index d11fa0cfb1a..254dd68c146 100644 --- a/tools/editor/editor_file_system.h +++ b/tools/editor/editor_file_system.h @@ -36,7 +36,7 @@ #include "os/thread_safe.h" class FileAccess; -class EditorProgressBG; +struct EditorProgressBG; class EditorFileSystemDirectory : public Object { OBJ_TYPE( EditorFileSystemDirectory,Object ); diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h index 6fc644acc2a..9170e372668 100644 --- a/tools/editor/editor_import_export.h +++ b/tools/editor/editor_import_export.h @@ -36,7 +36,7 @@ class EditorExportPlatform; class FileAccess; -class EditorProgress; +struct EditorProgress; class EditorImportPlugin : public Reference {