From b734b81e6bc7306e562f7090a14dbecca5a26816 Mon Sep 17 00:00:00 2001 From: Just Call Me Koko <25190487+justcallmekoko@users.noreply.github.com> Date: Wed, 5 Feb 2020 22:21:02 -0500 Subject: [PATCH] Fix center aligned button text --- Extensions/Button.cpp | 4 ++-- .../Generic/TFT_Button_Label_Datum/TFT_Button_Label_Datum.ino | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Extensions/Button.cpp b/Extensions/Button.cpp index 5575f27..a6d00bc 100644 --- a/Extensions/Button.cpp +++ b/Extensions/Button.cpp @@ -69,9 +69,9 @@ void TFT_eSPI_Button::drawButton(bool inverted, String long_name) { uint8_t tempdatum = _gfx->getTextDatum(); _gfx->setTextDatum(_textdatum); if (long_name == "") - _gfx->drawString(_label, _x1 + _xd, _y1 + (_h/2) + _yd); + _gfx->drawString(_label, _x1 + (_w/2) + _xd, _y1 + (_h/2) - 4 + _yd); else - _gfx->drawString(long_name, _x1 + _xd, _y1 + (_h/2) + _yd); + _gfx->drawString(long_name, _x1 + (_w/2) + _xd, _y1 + (_h/2) - 4 + _yd); _gfx->setTextDatum(tempdatum); } diff --git a/examples/Generic/TFT_Button_Label_Datum/TFT_Button_Label_Datum.ino b/examples/Generic/TFT_Button_Label_Datum/TFT_Button_Label_Datum.ino index 55f62fe..256e2b3 100644 --- a/examples/Generic/TFT_Button_Label_Datum/TFT_Button_Label_Datum.ino +++ b/examples/Generic/TFT_Button_Label_Datum/TFT_Button_Label_Datum.ino @@ -118,7 +118,7 @@ void drawButtons() // Adjust button label X delta according to array position // setLabelDatum(uint16_t x_delta, uint16_t y_delta, uint8_t datum) - key[i].setLabelDatum(i * 10, 0, ML_DATUM); + key[i].setLabelDatum(i * 10 - (KEY_W/2), 0, ML_DATUM); // Draw button and specify label string // Specifying label string here will allow more than the default 10 byte label