Skip to content

Commit

Permalink
Pull button background updating and text button font color updating t…
Browse files Browse the repository at this point in the history
…o separate methods

Consistency with ImageButton image updating
  • Loading branch information
MEEPofFaith committed Apr 9, 2024
1 parent 8a2decd commit e195798
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 10 additions & 4 deletions arc-core/src/arc/scene/ui/Button.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,8 @@ public ButtonGroup getButtonGroup(){
return buttonGroup;
}

@Override
public void draw(){
validate();

/** Updates the background with the appropriate Drawable from the style before it is drawn. */
public void updateBackground(){
boolean isDisabled = isDisabled();
boolean isPressed = isPressed();
boolean isChecked = isChecked();
Expand All @@ -228,6 +226,14 @@ else if(isOver && style.over != null){
background = style.up;

setBackground(background);
}

@Override
public void draw(){
validate();

boolean isPressed = isPressed();
updateBackground();

float offsetX, offsetY;
if(isPressed && !isDisabled){
Expand Down
10 changes: 8 additions & 2 deletions arc-core/src/arc/scene/ui/TextButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public void setStyle(ButtonStyle style){
}
}

@Override
public void draw(){

/** Updates the font color with the appropriate font color from the style before it is drawn. */
protected void updateFontColor(){
Color fontColor;
if(isDisabled() && style.disabledFontColor != null)
fontColor = style.disabledFontColor;
Expand All @@ -65,6 +66,11 @@ else if(isOver() && style.overFontColor != null)
else
fontColor = style.fontColor;
if(fontColor != null) label.getStyle().fontColor = fontColor;
}

@Override
public void draw(){
updateFontColor();
super.draw();
}

Expand Down

0 comments on commit e195798

Please sign in to comment.