summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/popup_menu.cpp1
-rw-r--r--scene/gui/texture_rect.cpp33
-rw-r--r--scene/gui/tree.cpp5
3 files changed, 24 insertions, 15 deletions
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index e6333a6179..87f17838cf 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -309,6 +309,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
bool was_during_grabbed_click = during_grabbed_click;
during_grabbed_click = false;
+ initial_button_mask = 0;
int over = _get_mouse_over(b->get_position());
diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp
index 9ac2415575..514eff358e 100644
--- a/scene/gui/texture_rect.cpp
+++ b/scene/gui/texture_rect.cpp
@@ -36,8 +36,9 @@ void TextureRect::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
- if (texture.is_null())
+ if (texture.is_null()) {
return;
+ }
Size2 size;
Point2 offset;
@@ -85,11 +86,11 @@ void TextureRect::_notification(int p_what) {
size = get_size();
Size2 tex_size = texture->get_size();
- Size2 scaleSize(size.width / tex_size.width, size.height / tex_size.height);
- float scale = scaleSize.width > scaleSize.height ? scaleSize.width : scaleSize.height;
- Size2 scaledTexSize = tex_size * scale;
+ Size2 scale_size(size.width / tex_size.width, size.height / tex_size.height);
+ float scale = scale_size.width > scale_size.height ? scale_size.width : scale_size.height;
+ Size2 scaled_tex_size = tex_size * scale;
- region.position = ((scaledTexSize - size) / scale).abs() / 2.0f;
+ region.position = ((scaled_tex_size - size) / scale).abs() / 2.0f;
region.size = size / scale;
} break;
}
@@ -107,11 +108,13 @@ void TextureRect::_notification(int p_what) {
Size2 TextureRect::get_minimum_size() const {
- if (!expand && !texture.is_null())
+ if (!expand && !texture.is_null()) {
return texture->get_size();
- else
+ } else {
return Size2();
+ }
}
+
void TextureRect::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &TextureRect::set_texture);
@@ -152,22 +155,21 @@ void TextureRect::_texture_changed() {
void TextureRect::set_texture(const Ref<Texture> &p_tex) {
- if (p_tex == texture)
+ if (p_tex == texture) {
return;
+ }
- if (texture.is_valid())
+ if (texture.is_valid()) {
texture->disconnect(CoreStringNames::get_singleton()->changed, this, "_texture_changed");
+ }
texture = p_tex;
- if (texture.is_valid())
+ if (texture.is_valid()) {
texture->connect(CoreStringNames::get_singleton()->changed, this, "_texture_changed");
+ }
update();
- /*
- if (texture.is_valid())
- texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
- */
minimum_size_changed();
}
@@ -182,6 +184,7 @@ void TextureRect::set_expand(bool p_expand) {
update();
minimum_size_changed();
}
+
bool TextureRect::has_expand() const {
return expand;
@@ -203,6 +206,7 @@ void TextureRect::set_flip_h(bool p_flip) {
hflip = p_flip;
update();
}
+
bool TextureRect::is_flipped_h() const {
return hflip;
@@ -213,6 +217,7 @@ void TextureRect::set_flip_v(bool p_flip) {
vflip = p_flip;
update();
}
+
bool TextureRect::is_flipped_v() const {
return vflip;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index f9d1b9e49a..3cf17bd210 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -3426,7 +3426,10 @@ int Tree::get_item_offset(TreeItem *p_item) const {
if (it == p_item)
return ofs;
- ofs += compute_item_height(it) + cache.vseparation;
+ ofs += compute_item_height(it);
+ if (it != root || !hide_root) {
+ ofs += cache.vseparation;
+ }
if (it->children && !it->collapsed) {