summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/control.cpp1
-rw-r--r--scene/gui/item_list.cpp1
-rw-r--r--scene/gui/label.cpp35
-rw-r--r--scene/gui/line_edit.cpp13
-rw-r--r--scene/gui/scroll_container.cpp2
-rw-r--r--scene/gui/tabs.cpp8
-rw-r--r--scene/gui/text_edit.cpp9
7 files changed, 42 insertions, 27 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 46c3a44e98..f9b7d828f4 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -2983,7 +2983,6 @@ void Control::_bind_methods() {
BIND_VMETHOD(MethodInfo("_structured_text_parser", PropertyInfo(Variant::ARRAY, "args"), PropertyInfo(Variant::STRING, "text")));
BIND_VMETHOD(MethodInfo("_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
- BIND_VMETHOD(MethodInfo("_unhandled_key_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
BIND_VMETHOD(MethodInfo(Variant::VECTOR2, "_get_minimum_size"));
MethodInfo get_drag_data = MethodInfo("get_drag_data", PropertyInfo(Variant::VECTOR2, "position"));
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 53fe5712c7..5be7804ac1 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -78,6 +78,7 @@ void ItemList::add_icon_item(const Ref<Texture2D> &p_item, bool p_selectable) {
item.icon_region = Rect2i();
item.icon_modulate = Color(1, 1, 1, 1);
//item.text=p_item;
+ item.text_buf.instance();
item.selectable = p_selectable;
item.selected = false;
item.disabled = false;
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index e83c062e8a..566d77e3fd 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -64,16 +64,17 @@ bool Label::is_uppercase() const {
}
int Label::get_line_height(int p_line) const {
+ Ref<Font> font = get_theme_font("font");
if (p_line >= 0 && p_line < lines_rid.size()) {
- return TS->shaped_text_get_size(lines_rid[p_line]).y;
+ return TS->shaped_text_get_size(lines_rid[p_line]).y + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM);
} else if (lines_rid.size() > 0) {
int h = 0;
for (int i = 0; i < lines_rid.size(); i++) {
- h = MAX(h, TS->shaped_text_get_size(lines_rid[i]).y);
+ h = MAX(h, TS->shaped_text_get_size(lines_rid[i]).y) + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM);
}
return h;
} else {
- return get_theme_font("font")->get_height(get_theme_font_size("font_size"));
+ return font->get_height(get_theme_font_size("font_size"));
}
}
@@ -138,6 +139,7 @@ void Label::_shape() {
void Label::_update_visible() {
int line_spacing = get_theme_constant("line_spacing", "Label");
Ref<StyleBox> style = get_theme_stylebox("normal", "Label");
+ Ref<Font> font = get_theme_font("font");
int lines_visible = lines_rid.size();
if (max_lines_visible >= 0 && lines_visible > max_lines_visible) {
@@ -147,7 +149,7 @@ void Label::_update_visible() {
minsize.height = 0;
int last_line = MIN(lines_rid.size(), lines_visible + lines_skipped);
for (int64_t i = lines_skipped; i < last_line; i++) {
- minsize.height += TS->shaped_text_get_size(lines_rid[i]).y + line_spacing;
+ minsize.height += TS->shaped_text_get_size(lines_rid[i]).y + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM) + line_spacing;
if (minsize.height > (get_size().height - style->get_minimum_size().height + line_spacing)) {
break;
}
@@ -197,7 +199,7 @@ void Label::_notification(int p_what) {
// Get number of lines to fit to the height.
for (int64_t i = lines_skipped; i < lines_rid.size(); i++) {
- total_h += TS->shaped_text_get_size(lines_rid[i]).y + line_spacing;
+ total_h += TS->shaped_text_get_size(lines_rid[i]).y + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM) + line_spacing;
if (total_h > (get_size().height - style->get_minimum_size().height + line_spacing)) {
break;
}
@@ -213,7 +215,7 @@ void Label::_notification(int p_what) {
// Get real total height.
total_h = 0;
for (int64_t i = lines_skipped; i < last_line; i++) {
- total_h += TS->shaped_text_get_size(lines_rid[i]).y + line_spacing;
+ total_h += TS->shaped_text_get_size(lines_rid[i]).y + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM) + line_spacing;
}
int vbegin = 0, vsep = 0;
@@ -249,8 +251,10 @@ void Label::_notification(int p_what) {
if (percent_visible < 1) {
int total_glyphs = 0;
for (int i = lines_skipped; i < last_line; i++) {
- const Vector<TextServer::Glyph> glyphs = TS->shaped_text_get_glyphs(lines_rid[i]);
- for (int j = 0; j < glyphs.size(); j++) {
+ const Vector<TextServer::Glyph> visual = TS->shaped_text_get_glyphs(lines_rid[i]);
+ const TextServer::Glyph *glyphs = visual.ptr();
+ int gl_size = visual.size();
+ for (int j = 0; j < gl_size; j++) {
if ((glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
total_glyphs++;
}
@@ -263,7 +267,7 @@ void Label::_notification(int p_what) {
ofs.y = style->get_offset().y + vbegin;
for (int i = lines_skipped; i < last_line; i++) {
ofs.x = 0;
- ofs.y += TS->shaped_text_get_ascent(lines_rid[i]);
+ ofs.y += TS->shaped_text_get_ascent(lines_rid[i]) + font->get_spacing(Font::SPACING_TOP);
switch (align) {
case ALIGN_FILL:
case ALIGN_LEFT: {
@@ -285,11 +289,13 @@ void Label::_notification(int p_what) {
} break;
}
- const Vector<TextServer::Glyph> glyphs = TS->shaped_text_get_glyphs(lines_rid[i]);
+ const Vector<TextServer::Glyph> visual = TS->shaped_text_get_glyphs(lines_rid[i]);
+ const TextServer::Glyph *glyphs = visual.ptr();
+ int gl_size = visual.size();
float x = ofs.x;
int outlines_drawn = glyhps_drawn;
- for (int j = 0; j < glyphs.size(); j++) {
+ for (int j = 0; j < gl_size; j++) {
for (int k = 0; k < glyphs[j].repeat; k++) {
if (glyphs[j].font_rid != RID()) {
if (font_color_shadow.a > 0) {
@@ -318,7 +324,7 @@ void Label::_notification(int p_what) {
}
ofs.x = x;
- for (int j = 0; j < glyphs.size(); j++) {
+ for (int j = 0; j < gl_size; j++) {
for (int k = 0; k < glyphs[j].repeat; k++) {
if (glyphs[j].font_rid != RID()) {
TS->font_draw_glyph(glyphs[j].font_rid, ci, glyphs[j].font_size, ofs + Vector2(glyphs[j].x_off, glyphs[j].y_off), glyphs[j].index, font_color);
@@ -337,7 +343,7 @@ void Label::_notification(int p_what) {
}
}
- ofs.y += TS->shaped_text_get_descent(lines_rid[i]) + vsep + line_spacing;
+ ofs.y += TS->shaped_text_get_descent(lines_rid[i]) + vsep + line_spacing + font->get_spacing(Font::SPACING_BOTTOM);
}
}
@@ -381,12 +387,13 @@ int Label::get_line_count() const {
}
int Label::get_visible_line_count() const {
+ Ref<Font> font = get_theme_font("font");
Ref<StyleBox> style = get_theme_stylebox("normal");
int line_spacing = get_theme_constant("line_spacing");
int lines_visible = 0;
float total_h = 0;
for (int64_t i = lines_skipped; i < lines_rid.size(); i++) {
- total_h += TS->shaped_text_get_size(lines_rid[i]).y + line_spacing;
+ total_h += TS->shaped_text_get_size(lines_rid[i]).y + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM) + line_spacing;
if (total_h > (get_size().height - style->get_minimum_size().height + line_spacing)) {
break;
}
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 2eaa814419..d06bdaad91 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -732,6 +732,7 @@ void LineEdit::_notification(int p_what) {
style = get_theme_stylebox("read_only");
draw_caret = false;
}
+ Ref<Font> font = get_theme_font("font");
style->draw(ci, Rect2(Point2(), size));
@@ -742,7 +743,7 @@ void LineEdit::_notification(int p_what) {
int x_ofs = 0;
bool using_placeholder = text.empty() && ime_text.empty();
float text_width = TS->shaped_text_get_size(text_rid).x;
- float text_height = TS->shaped_text_get_size(text_rid).y;
+ float text_height = TS->shaped_text_get_size(text_rid).y + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM);
switch (align) {
case ALIGN_FILL:
@@ -833,14 +834,16 @@ void LineEdit::_notification(int p_what) {
RenderingServer::get_singleton()->canvas_item_add_rect(ci, rect, selection_color);
}
}
- const Vector<TextServer::Glyph> glyphs = TS->shaped_text_get_glyphs(text_rid);
+ const Vector<TextServer::Glyph> visual = TS->shaped_text_get_glyphs(text_rid);
+ const TextServer::Glyph *glyphs = visual.ptr();
+ int gl_size = visual.size();
// Draw text.
ofs.y += TS->shaped_text_get_ascent(text_rid);
- for (int i = 0; i < glyphs.size(); i++) {
+ for (int i = 0; i < gl_size; i++) {
bool selected = selection.enabled && glyphs[i].start >= selection.begin && glyphs[i].end <= selection.end;
for (int j = 0; j < glyphs[i].repeat; j++) {
- if (ceil(ofs.x) >= x_ofs && floor(ofs.x + glyphs[i].advance) <= ofs_max) {
+ if (ceil(ofs.x) >= x_ofs && (ofs.x + glyphs[i].advance) <= ofs_max) {
if (glyphs[i].font_rid != RID()) {
TS->font_draw_glyph(glyphs[i].font_rid, ci, glyphs[i].font_size, ofs + Vector2(glyphs[i].x_off, glyphs[i].y_off), glyphs[i].index, selected ? font_color_selected : font_color);
} else if ((glyphs[i].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
@@ -1570,7 +1573,7 @@ Size2 LineEdit::get_minimum_size() const {
min_size.width = MAX(min_size.width, full_width + space_size);
}
- min_size.height = MAX(TS->shaped_text_get_size(text_rid).y, font->get_height(font_size));
+ min_size.height = MAX(TS->shaped_text_get_size(text_rid).y + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM), font->get_height(font_size));
// Take icons into account.
bool using_placeholder = text.empty() && ime_text.empty();
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 62ccd55e89..3a54ac7443 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -431,6 +431,7 @@ void ScrollContainer::update_scrollbars() {
v_scroll->set_max(min.height);
if (hide_scroll_v) {
+ v_scroll->set_page(size.height);
v_scroll->hide();
scroll.y = 0;
} else {
@@ -446,6 +447,7 @@ void ScrollContainer::update_scrollbars() {
h_scroll->set_max(min.width);
if (hide_scroll_h) {
+ h_scroll->set_page(size.width);
h_scroll->hide();
scroll.x = 0;
} else {
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index 06e55deacb..5b26428e45 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -153,7 +153,7 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
if (cb_pressing && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
if (cb_hover != -1) {
//pressed
- emit_signal("tab_close", cb_hover);
+ emit_signal("tab_closed", cb_hover);
}
cb_pressing = false;
@@ -641,7 +641,7 @@ void Tabs::_update_hover() {
}
if (hover != hover_now) {
hover = hover_now;
- emit_signal("tab_hover", hover);
+ emit_signal("tab_hovered", hover);
}
if (hover_buttons == -1) { // no hover
@@ -1114,8 +1114,8 @@ void Tabs::_bind_methods() {
ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("right_button_pressed", PropertyInfo(Variant::INT, "tab")));
- ADD_SIGNAL(MethodInfo("tab_close", PropertyInfo(Variant::INT, "tab")));
- ADD_SIGNAL(MethodInfo("tab_hover", PropertyInfo(Variant::INT, "tab")));
+ ADD_SIGNAL(MethodInfo("tab_closed", PropertyInfo(Variant::INT, "tab")));
+ ADD_SIGNAL(MethodInfo("tab_hovered", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("reposition_active_tab_request", PropertyInfo(Variant::INT, "idx_to")));
ADD_SIGNAL(MethodInfo("tab_clicked", PropertyInfo(Variant::INT, "tab")));
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index b9818e139f..906dd94fff 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1141,7 +1141,7 @@ void TextEdit::_notification(int p_what) {
// Draw line.
RID rid = ldata->get_line_rid(line_wrap_index);
- float text_height = TS->shaped_text_get_size(rid).y;
+ float text_height = TS->shaped_text_get_size(rid).y + cache.font->get_spacing(Font::SPACING_TOP) + cache.font->get_spacing(Font::SPACING_BOTTOM);
if (rtl) {
char_margin = size.width - char_margin - TS->shaped_text_get_size(rid).x;
@@ -1240,10 +1240,13 @@ void TextEdit::_notification(int p_what) {
ofs_y += (row_height - text_height) / 2;
- const Vector<TextServer::Glyph> glyphs = TS->shaped_text_get_glyphs(rid);
+ const Vector<TextServer::Glyph> visual = TS->shaped_text_get_glyphs(rid);
+ const TextServer::Glyph *glyphs = visual.ptr();
+ int gl_size = visual.size();
+
ofs_y += ldata->get_line_ascent(line_wrap_index);
float char_ofs = 0.f;
- for (int j = 0; j < glyphs.size(); j++) {
+ for (int j = 0; j < gl_size; j++) {
if (color_map.has(glyphs[j].start)) {
current_color = color_map[glyphs[j].start].get("color");
if (readonly && current_color.a > cache.font_color_readonly.a) {