summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/camera.cpp35
-rw-r--r--scene/3d/camera.h8
-rw-r--r--scene/gui/control.cpp4
-rw-r--r--scene/gui/text_edit.cpp40
4 files changed, 76 insertions, 11 deletions
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 1db9886261..27420f8002 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -86,6 +86,10 @@ bool Camera::_set(const StringName& p_name, const Variant& p_value) {
set_keep_aspect_mode(KeepAspect(int(p_value)));
else if (p_name=="vaspect")
set_keep_aspect_mode(p_value?KEEP_WIDTH:KEEP_HEIGHT);
+ else if (p_name=="h_offset")
+ h_offset=p_value;
+ else if (p_name=="v_offset")
+ v_offset=p_value;
else if (p_name=="current") {
if (p_value.operator bool()) {
make_current();
@@ -128,6 +132,10 @@ bool Camera::_get(const StringName& p_name,Variant &r_ret) const {
}
} else if (p_name=="visible_layers") {
r_ret=get_visible_layers();
+ } else if (p_name=="h_offset") {
+ r_ret=get_h_offset();
+ } else if (p_name=="v_offset") {
+ r_ret=get_v_offset();
} else if (p_name=="environment") {
r_ret=get_environment();
} else
@@ -170,12 +178,16 @@ void Camera::_get_property_list( List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo( Variant::BOOL, "current" ) );
p_list->push_back( PropertyInfo( Variant::INT, "visible_layers",PROPERTY_HINT_ALL_FLAGS ) );
p_list->push_back( PropertyInfo( Variant::OBJECT, "environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment" ) );
+ p_list->push_back( PropertyInfo( Variant::REAL, "h_offset" ) );
+ p_list->push_back( PropertyInfo( Variant::REAL, "v_offset" ) );
}
void Camera::_update_camera() {
Transform tr = get_camera_transform();
+ tr.origin+=tr.basis.get_axis(1)*v_offset;
+ tr.origin+=tr.basis.get_axis(0)*h_offset;
VisualServer::get_singleton()->camera_set_transform( camera, tr );
// here goes listener stuff
@@ -757,6 +769,27 @@ void Camera::look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, cons
}
+void Camera::set_v_offset(float p_offset) {
+
+ v_offset=p_offset;
+ _update_camera();;
+}
+
+float Camera::get_v_offset() const {
+
+ return v_offset;
+}
+
+void Camera::set_h_offset(float p_offset) {
+ h_offset=p_offset;
+ _update_camera();
+}
+
+float Camera::get_h_offset() const {
+
+ return h_offset;
+}
+
Camera::Camera() {
@@ -772,6 +805,8 @@ Camera::Camera() {
set_perspective(60.0,0.1,100.0);
keep_aspect=KEEP_HEIGHT;
layers=0xfffff;
+ v_offset=0;
+ h_offset=0;
VisualServer::get_singleton()->camera_set_visible_layers(camera,layers);
//active=false;
}
diff --git a/scene/3d/camera.h b/scene/3d/camera.h
index bac8173bb7..950688dfda 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera.h
@@ -61,6 +61,8 @@ private:
float fov;
float size;
float near,far;
+ float v_offset;
+ float h_offset;
KeepAspect keep_aspect;
RID camera;
@@ -140,6 +142,12 @@ public:
void look_at(const Vector3& p_target, const Vector3& p_up_normal);
void look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal);
+ void set_v_offset(float p_offset);
+ float get_v_offset() const;
+
+ void set_h_offset(float p_offset);
+ float get_h_offset() const;
+
Camera();
~Camera();
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 068801d0bb..ce268843b1 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -2684,8 +2684,8 @@ bool Control::is_stopping_mouse() const {
Control *Control::get_focus_owner() const {
ERR_FAIL_COND_V(!is_inside_tree(),NULL);
- ERR_FAIL_COND_V(!window,NULL);
- return window->key_focus;
+ ERR_FAIL_COND_V(!data.window,NULL);
+ return data.window->window->key_focus;
}
void Control::_bind_methods() {
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 933895a207..8afcbf3283 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -3274,19 +3274,41 @@ void TextEdit::_update_completion_candidates() {
String s;
-
- while(cofs>0 && l[cofs-1]>32 && _is_completable(l[cofs-1])) {
- s=String::chr(l[cofs-1])+s;
- if (l[cofs-1]=='\'' || l[cofs-1]=='"')
- break;
-
- cofs--;
+
+ //look for keywords first
+
+ bool pre_keyword=false;
+
+ if (cofs>0 && l[cofs-1]==' ') {
+ int kofs=cofs-1;
+ String kw;
+ while (kofs>=0 && l[kofs]==' ')
+ kofs--;
+
+ while(kofs>=0 && l[kofs]>32 && _is_completable(l[kofs])) {
+ kw=String::chr(l[kofs])+kw;
+ kofs--;
+ }
+
+ pre_keyword=keywords.has(kw);
+ print_line("KW "+kw+"? "+itos(pre_keyword));
+
+ } else {
+
+
+ while(cofs>0 && l[cofs-1]>32 && _is_completable(l[cofs-1])) {
+ s=String::chr(l[cofs-1])+s;
+ if (l[cofs-1]=='\'' || l[cofs-1]=='"')
+ break;
+
+ cofs--;
+ }
}
-
+
update();
- if (s=="" && (cofs==0 || !completion_prefixes.has(String::chr(l[cofs-1])))) {
+ if (!pre_keyword && s=="" && (cofs==0 || !completion_prefixes.has(String::chr(l[cofs-1])))) {
//none to complete, cancel
_cancel_completion();
return;