diff options
-rw-r--r-- | core/color.cpp | 2 | ||||
-rw-r--r-- | doc/classes/BaseButton.xml | 4 | ||||
-rw-r--r-- | doc/classes/LineEdit.xml | 4 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_gles3.cpp | 2 | ||||
-rw-r--r-- | drivers/gles3/shader_compiler_gles3.cpp | 2 | ||||
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 4 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 110 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.h | 1 | ||||
-rw-r--r-- | modules/gdnative/pluginscript/pluginscript_language.cpp | 8 | ||||
-rw-r--r-- | modules/mono/csharp_script.cpp | 2 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_utils.cpp | 6 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_utils.h | 2 | ||||
-rw-r--r-- | platform/osx/os_osx.h | 16 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 172 | ||||
-rw-r--r-- | scene/gui/base_button.cpp | 4 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 4 | ||||
-rw-r--r-- | scene/resources/bit_mask.cpp | 4 |
17 files changed, 222 insertions, 125 deletions
diff --git a/core/color.cpp b/core/color.cpp index 7278b5c4ee..36afe5e004 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -396,7 +396,7 @@ String Color::to_html(bool p_alpha) const { txt += _to_hex(g); txt += _to_hex(b); if (p_alpha) - txt = _to_hex(a) + txt; + txt += _to_hex(a); return txt; } diff --git a/doc/classes/BaseButton.xml b/doc/classes/BaseButton.xml index 7f1aaa6822..9dd3cf0eff 100644 --- a/doc/classes/BaseButton.xml +++ b/doc/classes/BaseButton.xml @@ -21,7 +21,7 @@ <method name="_toggled" qualifiers="virtual"> <return type="void"> </return> - <argument index="0" name="pressed" type="bool"> + <argument index="0" name="button_pressed" type="bool"> </argument> <description> Called when button is toggled (only if toggle_mode is active). @@ -82,7 +82,7 @@ </description> </signal> <signal name="toggled"> - <argument index="0" name="pressed" type="bool"> + <argument index="0" name="button_pressed" type="bool"> </argument> <description> This signal is emitted when the button was just toggled between pressed and normal states (only if toggle_mode is active). The new state is contained in the [i]pressed[/i] argument. diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml index 4434a7b7e2..c28b722eb3 100644 --- a/doc/classes/LineEdit.xml +++ b/doc/classes/LineEdit.xml @@ -131,14 +131,14 @@ </members> <signals> <signal name="text_changed"> - <argument index="0" name="text" type="String"> + <argument index="0" name="new_text" type="String"> </argument> <description> Emitted when the text changes. </description> </signal> <signal name="text_entered"> - <argument index="0" name="text" type="String"> + <argument index="0" name="new_text" type="String"> </argument> <description> Emitted when the user presses KEY_ENTER on the [code]LineEdit[/code]. diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 99ba0860bd..b43deab58f 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -345,7 +345,7 @@ void RasterizerGLES3::blit_render_target_to_screen(RID p_render_target, const Re glBindFramebuffer(GL_READ_FRAMEBUFFER, rt->fbo); glReadBuffer(GL_COLOR_ATTACHMENT0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo); - glBlitFramebuffer(0, 0, rt->width, rt->height, p_screen_rect.position.x, win_size.height - p_screen_rect.position.y - p_screen_rect.size.height, p_screen_rect.position.x + p_screen_rect.size.width, win_size.height, GL_COLOR_BUFFER_BIT, GL_NEAREST); + glBlitFramebuffer(0, 0, rt->width, rt->height, p_screen_rect.position.x, win_size.height - p_screen_rect.position.y - p_screen_rect.size.height, p_screen_rect.position.x + p_screen_rect.size.width, win_size.height - p_screen_rect.position.y, GL_COLOR_BUFFER_BIT, GL_NEAREST); #else canvas->canvas_begin(); diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index 875946f089..ada7acb879 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -715,7 +715,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_CANVAS_ITEM].renames["WORLD_MATRIX"] = "modelview_matrix"; actions[VS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix"; - actions[VS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] == "extra_matrix"; + actions[VS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] = "extra_matrix"; actions[VS::SHADER_CANVAS_ITEM].renames["TIME"] = "time"; actions[VS::SHADER_CANVAS_ITEM].renames["AT_LIGHT_PASS"] = "at_light_pass"; actions[VS::SHADER_CANVAS_ITEM].renames["INSTANCE_CUSTOM"] = "instance_custom"; diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 1aa28d0fd5..958a166968 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -1307,7 +1307,7 @@ void reflection_process(int idx, vec3 vertex, vec3 normal,vec3 binormal, vec3 ta //make blend more rounded blend=mix(length(inner_pos),blend,blend); blend*=blend; - blend=1.001-blend; + blend=max(0.0, 1.0-blend); if (reflections[idx].params.x>0.0){// compute reflection @@ -1476,7 +1476,7 @@ void gi_probe_compute(mediump sampler3D probe, mat4 probe_xform, vec3 bounds,vec } vec3 blendv = abs(probe_pos/bounds * 2.0 - 1.0); - float blend = 1.001-max(blendv.x,max(blendv.y,blendv.z)); + float blend = clamp(1.0-max(blendv.x,max(blendv.y,blendv.z)), 0.0, 1.0); //float blend=1.0; float max_distance = length(bounds); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 2a46aba207..bd5e5c7355 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -4435,6 +4435,7 @@ void CanvasItemEditorViewport::_on_change_type_closed() { void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const { label->set_position(get_global_position() + Point2(14, 14) * EDSCALE); label_desc->set_position(label->get_position() + Point2(0, label->get_size().height)); + bool add_preview = false; for (int i = 0; i < files.size(); i++) { String path = files[i]; RES res = ResourceLoader::load(path); @@ -4456,9 +4457,12 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons } } } - editor->get_scene_root()->add_child(preview_node); + add_preview = true; } } + + if (add_preview) + editor->get_scene_root()->add_child(preview_node); } void CanvasItemEditorViewport::_remove_preview() { @@ -4603,6 +4607,14 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons void CanvasItemEditorViewport::_perform_drop_data() { _remove_preview(); + // Without root dropping multiple files is not allowed + if (!target_node && selected_files.size() > 1) { + accept->get_ok()->set_text(TTR("Ok")); + accept->set_text(TTR("Cannot instantiate multiple nodes without root.")); + accept->popup_centered_minsize(); + return; + } + Vector<String> error_files; editor_data->get_undo_redo().create_action(TTR("Create Node")); @@ -4613,30 +4625,40 @@ void CanvasItemEditorViewport::_perform_drop_data() { if (res.is_null()) { continue; } - Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res)); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); - if (texture != NULL) { - Node *child; - if (default_type == "Light2D") - child = memnew(Light2D); - else if (default_type == "Particles2D") - child = memnew(Particles2D); - else if (default_type == "Polygon2D") - child = memnew(Polygon2D); - else if (default_type == "TouchScreenButton") - child = memnew(TouchScreenButton); - else if (default_type == "TextureRect") - child = memnew(TextureRect); - else if (default_type == "NinePatchRect") - child = memnew(NinePatchRect); - else - child = memnew(Sprite); // default - - _create_nodes(target_node, child, path, drop_pos); - } else if (scene != NULL) { - bool success = _create_instance(target_node, path, drop_pos); - if (!success) { - error_files.push_back(path); + if (scene != NULL && scene.is_valid()) { + if (!target_node) { + // Without root node act the same as "Load Inherited Scene" + Error err = EditorNode::get_singleton()->load_scene(path, false, true); + if (err != OK) { + error_files.push_back(path); + } + } else { + bool success = _create_instance(target_node, path, drop_pos); + if (!success) { + error_files.push_back(path); + } + } + } else { + Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res)); + if (texture != NULL && texture.is_valid()) { + Node *child; + if (default_type == "Light2D") + child = memnew(Light2D); + else if (default_type == "Particles2D") + child = memnew(Particles2D); + else if (default_type == "Polygon2D") + child = memnew(Polygon2D); + else if (default_type == "TouchScreenButton") + child = memnew(TouchScreenButton); + else if (default_type == "TextureRect") + child = memnew(TextureRect); + else if (default_type == "NinePatchRect") + child = memnew(NinePatchRect); + else + child = memnew(Sprite); // default + + _create_nodes(target_node, child, path, drop_pos); } } } @@ -4661,14 +4683,14 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian if (String(d["type"]) == "files") { Vector<String> files = d["files"]; bool can_instance = false; - for (int i = 0; i < files.size(); i++) { // check if dragged files contain resource or scene can be created at least one + for (int i = 0; i < files.size(); i++) { // check if dragged files contain resource or scene can be created at least once RES res = ResourceLoader::load(files[i]); if (res.is_null()) { continue; } String type = res->get_class(); if (type == "PackedScene") { - Ref<PackedScene> sdata = ResourceLoader::load(files[i]); + Ref<PackedScene> sdata = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE); if (!instanced_scene) { continue; @@ -4682,7 +4704,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian type == "StreamTexture" || type == "AtlasTexture" || type == "LargeTexture") { - Ref<Texture> texture = ResourceLoader::load(files[i]); + Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res)); if (texture.is_valid() == false) { continue; } @@ -4708,6 +4730,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian } void CanvasItemEditorViewport::_show_resource_type_selector() { + _remove_preview(); List<BaseButton *> btn_list; button_group->get_buttons(&btn_list); @@ -4719,6 +4742,17 @@ void CanvasItemEditorViewport::_show_resource_type_selector() { selector->popup_centered_minsize(); } +bool CanvasItemEditorViewport::_only_packed_scenes_selected() const { + + for (int i = 0; i < selected_files.size(); ++i) { + if (ResourceLoader::load(selected_files[i])->get_class() != "PackedScene") { + return false; + } + } + + return true; +} + void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) { bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT); bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT); @@ -4728,6 +4762,8 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p if (d.has("type") && String(d["type"]) == "files") { selected_files = d["files"]; } + if (selected_files.size() == 0) + return; List<Node *> list = editor->get_editor_selection()->get_selected_node_list(); if (list.size() == 0) { @@ -4737,25 +4773,19 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p } else { drop_pos = p_point; target_node = NULL; - _show_resource_type_selector(); - return; } } - if (list.size() != 1) { - accept->get_ok()->set_text(TTR("I see..")); - accept->set_text(TTR("This operation requires a single selected node.")); - accept->popup_centered_minsize(); - _remove_preview(); - return; - } - target_node = list[0]; - if (is_shift && target_node != editor->get_edited_scene()) { - target_node = target_node->get_parent(); + if (list.size() > 0) { + target_node = list[0]; + if (is_shift && target_node != editor->get_edited_scene()) { + target_node = target_node->get_parent(); + } } + drop_pos = p_point; - if (is_alt) { + if (is_alt && !_only_packed_scenes_selected()) { _show_resource_type_selector(); } else { _perform_drop_data(); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 5be71bfc28..ace87f9fe2 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -576,6 +576,7 @@ class CanvasItemEditorViewport : public Control { void _remove_preview(); bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node); + bool _only_packed_scenes_selected() const; void _create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point); bool _create_instance(Node *parent, String &path, const Point2 &p_point); void _perform_drop_data(); diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp index 2405afc677..8101ebc6f3 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.cpp +++ b/modules/gdnative/pluginscript/pluginscript_language.cpp @@ -45,7 +45,11 @@ void PluginScriptLanguage::init() { } String PluginScriptLanguage::get_type() const { - return String(_desc.type); + // We should use _desc.type here, however the returned type is used to + // query ClassDB which would complain given the type is not registered + // from his point of view... + // To solve this we just use a more generic (but present in ClassDB) type. + return String("PluginScript"); } String PluginScriptLanguage::get_extension() const { @@ -168,7 +172,7 @@ Error PluginScriptLanguage::complete_code(const String &p_code, const String &p_ for (int i = 0; i < options.size(); i++) { r_options->push_back(String(options[i])); } - Error err = *(Error *)tmp; + Error err = *(Error *)&tmp; return err; } return ERR_UNAVAILABLE; diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 2d7583cc23..db2d0a9780 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -449,7 +449,7 @@ Vector<ScriptLanguage::StackInfo> CSharpLanguage::debug_get_current_stack_info() // Printing an error here will result in endless recursion, so we must be careful - if (!gdmono->is_runtime_initialized() && GDMono::get_singleton()->get_editor_tools_assembly()) + if (!gdmono->is_runtime_initialized() && GDMono::get_singleton()->get_api_assembly()) return Vector<StackInfo>(); MonoObject *stack_trace = mono_object_new(mono_domain_get(), CACHED_CLASS(System_Diagnostics_StackTrace)->get_mono_ptr()); diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index 4aa2c007c2..d02c73978e 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -399,7 +399,7 @@ void print_unhandled_exception(MonoObject *p_exc) { print_unhandled_exception(p_exc, false); } -void print_unhandled_exception(MonoObject *p_exc, bool p_fail_silently) { +void print_unhandled_exception(MonoObject *p_exc, bool p_recursion_caution) { mono_print_unhandled_exception(p_exc); #ifdef DEBUG_ENABLED GDMonoClass *st_klass = CACHED_CLASS(System_Diagnostics_StackTrace); @@ -414,7 +414,7 @@ void print_unhandled_exception(MonoObject *p_exc, bool p_fail_silently) { if (unexpected_exc != NULL) { mono_print_unhandled_exception(unexpected_exc); - if (p_fail_silently) { + if (p_recursion_caution) { // Called from CSharpLanguage::get_current_stack_info, // so printing an error here could result in endless recursion OS::get_singleton()->printerr("Mono: Method GDMonoUtils::print_unhandled_exception failed"); @@ -425,7 +425,7 @@ void print_unhandled_exception(MonoObject *p_exc, bool p_fail_silently) { } Vector<ScriptLanguage::StackInfo> si; - if (stack_trace != NULL) + if (stack_trace != NULL && !p_recursion_caution) si = CSharpLanguage::get_singleton()->stack_trace_get_info(stack_trace); String file = si.size() ? si[0].file : __FILE__; diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h index 1acc547993..597397eced 100644 --- a/modules/mono/mono_gd/gd_mono_utils.h +++ b/modules/mono/mono_gd/gd_mono_utils.h @@ -177,7 +177,7 @@ MonoDomain *create_domain(const String &p_friendly_name); String get_exception_name_and_message(MonoObject *p_ex); void print_unhandled_exception(MonoObject *p_exc); -void print_unhandled_exception(MonoObject *p_exc, bool p_fail_silently); +void print_unhandled_exception(MonoObject *p_exc, bool p_recursion_caution); } // namespace GDMonoUtils diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 3648d41604..a1869497ef 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -52,6 +52,21 @@ class OS_OSX : public OS_Unix { public: + enum { + KEY_EVENT_BUFFER_SIZE = 512 + }; + + struct KeyEvent { + unsigned int osx_state; + bool pressed; + bool echo; + uint32_t scancode; + uint32_t unicode; + }; + + KeyEvent key_event_buffer[KEY_EVENT_BUFFER_SIZE]; + int key_event_pos; + bool force_quit; // rasterizer seems to no longer be given to visual server, its using GLES3 directly? //Rasterizer *rasterizer; @@ -72,6 +87,7 @@ public: CGEventSourceRef eventSource; void process_events(); + void process_key_events(); void *framework; // pthread_key_t current; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 939f75859c..d0cc115f0e 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -407,13 +407,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)insertText:(id)aString replacementRange:(NSRange)replacementRange { NSEvent *event = [NSApp currentEvent]; - Ref<InputEventKey> k; - k.instance(); - - get_key_modifier_state([event modifierFlags], k); - k->set_pressed(true); - k->set_echo(false); - k->set_scancode(0); NSString *characters; if ([aString isKindOfClass:[NSAttributedString class]]) { @@ -438,8 +431,15 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; if ((codepoint & 0xFF00) == 0xF700) continue; - k->set_unicode(codepoint); - OS_OSX::singleton->push_input(k); + OS_OSX::KeyEvent ke; + + ke.osx_state = [event modifierFlags]; + ke.pressed = true; + ke.echo = false; + ke.scancode = 0; + ke.unicode = codepoint; + + OS_OSX::singleton->key_event_buffer[OS_OSX::singleton->key_event_pos++] = ke; } [self cancelComposition]; } @@ -788,80 +788,87 @@ static int translateKey(unsigned int key) { - (void)keyDown:(NSEvent *)event { - Ref<InputEventKey> k; - k.instance(); - - get_key_modifier_state([event modifierFlags], k); - k->set_pressed(true); - k->set_scancode(latin_keyboard_keycode_convert(translateKey([event keyCode]))); - k->set_echo([event isARepeat]); + //disable raw input in IME mode + if (!imeMode) { + OS_OSX::KeyEvent ke; - NSString *characters = [event characters]; - NSUInteger i, length = [characters length]; + ke.osx_state = [event modifierFlags]; + ke.pressed = true; + ke.echo = [event isARepeat]; + ke.scancode = latin_keyboard_keycode_convert(translateKey([event keyCode])); + ke.unicode = 0; - //disable raw input in IME mode - if (!imeMode) - OS_OSX::singleton->push_input(k); + OS_OSX::singleton->key_event_buffer[OS_OSX::singleton->key_event_pos++] = ke; + } if ((OS_OSX::singleton->im_position.x != 0) && (OS_OSX::singleton->im_position.y != 0)) [self interpretKeyEvents:[NSArray arrayWithObject:event]]; } - (void)flagsChanged:(NSEvent *)event { - Ref<InputEventKey> k; - k.instance(); - int key = [event keyCode]; - int mod = [event modifierFlags]; + if (!imeMode) { + OS_OSX::KeyEvent ke; - if (key == 0x36 || key == 0x37) { - if (mod & NSEventModifierFlagCommand) { - mod &= ~NSEventModifierFlagCommand; - k->set_pressed(true); - } else { - k->set_pressed(false); - } - } else if (key == 0x38 || key == 0x3c) { - if (mod & NSEventModifierFlagShift) { - mod &= ~NSEventModifierFlagShift; - k->set_pressed(true); - } else { - k->set_pressed(false); - } - } else if (key == 0x3a || key == 0x3d) { - if (mod & NSEventModifierFlagOption) { - mod &= ~NSEventModifierFlagOption; - k->set_pressed(true); - } else { - k->set_pressed(false); - } - } else if (key == 0x3b || key == 0x3e) { - if (mod & NSEventModifierFlagControl) { - mod &= ~NSEventModifierFlagControl; - k->set_pressed(true); + ke.echo = false; + + int key = [event keyCode]; + int mod = [event modifierFlags]; + + if (key == 0x36 || key == 0x37) { + if (mod & NSEventModifierFlagCommand) { + mod &= ~NSEventModifierFlagCommand; + ke.pressed = true; + } else { + ke.pressed = false; + } + } else if (key == 0x38 || key == 0x3c) { + if (mod & NSEventModifierFlagShift) { + mod &= ~NSEventModifierFlagShift; + ke.pressed = true; + } else { + ke.pressed = false; + } + } else if (key == 0x3a || key == 0x3d) { + if (mod & NSEventModifierFlagOption) { + mod &= ~NSEventModifierFlagOption; + ke.pressed = true; + } else { + ke.pressed = false; + } + } else if (key == 0x3b || key == 0x3e) { + if (mod & NSEventModifierFlagControl) { + mod &= ~NSEventModifierFlagControl; + ke.pressed = true; + } else { + ke.pressed = false; + } } else { - k->set_pressed(false); + return; } - } else { - return; - } - get_key_modifier_state(mod, k); - k->set_scancode(latin_keyboard_keycode_convert(translateKey(key))); + ke.osx_state = mod; + ke.scancode = latin_keyboard_keycode_convert(translateKey(key)); + ke.unicode = 0; - OS_OSX::singleton->push_input(k); + OS_OSX::singleton->key_event_buffer[OS_OSX::singleton->key_event_pos++] = ke; + } } - (void)keyUp:(NSEvent *)event { - Ref<InputEventKey> k; - k.instance(); + if (!imeMode) { + + OS_OSX::KeyEvent ke; - get_key_modifier_state([event modifierFlags], k); - k->set_pressed(false); - k->set_scancode(latin_keyboard_keycode_convert(translateKey([event keyCode]))); + ke.osx_state = [event modifierFlags]; + ke.pressed = false; + ke.echo = false; + ke.scancode = latin_keyboard_keycode_convert(translateKey([event keyCode])); + ke.unicode = 0; - OS_OSX::singleton->push_input(k); + OS_OSX::singleton->key_event_buffer[OS_OSX::singleton->key_event_pos++] = ke; + } } inline void sendScrollEvent(int button, double factor, int modifierFlags) { @@ -2060,11 +2067,49 @@ void OS_OSX::process_events() { [NSApp sendEvent:event]; } + process_key_events(); [autoreleasePool drain]; autoreleasePool = [[NSAutoreleasePool alloc] init]; } +void OS_OSX::process_key_events() { + + Ref<InputEventKey> k; + for (int i = 0; i < key_event_pos; i++) { + + KeyEvent &ke = key_event_buffer[i]; + + if ((i == 0 && ke.scancode == 0) || (i > 0 && key_event_buffer[i - 1].scancode == 0)) { + k.instance(); + + get_key_modifier_state(ke.osx_state, k); + k->set_pressed(ke.pressed); + k->set_echo(ke.echo); + k->set_scancode(0); + k->set_unicode(ke.unicode); + + push_input(k); + } + if (ke.scancode != 0) { + k.instance(); + + get_key_modifier_state(ke.osx_state, k); + k->set_pressed(ke.pressed); + k->set_echo(ke.echo); + k->set_scancode(ke.scancode); + + if (i + 1 < key_event_pos && key_event_buffer[i + 1].scancode == 0) { + k->set_unicode(key_event_buffer[i + 1].unicode); + } + + push_input(k); + } + } + + key_event_pos = 0; +} + void OS_OSX::push_input(const Ref<InputEvent> &p_event) { Ref<InputEvent> ev = p_event; @@ -2184,6 +2229,7 @@ OS_OSX *OS_OSX::singleton = NULL; OS_OSX::OS_OSX() { + key_event_pos = 0; mouse_mode = OS::MOUSE_MODE_VISIBLE; main_loop = NULL; singleton = this; diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index d765248cca..8b9469021c 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -504,12 +504,12 @@ void BaseButton::_bind_methods() { ClassDB::bind_method(D_METHOD("get_button_group"), &BaseButton::get_button_group); BIND_VMETHOD(MethodInfo("_pressed")); - BIND_VMETHOD(MethodInfo("_toggled", PropertyInfo(Variant::BOOL, "pressed"))); + BIND_VMETHOD(MethodInfo("_toggled", PropertyInfo(Variant::BOOL, "button_pressed"))); ADD_SIGNAL(MethodInfo("pressed")); ADD_SIGNAL(MethodInfo("button_up")); ADD_SIGNAL(MethodInfo("button_down")); - ADD_SIGNAL(MethodInfo("toggled", PropertyInfo(Variant::BOOL, "pressed"))); + ADD_SIGNAL(MethodInfo("toggled", PropertyInfo(Variant::BOOL, "button_pressed"))); ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "disabled"), "set_disabled", "is_disabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "toggle_mode"), "set_toggle_mode", "is_toggle_mode"); ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 53f609723f..97f740a4ba 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1413,8 +1413,8 @@ void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &LineEdit::set_context_menu_enabled); ClassDB::bind_method(D_METHOD("is_context_menu_enabled"), &LineEdit::is_context_menu_enabled); - ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "text"))); - ADD_SIGNAL(MethodInfo("text_entered", PropertyInfo(Variant::STRING, "text"))); + ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "new_text"))); + ADD_SIGNAL(MethodInfo("text_entered", PropertyInfo(Variant::STRING, "new_text"))); BIND_ENUM_CONSTANT(ALIGN_LEFT); BIND_ENUM_CONSTANT(ALIGN_CENTER); diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp index e99db8d9cb..e9e15a2532 100644 --- a/scene/resources/bit_mask.cpp +++ b/scene/resources/bit_mask.cpp @@ -81,7 +81,7 @@ void BitMap::set_bit_rect(const Rect2 &p_rect, bool p_value) { if (p_value) b |= (1 << bbit); else - b &= !(1 << bbit); + b &= ~(1 << bbit); data[bbyte] = b; } @@ -127,7 +127,7 @@ void BitMap::set_bit(const Point2 &p_pos, bool p_value) { if (p_value) b |= (1 << bbit); else - b &= !(1 << bbit); + b &= ~(1 << bbit); bitmask[bbyte] = b; } |