diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/sprite.cpp | 1 | ||||
-rw-r--r-- | scene/gui/menu_button.cpp | 2 | ||||
-rw-r--r-- | scene/gui/patch_9_rect.cpp | 1 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 104 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 1 | ||||
-rw-r--r-- | scene/resources/style_box.cpp | 1 | ||||
-rw-r--r-- | scene/resources/surface_tool.cpp | 19 | ||||
-rw-r--r-- | scene/resources/texture.cpp | 10 |
8 files changed, 78 insertions, 61 deletions
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index b469013819..ad34dfd63a 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -109,6 +109,7 @@ void Sprite::set_texture(const Ref<Texture> &p_texture) { update(); emit_signal("texture_changed"); item_rect_changed(); + _change_notify("texture"); } void Sprite::set_normal_map(const Ref<Texture> &p_texture) { diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index fe76b16460..57aa72b7d0 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -55,7 +55,6 @@ void MenuButton::pressed() { popup->set_size(Size2(size.width, 0)); popup->set_parent_rect(Rect2(Point2(gp - popup->get_global_position()), get_size())); popup->popup(); - popup->call_deferred("grab_click_focus"); popup->set_invalidate_click_until_motion(); } @@ -112,6 +111,7 @@ MenuButton::MenuButton() { popup->hide(); add_child(popup); popup->set_as_toplevel(true); + connect("button_up", popup, "call_deferred", make_binds("grab_click_focus")); set_process_unhandled_key_input(true); set_action_mode(ACTION_MODE_BUTTON_PRESS); } diff --git a/scene/gui/patch_9_rect.cpp b/scene/gui/patch_9_rect.cpp index 16f2bb6b6f..e577000f99 100644 --- a/scene/gui/patch_9_rect.cpp +++ b/scene/gui/patch_9_rect.cpp @@ -99,6 +99,7 @@ void NinePatchRect::set_texture(const Ref<Texture> &p_tex) { */ minimum_size_changed(); emit_signal("texture_changed"); + _change_notify("texture"); } Ref<Texture> NinePatchRect::get_texture() const { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 8baca50d32..d604738da1 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -49,6 +49,10 @@ static bool _is_symbol(CharType c) { return c != '_' && ((c >= '!' && c <= '/') || (c >= ':' && c <= '@') || (c >= '[' && c <= '`') || (c >= '{' && c <= '~') || c == '\t' || c == ' '); } +static bool _is_whitespace(CharType c) { + return c == '\t' || c == ' '; +} + static bool _is_char(CharType c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'; @@ -2096,45 +2100,43 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { break; #ifdef APPLE_STYLE_KEYS - if (k->get_alt()) { + if (k->get_alt() && cursor.column > 1) { #else if (k->get_alt()) { scancode_handled = false; break; - } else if (k->get_command()) { + } else if (k->get_command() && cursor.column > 1) { #endif int line = cursor.line; int column = cursor.column; - bool prev_char = false; - bool only_whitespace = true; - - while (only_whitespace && line > 0) { - - while (column > 0) { - CharType c = text[line][column - 1]; - - if (c != '\t' && c != ' ') { - only_whitespace = false; - break; - } + // check if we are removing a single whitespace, if so remove it and the next char type + // else we just remove the whitespace + bool only_whitespace = false; + if (_is_whitespace(text[line][column - 1]) && _is_whitespace(text[line][column - 2])) { + only_whitespace = true; + } else if (_is_whitespace(text[line][column - 1])) { + // remove the single whitespace + column--; + } - column--; - } + // check if its a text char + bool only_char = (_is_text_char(text[line][column - 1]) && !only_whitespace); - if (only_whitespace) { - line--; - column = text[line].length(); - } - } + // if its not whitespace or char then symbol. + bool only_symbols = !(only_whitespace || only_char); while (column > 0) { - bool ischar = _is_text_char(text[line][column - 1]); + bool is_whitespace = _is_whitespace(text[line][column - 1]); + bool is_text_char = _is_text_char(text[line][column - 1]); - if (prev_char && !ischar) + if (only_whitespace && !is_whitespace) { break; - - prev_char = ischar; + } else if (only_char && !is_text_char) { + break; + } else if (only_symbols && (is_whitespace || is_text_char)) { + break; + } column--; } @@ -2356,52 +2358,50 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { int next_column; #ifdef APPLE_STYLE_KEYS - if (k->get_alt()) { + if (k->get_alt() && cursor.column < curline_len - 1) { #else if (k->get_alt()) { scancode_handled = false; break; - } else if (k->get_command()) { + } else if (k->get_command() && cursor.column < curline_len - 1) { #endif - int last_line = text.size() - 1; int line = cursor.line; int column = cursor.column; - bool prev_char = false; - bool only_whitespace = true; - - while (only_whitespace && line < last_line) { - - while (column < text[line].length()) { - CharType c = text[line][column]; - - if (c != '\t' && c != ' ') { - only_whitespace = false; - break; - } - - column++; - } - - if (only_whitespace) { - line++; - column = 0; - } + // check if we are removing a single whitespace, if so remove it and the next char type + // else we just remove the whitespace + bool only_whitespace = false; + if (_is_whitespace(text[line][column]) && _is_whitespace(text[line][column + 1])) { + only_whitespace = true; + } else if (_is_whitespace(text[line][column])) { + // remove the single whitespace + column++; } - while (column < text[line].length()) { + // check if its a text char + bool only_char = (_is_text_char(text[line][column]) && !only_whitespace); - bool ischar = _is_text_char(text[line][column]); + // if its not whitespace or char then symbol. + bool only_symbols = !(only_whitespace || only_char); - if (prev_char && !ischar) + while (column < curline_len) { + bool is_whitespace = _is_whitespace(text[line][column]); + bool is_text_char = _is_text_char(text[line][column]); + + if (only_whitespace && !is_whitespace) { break; - prev_char = ischar; + } else if (only_char && !is_text_char) { + break; + } else if (only_symbols && (is_whitespace || is_text_char)) { + break; + } column++; } next_line = line; next_column = column; + } else { next_column = cursor.column < curline_len ? (cursor.column + 1) : 0; } diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 1456ab51c0..0b57841be7 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1605,7 +1605,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool int plus = 1; while (i + plus < columns.size() && !p_item->cells[i + plus].editable && p_item->cells[i + plus].mode == TreeItem::CELL_MODE_STRING && p_item->cells[i + plus].text == "" && p_item->cells[i + plus].icon.is_null()) { - plus++; col_width += cache.hseparation; col_width += get_column_width(i + plus); plus++; diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index e0a9de6062..3666c18487 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -107,6 +107,7 @@ void StyleBoxTexture::set_texture(RES p_texture) { region_rect = Rect2(Point2(), texture->get_size()); emit_signal("texture_changed"); emit_changed(); + _change_notify("texture"); } RES StyleBoxTexture::get_texture() const { diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 8b747e1b43..8478432a04 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -818,6 +818,7 @@ void SurfaceTool::clear() { void SurfaceTool::_bind_methods() { ClassDB::bind_method(D_METHOD("begin", "primitive"), &SurfaceTool::begin); + ClassDB::bind_method(D_METHOD("add_vertex", "vertex"), &SurfaceTool::add_vertex); ClassDB::bind_method(D_METHOD("add_color", "color"), &SurfaceTool::add_color); ClassDB::bind_method(D_METHOD("add_normal", "normal"), &SurfaceTool::add_normal); @@ -827,15 +828,25 @@ void SurfaceTool::_bind_methods() { ClassDB::bind_method(D_METHOD("add_bones", "bones"), &SurfaceTool::add_bones); ClassDB::bind_method(D_METHOD("add_weights", "weights"), &SurfaceTool::add_weights); ClassDB::bind_method(D_METHOD("add_smooth_group", "smooth"), &SurfaceTool::add_smooth_group); + ClassDB::bind_method(D_METHOD("add_triangle_fan", "vertexes", "uvs", "colors", "uv2s", "normals", "tangents"), &SurfaceTool::add_triangle_fan, DEFVAL(Vector<Vector2>()), DEFVAL(Vector<Color>()), DEFVAL(Vector<Vector2>()), DEFVAL(Vector<Vector3>()), DEFVAL(Vector<Plane>())); - ClassDB::bind_method(D_METHOD("set_material", "material:Material"), &SurfaceTool::set_material); + + ClassDB::bind_method(D_METHOD("add_index", "index"), &SurfaceTool::add_index); + ClassDB::bind_method(D_METHOD("index"), &SurfaceTool::index); ClassDB::bind_method(D_METHOD("deindex"), &SurfaceTool::deindex); - ///ClassDB::bind_method(D_METHOD("generate_flat_normals"),&SurfaceTool::generate_flat_normals); ClassDB::bind_method(D_METHOD("generate_normals"), &SurfaceTool::generate_normals); - ClassDB::bind_method(D_METHOD("add_index", "index"), &SurfaceTool::add_index); - ClassDB::bind_method(D_METHOD("commit:Mesh", "existing:Mesh"), &SurfaceTool::commit, DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("generate_tangents"), &SurfaceTool::generate_tangents); + + ClassDB::bind_method(D_METHOD("add_to_format", "flags"), &SurfaceTool::add_to_format); + + ClassDB::bind_method(D_METHOD("set_material", "material:Material"), &SurfaceTool::set_material); + ClassDB::bind_method(D_METHOD("clear"), &SurfaceTool::clear); + + ClassDB::bind_method(D_METHOD("create_from", "existing:Mesh", "surface"), &SurfaceTool::create_from); + ClassDB::bind_method(D_METHOD("append_from", "existing:Mesh", "surface", "transform"), &SurfaceTool::append_from); + ClassDB::bind_method(D_METHOD("commit:Mesh", "existing:Mesh"), &SurfaceTool::commit, DEFVAL(Variant())); } SurfaceTool::SurfaceTool() { diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 5cd75b5a69..fe7cd0097c 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -830,7 +830,7 @@ void AtlasTexture::set_atlas(const Ref<Texture> &p_atlas) { return; atlas = p_atlas; emit_changed(); - emit_signal("atlas_changed"); + _change_notify("atlas"); } Ref<Texture> AtlasTexture::get_atlas() const { @@ -839,8 +839,11 @@ Ref<Texture> AtlasTexture::get_atlas() const { void AtlasTexture::set_region(const Rect2 &p_region) { + if (region == p_region) + return; region = p_region; emit_changed(); + _change_notify("region"); } Rect2 AtlasTexture::get_region() const { @@ -850,8 +853,11 @@ Rect2 AtlasTexture::get_region() const { void AtlasTexture::set_margin(const Rect2 &p_margin) { + if (margin == p_margin) + return; margin = p_margin; emit_changed(); + _change_notify("margin"); } Rect2 AtlasTexture::get_margin() const { @@ -870,8 +876,6 @@ void AtlasTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("set_margin", "margin"), &AtlasTexture::set_margin); ClassDB::bind_method(D_METHOD("get_margin"), &AtlasTexture::get_margin); - ADD_SIGNAL(MethodInfo("atlas_changed")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "atlas", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_atlas", "get_atlas"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region"), "set_region", "get_region"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "margin"), "set_margin", "get_margin"); |