summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/button_array.cpp14
-rw-r--r--scene/gui/button_array.h1
-rw-r--r--scene/gui/control.cpp2
-rw-r--r--scene/gui/dialogs.cpp4
-rw-r--r--scene/gui/item_list.cpp18
-rw-r--r--scene/gui/item_list.h1
-rw-r--r--scene/gui/label.cpp2
-rw-r--r--scene/gui/text_edit.cpp2
-rw-r--r--scene/gui/tree.cpp2
9 files changed, 34 insertions, 12 deletions
diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp
index c05b787bf5..2fd5f0df83 100644
--- a/scene/gui/button_array.cpp
+++ b/scene/gui/button_array.cpp
@@ -58,9 +58,10 @@ bool ButtonArray::_set(const StringName& p_name, const Variant& p_value) {
int idx=what.to_int();
ERR_FAIL_INDEX_V(idx,buttons.size(),false);
String f = n.get_slicec('/',2);
- if (f=="text")
+ if (f=="text") {
buttons[idx].text=p_value;
- else if (f=="tooltip")
+ buttons[idx].xl_text=XL_MESSAGE(p_value);
+ } else if (f=="tooltip")
buttons[idx].tooltip=p_value;
else if (f=="icon")
buttons[idx].icon=p_value;
@@ -146,7 +147,7 @@ Size2 ButtonArray::get_minimum_size() const {
Ref<Font> f = i==selected ? font_selected : font_normal;
Size2 ms;
- ms = f->get_string_size(buttons[i].text);
+ ms = f->get_string_size(buttons[i].xl_text);
if (buttons[i].icon.is_valid()) {
Size2 bs = buttons[i].icon->get_size();
@@ -275,7 +276,7 @@ void ButtonArray::_notification(int p_what) {
c=color_normal;
}
- Size2 ssize = f->get_string_size(buttons[i].text);
+ Size2 ssize = f->get_string_size(buttons[i].xl_text);
if (buttons[i].icon.is_valid()) {
ssize.x+=buttons[i].icon->get_width();
@@ -287,7 +288,7 @@ void ButtonArray::_notification(int p_what) {
text_ofs.x+=buttons[i].icon->get_width()+icon_sep;
}
- draw_string(f,text_ofs+r.pos,buttons[i].text,c);
+ draw_string(f,text_ofs+r.pos,buttons[i].xl_text,c);
buttons[i]._pos_cache=ofs;
buttons[i]._size_cache=s;
@@ -404,6 +405,7 @@ void ButtonArray::add_button(const String& p_text,const String& p_tooltip) {
Button button;
button.text=p_text;
+ button.xl_text=XL_MESSAGE(p_text);
button.tooltip=p_tooltip;
buttons.push_back(button);
update();
@@ -418,6 +420,7 @@ void ButtonArray::add_icon_button(const Ref<Texture>& p_icon,const String& p_tex
Button button;
button.text=p_text;
+ button.xl_text=XL_MESSAGE(p_text);
button.icon=p_icon;
button.tooltip=p_tooltip;
buttons.push_back(button);
@@ -432,6 +435,7 @@ void ButtonArray::set_button_text(int p_button, const String& p_text) {
ERR_FAIL_INDEX(p_button,buttons.size());
buttons[p_button].text=p_text;
+ buttons[p_button].xl_text=XL_MESSAGE(p_text);
update();
minimum_size_changed();
diff --git a/scene/gui/button_array.h b/scene/gui/button_array.h
index 37533695c9..4865ef0373 100644
--- a/scene/gui/button_array.h
+++ b/scene/gui/button_array.h
@@ -50,6 +50,7 @@ private:
struct Button {
String text;
+ String xl_text;
String tooltip;
Ref<Texture> icon;
mutable int _ms_cache;
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index e52afdffdf..cffe2ce218 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -30,7 +30,7 @@
#include "servers/visual_server.h"
#include "scene/main/viewport.h"
#include "scene/main/canvas_layer.h"
-#include "globals.h"
+#include "global_config.h"
#include "print_string.h"
#include "os/keyboard.h"
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 2f97ce2d51..72d3f0e8f8 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -272,7 +272,7 @@ void AcceptDialog::_update_child_rects() {
if (!c)
continue;
- if (c==hbc || c==label || c==get_close_button())
+ if (c==hbc || c==label || c==get_close_button() || c->is_set_as_toplevel())
continue;
c->set_pos(cpos);
@@ -299,7 +299,7 @@ Size2 AcceptDialog::get_minimum_size() const {
if (!c)
continue;
- if (c==hbc || c==label || c==const_cast<AcceptDialog*>(this)->get_close_button())
+ if (c==hbc || c==label || c==const_cast<AcceptDialog*>(this)->get_close_button() || c->is_set_as_toplevel())
continue;
Size2 cminsize = c->get_combined_minimum_size();
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 4e10f1d622..a35df53e52 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "item_list.h"
#include "os/os.h"
-#include "globals.h"
+#include "global_config.h"
void ItemList::add_item(const String& p_item,const Ref<Texture>& p_texture,bool p_selectable) {
@@ -1204,6 +1204,22 @@ int ItemList::get_item_at_pos(const Point2& p_pos, bool p_exact) const {
return closest;
}
+bool ItemList::is_pos_at_end_of_items(const Point2& p_pos) const {
+
+ if (items.empty())
+ return true;
+
+ Vector2 pos=p_pos;
+ Ref<StyleBox> bg = get_stylebox("bg");
+ pos-=bg->get_offset();
+ pos.y+=scroll_bar->get_value();
+
+ Rect2 endrect = items[items.size()-1].rect_cache;
+ return (pos.y > endrect.pos.y + endrect.size.y);
+
+}
+
+
String ItemList::get_tooltip(const Point2& p_pos) const {
int closest = get_item_at_pos(p_pos);
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index f4a864c782..35ffb1be9c 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -191,6 +191,7 @@ public:
virtual String get_tooltip(const Point2& p_pos) const;
int get_item_at_pos(const Point2& p_pos,bool p_exact=false) const;
+ bool is_pos_at_end_of_items(const Point2& p_pos) const;
void set_icon_scale(real_t p_scale);
real_t get_icon_scale() const;
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index dfcea30056..915eaa2f45 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "label.h"
#include "print_string.h"
-#include "globals.h"
+#include "global_config.h"
#include "translation.h"
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index cacb79268c..3f2eab8bef 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -32,7 +32,7 @@
#include "os/input.h"
#include "os/os.h"
-#include "globals.h"
+#include "global_config.h"
#include "message_queue.h"
#include "scene/main/viewport.h"
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 524ef2aae4..7bfc24079b 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -30,7 +30,7 @@
#include "print_string.h"
#include "os/os.h"
#include "os/keyboard.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/input.h"
#include "scene/main/viewport.h"