Fixed that very annoying label bug, where the 'g' in the Registers label (in the Target Registers tool button) was being clipped.

This commit is contained in:
Nav
2022-04-28 21:08:31 +01:00
parent fa037a81b1
commit 178df2d9e0
2 changed files with 10 additions and 6 deletions

View File

@@ -114,7 +114,7 @@ namespace Bloom
auto* targetRegisterButtonLayout = this->targetRegistersButton->findChild<QVBoxLayout*>(); auto* targetRegisterButtonLayout = this->targetRegistersButton->findChild<QVBoxLayout*>();
auto* registersBtnLabel = new RotatableLabel(270, "Registers", this->targetRegistersButton); auto* registersBtnLabel = new RotatableLabel(270, "Registers", this->targetRegistersButton);
registersBtnLabel->setObjectName("target-registers-btn-label"); registersBtnLabel->setObjectName("target-registers-btn-label");
registersBtnLabel->setContentsMargins(5,0,9,0); registersBtnLabel->setContentsMargins(4, 3, 10, 0);
targetRegisterButtonLayout->insertWidget(0, registersBtnLabel, 0, Qt::AlignTop); targetRegisterButtonLayout->insertWidget(0, registersBtnLabel, 0, Qt::AlignTop);
this->bottomMenuBar = this->container->findChild<QWidget*>("bottom-menu-bar"); this->bottomMenuBar = this->container->findChild<QWidget*>("bottom-menu-bar");

View File

@@ -6,9 +6,10 @@ namespace Bloom::Widgets
{ {
void RotatableLabel::paintEvent(QPaintEvent* event) { void RotatableLabel::paintEvent(QPaintEvent* event) {
auto painter = QPainter(this); auto painter = QPainter(this);
static auto containerSize = this->getContainerSize(); const auto containerSize = this->getContainerSize();
static auto textSize = QLabel::minimumSizeHint(); const auto textSize = QLabel::minimumSizeHint();
static auto margins = this->contentsMargins(); const auto margins = this->contentsMargins();
painter.setClipRect(0, 0, containerSize.width(), containerSize.height()); painter.setClipRect(0, 0, containerSize.width(), containerSize.height());
painter.save(); painter.save();
painter.setPen(Qt::PenStyle::SolidLine); painter.setPen(Qt::PenStyle::SolidLine);
@@ -16,8 +17,11 @@ namespace Bloom::Widgets
painter.translate(std::ceil(containerSize.width() / 2), std::ceil(containerSize.height() / 2)); painter.translate(std::ceil(containerSize.width() / 2), std::ceil(containerSize.height() / 2));
painter.rotate(this->angle); painter.rotate(this->angle);
painter.drawText( painter.drawText(
-(textSize.width() / 2) + margins.left(), -(containerSize.height() / 2) + margins.left(),
(textSize.height() / 2) + margins.top(), -(textSize.height() / 2) + margins.top(),
textSize.width(),
textSize.height(),
Qt::AlignTop,
this->text() this->text()
); );