summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/color_picker.cpp1
-rw-r--r--scene/gui/popup_menu.cpp5
-rw-r--r--scene/gui/rich_text_label.cpp31
-rw-r--r--scene/gui/text_edit.cpp22
-rw-r--r--scene/gui/tree.cpp32
-rw-r--r--scene/register_scene_types.cpp74
-rw-r--r--scene/resources/default_theme/default_theme.cpp4
-rw-r--r--scene/resources/environment.cpp2
8 files changed, 100 insertions, 71 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 95298f5a18..63478886c6 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -209,6 +209,7 @@ Color ColorPicker::get_pick_color() const {
}
void ColorPicker::add_preset(const Color &p_color) {
+
if (presets.find(p_color)) {
presets.move_to_back(presets.find(p_color));
} else {
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 7999f50013..97f7c65cbe 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -122,8 +122,7 @@ int PopupMenu::_get_mouse_over(const Point2 &p_over) const {
for (int i = 0; i < items.size(); i++) {
- if (i > 0)
- ofs.y += vseparation;
+ ofs.y += vseparation;
float h;
if (!items[i].icon.is_null()) {
@@ -459,7 +458,7 @@ void PopupMenu::_notification(int p_what) {
if (i == mouse_over) {
- hover->draw(ci, Rect2(item_ofs + Point2(-hseparation, -vseparation), Size2(get_size().width - style->get_minimum_size().width + hseparation * 2, h + vseparation * 2)));
+ hover->draw(ci, Rect2(item_ofs + Point2(-hseparation, -vseparation / 2), Size2(get_size().width - style->get_minimum_size().width + hseparation * 2, h + vseparation)));
}
if (items[i].separator) {
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 4f2cfccd4a..bf048ea1b6 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -371,19 +371,20 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
cw = tab_size * font->get_char_size(' ').width;
}
- if (underline) {
- Color uc = color;
- uc.a *= 0.5;
- int uy = y + lh - fh + ascent + 2;
- float underline_width = 1.0;
-#ifdef TOOLS_ENABLED
- underline_width *= EDSCALE;
-#endif
- VS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + pofs, uy), p_ofs + Point2(align_ofs + pofs + cw, uy), uc, underline_width);
- }
ofs += cw;
}
}
+
+ if (underline) {
+ Color uc = color;
+ uc.a *= 0.5;
+ int uy = y + lh - fh + ascent + 2;
+ float underline_width = 1.0;
+#ifdef TOOLS_ENABLED
+ underline_width *= EDSCALE;
+#endif
+ VS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, underline_width);
+ }
}
ADVANCE(fw);
@@ -451,6 +452,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
table->columns[i].width = 0;
}
//compute minimum width for each cell
+ const int available_width = p_width - hseparation * (table->columns.size() - 1) - wofs;
+
for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) {
ERR_CONTINUE(E->get()->type != ITEM_FRAME); //children should all be frames
ItemFrame *frame = static_cast<ItemFrame *>(E->get());
@@ -461,7 +464,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
for (int i = 0; i < frame->lines.size(); i++) {
- _process_line(frame, Point2(), ly, p_width, i, PROCESS_CACHE, cfont, Color());
+ _process_line(frame, Point2(), ly, available_width, i, PROCESS_CACHE, cfont, Color());
table->columns[column].min_width = MAX(table->columns[column].min_width, frame->lines[i].minimum_width);
}
idx++;
@@ -470,11 +473,11 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
//compute available width and total ratio (for expanders)
int total_ratio = 0;
- int available_width = p_width - hseparation * (table->columns.size() - 1);
+ int remaining_width = available_width;
table->total_width = hseparation;
for (int i = 0; i < table->columns.size(); i++) {
- available_width -= table->columns[i].min_width;
+ remaining_width -= table->columns[i].min_width;
if (table->columns[i].expand)
total_ratio += table->columns[i].expand_ratio;
}
@@ -484,7 +487,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
for (int i = 0; i < table->columns.size(); i++) {
table->columns[i].width = table->columns[i].min_width;
if (table->columns[i].expand)
- table->columns[i].width += table->columns[i].expand_ratio * available_width / total_ratio;
+ table->columns[i].width += table->columns[i].expand_ratio * remaining_width / total_ratio;
table->total_width += table->columns[i].width + hseparation;
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 9247fc943b..95c4b9058d 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1746,15 +1746,15 @@ void TextEdit::indent_left() {
void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) const {
float rows = p_mouse.y;
- rows -= cache.style_normal->get_margin(MARGIN_TOP);
rows /= get_row_height();
- int lsp = get_line_scroll_pos(true);
- int row = cursor.line_ofs + (rows + (round(v_scroll->get_value()) - lsp));
+ rows += v_scroll->get_value();
+ int row = Math::floor(rows);
if (is_hiding_enabled()) {
// row will be offset by the hidden rows
- int f_ofs = num_lines_from(CLAMP(cursor.line_ofs, 0, text.size() - 1), MIN(rows + 1, text.size() - cursor.line_ofs)) - 1;
- row = cursor.line_ofs + (f_ofs + (round(v_scroll->get_value()) - lsp));
+ int lsp = get_line_scroll_pos(true);
+ int f_ofs = num_lines_from(CLAMP(cursor.line_ofs, 0, text.size() - 1), MIN(row + 1 - cursor.line_ofs, text.size() - cursor.line_ofs)) - 1;
+ row = cursor.line_ofs + f_ofs;
row = CLAMP(row, 0, text.size() - num_lines_from(text.size() - 1, -1));
}
@@ -1822,10 +1822,18 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (mb->is_pressed()) {
if (mb->get_button_index() == BUTTON_WHEEL_UP && !mb->get_command()) {
- _scroll_up(3 * mb->get_factor());
+ if (mb->get_shift()) {
+ h_scroll->set_value(h_scroll->get_value() - (100 * mb->get_factor()));
+ } else {
+ _scroll_up(3 * mb->get_factor());
+ }
}
if (mb->get_button_index() == BUTTON_WHEEL_DOWN && !mb->get_command()) {
- _scroll_down(3 * mb->get_factor());
+ if (mb->get_shift()) {
+ h_scroll->set_value(h_scroll->get_value() + (100 * mb->get_factor()));
+ } else {
+ _scroll_down(3 * mb->get_factor());
+ }
}
if (mb->get_button_index() == BUTTON_WHEEL_LEFT) {
h_scroll->set_value(h_scroll->get_value() - (100 * mb->get_factor()));
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 08f1bdff3d..b1a421c24f 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1423,17 +1423,33 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
#endif
Point2i parent_pos = Point2i(parent_ofs - cache.arrow->get_width() / 2, p_pos.y + label_h / 2 + cache.arrow->get_height() / 2) - cache.offset + p_draw_ofs;
- VisualServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x - Math::floor(line_width / 2), root_pos.y), cache.relationship_line_color, line_width);
- VisualServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y), parent_pos, cache.relationship_line_color, line_width);
+
+ if (root_pos.y + line_width >= 0) {
+ VisualServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x - Math::floor(line_width / 2), root_pos.y), cache.relationship_line_color, line_width);
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y), parent_pos, cache.relationship_line_color, line_width);
+ }
+
+ if (htotal < 0) {
+ return -1;
+ }
}
- int child_h = draw_item(children_pos, p_draw_ofs, p_draw_size, c);
+ if (htotal >= 0) {
+ int child_h = draw_item(children_pos, p_draw_ofs, p_draw_size, c);
- if (child_h < 0 && cache.draw_relationship_lines == 0)
- return -1; // break, stop drawing, no need to anymore
+ if (child_h < 0) {
+ if (cache.draw_relationship_lines == 0) {
+ return -1; // break, stop drawing, no need to anymore
+ } else {
+ htotal = -1;
+ children_pos.y = cache.offset.y + p_draw_size.height;
+ }
+ } else {
+ htotal += child_h;
+ children_pos.y += child_h;
+ }
+ }
- htotal += child_h;
- children_pos.y += child_h;
c = c->next;
}
}
@@ -2352,8 +2368,6 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
last_keypress = 0;
}
} break;
-
- last_keypress = 0;
}
}
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 4036735807..998c790c94 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -220,31 +220,17 @@ void register_scene_types() {
resource_loader_theme = memnew(ResourceFormatLoaderTheme);
ResourceLoader::add_resource_format_loader(resource_loader_theme);
- bool default_theme_hidpi = GLOBAL_DEF("gui/theme/use_hidpi", false);
- ProjectSettings::get_singleton()->set_custom_property_info("gui/theme/use_hidpi", PropertyInfo(Variant::BOOL, "gui/theme/use_hidpi", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
- String theme_path = GLOBAL_DEF("gui/theme/custom", "");
- ProjectSettings::get_singleton()->set_custom_property_info("gui/theme/custom", PropertyInfo(Variant::STRING, "gui/theme/custom", PROPERTY_HINT_FILE, "*.tres,*.res", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
- String font_path = GLOBAL_DEF("gui/theme/custom_font", "");
- ProjectSettings::get_singleton()->set_custom_property_info("gui/theme/custom_font", PropertyInfo(Variant::STRING, "gui/theme/custom_font", PROPERTY_HINT_FILE, "*.tres,*.res,*.font", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
+ resource_saver_text = memnew(ResourceFormatSaverText);
+ ResourceSaver::add_resource_format_saver(resource_saver_text, true);
- bool has_theme = false;
- if (theme_path != String()) {
- Ref<Theme> theme = ResourceLoader::load(theme_path);
- if (theme.is_valid()) {
- Theme::set_default(theme);
- has_theme = true;
- } else {
- ERR_PRINTS("Error loading custom theme '" + theme_path + "'");
- }
- }
+ resource_loader_text = memnew(ResourceFormatLoaderText);
+ ResourceLoader::add_resource_format_loader(resource_loader_text, true);
- if (!has_theme) {
- Ref<Font> font;
- if (font_path != String()) {
- font = ResourceLoader::load(font_path);
- }
- make_default_theme(default_theme_hidpi, font);
- }
+ resource_saver_shader = memnew(ResourceFormatSaverShader);
+ ResourceSaver::add_resource_format_saver(resource_saver_shader, true);
+
+ resource_loader_shader = memnew(ResourceFormatLoaderShader);
+ ResourceLoader::add_resource_format_loader(resource_loader_shader, true);
OS::get_singleton()->yield(); //may take time to init
@@ -604,24 +590,42 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
- resource_saver_text = memnew(ResourceFormatSaverText);
- ResourceSaver::add_resource_format_saver(resource_saver_text, true);
-
- resource_loader_text = memnew(ResourceFormatLoaderText);
- ResourceLoader::add_resource_format_loader(resource_loader_text, true);
-
- resource_saver_shader = memnew(ResourceFormatSaverShader);
- ResourceSaver::add_resource_format_saver(resource_saver_shader, true);
-
- resource_loader_shader = memnew(ResourceFormatLoaderShader);
- ResourceLoader::add_resource_format_loader(resource_loader_shader, true);
-
for (int i = 0; i < 20; i++) {
GLOBAL_DEF("layer_names/2d_render/layer_" + itos(i + 1), "");
GLOBAL_DEF("layer_names/2d_physics/layer_" + itos(i + 1), "");
GLOBAL_DEF("layer_names/3d_render/layer_" + itos(i + 1), "");
GLOBAL_DEF("layer_names/3d_physics/layer_" + itos(i + 1), "");
}
+
+ bool default_theme_hidpi = GLOBAL_DEF("gui/theme/use_hidpi", false);
+ ProjectSettings::get_singleton()->set_custom_property_info("gui/theme/use_hidpi", PropertyInfo(Variant::BOOL, "gui/theme/use_hidpi", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
+ String theme_path = GLOBAL_DEF("gui/theme/custom", "");
+ ProjectSettings::get_singleton()->set_custom_property_info("gui/theme/custom", PropertyInfo(Variant::STRING, "gui/theme/custom", PROPERTY_HINT_FILE, "*.tres,*.res,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
+ String font_path = GLOBAL_DEF("gui/theme/custom_font", "");
+ ProjectSettings::get_singleton()->set_custom_property_info("gui/theme/custom_font", PropertyInfo(Variant::STRING, "gui/theme/custom_font", PROPERTY_HINT_FILE, "*.tres,*.res,*.font", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
+
+ Ref<Font> font;
+ if (font_path != String()) {
+ font = ResourceLoader::load(font_path);
+ if (!font.is_valid()) {
+ ERR_PRINTS("Error loading custom font '" + font_path + "'");
+ }
+ }
+
+ // Always make the default theme to avoid invalid default font/icon/style in the given theme
+ make_default_theme(default_theme_hidpi, font);
+
+ if (theme_path != String()) {
+ Ref<Theme> theme = ResourceLoader::load(theme_path);
+ if (theme.is_valid()) {
+ Theme::set_default(theme);
+ if (font.is_valid()) {
+ Theme::set_default_font(font);
+ }
+ } else {
+ ERR_PRINTS("Error loading custom theme '" + theme_path + "'");
+ }
+ }
}
void unregister_scene_types() {
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index b18583dfb1..a4049e4461 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -880,7 +880,7 @@ void make_default_theme(bool p_hidpi, Ref<Font> p_font) {
Ref<StyleBox> default_style;
Ref<Texture> default_icon;
- Ref<BitmapFont> default_font;
+ Ref<Font> default_font;
if (p_font.is_valid()) {
default_font = p_font;
} else if (p_hidpi) {
@@ -888,7 +888,7 @@ void make_default_theme(bool p_hidpi, Ref<Font> p_font) {
} else {
default_font = make_font2(_lodpi_font_height, _lodpi_font_ascent, _lodpi_font_charcount, &_lodpi_font_charrects[0][0], _lodpi_font_kerning_pair_count, &_lodpi_font_kerning_pairs[0][0], _lodpi_font_img_width, _lodpi_font_img_height, _lodpi_font_img_data);
}
- Ref<BitmapFont> large_font = default_font;
+ Ref<Font> large_font = default_font;
fill_default_theme(t, default_font, large_font, default_icon, default_style, p_hidpi ? 2.0 : 1.0);
Theme::set_default(t);
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index 6216893667..b2c91f90eb 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -1218,7 +1218,7 @@ Environment::Environment() {
ssao_radius2 = 0;
ssao_intensity2 = 1;
ssao_bias = 0.01;
- ssao_direct_light_affect = false;
+ ssao_direct_light_affect = 0.0;
ssao_blur = SSAO_BLUR_3x3;
set_ssao_edge_sharpness(4);
set_ssao_quality(SSAO_QUALITY_LOW);