diff --git a/arc-core/src/arc/scene/ui/Button.java b/arc-core/src/arc/scene/ui/Button.java index dcebdba5..95b694cf 100644 --- a/arc-core/src/arc/scene/ui/Button.java +++ b/arc-core/src/arc/scene/ui/Button.java @@ -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(); @@ -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){ diff --git a/arc-core/src/arc/scene/ui/TextButton.java b/arc-core/src/arc/scene/ui/TextButton.java index 9a14012b..278657ac 100644 --- a/arc-core/src/arc/scene/ui/TextButton.java +++ b/arc-core/src/arc/scene/ui/TextButton.java @@ -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; @@ -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(); }