summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/base_button.cpp2
-rw-r--r--scene/gui/color_picker.cpp12
-rw-r--r--scene/gui/color_picker.h1
-rw-r--r--scene/gui/grid_container.cpp1
-rw-r--r--scene/gui/text_edit.cpp19
-rw-r--r--scene/gui/tree.cpp7
-rw-r--r--scene/main/viewport.cpp64
-rw-r--r--scene/resources/packed_scene.cpp4
-rw-r--r--scene/resources/sample_library.cpp10
9 files changed, 93 insertions, 27 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index a2b7cd2e0a..699062fee4 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -416,7 +416,7 @@ Ref<ShortCut> BaseButton:: get_shortcut() const {
void BaseButton::_unhandled_input(InputEvent p_event) {
- if (!is_disabled() && is_visible() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {
+ if (!is_disabled() && is_visible() && p_event.is_pressed() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {
if (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this))
return; //ignore because of modal window
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index d6bbdf2d21..06f8c27957 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -72,13 +72,16 @@ void ColorPicker::_notification(int p_what) {
_update_color();
}
- case NOTIFICATION_VISIBILITY_CHANGED: {
- c_text->call_deferred("grab_focus");
- c_text->call_deferred("select");
- } break;
+
}
}
+void ColorPicker::set_focus_on_line_edit() {
+
+ c_text->grab_focus();
+ c_text->select();
+}
+
void ColorPicker::_update_controls() {
if (edit_alpha) {
@@ -628,6 +631,7 @@ void ColorPickerButton::pressed() {
popup->set_pos(get_global_pos()-Size2(0,ms.height));
popup->set_size(ms);
popup->popup();
+ picker->set_focus_on_line_edit();
}
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index f5de982200..b9ef1f1e2f 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -107,6 +107,7 @@ public:
void set_raw_mode(bool p_enabled);
bool is_raw_mode() const;
+ void set_focus_on_line_edit();
ColorPicker();
};
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index dde9768a6d..5e6622b3f8 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -156,6 +156,7 @@ void GridContainer::_notification(int p_what) {
void GridContainer::set_columns(int p_columns) {
+ ERR_FAIL_COND(p_columns<1);
columns=p_columns;
queue_sort();
minimum_size_changed();
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index e106f0dfc6..40fc9a70cc 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -4140,13 +4140,26 @@ void TextEdit::_update_completion_candidates() {
int ci_match=0;
Vector<float> sim_cache;
for(int i=0;i<completion_strings.size();i++) {
+ if (s == completion_strings[i]) {
+ // A perfect match, stop completion
+ _cancel_completion();
+ return;
+ }
if (s.is_subsequence_ofi(completion_strings[i])) {
// don't remove duplicates if no input is provided
if (s != "" && completion_options.find(completion_strings[i]) != -1) {
continue;
}
// Calculate the similarity to keep completions in good order
- float similarity = s.similarity(completion_strings[i]);
+ float similarity;
+ if (completion_strings[i].to_lower().begins_with(s.to_lower())) {
+ // Substrings are the best candidates
+ similarity = 1.1;
+ } else {
+ // Otherwise compute the similarity
+ similarity = s.to_lower().similarity(completion_strings[i].to_lower());
+ }
+
int comp_size = completion_options.size();
if (comp_size == 0) {
completion_options.push_back(completion_strings[i]);
@@ -4156,8 +4169,8 @@ void TextEdit::_update_completion_candidates() {
int pos = 0;
do {
comp_sim = sim_cache[pos++];
- } while(pos < comp_size && similarity <= comp_sim);
- pos--; // Pos will be off by one
+ } while(pos < comp_size && similarity < comp_sim);
+ pos = similarity > comp_sim ? pos - 1 : pos; // Pos will be off by one
completion_options.insert(pos, completion_strings[i]);
sim_cache.insert(pos, similarity);
}
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index f8516f8f5d..db14c15db8 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1355,6 +1355,8 @@ void Tree::select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col
switched=true;
}
+ bool emitted_row=false;
+
for (int i=0;i<columns.size();i++) {
TreeItem::Cell &c=p_current->cells[i];
@@ -1373,7 +1375,10 @@ void Tree::select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col
selected_item=p_selected;
selected_col=0;
selected_item=p_selected;
- emit_signal("item_selected");
+ if (!emitted_row) {
+ emit_signal("item_selected");
+ emitted_row=true;
+ }
//if (p_col==i)
// p_current->selected_signal.call(p_col);
}
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 68f5a252e5..c6a32d5568 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1788,15 +1788,12 @@ void Viewport::_gui_input_event(InputEvent p_event) {
if (p_event.mouse_button.button_index==BUTTON_LEFT) {
gui.drag_accum=Vector2();
gui.drag_attempted=false;
- if (gui.drag_data.get_type()!=Variant::NIL) {
- _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
- }
- gui.drag_data=Variant();
}
}
+
p_event.mouse_button.global_x = pos.x;
p_event.mouse_button.global_y = pos.y;
@@ -1832,30 +1829,55 @@ void Viewport::_gui_input_event(InputEvent p_event) {
get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
get_tree()->set_input_as_handled();
+
+ if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+
+ //alternate drop use (when using force_drag(), as proposed by #5342
+ if (gui.mouse_focus && gui.mouse_focus->can_drop_data(pos,gui.drag_data)) {
+ gui.mouse_focus->drop_data(pos,gui.drag_data);
+ }
+
+ gui.drag_data=Variant();
+
+ if (gui.drag_preview) {
+ memdelete( gui.drag_preview );
+ gui.drag_preview=NULL;
+ }
+ _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
+ //change mouse accordingly
+ }
+
+
+
_gui_cancel_tooltip();
//gui.tooltip_popup->hide();
} else {
- if (gui.drag_preview && p_event.mouse_button.button_index==BUTTON_LEFT) {
- memdelete( gui.drag_preview );
- gui.drag_preview=NULL;
- }
- if (!gui.mouse_focus) {
- if (gui.mouse_over && gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (gui.mouse_over) {
Size2 pos = mpos;
pos = gui.focus_inv_xform.xform(pos);
if (gui.mouse_over->can_drop_data(pos,gui.drag_data)) {
gui.mouse_over->drop_data(pos,gui.drag_data);
}
- gui.drag_data=Variant();
- _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
- //change mouse accordingly
}
+ if (gui.drag_preview && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ memdelete( gui.drag_preview );
+ gui.drag_preview=NULL;
+ }
+
+ gui.drag_data=Variant();
+ _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
+ //change mouse accordingly
+ }
+
+ if (!gui.mouse_focus) {
+ //release event is only sent if a mouse focus (previously pressed button) exists
break;
}
@@ -1875,10 +1897,10 @@ void Viewport::_gui_input_event(InputEvent p_event) {
gui.mouse_focus_button=-1;
}
- if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ /*if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
_propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
gui.drag_data=Variant(); //always clear
- }
+ }*/
get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
@@ -2036,7 +2058,12 @@ void Viewport::_gui_input_event(InputEvent p_event) {
case InputEvent::JOYSTICK_BUTTON:
case InputEvent::KEY: {
- if (gui.key_focus) {
+
+ if (gui.key_focus && !gui.key_focus->is_visible()) {
+ gui.key_focus->release_focus();
+ }
+
+ if (gui.key_focus) {
gui.key_event_accepted=false;
if (gui.key_focus->can_process()) {
@@ -2176,6 +2203,9 @@ void Viewport::_gui_remove_from_modal_stack(List<Control*>::Element *MI,ObjectID
void Viewport::_gui_force_drag(Control *p_base, const Variant& p_data, Control *p_control) {
+ ERR_EXPLAIN("Drag data must be a value");
+ ERR_FAIL_COND(p_data.get_type()==Variant::NIL);
+
gui.drag_data=p_data;
gui.mouse_focus=NULL;
@@ -2372,8 +2402,8 @@ void Viewport::input(const InputEvent& p_event) {
ERR_FAIL_COND(!is_inside_tree());
+ get_tree()->_call_input_pause(input_group,"_input",p_event); //not a bug, must happen before GUI, order is _input -> gui input -> _unhandled input
_gui_input_event(p_event);
- get_tree()->_call_input_pause(input_group,"_input",p_event);
//get_tree()->call_group(SceneTree::GROUP_CALL_REVERSE|SceneTree::GROUP_CALL_REALTIME|SceneTree::GROUP_CALL_MULIILEVEL,gui_input_group,"_gui_input",p_event); //special one for GUI, as controls use their own process check
}
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 50852dc1f7..4f5eed8796 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -731,6 +731,7 @@ Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,
List<MethodInfo> _signals;
p_node->get_signal_list(&_signals);
+ _signals.sort();
//ERR_FAIL_COND_V( !node_map.has(p_node), ERR_BUG);
//NodeData &nd = nodes[node_map[p_node]];
@@ -740,6 +741,9 @@ Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,
List<Node::Connection> conns;
p_node->get_signal_connection_list(E->get().name,&conns);
+
+ conns.sort();
+
for(List<Node::Connection>::Element *F=conns.front();F;F=F->next()) {
const Node::Connection &c = F->get();
diff --git a/scene/resources/sample_library.cpp b/scene/resources/sample_library.cpp
index 5b70ee0e11..73517b180e 100644
--- a/scene/resources/sample_library.cpp
+++ b/scene/resources/sample_library.cpp
@@ -122,9 +122,17 @@ bool SampleLibrary::has_sample(const StringName& p_name) const {
void SampleLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
+
+ List<PropertyInfo> tpl;
for(Map<StringName,SampleData>::Element *E=sample_map.front();E;E=E->next()) {
- p_list->push_back( PropertyInfo( Variant::DICTIONARY, "samples/"+E->key(),PROPERTY_HINT_RESOURCE_TYPE,"Sample",PROPERTY_USAGE_NOEDITOR ) );
+ tpl.push_back( PropertyInfo( Variant::DICTIONARY, "samples/"+E->key(),PROPERTY_HINT_RESOURCE_TYPE,"Sample",PROPERTY_USAGE_NOEDITOR ) );
+ }
+
+ tpl.sort();
+ //sort so order is kept
+ for(List<PropertyInfo>::Element *E=tpl.front();E;E=E->next()) {
+ p_list->push_back(E->get());
}
}