|
35 | 35 | #include "core/object/class_db.h" |
36 | 36 | #include "scene/gui/label.h" |
37 | 37 | #include "scene/main/timer.h" |
| 38 | +#include "scene/theme/theme_db.h" |
38 | 39 | #include "servers/display/accessibility_server.h" |
39 | 40 |
|
40 | 41 | void BaseButton::_unpress_group() { |
@@ -394,6 +395,16 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const { |
394 | 395 | } |
395 | 396 | } |
396 | 397 |
|
| 398 | +bool BaseButton::has_point(const Point2 &p_point) const { |
| 399 | + ERR_READ_THREAD_GUARD_V(false); |
| 400 | + bool ret; |
| 401 | + if (GDVIRTUAL_CALL(_has_point, p_point, ret)) { |
| 402 | + return ret; |
| 403 | + } |
| 404 | + Rect2 rect = Rect2(Point2(), get_size()).grow(theme_cache.click_margin); |
| 405 | + return rect.has_area() && rect.has_point(p_point); |
| 406 | +} |
| 407 | + |
397 | 408 | void BaseButton::set_toggle_mode(bool p_on) { |
398 | 409 | // Make sure to set 'pressed' to false if we are not in toggle mode |
399 | 410 | if (!p_on) { |
@@ -625,6 +636,8 @@ void BaseButton::_bind_methods() { |
625 | 636 | ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shortcut_feedback"), "set_shortcut_feedback", "is_shortcut_feedback"); |
626 | 637 | ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shortcut_in_tooltip"), "set_shortcut_in_tooltip", "is_shortcut_in_tooltip_enabled"); |
627 | 638 |
|
| 639 | + BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, BaseButton, click_margin); |
| 640 | + |
628 | 641 | BIND_ENUM_CONSTANT(DRAW_NORMAL); |
629 | 642 | BIND_ENUM_CONSTANT(DRAW_PRESSED); |
630 | 643 | BIND_ENUM_CONSTANT(DRAW_HOVER); |
|
0 commit comments