summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/area_2d.cpp6
-rw-r--r--scene/2d/light_2d.cpp6
-rw-r--r--scene/gui/box_container.cpp1
-rw-r--r--scene/gui/item_list.cpp25
-rw-r--r--scene/gui/item_list.h5
-rw-r--r--scene/gui/texture_frame.cpp46
-rw-r--r--scene/gui/texture_frame.h15
-rw-r--r--scene/resources/default_theme/default_theme.cpp2
8 files changed, 93 insertions, 13 deletions
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index 8b7aff3b7a..71728966fd 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -660,9 +660,9 @@ void Area2D::_bind_methods() {
ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"gravity_point"),_SCS("set_gravity_is_point"),_SCS("is_gravity_a_point"));
ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"gravity_distance_scale", PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_gravity_distance_scale"),_SCS("get_gravity_distance_scale"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"gravity_vec"),_SCS("set_gravity_vector"),_SCS("get_gravity_vector"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-1024,1024,0.01"),_SCS("set_gravity"),_SCS("get_gravity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-1024,1024,0.001"),_SCS("set_gravity"),_SCS("get_gravity"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),_SCS("set_priority"),_SCS("get_priority"));
ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled"));
ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable"));
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index b79c07360b..1cb34075bb 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -357,11 +357,11 @@ void Light2D::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"scale",PROPERTY_HINT_RANGE,"0.01,4096,0.01"),_SCS("set_texture_scale"),_SCS("get_texture_scale"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"scale",PROPERTY_HINT_RANGE,"0.01,50,0.01"),_SCS("set_texture_scale"),_SCS("get_texture_scale"));
ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy"),_SCS("set_energy"),_SCS("get_energy"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_RANGE,"0.01,100,0.01"),_SCS("set_energy"),_SCS("get_energy"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Add,Sub,Mix,Mask"),_SCS("set_mode"),_SCS("get_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"range/height"),_SCS("set_height"),_SCS("get_height"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"range/height",PROPERTY_HINT_RANGE,"-100,100,0.1"),_SCS("set_height"),_SCS("get_height"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_min",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_min"),_SCS("get_z_range_min"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_max",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_max"),_SCS("get_z_range_max"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"range/layer_min",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_min"),_SCS("get_layer_range_min"));
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp
index a9522cf248..a6ffc30a83 100644
--- a/scene/gui/box_container.cpp
+++ b/scene/gui/box_container.cpp
@@ -280,6 +280,7 @@ BoxContainer::AlignMode BoxContainer::get_alignment() const {
void BoxContainer::add_spacer(bool p_begin) {
Control *c = memnew( Control );
+ c->set_stop_mouse(false);
if (vertical)
c->set_v_size_flags(SIZE_EXPAND_FILL);
else
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index c1a0e43e49..a616dc9254 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -720,7 +720,7 @@ void ItemList::ensure_current_is_visible() {
update();
}
-static Size2 _adjust_to_max_size(Size2 p_size, Size2 p_max_size) {
+static Size2 _adjust_to_max_size(Size2 p_size, Size2 p_max_size, bool p_stretch) {
if (p_max_size.x<=0)
p_max_size.x=1e20;
@@ -730,6 +730,10 @@ static Size2 _adjust_to_max_size(Size2 p_size, Size2 p_max_size) {
Size2 new_size;
+ if (p_stretch && (p_size.x * p_size.y < p_max_size.x * p_max_size.y)) {
+ return p_max_size;
+ }
+
if (p_size.x > p_max_size.x) {
new_size.width=p_max_size.x;
@@ -831,7 +835,7 @@ void ItemList::_notification(int p_what) {
Size2 minsize;
if (items[i].icon.is_valid()) {
- minsize=_adjust_to_max_size(items[i].get_icon_size(),max_icon_size);
+ minsize=_adjust_to_max_size(items[i].get_icon_size(),max_icon_size, icon_stretch);
if (items[i].text!="") {
if (icon_mode==ICON_MODE_TOP) {
@@ -976,7 +980,7 @@ void ItemList::_notification(int p_what) {
Vector2 text_ofs;
if (items[i].icon.is_valid()) {
- Size2 icon_size = _adjust_to_max_size(items[i].get_icon_size(),max_icon_size);
+ Size2 icon_size = _adjust_to_max_size(items[i].get_icon_size(),max_icon_size, icon_stretch);
Vector2 icon_ofs;
if (min_icon_size!=Vector2()) {
@@ -1201,6 +1205,16 @@ bool ItemList::get_allow_rmb_select() const {
return allow_rmb_select;
}
+void ItemList::set_icon_stretch_to_max_size(bool p_stretch) {
+
+ icon_stretch = p_stretch;
+}
+
+bool ItemList::get_icon_stretch_to_max_size() const {
+
+ return icon_stretch;
+}
+
void ItemList::_bind_methods(){
ObjectTypeDB::bind_method(_MD("add_item","text","icon:Texture","selectable"),&ItemList::add_item,DEFVAL(Variant()),DEFVAL(true));
@@ -1261,6 +1275,9 @@ void ItemList::_bind_methods(){
ObjectTypeDB::bind_method(_MD("set_max_icon_size","size"),&ItemList::set_max_icon_size);
ObjectTypeDB::bind_method(_MD("get_max_icon_size"),&ItemList::get_max_icon_size);
+ ObjectTypeDB::bind_method(_MD("set_icon_stretch_to_max_size","stretch"),&ItemList::set_icon_stretch_to_max_size);
+ ObjectTypeDB::bind_method(_MD("get_icon_stretch_to_max_size"),&ItemList::get_icon_stretch_to_max_size);
+
ObjectTypeDB::bind_method(_MD("set_allow_rmb_select","allow"),&ItemList::set_allow_rmb_select);
ObjectTypeDB::bind_method(_MD("get_allow_rmb_select"),&ItemList::get_allow_rmb_select);
@@ -1308,6 +1325,8 @@ ItemList::ItemList() {
defer_select_single=-1;
allow_rmb_select=false;
+ icon_stretch = false;
+
}
ItemList::~ItemList() {
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index 59fa1d8270..a79d2575bd 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -45,6 +45,8 @@ private:
bool ensure_selected_visible;
+ bool icon_stretch;
+
Vector<Item> items;
Vector<int> separators;
@@ -150,6 +152,9 @@ public:
virtual String get_tooltip(const Point2& p_pos) const;
int get_item_at_pos(const Point2& p_pos,bool p_exact=false) const;
+ void set_icon_stretch_to_max_size(bool p_stretch);
+ bool get_icon_stretch_to_max_size() const;
+
ItemList();
~ItemList();
};
diff --git a/scene/gui/texture_frame.cpp b/scene/gui/texture_frame.cpp
index 73fecf591a..2fe8735fda 100644
--- a/scene/gui/texture_frame.cpp
+++ b/scene/gui/texture_frame.cpp
@@ -37,9 +37,31 @@ void TextureFrame::_notification(int p_what) {
return;
- Size2 s=expand?get_size():texture->get_size();
+
RID ci = get_canvas_item();
- draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
+
+ switch(stretch_mode) {
+ case STRETCH_SCALE_ON_EXPAND: {
+ Size2 s=expand?get_size():texture->get_size();
+ draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
+ } break;
+ case STRETCH_SCALE: {
+ draw_texture_rect(texture,Rect2(Point2(),get_size()),false,modulate);
+ } break;
+ case STRETCH_TILE: {
+ draw_texture_rect(texture,Rect2(Point2(),get_size()),true,modulate);
+ } break;
+ case STRETCH_KEEP: {
+ draw_texture_rect(texture,Rect2(Point2(),texture->get_size()),false,modulate);
+
+ } break;
+ case STRETCH_KEEP_CENTERED: {
+
+ Vector2 ofs = (get_size() - texture->get_size())/2;
+ draw_texture_rect(texture,Rect2(ofs,texture->get_size()),false,modulate);
+ } break;
+ }
+
/*
Vector<Point2> points;
@@ -76,11 +98,19 @@ void TextureFrame::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_modulate"), & TextureFrame::get_modulate );
ObjectTypeDB::bind_method(_MD("set_expand","enable"), & TextureFrame::set_expand );
ObjectTypeDB::bind_method(_MD("has_expand"), & TextureFrame::has_expand );
+ ObjectTypeDB::bind_method(_MD("set_stretch_mode","stretch_mode"), & TextureFrame::set_stretch_mode );
+ ObjectTypeDB::bind_method(_MD("get_stretch_mode"), & TextureFrame::get_stretch_mode );
ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") );
ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate") );
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") );
+ ADD_PROPERTYNO( PropertyInfo( Variant::INT, "stretch_mode",PROPERTY_HINT_ENUM,"Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered"), _SCS("set_stretch_mode"),_SCS("get_stretch_mode") );
+ BIND_CONSTANT( STRETCH_SCALE_ON_EXPAND );
+ BIND_CONSTANT( STRETCH_SCALE );
+ BIND_CONSTANT( STRETCH_TILE );
+ BIND_CONSTANT( STRETCH_KEEP );
+ BIND_CONSTANT( STRETCH_KEEP_CENTERED );
}
@@ -121,12 +151,24 @@ bool TextureFrame::has_expand() const {
return expand;
}
+void TextureFrame::set_stretch_mode(StretchMode p_mode) {
+
+ stretch_mode=p_mode;
+ update();
+}
+
+TextureFrame::StretchMode TextureFrame::get_stretch_mode() const {
+
+ return stretch_mode;
+}
+
TextureFrame::TextureFrame() {
expand=false;
modulate=Color(1,1,1,1);
set_ignore_mouse(true);
+ stretch_mode=STRETCH_SCALE_ON_EXPAND;
}
diff --git a/scene/gui/texture_frame.h b/scene/gui/texture_frame.h
index e1f0de92df..a4acf588ea 100644
--- a/scene/gui/texture_frame.h
+++ b/scene/gui/texture_frame.h
@@ -36,10 +36,19 @@
class TextureFrame : public Control {
OBJ_TYPE(TextureFrame,Control);
-
+public:
+ enum StretchMode {
+ STRETCH_SCALE_ON_EXPAND, //default, for backwards compatibility
+ STRETCH_SCALE,
+ STRETCH_TILE,
+ STRETCH_KEEP,
+ STRETCH_KEEP_CENTERED,
+ };
+private:
bool expand;
Color modulate;
Ref<Texture> texture;
+ StretchMode stretch_mode;
protected:
void _notification(int p_what);
@@ -57,9 +66,13 @@ public:
void set_expand(bool p_expand);
bool has_expand() const;
+ void set_stretch_mode(StretchMode p_mode);
+ StretchMode get_stretch_mode() const;
+
TextureFrame();
~TextureFrame();
};
+VARIANT_ENUM_CAST( TextureFrame::StretchMode );
#endif // TEXTURE_FRAME_H
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 0c4d8ae841..cd90bf52b6 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -468,7 +468,7 @@ void make_default_theme() {
t->set_color("mark_color","TextEdit", Color(1.0,0.4,0.4,0.4) );
t->set_color("breakpoint_color","TextEdit", Color(0.8,0.8,0.4,0.2) );
t->set_color("current_line_color","TextEdit", Color(0.25,0.25,0.26,0.8) );
- t->set_color("cursor_color","TextEdit", control_font_color );
+ t->set_color("caret_color","TextEdit", control_font_color );
t->set_color("symbol_color","TextEdit", control_font_color_hover );
t->set_color("brace_mismatch_color","TextEdit", Color(1,0.2,0.2) );