mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-20 11:35:54 +00:00
Use const int in TAS widgets
This commit is contained in:
parent
08476ab425
commit
4ec40d3d1a
2 changed files with 11 additions and 11 deletions
|
@ -54,14 +54,14 @@ void IRWidget::paintEvent(QPaintEvent* event)
|
|||
painter.drawLine(PADDING + w / 2, PADDING, PADDING + w / 2, PADDING + h);
|
||||
|
||||
// convert from value space to widget space
|
||||
u16 x = PADDING + ((m_x * w) / IR_MAX_X);
|
||||
u16 y = PADDING + (h - (m_y * h) / IR_MAX_Y);
|
||||
const int x = PADDING + ((m_x * w) / IR_MAX_X);
|
||||
const int y = PADDING + (h - (m_y * h) / IR_MAX_Y);
|
||||
|
||||
painter.drawLine(PADDING + w / 2, PADDING + h / 2, x, y);
|
||||
|
||||
painter.setBrush(Qt::blue);
|
||||
int wh_avg = (w + h) / 2;
|
||||
int radius = wh_avg / 30;
|
||||
const int wh_avg = (w + h) / 2;
|
||||
const int radius = wh_avg / 30;
|
||||
painter.drawEllipse(x - radius, y - radius, radius * 2, radius * 2);
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,8 @@ void IRWidget::handleMouseEvent(QMouseEvent* event)
|
|||
else
|
||||
{
|
||||
// convert from widget space to value space
|
||||
int new_x = (event->pos().x() * IR_MAX_X) / width();
|
||||
int new_y = IR_MAX_Y - (event->pos().y() * IR_MAX_Y) / height();
|
||||
const int new_x = (event->pos().x() * IR_MAX_X) / width();
|
||||
const int new_y = IR_MAX_Y - (event->pos().y() * IR_MAX_Y) / height();
|
||||
|
||||
m_x = std::max(0, std::min(static_cast<int>(IR_MAX_X), new_x));
|
||||
m_y = std::max(0, std::min(static_cast<int>(IR_MAX_Y), new_y));
|
||||
|
|
|
@ -57,13 +57,13 @@ void StickWidget::paintEvent(QPaintEvent* event)
|
|||
painter.drawLine(PADDING + diameter / 2, PADDING, PADDING + diameter / 2, PADDING + diameter);
|
||||
|
||||
// convert from value space to widget space
|
||||
u16 x = PADDING + ((m_x * diameter) / m_max_x);
|
||||
u16 y = PADDING + (diameter - (m_y * diameter) / m_max_y);
|
||||
const int x = PADDING + ((m_x * diameter) / m_max_x);
|
||||
const int y = PADDING + (diameter - (m_y * diameter) / m_max_y);
|
||||
|
||||
painter.drawLine(PADDING + diameter / 2, PADDING + diameter / 2, x, y);
|
||||
|
||||
painter.setBrush(Qt::blue);
|
||||
int neutral_radius = diameter / 30;
|
||||
const int neutral_radius = diameter / 30;
|
||||
painter.drawEllipse(x - neutral_radius, y - neutral_radius, neutral_radius * 2,
|
||||
neutral_radius * 2);
|
||||
}
|
||||
|
@ -93,8 +93,8 @@ void StickWidget::handleMouseEvent(QMouseEvent* event)
|
|||
else
|
||||
{
|
||||
// convert from widget space to value space
|
||||
int new_x = (event->pos().x() * m_max_x) / width();
|
||||
int new_y = m_max_y - (event->pos().y() * m_max_y) / height();
|
||||
const int new_x = (event->pos().x() * m_max_x) / width();
|
||||
const int new_y = m_max_y - (event->pos().y() * m_max_y) / height();
|
||||
|
||||
m_x = std::max(0, std::min(static_cast<int>(m_max_x), new_x));
|
||||
m_y = std::max(0, std::min(static_cast<int>(m_max_y), new_y));
|
||||
|
|
Loading…
Add table
Reference in a new issue