浏览代码

misc cleanup

Juan Linietsky 10 年之前
父节点
当前提交
ab22203791

+ 1 - 1
scene/3d/baked_light_instance.cpp

@@ -81,7 +81,7 @@ float BakedLightSampler::get_param(Param p_param) const{
 
 void BakedLightSampler::set_resolution(int p_resolution){
 
-	ERR_FAIL_COND(p_resolution<4 && p_resolution>32);
+    ERR_FAIL_COND(p_resolution<4 || p_resolution>32);
 	resolution=p_resolution;
 	VS::get_singleton()->baked_light_sampler_set_resolution(base,resolution);
 }

+ 1 - 1
scene/3d/collision_polygon.cpp

@@ -126,7 +126,7 @@ void CollisionPolygon::_notification(int p_what) {
 
 		} break;
 		case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
-			if (!can_update_body && shape_from>=0 && shape_from>=0) {
+            if (!can_update_body && shape_from>=0 && shape_to>=0) {
 
 				CollisionObject *co = get_parent()->cast_to<CollisionObject>();
 				if (co) {

+ 15 - 0
scene/gui/control.cpp

@@ -2713,6 +2713,21 @@ void Control::warp_mouse(const Point2& p_to_pos) {
 	get_viewport()->warp_mouse(get_global_transform().xform(p_to_pos));
 }
 
+
+bool Control::is_text_field() const {
+/*
+    if (get_script_instance()) {
+        Variant v=p_point;
+        const Variant *p[2]={&v,&p_data};
+        Variant::CallError ce;
+        Variant ret = get_script_instance()->call("is_text_field",p,2,ce);
+        if (ce.error==Variant::CallError::CALL_OK)
+            return ret;
+    }
+  */
+    return false;
+}
+
 void Control::_bind_methods() {
 
 	ObjectTypeDB::bind_method(_MD("_window_input_event"),&Control::_window_input_event);

+ 2 - 0
scene/gui/control.h

@@ -382,6 +382,8 @@ public:
 
 	void warp_mouse(const Point2& p_to_pos);
 
+    virtual bool is_text_field() const;
+
 	Control();	
 	~Control();
 

+ 4 - 0
scene/gui/line_edit.cpp

@@ -782,6 +782,10 @@ void LineEdit::select(int p_from, int p_to) {
 	update();
 }
 
+bool LineEdit::is_text_field() const {
+
+    return true;
+}
 
 void LineEdit::_bind_methods() {
 	

+ 2 - 0
scene/gui/line_edit.h

@@ -112,6 +112,8 @@ public:
 	void select(int p_from=0, int p_to=-1);
 
 	virtual Size2 get_minimum_size() const;
+
+    virtual bool is_text_field() const;
 	LineEdit();
 	~LineEdit();
 	

+ 3 - 0
scene/gui/text_edit.cpp

@@ -3568,7 +3568,10 @@ void TextEdit::set_show_line_numbers(bool p_show) {
 	update();
 }
 
+bool TextEdit::is_text_field() const {
 
+    return true;
+}
 void TextEdit::_bind_methods() {
 	
 	

+ 1 - 0
scene/gui/text_edit.h

@@ -393,6 +393,7 @@ public:
 
 	String get_text_for_completion();
 
+    virtual bool is_text_field() const;
 	TextEdit();
 	~TextEdit();
 };

+ 1 - 1
servers/visual/visual_server_raster.cpp

@@ -1375,7 +1375,7 @@ void VisualServerRaster::_update_baked_light_sampler_dp_cache(BakedLightSampler
 
 void VisualServerRaster::baked_light_sampler_set_resolution(RID p_baked_light_sampler,int p_resolution){
 
-	ERR_FAIL_COND(p_resolution<4 && p_resolution>64);
+    ERR_FAIL_COND(p_resolution<4 || p_resolution>64);
 	VS_CHANGED;
 	BakedLightSampler * blsamp = baked_light_sampler_owner.get(p_baked_light_sampler);
 	ERR_FAIL_COND(!blsamp);

+ 1 - 1
tools/editor/animation_editor.cpp

@@ -2369,7 +2369,7 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) {
 			te->update();
 			track_editor->set_tooltip("");
 
-			if (!track_editor->has_focus() && (!get_focus_owner() || !get_focus_owner()->cast_to<LineEdit>()))
+            if (!track_editor->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
 				track_editor->call_deferred("grab_focus");
 
 

+ 1 - 1
tools/editor/plugins/canvas_item_editor_plugin.cpp

@@ -1281,7 +1281,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
 
 	if (p_event.type==InputEvent::MOUSE_MOTION) {
 
-		if (!viewport->has_focus())
+        if (!viewport->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
 			viewport->call_deferred("grab_focus");
 
 		const InputEventMouseMotion &m=p_event.mouse_motion;

+ 1 - 1
tools/editor/plugins/editor_preview_plugins.cpp

@@ -25,7 +25,7 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES& p_from) {
 	if (img.is_compressed()) {
 		if (img.decompress()!=OK)
 			return Ref<Texture>();
-	} else if (img.get_format()!=Image::FORMAT_RGB && img.get_format()!=Image::FORMAT_RGB) {
+    } else if (img.get_format()!=Image::FORMAT_RGB && img.get_format()!=Image::FORMAT_RGBA) {
 		img.convert(Image::FORMAT_RGBA);
 	}
 

+ 2 - 1
tools/editor/plugins/spatial_editor_plugin.cpp

@@ -677,7 +677,8 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2& p_screenpos,bool p_hili
 
 void SpatialEditorViewport::_smouseenter() {
 
-	surface->grab_focus();
+    if (!surface->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
+            surface->grab_focus();
 }
 
 void SpatialEditorViewport::_sinput(const InputEvent &p_event) {