Adafruit-GFX-Library
Adafruit-GFX-Library copied to clipboard
Adafruit_GFX_Button & Adafruit_GFX changes: pressedcolor, radius, custom fonts.
This pull request adds functionality to Adafruit_GFX_Button: setting a custom backcolour for when the button is pressed; setting the radius of the rounded corners and fixes an issue with using custom fonts on labels, along with allowing more than 9 characters on a label. The Adafruit_GFX class has been extended to include a getFont() function that exposes the current font.
Adafruit_GFX_Button:
- radius property to Adafruit_GFX_Button, to allow buttons to have different sized radius corners. 0 or less results in sharp corners
- getLabel() function, exposes the current label.
- drawButton can now show a different colour background when the button is pressed.
- _pressedcolor field added to hold the background colour of a pressed button..
- new overrides to initButton to allow setting of pressedColor.
- _maxlabellength used to hold the maximum length of the label - here increased to 40 characters. The property is used in the drawButton function, so changes need making purely to the static const int in the .h file.
- drawButton now respects the current font, so the label is positioned correctly.
Adafuit_GFX
getFont() function to get the current font. This allows the Button etc to change behaviour based on the font. e.g. in the Button, we can now better calculate the width of the label correctly and therefore position it better.