summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/base/classes.xml9
-rw-r--r--scene/gui/color_picker.cpp45
-rw-r--r--scene/gui/color_picker.h1
-rw-r--r--scene/gui/text_edit.cpp5
-rw-r--r--scene/resources/font.cpp6
-rw-r--r--scene/resources/font.h1
-rw-r--r--servers/physics_2d/body_pair_2d_sw.cpp45
-rw-r--r--tools/editor/create_dialog.cpp3
-rw-r--r--tools/editor/io_plugins/editor_scene_import_plugin.cpp2
9 files changed, 68 insertions, 49 deletions
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index d3d8b2d9f6..5be3639d9f 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -8663,7 +8663,7 @@
<return type="bool">
</return>
<description>
- Returns whether this color picker is in raw mode or not
+ Returns whether this color picker is in raw mode or not, raw mode will allow the color R, G, B component values to go beyond 1, you have to consider that the max value for color components is 1, going beyond that value will not have effect in the color, but can be used for special operations that require it (like tinting without darkening or rendering sprites in HDR).
</description>
</method>
<method name="set_color">
@@ -8684,7 +8684,7 @@
<argument index="0" name="mode" type="bool">
</argument>
<description>
- When set to true, every color channel will be represented as a value from 0 to 1, insetead of 0, 255.
+ Set whether this color picker is using raw mode or not, see [method is_raw_mode].
</description>
</method>
</methods>
@@ -12999,6 +12999,11 @@
Return the font descent (number of pixels below the baseline).
</description>
</method>
+ <method name="update_changes">
+ <description>
+ After editing a font (changing size, ascent, char rects, etc.). Call this function to propagate changes to controls that might use it.
+ </description>
+ </method>
<method name="get_height" qualifiers="const">
<return type="float">
</return>
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 06f8c27957..c8bd9749df 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -140,14 +140,13 @@ void ColorPicker::_value_changed(double) {
if (updating)
return;
- for(int i=0;i<3;i++) {
+ for(int i=0;i<4;i++) {
color.components[i] = scroll[i]->get_val()/(raw_mode_enabled?1.0:255.0);
}
- color.components[3] = scroll[3]->get_val()/255.0;
set_color(color);
- c_text->set_text(color.to_html(edit_alpha && color.a<1));
+ _update_text_value();
emit_signal("color_changed",color);
@@ -174,22 +173,16 @@ void ColorPicker::_update_color() {
for(int i=0;i<4;i++) {
scroll[i]->set_max(255);
scroll[i]->set_step(0.01);
- if (raw_mode_enabled && i != 3)
+ if (raw_mode_enabled) {
+ if (i == 3)
+ scroll[i]->set_max(1);
scroll[i]->set_val(color.components[i]);
- else
- scroll[i]->set_val(color.components[i]*255);
+ } else {
+ scroll[i]->set_val(color.components[i] * 255);
+ }
}
- if (text_is_constructor) {
- String t = "Color("+String::num(color.r)+","+String::num(color.g)+","+String::num(color.b);
- if (edit_alpha && color.a<1)
- t+=(","+String::num(color.a)+")") ;
- else
- t+=")";
- c_text->set_text(t);
- } else {
- c_text->set_text(color.to_html(edit_alpha && color.a<1));
- }
+ _update_text_value();
sample->update();
updating=false;
@@ -262,6 +255,20 @@ bool ColorPicker::is_raw_mode() const {
return raw_mode_enabled;
}
+
+void ColorPicker::_update_text_value() {
+ if (text_is_constructor) {
+ String t = "Color("+String::num(color.r)+","+String::num(color.g)+","+String::num(color.b);
+ if (edit_alpha && color.a<1)
+ t+=(","+String::num(color.a)+")") ;
+ else
+ t+=")";
+ c_text->set_text(t);
+ } else {
+ c_text->set_text(color.to_html(edit_alpha && color.a<1));
+ }
+}
+
void ColorPicker::_sample_draw() {
sample->draw_rect(Rect2(Point2(),Size2(256,20)),color);
}
@@ -271,12 +278,12 @@ void ColorPicker::_hsv_draw(int p_wich,Control* c)
if (!c)
return;
if (p_wich==0) {
- int x=c->get_size().x*s;
- int y=c->get_size().y-c->get_size().y*v;
+ int x = CLAMP(c->get_size().x * s, 0, c->get_size().x);
+ int y = CLAMP(c->get_size().y-c->get_size().y * v, 0, c->get_size().y);
Color col = color;
col.a=1;
c->draw_line(Point2(x,0),Point2(x,c->get_size().y),col.inverted());
- c->draw_line(Point2(0,y),Point2(c->get_size().x,y),col.inverted());
+ c->draw_line(Point2(0, y),Point2(c->get_size().x, y),col.inverted());
c->draw_line(Point2(x,y),Point2(x,y),Color(1,1,1),2);
} else if (p_wich==1) {
int y=c->get_size().y-c->get_size().y*h;
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index b9ef1f1e2f..5e2cc57274 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -80,6 +80,7 @@ private:
void _update_controls();
void _update_color();
void _update_presets();
+ void _update_text_value();
void _text_type_toggled();
void _sample_draw();
void _hsv_draw(int p_wich,Control *c);
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 46b64ce401..50b44c55a9 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1007,12 +1007,13 @@ void TextEdit::_notification(int p_what) {
cursor_pos.y += (get_row_height() - 3);
}
+ int caret_w = (str[j]=='\t') ? cache.font->get_char_size(' ').width : char_w;
if (draw_caret) {
if (insert_mode) {
int caret_h = (block_caret) ? 4 : 1;
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(char_w,caret_h)),cache.caret_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(caret_w,caret_h)),cache.caret_color);
} else {
- int caret_w = (block_caret) ? char_w : 1;
+ caret_w = (block_caret) ? caret_w : 1;
VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(caret_w,get_row_height())),cache.caret_color);
}
}
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 6ad8a95565..1afa3fec19 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -71,6 +71,11 @@ void Font::draw(RID p_canvas_item, const Point2& p_pos, const String& p_text, co
}
}
+void Font::update_changes() {
+
+ emit_changed();
+}
+
void Font::_bind_methods() {
ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","string","modulate","clip_w"),&Font::draw,DEFVAL(Color(1,1,1)),DEFVAL(-1));
@@ -80,6 +85,7 @@ void Font::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_distance_field_hint"),&Font::is_distance_field_hint);
ObjectTypeDB::bind_method(_MD("get_string_size","string"),&Font::get_string_size);
ObjectTypeDB::bind_method(_MD("draw_char","canvas_item","pos","char","next","modulate"),&Font::draw_char,DEFVAL(-1),DEFVAL(Color(1,1,1)));
+ ObjectTypeDB::bind_method(_MD("update_changes"),&Font::update_changes);
}
diff --git a/scene/resources/font.h b/scene/resources/font.h
index 67836564cd..fe4558f9e3 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -61,6 +61,7 @@ public:
void draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate=Color(1,1,1)) const;
virtual float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char, CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const=0;
+ void update_changes();
Font();
};
diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp
index 35f19605df..ba0358a1f2 100644
--- a/servers/physics_2d/body_pair_2d_sw.cpp
+++ b/servers/physics_2d/body_pair_2d_sw.cpp
@@ -298,19 +298,17 @@ bool BodyPair2DSW::setup(float p_step) {
if (A->is_using_one_way_collision()) {
Vector2 direction = A->get_one_way_collision_direction();
bool valid=false;
- for(int i=0;i<contact_count;i++) {
- Contact& c = contacts[i];
-
- if (c.normal.dot(direction)<0)
- continue;
- if (B->get_linear_velocity().dot(direction)<0)
- continue;
-
- if (!c.reused) {
- continue;
+ if (B->get_linear_velocity().dot(direction)>=0){
+ for(int i=0;i<contact_count;i++) {
+ Contact& c = contacts[i];
+ if (!c.reused)
+ continue;
+ if (c.normal.dot(direction)<0)
+ continue;
+
+ valid=true;
+ break;
}
-
- valid=true;
}
if (!valid) {
@@ -323,20 +321,17 @@ bool BodyPair2DSW::setup(float p_step) {
if (B->is_using_one_way_collision()) {
Vector2 direction = B->get_one_way_collision_direction();
bool valid=false;
- for(int i=0;i<contact_count;i++) {
-
- Contact& c = contacts[i];
-
- if (c.normal.dot(direction)<0)
- continue;
- if (A->get_linear_velocity().dot(direction)<0)
- continue;
-
- if (!c.reused) {
- continue;
+ if (A->get_linear_velocity().dot(direction)>=0){
+ for(int i=0;i<contact_count;i++) {
+ Contact& c = contacts[i];
+ if (!c.reused)
+ continue;
+ if (c.normal.dot(direction)<0)
+ continue;
+
+ valid=true;
+ break;
}
-
- valid=true;
}
if (!valid) {
collided=false;
diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp
index 210b799f3d..07d1566ab8 100644
--- a/tools/editor/create_dialog.cpp
+++ b/tools/editor/create_dialog.cpp
@@ -154,6 +154,9 @@ void CreateDialog::_update_search() {
TreeItem *root = search_options->create_item();
root->set_text(0,base_type);
+ if (has_icon(base_type,"EditorIcons")) {
+ root->set_icon(0,get_icon(base_type,"EditorIcons"));
+ }
List<StringName>::Element *I=type_list.front();
TreeItem *to_select=NULL;
diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
index e24412d4ef..61e92309eb 100644
--- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
@@ -756,7 +756,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) {
}
- String save_file = save_path->get_text().plus_file(import_path->get_text().get_file().basename()+".scn");
+ String save_file = save_path->get_text().plus_file(import_path->get_text().get_file().basename()+".tscn");
print_line("Saving to: "+save_file);