summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/SCsub2
-rw-r--r--scene/2d/ray_cast_2d.cpp48
-rw-r--r--scene/2d/ray_cast_2d.h3
-rw-r--r--scene/3d/SCsub8
-rw-r--r--scene/3d/ray_cast.cpp48
-rw-r--r--scene/3d/ray_cast.h2
-rw-r--r--scene/SCsub22
-rw-r--r--scene/animation/SCsub2
-rw-r--r--scene/animation/animation_tree_player.cpp20
-rw-r--r--scene/animation/animation_tree_player.h1
-rw-r--r--scene/animation/tween.cpp18
-rw-r--r--scene/animation/tween.h1
-rw-r--r--scene/audio/SCsub2
-rw-r--r--scene/gui/SCsub2
-rw-r--r--scene/gui/dialogs.cpp42
-rw-r--r--scene/gui/file_dialog.cpp34
-rw-r--r--scene/gui/item_list.cpp5
-rw-r--r--scene/gui/label.cpp10
-rw-r--r--scene/gui/line_edit.cpp2
-rw-r--r--scene/gui/link_button.cpp7
-rw-r--r--scene/gui/link_button.h3
-rw-r--r--scene/gui/range.cpp17
-rw-r--r--scene/gui/spin_box.cpp5
-rw-r--r--scene/gui/text_edit.cpp28
-rw-r--r--scene/gui/text_edit.h6
-rw-r--r--scene/gui/tree.cpp34
-rw-r--r--scene/gui/tree.h6
-rw-r--r--scene/io/SCsub2
-rw-r--r--scene/main/SCsub2
-rw-r--r--scene/main/node.cpp6
-rw-r--r--scene/resources/SCsub6
-rw-r--r--scene/resources/default_theme/SCsub2
-rw-r--r--scene/resources/default_theme/default_theme.cpp1
-rw-r--r--scene/resources/default_theme/make_header.py83
34 files changed, 229 insertions, 251 deletions
diff --git a/scene/2d/SCsub b/scene/2d/SCsub
index 9fa89edbf7..bf9125be7f 100644
--- a/scene/2d/SCsub
+++ b/scene/2d/SCsub
@@ -2,6 +2,6 @@
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index b5d62adfb4..bd7f4faae5 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -187,39 +187,44 @@ void RayCast2D::_notification(int p_what) {
if (!enabled)
break;
+ _update_raycast_state();
- Ref<World2D> w2d = get_world_2d();
- ERR_BREAK( w2d.is_null() );
-
- Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space());
- ERR_BREAK( !dss );
-
- Matrix32 gt = get_global_transform();
+ } break;
+ }
+}
- Vector2 to = cast_to;
- if (to==Vector2())
- to=Vector2(0,0.01);
+void RayCast2D::_update_raycast_state() {
+ Ref<World2D> w2d = get_world_2d();
+ ERR_FAIL_COND( w2d.is_null() );
- Physics2DDirectSpaceState::RayResult rr;
+ Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space());
+ ERR_FAIL_COND( !dss );
- if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude,layer_mask,type_mask)) {
+ Matrix32 gt = get_global_transform();
- collided=true;
- against=rr.collider_id;
- collision_point=rr.position;
- collision_normal=rr.normal;
- against_shape=rr.shape;
- } else {
- collided=false;
- }
+ Vector2 to = cast_to;
+ if (to==Vector2())
+ to=Vector2(0,0.01);
+ Physics2DDirectSpaceState::RayResult rr;
+ if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude,layer_mask,type_mask)) {
- } break;
+ collided=true;
+ against=rr.collider_id;
+ collision_point=rr.position;
+ collision_normal=rr.normal;
+ against_shape=rr.shape;
+ } else {
+ collided=false;
}
}
+void RayCast2D::force_raycast_update() {
+ _update_raycast_state();
+}
+
void RayCast2D::add_exception_rid(const RID& p_rid) {
exclude.insert(p_rid);
@@ -265,6 +270,7 @@ void RayCast2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_cast_to"),&RayCast2D::get_cast_to);
ObjectTypeDB::bind_method(_MD("is_colliding"),&RayCast2D::is_colliding);
+ ObjectTypeDB::bind_method(_MD("force_raycast_update"),&RayCast2D::force_raycast_update);
ObjectTypeDB::bind_method(_MD("get_collider"),&RayCast2D::get_collider);
ObjectTypeDB::bind_method(_MD("get_collider_shape"),&RayCast2D::get_collider_shape);
diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h
index e1caa8b63e..9bdcc2e199 100644
--- a/scene/2d/ray_cast_2d.h
+++ b/scene/2d/ray_cast_2d.h
@@ -52,6 +52,7 @@ class RayCast2D : public Node2D {
protected:
void _notification(int p_what);
+ void _update_raycast_state();
static void _bind_methods();
public:
@@ -70,6 +71,8 @@ public:
void set_exclude_parent_body(bool p_exclude_parent_body);
bool get_exclude_parent_body() const;
+ void force_raycast_update();
+
bool is_colliding() const;
Object *get_collider() const;
int get_collider_shape() const;
diff --git a/scene/3d/SCsub b/scene/3d/SCsub
index 1205deb94a..90e78ba8d3 100644
--- a/scene/3d/SCsub
+++ b/scene/3d/SCsub
@@ -3,11 +3,11 @@
Import('env')
-if (env["disable_3d"]=="yes"):
+if (env["disable_3d"] == "yes"):
- env.scene_sources.append("3d/spatial.cpp")
- env.scene_sources.append("3d/skeleton.cpp")
+ env.scene_sources.append("3d/spatial.cpp")
+ env.scene_sources.append("3d/skeleton.cpp")
else:
- env.add_source_files(env.scene_sources,"*.cpp")
+ env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp
index 1acda8d1f8..2b8df8265e 100644
--- a/scene/3d/ray_cast.cpp
+++ b/scene/3d/ray_cast.cpp
@@ -134,39 +134,44 @@ void RayCast::_notification(int p_what) {
if (!enabled)
break;
+ _update_raycast_state();
- Ref<World> w3d = get_world();
- ERR_BREAK( w3d.is_null() );
-
- PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(w3d->get_space());
- ERR_BREAK( !dss );
-
- Transform gt = get_global_transform();
+ } break;
+ }
+}
- Vector3 to = cast_to;
- if (to==Vector3())
- to=Vector3(0,0.01,0);
+void RayCast::_update_raycast_state(){
+ Ref<World> w3d = get_world();
+ ERR_FAIL_COND( w3d.is_null() );
- PhysicsDirectSpaceState::RayResult rr;
+ PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(w3d->get_space());
+ ERR_FAIL_COND( !dss );
- if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude, layer_mask, type_mask)) {
+ Transform gt = get_global_transform();
- collided=true;
- against=rr.collider_id;
- collision_point=rr.position;
- collision_normal=rr.normal;
- against_shape=rr.shape;
- } else {
- collided=false;
- }
+ Vector3 to = cast_to;
+ if (to==Vector3())
+ to=Vector3(0,0.01,0);
+ PhysicsDirectSpaceState::RayResult rr;
+ if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude, layer_mask, type_mask)) {
- } break;
+ collided=true;
+ against=rr.collider_id;
+ collision_point=rr.position;
+ collision_normal=rr.normal;
+ against_shape=rr.shape;
+ } else {
+ collided=false;
}
}
+void RayCast::force_raycast_update() {
+ _update_raycast_state();
+}
+
void RayCast::add_exception_rid(const RID& p_rid) {
exclude.insert(p_rid);
@@ -212,6 +217,7 @@ void RayCast::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_cast_to"),&RayCast::get_cast_to);
ObjectTypeDB::bind_method(_MD("is_colliding"),&RayCast::is_colliding);
+ ObjectTypeDB::bind_method(_MD("force_raycast_update"),&RayCast::force_raycast_update);
ObjectTypeDB::bind_method(_MD("get_collider"),&RayCast::get_collider);
ObjectTypeDB::bind_method(_MD("get_collider_shape"),&RayCast::get_collider_shape);
diff --git a/scene/3d/ray_cast.h b/scene/3d/ray_cast.h
index 4f6514e61b..47553f08ed 100644
--- a/scene/3d/ray_cast.h
+++ b/scene/3d/ray_cast.h
@@ -53,6 +53,7 @@ class RayCast : public Spatial {
protected:
void _notification(int p_what);
+ void _update_raycast_state();
static void _bind_methods();
public:
@@ -68,6 +69,7 @@ public:
void set_type_mask(uint32_t p_mask);
uint32_t get_type_mask() const;
+ void force_raycast_update();
bool is_colliding() const;
Object *get_collider() const;
int get_collider_shape() const;
diff --git a/scene/SCsub b/scene/SCsub
index 79da365192..bd2da1eab9 100644
--- a/scene/SCsub
+++ b/scene/SCsub
@@ -2,21 +2,21 @@
Import('env')
-env.scene_sources=[]
-env.add_source_files(env.scene_sources,"*.cpp")
+env.scene_sources = []
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
-SConscript('main/SCsub');
-SConscript('gui/SCsub');
-SConscript('3d/SCsub');
-SConscript('2d/SCsub');
-SConscript('animation/SCsub');
-SConscript('audio/SCsub');
-SConscript('resources/SCsub');
-SConscript('io/SCsub');
+SConscript('main/SCsub')
+SConscript('gui/SCsub')
+SConscript('3d/SCsub')
+SConscript('2d/SCsub')
+SConscript('animation/SCsub')
+SConscript('audio/SCsub')
+SConscript('resources/SCsub')
+SConscript('io/SCsub')
-lib = env.Library("scene",env.scene_sources)
+lib = env.Library("scene", env.scene_sources)
env.Prepend(LIBS=[lib])
diff --git a/scene/animation/SCsub b/scene/animation/SCsub
index 9fa89edbf7..bf9125be7f 100644
--- a/scene/animation/SCsub
+++ b/scene/animation/SCsub
@@ -2,6 +2,6 @@
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index 9488ae37a8..6ab1a3e5a1 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -494,15 +494,8 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
case NODE_OUTPUT: {
NodeOut *on = static_cast<NodeOut*>(nb);
-
- for(TrackMap::Element *E=track_map.front();E;E=E->next()) {
- E->get().total_weight = 0;
- }
-
HashMap<NodePath, float> weights;
-
-
return _process_node(on->inputs[0].node,r_prev_anim,p_time,p_seek, p_fallback_weight, &weights);
} break;
@@ -544,15 +537,12 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
NodePath track_path = an->animation->track_get_path(E->get().local_track);
if (an->filter.has(track_path) && an->filter[track_path]) {
E->get().weight = 0;
- E->get().track->total_weight += p_fallback_weight;
} else {
if (p_weights->has(track_path)) {
float weight = (*p_weights)[track_path];
E->get().weight = weight;
- E->get().track->total_weight += weight;
} else {
E->get().weight = p_fallback_weight;
- E->get().track->total_weight += p_fallback_weight;
}
}
if (E->get().weight>CMP_EPSILON)
@@ -875,8 +865,6 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
if (tr.track==NULL || tr.local_track<0 || tr.weight < CMP_EPSILON)
continue;
- float blend=tr.weight / tr.track->total_weight;
-
switch(a->track_get_type(tr.local_track)) {
case Animation::TYPE_TRANSFORM: { ///< Transform a node or a bone.
@@ -885,14 +873,14 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
Vector3 scale;
a->transform_track_interpolate(tr.local_track,anim_list->time,&loc,&rot,&scale);
- tr.track->loc+=loc*blend;
+ tr.track->loc+=loc*tr.weight;
scale.x-=1.0;
scale.y-=1.0;
scale.z-=1.0;
- tr.track->scale+=scale*blend;
+ tr.track->scale+=scale*tr.weight;
- tr.track->rot = tr.track->rot * empty_rot.slerp(rot,blend);
+ tr.track->rot = tr.track->rot * empty_rot.slerp(rot,tr.weight);
} break;
@@ -900,7 +888,7 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
if (a->value_track_get_update_mode(tr.local_track)==Animation::UPDATE_CONTINUOUS) {
Variant value = a->value_track_interpolate(tr.local_track,anim_list->time);
- Variant::blend(tr.track->value,value,blend,tr.track->value);
+ Variant::blend(tr.track->value,value,tr.weight,tr.track->value);
} else {
int index = a->track_find_key(tr.local_track,anim_list->time);
tr.track->value = a->track_get_key_value(tr.local_track, index);
diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h
index 6b5350e9ee..909748924f 100644
--- a/scene/animation/animation_tree_player.h
+++ b/scene/animation/animation_tree_player.h
@@ -111,7 +111,6 @@ private:
Variant value;
bool skip;
- float total_weight;
};
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 156f4956bb..cbaaeb03e5 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -206,6 +206,7 @@ void Tween::_bind_methods() {
ObjectTypeDB::bind_method(_MD("resume","object","key"),&Tween::resume, DEFVAL("") );
ObjectTypeDB::bind_method(_MD("resume_all"),&Tween::resume_all );
ObjectTypeDB::bind_method(_MD("remove","object","key"),&Tween::remove, DEFVAL("") );
+ ObjectTypeDB::bind_method(_MD("_remove","object","key","first_only"),&Tween::_remove );
ObjectTypeDB::bind_method(_MD("remove_all"),&Tween::remove_all );
ObjectTypeDB::bind_method(_MD("seek","time"),&Tween::seek );
ObjectTypeDB::bind_method(_MD("tell"),&Tween::tell );
@@ -620,7 +621,7 @@ void Tween::_tween_process(float p_delta) {
object->call(data.key, (const Variant **) arg, data.args, error);
}
if (!repeat)
- call_deferred("remove", object, data.key);
+ call_deferred("_remove", object, data.key, true);
}
continue;
}
@@ -634,7 +635,7 @@ void Tween::_tween_process(float p_delta) {
emit_signal("tween_complete",object,data.key);
// not repeat mode, remove completed action
if (!repeat)
- call_deferred("remove", object, data.key);
+ call_deferred("_remove", object, data.key, true);
}
}
pending_update --;
@@ -816,10 +817,15 @@ bool Tween::resume_all() {
}
bool Tween::remove(Object *p_object, String p_key) {
+ _remove(p_object, p_key, false);
+ return true;
+}
+
+void Tween::_remove(Object *p_object, String p_key, bool first_only) {
if(pending_update != 0) {
- call_deferred("remove", p_object, p_key);
- return true;
+ call_deferred("_remove", p_object, p_key, first_only);
+ return;
}
List<List<InterpolateData>::Element *> for_removal;
for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
@@ -830,12 +836,14 @@ bool Tween::remove(Object *p_object, String p_key) {
continue;
if(object == p_object && (data.key == p_key || p_key == "")) {
for_removal.push_back(E);
+ if (first_only) {
+ break;
+ }
}
}
for(List<List<InterpolateData>::Element *>::Element *E=for_removal.front();E;E=E->next()) {
interpolates.erase(E->get());
}
- return true;
}
bool Tween::remove_all() {
diff --git a/scene/animation/tween.h b/scene/animation/tween.h
index d0455cdc71..844a012b9f 100644
--- a/scene/animation/tween.h
+++ b/scene/animation/tween.h
@@ -143,6 +143,7 @@ private:
void _tween_process(float p_delta);
void _set_process(bool p_process,bool p_force=false);
+ void _remove(Object *p_node, String p_key, bool first_only);
protected:
diff --git a/scene/audio/SCsub b/scene/audio/SCsub
index 9fa89edbf7..bf9125be7f 100644
--- a/scene/audio/SCsub
+++ b/scene/audio/SCsub
@@ -2,6 +2,6 @@
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/gui/SCsub b/scene/gui/SCsub
index 9fa89edbf7..bf9125be7f 100644
--- a/scene/gui/SCsub
+++ b/scene/gui/SCsub
@@ -2,6 +2,6 @@
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index b8c5f227c6..49782bcb75 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -254,52 +254,40 @@ void AcceptDialog::register_text_enter(Node *p_line_edit) {
}
void AcceptDialog::_update_child_rect() {
-
- const int margin = get_constant("margin","Dialogs");
- const Size2 size = get_size();
+ Size2 label_size=label->get_minimum_size();
+ if (label->get_text().empty()) {
+ label_size.height = 0;
+ }
+ int margin = get_constant("margin","Dialogs");
+ Size2 size = get_size();
Size2 hminsize = hbc->get_combined_minimum_size();
- const Size2 max_csize(
- size.width - margin * 2,
- size.height - margin * 3 - hminsize.height);
- hminsize.width = max_csize.width;
-
- Point2 cpos(margin, margin);
- Size2 csize = label->get_combined_minimum_size();
- if(label->get_text().empty())
- csize.y = 0;
- csize.x = MIN(csize.width, max_csize.width);
- csize.y = MIN(csize.height, max_csize.height);
- label->set_pos(cpos);
- label->set_size(csize);
-
- if(child) {
- const float child_y_offset = csize.height + (csize.height > 0 ? margin : 0);
- cpos.y += child_y_offset;
- csize = max_csize;
- csize.height -= child_y_offset;
+ Vector2 cpos(margin,margin+label_size.height);
+ Vector2 csize(size.x-margin*2,size.y-margin*3-hminsize.y-label_size.height);
+
+ if (child) {
child->set_pos(cpos);
child->set_size(csize);
}
- cpos.y += csize.height + margin;
+ cpos.y+=csize.y+margin;
+ csize.y=hminsize.y;
hbc->set_pos(cpos);
- hbc->set_size(hminsize);
+ hbc->set_size(csize);
+
}
Size2 AcceptDialog::get_minimum_size() const {
int margin = get_constant("margin","Dialogs");
Size2 minsize = label->get_combined_minimum_size();
- if(label->get_text().empty())
- minsize.y = 0;
if (child) {
Size2 cminsize = child->get_combined_minimum_size();
minsize.x=MAX(cminsize.x,minsize.x);
- minsize.y += cminsize.y + (minsize.y > 0 ? margin : 0);
+ minsize.y=MAX(cminsize.y,minsize.y);
}
Size2 hminsize = hbc->get_combined_minimum_size();
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 6b43425edc..f942f15ed0 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -186,15 +186,17 @@ void FileDialog::_action_pressed() {
hide();
}else if (mode==MODE_OPEN_ANY || mode==MODE_OPEN_DIR) {
-
String path=dir_access->get_current_dir();
- /*if (tree->get_selected()) {
- Dictionary d = tree->get_selected()->get_metadata(0);
+
+ path=path.replace("\\","/");
+
+ if (TreeItem* item = tree->get_selected()) {
+ Dictionary d = item->get_metadata(0);
if (d["dir"]) {
- path=path+"/"+String(d["name"]);
+ path=path.plus_file(d["name"]);
}
- }*/
- path=path.replace("\\","/");
+ }
+
emit_signal("dir_selected",path);
hide();
}
@@ -348,18 +350,18 @@ void FileDialog::update_file_list() {
files.sort_custom<NoCaseComparator>();
while(!dirs.empty()) {
+ String& dir_name = dirs.front()->get();
+ TreeItem *ti=tree->create_item(root);
+ ti->set_text(0,dir_name+"/");
+ ti->set_icon(0,folder);
- if (dirs.front()->get()!=".") {
- TreeItem *ti=tree->create_item(root);
- ti->set_text(0,dirs.front()->get()+"/");
- ti->set_icon(0,folder);
- Dictionary d;
- d["name"]=dirs.front()->get();
- d["dir"]=true;
- ti->set_metadata(0,d);
- }
- dirs.pop_front();
+ Dictionary d;
+ d["name"]=dir_name;
+ d["dir"]=true;
+
+ ti->set_metadata(0,d);
+ dirs.pop_front();
}
dirs.clear();
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index f69ad8fa7e..191627cadb 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -801,7 +801,10 @@ void ItemList::_notification(int p_what) {
Size2 size = get_size();
float page = size.height-bg->get_minimum_size().height;
- int width = size.width - mw - bg->get_minimum_size().width;
+ int width = size.width-bg->get_minimum_size().width;
+ if (!scroll_bar->is_hidden()){
+ width-=mw+bg->get_margin(MARGIN_RIGHT);
+ }
scroll_bar->set_page(page);
draw_style_box(bg,Rect2(Point2(),size));
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index ec89b7b690..f95b151024 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -85,7 +85,7 @@ void Label::_notification(int p_what) {
Ref<Font> font = get_font("font");
Color font_color = get_color("font_color");
Color font_color_shadow = get_color("font_color_shadow");
- bool use_outlinde = get_constant("shadow_as_outline");
+ bool use_outline = get_constant("shadow_as_outline");
Point2 shadow_ofs(get_constant("shadow_offset_x"),get_constant("shadow_offset_y"));
int line_spacing = get_constant("line_spacing");
@@ -118,19 +118,19 @@ void Label::_notification(int p_what) {
//nothing
} break;
case VALIGN_CENTER: {
- vbegin=(size.y - lines_visible * font_h) / 2;
+ vbegin=(size.y - (lines_visible * font_h - line_spacing)) / 2;
vsep=0;
} break;
case VALIGN_BOTTOM: {
- vbegin=size.y - lines_visible * font_h;
+ vbegin=size.y - (lines_visible * font_h - line_spacing);
vsep=0;
} break;
case VALIGN_FILL: {
vbegin=0;
if (lines_visible>1) {
- vsep=(size.y - lines_visible * font_h) / (lines_visible - 1);
+ vsep=(size.y - (lines_visible * font_h - line_spacing)) / (lines_visible - 1);
} else {
vsep=0;
}
@@ -247,7 +247,7 @@ void Label::_notification(int p_what) {
}
float move=font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+shadow_ofs, c, n,font_color_shadow );
- if (use_outlinde) {
+ if (use_outline) {
font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(-shadow_ofs.x,shadow_ofs.y), c, n,font_color_shadow );
font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(shadow_ofs.x,-shadow_ofs.y), c, n,font_color_shadow );
font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(-shadow_ofs.x,-shadow_ofs.y), c, n,font_color_shadow );
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index f7d74b2b49..eecc730f5c 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -853,7 +853,7 @@ void LineEdit::_reset_caret_blink_timer() {
void LineEdit::_toggle_draw_caret() {
draw_caret = !draw_caret;
- if (is_visible()) {
+ if (is_visible() && has_focus() && window_has_focus) {
update();
}
}
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp
index 62829fd5a4..e6f85c5935 100644
--- a/scene/gui/link_button.cpp
+++ b/scene/gui/link_button.cpp
@@ -87,13 +87,13 @@ void LinkButton::_notification(int p_what) {
else
color=get_color("font_color");
- do_underline=true;
+ do_underline=underline_mode!=UNDERLINE_MODE_NEVER;
} break;
case DRAW_HOVER: {
color=get_color("font_color_hover");
- do_underline=true;
+ do_underline=underline_mode!=UNDERLINE_MODE_NEVER;
} break;
case DRAW_DISABLED: {
@@ -139,9 +139,10 @@ void LinkButton::_bind_methods() {
BIND_CONSTANT( UNDERLINE_MODE_ALWAYS );
BIND_CONSTANT( UNDERLINE_MODE_ON_HOVER );
+ BIND_CONSTANT( UNDERLINE_MODE_NEVER );
ADD_PROPERTYNZ(PropertyInfo(Variant::STRING,"text"), _SCS("set_text"), _SCS("get_text"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"underline",PROPERTY_HINT_ENUM,"Always,On Hover"), _SCS("set_underline_mode"), _SCS("get_underline_mode"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"underline",PROPERTY_HINT_ENUM,"Always,On Hover,Never"), _SCS("set_underline_mode"), _SCS("get_underline_mode"));
}
diff --git a/scene/gui/link_button.h b/scene/gui/link_button.h
index 9978f66cc0..a44fc2ec1b 100644
--- a/scene/gui/link_button.h
+++ b/scene/gui/link_button.h
@@ -40,7 +40,8 @@ public:
enum UnderlineMode {
UNDERLINE_MODE_ALWAYS,
- UNDERLINE_MODE_ON_HOVER
+ UNDERLINE_MODE_ON_HOVER,
+ UNDERLINE_MODE_NEVER
};
private:
String text;
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index e056c55f71..ed58c4eb49 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -136,16 +136,25 @@ double Range::get_page() const {
}
void Range::set_unit_value(double p_value) {
+
+ double v;
+
if (shared->exp_unit_value && get_min()>0) {
double exp_min = Math::log(get_min())/Math::log(2);
double exp_max = Math::log(get_max())/Math::log(2);
- double v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
-
- set_val( v );
+ v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
} else {
- set_val( (get_max() - get_min()) * p_value + get_min() );
+
+ double percent = (get_max() - get_min()) * p_value;
+ if (get_step() > 0) {
+ double steps = round(percent / get_step());
+ v = steps * get_step() + get_min();
+ } else {
+ v = percent + get_min();
+ }
}
+ set_val( v );
}
double Range::get_unit_value() const {
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 98e1a32aef..9417c25424 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -51,7 +51,10 @@ void SpinBox::_text_entered(const String& p_string) {
//if (!p_string.is_numeric())
// return;
- set_val( p_string.to_double() );
+ String value = p_string;
+ if (prefix!="" && p_string.begins_with(prefix))
+ value = p_string.substr(prefix.length(), p_string.length()-prefix.length());
+ set_val( value.to_double() );
_value_changed(0);
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index f1a2823e8f..871a3ca68f 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -492,10 +492,10 @@ void TextEdit::_notification(int p_what) {
if (syntax_coloring) {
- if (custom_bg_color.a>0.01) {
+ if (cache.background_color.a>0.01) {
Point2i ofs = Point2i(cache.style_normal->get_offset())/2.0;
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(ofs, get_size()-cache.style_normal->get_minimum_size()+ofs),custom_bg_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(ofs, get_size()-cache.style_normal->get_minimum_size()+ofs),cache.background_color);
}
//compute actual region to start (may be inside say, a comment).
//slow in very large documments :( but ok for source!
@@ -907,7 +907,7 @@ void TextEdit::_notification(int p_what) {
else if (in_function_name)
color=cache.function_color;
else if (is_symbol)
- color=symbol_color;
+ color=cache.symbol_color;
else if (is_number)
color=cache.number_color;
@@ -3458,7 +3458,7 @@ void TextEdit::_reset_caret_blink_timer() {
void TextEdit::_toggle_draw_caret() {
draw_caret = !draw_caret;
- if (is_visible()) {
+ if (is_visible() && has_focus() && window_has_focus) {
update();
}
}
@@ -3489,6 +3489,8 @@ void TextEdit::_update_caches() {
cache.word_highlighted_color=get_color("word_highlighted_color");
cache.search_result_color=get_color("search_result_color");
cache.search_result_border_color=get_color("search_result_border_color");
+ cache.symbol_color=get_color("symbol_color");
+ cache.background_color=get_color("background_color");
cache.line_spacing=get_constant("line_spacing");
cache.row_height = cache.font->get_height() + cache.line_spacing;
cache.tab_icon=get_icon("tab");
@@ -3500,15 +3502,8 @@ void TextEdit::_update_caches() {
void TextEdit::clear_colors() {
keywords.clear();
- color_regions.clear();;
+ color_regions.clear();
text.clear_caches();
- custom_bg_color=Color(0,0,0,0);
-}
-
-void TextEdit::set_custom_bg_color(const Color& p_color) {
-
- custom_bg_color=p_color;
- update();
}
void TextEdit::add_keyword_color(const String& p_keyword,const Color& p_color) {
@@ -3526,12 +3521,6 @@ void TextEdit::add_color_region(const String& p_begin_key,const String& p_end_ke
}
-void TextEdit::set_symbol_color(const Color& p_color) {
-
- symbol_color=p_color;
- update();
-}
-
void TextEdit::set_syntax_coloring(bool p_enabled) {
syntax_coloring=p_enabled;
@@ -4689,8 +4678,6 @@ void TextEdit::_bind_methods() {
ObjectTypeDB::bind_method(_MD("add_keyword_color","keyword","color"),&TextEdit::add_keyword_color);
ObjectTypeDB::bind_method(_MD("add_color_region","begin_key","end_key","color","line_only"),&TextEdit::add_color_region,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("set_symbol_color","color"),&TextEdit::set_symbol_color);
- ObjectTypeDB::bind_method(_MD("set_custom_bg_color","color"),&TextEdit::set_custom_bg_color);
ObjectTypeDB::bind_method(_MD("clear_colors"),&TextEdit::clear_colors);
ObjectTypeDB::bind_method(_MD("menu_option"),&TextEdit::menu_option);
ObjectTypeDB::bind_method(_MD("get_menu:PopupMenu"),&TextEdit::get_menu);
@@ -4775,7 +4762,6 @@ TextEdit::TextEdit() {
caret_blink_timer->connect("timeout", this,"_toggle_draw_caret");
cursor_set_blink_enabled(false);
- custom_bg_color=Color(0,0,0,0);
idle_detect = memnew( Timer );
add_child(idle_detect);
idle_detect->set_one_shot(true);
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 7820fefdd2..4cf096b7bf 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -95,6 +95,8 @@ class TextEdit : public Control {
Color word_highlighted_color;
Color search_result_color;
Color search_result_border_color;
+ Color symbol_color;
+ Color background_color;
int row_height;
int line_spacing;
@@ -187,9 +189,7 @@ class TextEdit : public Control {
//syntax coloring
- Color symbol_color;
HashMap<String,Color> keywords;
- Color custom_bg_color;
Vector<ColorRegion> color_regions;
@@ -471,8 +471,6 @@ public:
void add_keyword_color(const String& p_keyword,const Color& p_color);
void add_color_region(const String& p_begin_key=String(),const String& p_end_key=String(),const Color &p_color=Color(),bool p_line_only=false);
- void set_symbol_color(const Color& p_color);
- void set_custom_bg_color(const Color& p_color);
void clear_colors();
int get_v_scroll() const;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index ca9c666c01..912371142f 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2363,19 +2363,11 @@ void Tree::_input_event(InputEvent p_event) {
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
warp_mouse(range_drag_capture_pos);
} else {
-
- if (delayed_text_editor) {
- uint64_t diff = OS::get_singleton()->get_ticks_msec() - first_selection_time;
- if (diff >= 400 && diff <= 800)
- edit_selected();
- // fast double click
- else if (diff < 400) {
- emit_signal("item_double_clicked");
- }
-
- first_selection_time = OS::get_singleton()->get_ticks_msec();
- } else {
+ Rect2 rect = get_selected()->get_meta("__focus_rect");
+ if (rect.has_point(Point2(p_event.mouse_button.x,p_event.mouse_button.y))) {
edit_selected();
+ } else {
+ emit_signal("item_double_clicked");
}
}
pressing_for_editor=false;
@@ -2921,8 +2913,6 @@ void Tree::item_selected(int p_column,TreeItem *p_item) {
p_item->cells[p_column].selected=true;
//emit_signal("multi_selected",p_item,p_column,true); - NO this is for TreeItem::select
- if (delayed_text_editor)
- first_selection_time = OS::get_singleton()->get_ticks_msec();
} else {
@@ -3572,15 +3562,6 @@ bool Tree::get_allow_rmb_select() const{
}
-void Tree::set_delayed_text_editor(bool enabled) {
- delayed_text_editor = enabled;
-}
-
-bool Tree::is_delayed_text_editor_enabled() const {
- return delayed_text_editor;
-}
-
-
void Tree::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_range_click_timeout"),&Tree::_range_click_timeout);
@@ -3634,10 +3615,6 @@ void Tree::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_allow_rmb_select","allow"),&Tree::set_allow_rmb_select);
ObjectTypeDB::bind_method(_MD("get_allow_rmb_select"),&Tree::get_allow_rmb_select);
- ObjectTypeDB::bind_method(_MD("set_delayed_text_editor","enable"),&Tree::set_delayed_text_editor);
- ObjectTypeDB::bind_method(_MD("is_delayed_text_editor_enabled"),&Tree::is_delayed_text_editor_enabled);
-
-
ObjectTypeDB::bind_method(_MD("set_single_select_cell_editing_only_when_already_selected","enable"),&Tree::set_single_select_cell_editing_only_when_already_selected);
ObjectTypeDB::bind_method(_MD("get_single_select_cell_editing_only_when_already_selected"),&Tree::get_single_select_cell_editing_only_when_already_selected);
@@ -3751,9 +3728,6 @@ Tree::Tree() {
force_select_on_already_selected=false;
allow_rmb_select=false;
-
- first_selection_time = 0;
- delayed_text_editor = false;
}
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 6c2f1dae40..1936f926c8 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -439,9 +439,6 @@ friend class TreeItem;
float last_drag_time;
float time_since_motion;*/
- bool delayed_text_editor;
- uint64_t first_selection_time;
-
float drag_speed;
float drag_from;
float drag_accum;
@@ -537,9 +534,6 @@ public:
void set_value_evaluator(ValueEvaluator *p_evaluator);
- void set_delayed_text_editor(bool enabled);
- bool is_delayed_text_editor_enabled() const;
-
Tree();
~Tree();
diff --git a/scene/io/SCsub b/scene/io/SCsub
index 9fa89edbf7..bf9125be7f 100644
--- a/scene/io/SCsub
+++ b/scene/io/SCsub
@@ -2,6 +2,6 @@
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/main/SCsub b/scene/main/SCsub
index 9fa89edbf7..bf9125be7f 100644
--- a/scene/main/SCsub
+++ b/scene/main/SCsub
@@ -2,6 +2,6 @@
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 6e33dcb4c9..f4fb48682c 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2485,6 +2485,12 @@ void Node::replace_by(Node* p_node,bool p_keep_data) {
rd.name=E->get().name;
rd.value=get(rd.name);
}
+
+ List<GroupInfo> groups;
+ get_groups(&groups);
+
+ for(List<GroupInfo>::Element *E=groups.front();E;E=E->next())
+ p_node->add_to_group(E->get().name, E->get().persistent);
}
_replace_connections_target(p_node);
diff --git a/scene/resources/SCsub b/scene/resources/SCsub
index 702ed1a9bf..60b16cd0d4 100644
--- a/scene/resources/SCsub
+++ b/scene/resources/SCsub
@@ -2,9 +2,9 @@
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
-env.add_source_files(env.scene_sources,"*.c")
+env.add_source_files(env.scene_sources, "*.cpp")
+env.add_source_files(env.scene_sources, "*.c")
Export('env')
-SConscript("default_theme/SCsub");
+SConscript("default_theme/SCsub")
diff --git a/scene/resources/default_theme/SCsub b/scene/resources/default_theme/SCsub
index 9fa89edbf7..bf9125be7f 100644
--- a/scene/resources/default_theme/SCsub
+++ b/scene/resources/default_theme/SCsub
@@ -2,6 +2,6 @@
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 0740b591c4..4c759bddef 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -490,6 +490,7 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_font("font","TextEdit", default_font );
+ t->set_color("background_color", "TextEdit", Color(0,0,0,0));
t->set_color("completion_background_color", "TextEdit",Color::html("2C2A32"));
t->set_color("completion_selected_color", "TextEdit",Color::html("434244"));
t->set_color("completion_existing_color", "TextEdit",Color::html("21dfdfdf"));
diff --git a/scene/resources/default_theme/make_header.py b/scene/resources/default_theme/make_header.py
index 2d3f989e01..68c9e92527 100644
--- a/scene/resources/default_theme/make_header.py
+++ b/scene/resources/default_theme/make_header.py
@@ -1,72 +1,71 @@
-import os;
-import glob;
-import string;
+import os
+import glob
+import string
-#Generate include files
+# Generate include files
-f=open("theme_data.h","wb")
+f = open("theme_data.h", "wb")
-f.write("// THIS FILE HAS BEEN AUTOGENERATED, DONT EDIT!!\n");
+f.write("// THIS FILE HAS BEEN AUTOGENERATED, DONT EDIT!!\n")
-f.write("\n\n");
+f.write("\n\n")
-#Generate png image block
+# Generate png image block
-pixmaps = glob.glob("*.png");
+pixmaps = glob.glob("*.png")
-pixmaps.sort();
+pixmaps.sort()
-f.write("\n\n\n");
+f.write("\n\n\n")
for x in pixmaps:
- var_str=x[:-4]+"_png";
+ var_str = x[:-4] + "_png"
- f.write("static const unsigned char "+ var_str +"[]={\n");
+ f.write("static const unsigned char " + var_str + "[]={\n")
- pngf=open(x,"rb");
+ pngf = open(x, "rb")
- b=pngf.read(1);
- while(len(b)==1):
- f.write(hex(ord(b)))
- b=pngf.read(1);
- if (len(b)==1):
- f.write(",")
+ b = pngf.read(1)
+ while(len(b) == 1):
+ f.write(hex(ord(b)))
+ b = pngf.read(1)
+ if (len(b) == 1):
+ f.write(",")
- f.write("\n};\n\n\n");
- pngf.close();
+ f.write("\n};\n\n\n")
+ pngf.close()
-#Generate shaders block
+# Generate shaders block
shaders = glob.glob("*.gsl")
-shaders.sort();
+shaders.sort()
-f.write("\n\n\n");
+f.write("\n\n\n")
for x in shaders:
- var_str=x[:-4]+"_shader_code";
+ var_str = x[:-4] + "_shader_code"
- f.write("static const char *"+ var_str +"=\n");
+ f.write("static const char *" + var_str + "=\n")
- sf=open(x,"rb");
+ sf = open(x, "rb")
+ b = sf.readline()
+ while(b != ""):
+ if (b.endswith("\r\n")):
+ b = b[:-2]
+ if (b.endswith("\n")):
+ b = b[:-1]
+ f.write(" \"" + b)
+ b = sf.readline()
+ if (b != ""):
+ f.write("\"\n")
- b=sf.readline();
- while(b!=""):
- if (b.endswith("\r\n")):
- b=b[:-2]
- if (b.endswith("\n")):
- b=b[:-1]
- f.write(" \""+b)
- b=sf.readline();
- if (b!=""):
- f.write("\"\n")
+ f.write("\";\n\n\n")
+ sf.close()
- f.write("\";\n\n\n");
- sf.close();
-
-f.close();
+f.close()