diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/collision_polygon_2d.cpp | 2 | ||||
-rw-r--r-- | scene/2d/navigation2d.cpp | 12 | ||||
-rw-r--r-- | scene/2d/path_2d.cpp | 2 | ||||
-rw-r--r-- | scene/2d/screen_button.cpp | 4 | ||||
-rw-r--r-- | scene/gui/control.cpp | 4 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 61 | ||||
-rw-r--r-- | scene/gui/range.cpp | 6 | ||||
-rw-r--r-- | scene/gui/tabs.cpp | 84 | ||||
-rw-r--r-- | scene/gui/tabs.h | 6 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 84 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 4 |
11 files changed, 229 insertions, 40 deletions
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 386c7b9dd0..2a40a6207d 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -197,7 +197,7 @@ void CollisionPolygon2D::_notification(int p_what) { Vector2 n = polygon[(i+1)%polygon.size()]; draw_line(p,n,Color(0.9,0.2,0.0,0.8),3); } -//#define DEBUG_DECOMPOSE +#define DEBUG_DECOMPOSE #if defined(TOOLS_ENABLED) && defined (DEBUG_DECOMPOSE) Vector< Vector<Vector2> > decomp = _decompose_in_convex(); diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index e2a4de5fac..c7542407cb 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -508,7 +508,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect points+=", "; points+=_get_vertex(p->edges[i].point); } - print_line("poly "+itos(idx++)+" - "+points); + //print_line("poly "+itos(idx++)+" - "+points); p = p->edges[prev].C; if (p==begin_poly) break; @@ -557,6 +557,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect bool skip=false; + /* print_line("-----\nAPEX: "+(apex_point-end_point)); print_line("LEFT:"); print_line("\tPortal: "+(portal_left-end_point)); @@ -570,6 +571,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect print_line("\tRight Tangent: "+rtos(CLOCK_TANGENT(apex_point,portal_right,right))); print_line("\tRight Distance: "+rtos(portal_right.distance_squared_to(apex_point))); print_line("\tRight Test: "+rtos(CLOCK_TANGENT(apex_point,right,portal_left))); + */ if (CLOCK_TANGENT(apex_point,portal_left,left) >= 0){ @@ -577,7 +579,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect if (portal_left.distance_squared_to(apex_point)<CMP_EPSILON || CLOCK_TANGENT(apex_point,left,portal_right) > 0) { left_poly=p; portal_left=left; - print_line("***ADVANCE LEFT"); + //print_line("***ADVANCE LEFT"); } else { //_clip_path(path,apex_poly,portal_right,right_poly); @@ -592,7 +594,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect path.push_back(apex_point); skip=true; //print_line("addpoint left"); - print_line("***CLIP LEFT"); + //print_line("***CLIP LEFT"); } } @@ -601,7 +603,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect if (portal_right.distance_squared_to(apex_point)<CMP_EPSILON || CLOCK_TANGENT(apex_point,right,portal_left) < 0) { right_poly=p; portal_right=right; - print_line("***ADVANCE RIGHT"); + //print_line("***ADVANCE RIGHT"); } else { //_clip_path(path,apex_poly,portal_left,left_poly); @@ -615,7 +617,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect if (path[path.size()-1].distance_to(apex_point)>CMP_EPSILON) path.push_back(apex_point); //print_line("addpoint right"); - print_line("***CLIP RIGHT"); + //print_line("***CLIP RIGHT"); } } diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index f135864098..bd7415aa04 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -74,6 +74,8 @@ void Path2D::set_curve(const Ref<Curve2D>& p_curve) { curve->connect("changed",this,"_curve_changed"); } + _curve_changed(); + } Ref<Curve2D> Path2D::get_curve() const{ diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp index d7f9b191fe..fac94f19dc 100644 --- a/scene/2d/screen_button.cpp +++ b/scene/2d/screen_button.cpp @@ -102,6 +102,10 @@ void TouchScreenButton::_notification(int p_what) { action_id=-1; } } break; + case NOTIFICATION_EXIT_TREE: { + if (is_pressed()) + Input::get_singleton()->action_release(action); + } break; } } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 34864d68ec..5a8ecfeffe 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -923,7 +923,7 @@ void Control::_window_show_tooltip() { void Control::_window_call_input(Control *p_control,const InputEvent& p_input) { - _block(); +// _block(); while(p_control) { @@ -941,7 +941,7 @@ void Control::_window_call_input(Control *p_control,const InputEvent& p_input) { p_control=p_control->data.parent; } - _unblock(); + //_unblock(); } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index db463c133b..49ea077a30 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -245,12 +245,26 @@ void LineEdit::_input_event(InputEvent p_event) { delete_char(); } } break; + case KEY_KP_4: { + if (k.unicode != 0) { + handled = false; + break; + } + // numlock disabled. fallthrough to key_left + } case KEY_LEFT: { shift_selection_check_pre(k.mod.shift); set_cursor_pos(get_cursor_pos()-1); shift_selection_check_post(k.mod.shift); } break; + case KEY_KP_6: { + if (k.unicode != 0) { + handled = false; + break; + } + // numlock disabled. fallthrough to key_right + } case KEY_RIGHT: { shift_selection_check_pre(k.mod.shift); @@ -271,12 +285,26 @@ void LineEdit::_input_event(InputEvent p_event) { } } break; + case KEY_KP_7: { + if (k.unicode != 0) { + handled = false; + break; + } + // numlock disabled. fallthrough to key_home + } case KEY_HOME: { shift_selection_check_pre(k.mod.shift); set_cursor_pos(0); shift_selection_check_post(k.mod.shift); } break; + case KEY_KP_1: { + if (k.unicode != 0) { + handled = false; + break; + } + // numlock disabled. fallthrough to key_end + } case KEY_END: { shift_selection_check_pre(k.mod.shift); @@ -287,26 +315,27 @@ void LineEdit::_input_event(InputEvent p_event) { default: { - if (k.unicode>=32 && k.scancode!=KEY_DELETE) { - - if (editable) { - selection_delete(); - CharType ucodestr[2]={(CharType)k.unicode,0}; - append_at_cursor(ucodestr); - emit_signal("text_changed",text); - _change_notify("text"); - } - - } else { - handled=false; - } + handled=false; } break; } - if (handled) + if (handled) { accept_event(); - else - return; + } else { + if (k.unicode>=32 && k.scancode!=KEY_DELETE) { + + if (editable) { + selection_delete(); + CharType ucodestr[2]={(CharType)k.unicode,0}; + append_at_cursor(ucodestr); + emit_signal("text_changed",text); + _change_notify("text"); + } + + } else { + return; + } + } selection.old_shift=k.mod.shift; diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index 25b7952da1..d3b7521c9a 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -77,7 +77,11 @@ void Range::set_val(double p_val) { if (p_val<shared->min) p_val=shared->min; - + + //avoid to set -0 + if (p_val == 0) + p_val = 0; + if (shared->val==p_val) return; diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index 14cd0bee8e..bb64a57212 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -266,6 +266,7 @@ void Tabs::_notification(int p_what) { int label_valign_fg = get_constant("label_valign_fg"); int label_valign_bg = get_constant("label_valign_bg"); + int w=0; int mw = 0; @@ -277,12 +278,16 @@ void Tabs::_notification(int p_what) { for(int i=0;i<tabs.size();i++) { + Ref<Texture> tex = tabs[i].icon; if (tex.is_valid()) { if (tabs[i].text!="") mw+=get_constant("hseparation"); } + + tabs[i].ofs_cache=mw; + mw+=font->get_string_size(tabs[i].text).width; if (current==i) mw+=tab_fg->get_minimum_size().width; @@ -303,6 +308,9 @@ void Tabs::_notification(int p_what) { bms.width+=get_constant("hseparation"); mw+=bms.width; } + + + } } @@ -758,6 +766,79 @@ Tabs::TabAlign Tabs::get_tab_align() const { } +void Tabs::ensure_tab_visible(int p_idx) { + + if (!is_inside_tree()) + return; + + ERR_FAIL_INDEX(p_idx,tabs.size()); + + if (p_idx<offset) { + offset=p_idx; + update(); + return; + } + + Ref<StyleBox> tab_bg = get_stylebox("tab_bg"); + Ref<StyleBox> tab_fg = get_stylebox("tab_fg"); + Ref<Font> font = get_font("font"); + + Ref<Texture> incr = get_icon("increment"); + Ref<Texture> decr = get_icon("decrement"); + + int limit=get_size().width-incr->get_width()-decr->get_width(); + + + + int x=0; + for(int i=0;i<tabs.size();i++) { + + if (i<offset) + continue; + + Ref<Texture> tex = tabs[i].icon; + if (tex.is_valid()) { + if (tabs[i].text!="") + x+=get_constant("hseparation"); + + } + + tabs[i].x_cache=x; + + x+=font->get_string_size(tabs[i].text).width; + if (current==i) + x+=tab_fg->get_minimum_size().width; + else + x+=tab_bg->get_minimum_size().width; + + if (tabs[i].right_button.is_valid()) { + Ref<Texture> rb=tabs[i].right_button; + Size2 bms = rb->get_size();//+get_stylebox("button")->get_minimum_size(); + bms.width+=get_constant("hseparation"); + + x+=bms.width; + } + + if (tabs[i].close_button.is_valid()) { + Ref<Texture> cb=tabs[i].close_button; + Size2 bms = cb->get_size();//+get_stylebox("button")->get_minimum_size(); + bms.width+=get_constant("hseparation"); + x+=bms.width; + } + + tabs[i].x_size_cache=x-tabs[i].x_cache; + + + + } + + while(offset<tabs.size() && ( (tabs[p_idx].x_cache + tabs[p_idx].x_size_cache) - tabs[offset].x_cache) < limit) { + offset++; + } + + update(); +} + void Tabs::_bind_methods() { ObjectTypeDB::bind_method(_MD("_input_event"),&Tabs::_input_event); @@ -772,6 +853,7 @@ void Tabs::_bind_methods() { ObjectTypeDB::bind_method(_MD("add_tab","title","icon:Texture"),&Tabs::add_tab); ObjectTypeDB::bind_method(_MD("set_tab_align","align"),&Tabs::set_tab_align); ObjectTypeDB::bind_method(_MD("get_tab_align"),&Tabs::get_tab_align); + ObjectTypeDB::bind_method(_MD("ensure_tab_visible","idx"),&Tabs::ensure_tab_visible); ADD_SIGNAL(MethodInfo("tab_changed",PropertyInfo(Variant::INT,"tab"))); ADD_SIGNAL(MethodInfo("right_button_pressed",PropertyInfo(Variant::INT,"tab"))); @@ -804,4 +886,6 @@ Tabs::Tabs() { cb_displaypolicy = SHOW_NEVER; // Default : no close button offset=0; max_drawn_tab=0; + + } diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h index efcb291a52..82035291ec 100644 --- a/scene/gui/tabs.h +++ b/scene/gui/tabs.h @@ -59,10 +59,14 @@ private: Ref<Texture> icon; int ofs_cache; int size_cache; + int x_cache; + int x_size_cache; + Ref<Texture> right_button; Rect2 rb_rect; Ref<Texture> close_button; Rect2 cb_rect; + }; @@ -119,6 +123,8 @@ public: void clear_tabs(); + void ensure_tab_visible(int p_idx); + Size2 get_minimum_size() const; Tabs(); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 70da7e39a4..7f7c8c023c 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -839,7 +839,7 @@ void TextEdit::_notification(int p_what) { } - if (cursor.column==str.length() && cursor.line==line) { + if (cursor.column==str.length() && cursor.line==line && (char_ofs+char_margin)>=xmargin_beg) { cursor_pos=Point2i( char_ofs+char_margin, ofs_y ); VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(1,get_row_height())),cache.font_color); @@ -1740,6 +1740,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { } } break; + case KEY_KP_4: { + if (k.unicode != 0) { + scancode_handled = false; + break; + } + // numlock disabled. fallthrough to key_left + } case KEY_LEFT: { if (k.mod.shift) @@ -1786,6 +1793,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { _post_shift_selection(); } break; + case KEY_KP_6: { + if (k.unicode != 0) { + scancode_handled = false; + break; + } + // numlock disabled. fallthrough to key_right + } case KEY_RIGHT: { if (k.mod.shift) @@ -1829,6 +1843,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { _post_shift_selection(); } break; + case KEY_KP_8: { + if (k.unicode != 0) { + scancode_handled = false; + break; + } + // numlock disabled. fallthrough to key_up + } case KEY_UP: { if (k.mod.shift) @@ -1849,6 +1870,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { _cancel_code_hint(); } break; + case KEY_KP_2: { + if (k.unicode != 0) { + scancode_handled = false; + break; + } + // numlock disabled. fallthrough to key_down + } case KEY_DOWN: { if (k.mod.shift) @@ -1937,6 +1965,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { update(); } break; + case KEY_KP_7: { + if (k.unicode != 0) { + scancode_handled = false; + break; + } + // numlock disabled. fallthrough to key_home + } #ifdef APPLE_STYLE_KEYS case KEY_HOME: { @@ -1950,18 +1985,6 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { _post_shift_selection(); } break; - case KEY_END: { - - if (k.mod.shift) - _pre_shift_selection(); - - cursor_set_line(text.size()-1); - - if (k.mod.shift) - _post_shift_selection(); - - } break; - #else case KEY_HOME: { @@ -1992,6 +2015,27 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { completion_hint=""; } break; +#endif + case KEY_KP_1: { + if (k.unicode != 0) { + scancode_handled = false; + break; + } + // numlock disabled. fallthrough to key_end + } +#ifdef APPLE_STYLE_KEYS + case KEY_END: { + + if (k.mod.shift) + _pre_shift_selection(); + + cursor_set_line(text.size()-1); + + if (k.mod.shift) + _post_shift_selection(); + + } break; +#else case KEY_END: { if (k.mod.shift) @@ -2009,6 +2053,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { } break; #endif + case KEY_KP_9: { + if (k.unicode != 0) { + scancode_handled = false; + break; + } + // numlock disabled. fallthrough to key_pageup + } case KEY_PAGEUP: { if (k.mod.shift) @@ -2024,6 +2075,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { } break; + case KEY_KP_3: { + if (k.unicode != 0) { + scancode_handled = false; + break; + } + // numlock disabled. fallthrough to key_pageup + } case KEY_PAGEDOWN: { if (k.mod.shift) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 6d18a53c9f..330f855006 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -577,7 +577,7 @@ void Viewport::_notification(int p_what) { PhysicsDirectSpaceState *space = PhysicsServer::get_singleton()->space_get_direct_state(find_world()->get_space()); if (space) { - bool col = space->intersect_ray(from,from+dir*10000,result,Set<RID>(),0xFFFFFFFF,0xFFFFFFFF); + bool col = space->intersect_ray(from,from+dir*10000,result,Set<RID>(),0xFFFFFFFF,0xFFFFFFFF,true); ObjectID new_collider=0; if (col) { @@ -617,7 +617,7 @@ void Viewport::_notification(int p_what) { PhysicsDirectSpaceState *space = PhysicsServer::get_singleton()->space_get_direct_state(find_world()->get_space()); if (space) { - bool col = space->intersect_ray(from,from+dir*10000,result,Set<RID>(),0xFFFFFFFF,0xFFFFFFFF); + bool col = space->intersect_ray(from,from+dir*10000,result,Set<RID>(),0xFFFFFFFF,0xFFFFFFFF,true); ObjectID new_collider=0; if (col) { if (result.collider) { |