mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
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:
@ -12,12 +12,17 @@
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
constexpr int PADDING = 1;
|
||||
|
||||
StickWidget::StickWidget(QWidget* parent, u16 max_x, u16 max_y)
|
||||
: QWidget(parent), m_max_x(max_x), m_max_y(max_y)
|
||||
{
|
||||
setMouseTracking(false);
|
||||
setToolTip(tr("Left click to set the stick value.\n"
|
||||
"Right click to re-center it."));
|
||||
|
||||
// If the widget gets too small, it will get deformed.
|
||||
setMinimumSize(QSize(64, 64));
|
||||
}
|
||||
|
||||
void StickWidget::SetX(u16 x)
|
||||
@ -41,22 +46,24 @@ void StickWidget::paintEvent(QPaintEvent* event)
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||
|
||||
painter.setBrush(Qt::white);
|
||||
painter.drawEllipse(0, 0, width() - 1, height() - 1);
|
||||
const int diameter = std::min(width(), height()) - PADDING * 2;
|
||||
|
||||
painter.drawLine(0, height() / 2, width(), height() / 2);
|
||||
painter.drawLine(width() / 2, 0, width() / 2, height());
|
||||
painter.setBrush(Qt::white);
|
||||
painter.drawEllipse(PADDING, PADDING, diameter, diameter);
|
||||
|
||||
painter.drawLine(PADDING, PADDING + diameter / 2, PADDING + diameter, PADDING + diameter / 2);
|
||||
painter.drawLine(PADDING + diameter / 2, PADDING, PADDING + diameter / 2, PADDING + diameter);
|
||||
|
||||
// convert from value space to widget space
|
||||
u16 x = (m_x * width()) / m_max_x;
|
||||
u16 y = height() - (m_y * height()) / m_max_y;
|
||||
u16 x = PADDING + ((m_x * diameter) / m_max_x);
|
||||
u16 y = PADDING + (diameter - (m_y * diameter) / m_max_y);
|
||||
|
||||
painter.drawLine(width() / 2, height() / 2, x, y);
|
||||
painter.drawLine(PADDING + diameter / 2, PADDING + diameter / 2, x, y);
|
||||
|
||||
painter.setBrush(Qt::blue);
|
||||
int wh_avg = (width() + height()) / 2;
|
||||
int radius = wh_avg / 30;
|
||||
painter.drawEllipse(x - radius, y - radius, radius * 2, radius * 2);
|
||||
int neutral_radius = diameter / 30;
|
||||
painter.drawEllipse(x - neutral_radius, y - neutral_radius, neutral_radius * 2,
|
||||
neutral_radius * 2);
|
||||
}
|
||||
|
||||
void StickWidget::mousePressEvent(QMouseEvent* event)
|
||||
|
Reference in New Issue
Block a user