Qt/TAS: Improve TAS windows

- Use the Dolphin Icon in TAS Windows
- Prevent deformation of the stick widget (#11988)
- Improve visual appearance
- Set a reasonable minimum size
This commit is contained in:
spycrab
2020-02-17 15:07:18 +01:00
parent 2d6a72e941
commit 29c7c12016
3 changed files with 36 additions and 18 deletions

View File

@ -12,11 +12,16 @@
#include "Common/CommonTypes.h"
constexpr int PADDING = 1;
IRWidget::IRWidget(QWidget* parent) : QWidget(parent)
{
setMouseTracking(false);
setToolTip(tr("Left click to set the IR value.\n"
"Right click to re-center it."));
// If the widget gets too small, it will get deformed.
setMinimumSize(QSize(64, 48));
}
void IRWidget::SetX(u16 x)
@ -40,20 +45,23 @@ void IRWidget::paintEvent(QPaintEvent* event)
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
painter.setBrush(Qt::white);
painter.drawRect(0, 0, width() - 1, height() - 1);
const int w = width() - PADDING * 2;
const int h = height() - PADDING * 2;
painter.drawLine(0, height() / 2, width(), height() / 2);
painter.drawLine(width() / 2, 0, width() / 2, height());
painter.setBrush(Qt::white);
painter.drawRect(PADDING, PADDING, w, h);
painter.drawLine(PADDING, PADDING + h / 2, PADDING + w, PADDING + h / 2);
painter.drawLine(PADDING + w / 2, PADDING, PADDING + w / 2, PADDING + h);
// convert from value space to widget space
u16 x = width() - (m_x * width()) / ir_max_x;
u16 y = (m_y * height()) / ir_max_y;
u16 x = PADDING + (w - (m_x * w) / ir_max_x);
u16 y = PADDING + ((m_y * h) / ir_max_y);
painter.drawLine(width() / 2, height() / 2, x, y);
painter.drawLine(PADDING + w / 2, PADDING + h / 2, x, y);
painter.setBrush(Qt::blue);
int wh_avg = (width() + height()) / 2;
int wh_avg = (w + h) / 2;
int radius = wh_avg / 30;
painter.drawEllipse(x - radius, y - radius, radius * 2, radius * 2);
}