summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scene/gui/texture_button.cpp13
-rw-r--r--scene/gui/texture_button.h6
2 files changed, 11 insertions, 8 deletions
diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp
index e8967927cb..1a7087b7ef 100644
--- a/scene/gui/texture_button.cpp
+++ b/scene/gui/texture_button.cpp
@@ -53,6 +53,10 @@ Size2 TextureButton::get_minimum_size() const {
bool TextureButton::has_point(const Point2& p_point) const {
+ if (scale[0] <= 0 || scale[1] <= 0) {
+ return false;
+ }
+
Point2 ppos = p_point/scale;
if (click_mask.is_valid()) {
@@ -159,7 +163,7 @@ void TextureButton::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture"));
ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture"));
ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ;
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_scale"), _SCS("get_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_scale"), _SCS("get_scale"));
ADD_PROPERTY(PropertyInfo(Variant::COLOR,"params/modulate"), _SCS("set_modulate"), _SCS("get_modulate"));
}
@@ -228,15 +232,14 @@ void TextureButton::set_focused_texture(const Ref<Texture>& p_focused) {
focused = p_focused;
};
-void TextureButton::set_scale(float p_scale) {
+void TextureButton::set_scale(Size2 p_scale) {
- ERR_FAIL_COND(p_scale<=0);
scale=p_scale;
minimum_size_changed();
update();
}
-float TextureButton::get_scale() const{
+Size2 TextureButton::get_scale() const{
return scale;
}
@@ -252,6 +255,6 @@ Color TextureButton::get_modulate() const {
TextureButton::TextureButton() {
- scale=1.0;
+ scale=Size2(1.0, 1.0);
modulate=Color(1,1,1);
}
diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h
index 0209d3c260..94bc53b3ff 100644
--- a/scene/gui/texture_button.h
+++ b/scene/gui/texture_button.h
@@ -41,7 +41,7 @@ class TextureButton : public BaseButton {
Ref<Texture> disabled;
Ref<Texture> focused;
Ref<BitMap> click_mask;
- float scale;
+ Size2 scale;
Color modulate;
@@ -68,8 +68,8 @@ public:
Ref<Texture> get_focused_texture() const;
Ref<BitMap> get_click_mask() const;
- void set_scale(float p_scale);
- float get_scale() const;
+ void set_scale(Size2 p_scale);
+ Size2 get_scale() const;
void set_modulate(const Color& p_modulate);
Color get_modulate() const;