Skip to content

Commit

Permalink
TextureButton Fix logic for drawing only the focus texture
Browse files Browse the repository at this point in the history
(cherry picked from commit 078b8c2)
  • Loading branch information
kleonc authored and akien-mga committed Jan 31, 2022
1 parent aa3ef20 commit 32d8305
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scene/gui/texture_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ void TextureButton::_notification(int p_what) {
bool draw_focus = (has_focus() && focused.is_valid());

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

Expand Down Expand Up @@ -230,7 +231,7 @@ void TextureButton::_notification(int p_what) {
size.width *= hflip ? -1.0f : 1.0f;
size.height *= vflip ? -1.0f : 1.0f;

if (texdraw == focused) {
if (draw_focus_only) {
// Do nothing, we only needed to calculate the rectangle.
} else if (_tile) {
draw_texture_rect(texdraw, Rect2(ofs, size), _tile);
Expand Down

0 comments on commit 32d8305

Please sign in to comment.