Skip to content

Commit

Permalink
Merge pull request #56472 from KoBeWi/now_focus
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Jan 7, 2022
2 parents a1ea897 + 11111d9 commit 096a13b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scene/gui/texture_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ void TextureButton::_notification(int p_what) {

Point2 ofs;
Size2 size;
bool draw_focus = (has_focus() && focused.is_valid());

// If no other texture is valid, try using focused texture.
if (!texdraw.is_valid() && draw_focus) {
texdraw = focused;
}

if (texdraw.is_valid()) {
size = texdraw->get_size();
Expand Down Expand Up @@ -226,7 +232,9 @@ void TextureButton::_notification(int p_what) {
size.width *= hflip ? -1.0f : 1.0f;
size.height *= vflip ? -1.0f : 1.0f;

if (_tile) {
if (texdraw == focused) {
// Do nothing, we only needed to calculate the rectangle.
} else if (_tile) {
draw_texture_rect(texdraw, Rect2(ofs, size), _tile);
} else {
draw_texture_rect_region(texdraw, Rect2(ofs, size), _texture_region);
Expand All @@ -235,7 +243,7 @@ void TextureButton::_notification(int p_what) {
_position_rect = Rect2();
}

if (has_focus() && focused.is_valid()) {
if (draw_focus) {
draw_texture_rect(focused, Rect2(ofs, size), false);
};
} break;
Expand Down

0 comments on commit 096a13b

Please sign in to comment.