From 5fe72700fade70511852979af33d8da5506754fc Mon Sep 17 00:00:00 2001 From: Lucas Kent Date: Tue, 13 Feb 2018 07:31:40 +1100 Subject: [PATCH] Qt: TAS input window - Fix mac os --- Source/Core/DolphinQt2/TAS/IRWidget.cpp | 16 ++++++++-------- Source/Core/DolphinQt2/TAS/IRWidget.h | 8 ++++---- Source/Core/DolphinQt2/TAS/WiiTASInputWindow.cpp | 10 +++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/Core/DolphinQt2/TAS/IRWidget.cpp b/Source/Core/DolphinQt2/TAS/IRWidget.cpp index bdb40b956c..947912db9a 100644 --- a/Source/Core/DolphinQt2/TAS/IRWidget.cpp +++ b/Source/Core/DolphinQt2/TAS/IRWidget.cpp @@ -18,14 +18,14 @@ IRWidget::IRWidget(QWidget* parent) : QWidget(parent) void IRWidget::SetX(u16 x) { - m_x = std::min(max_x, x); + m_x = std::min(ir_max_x, x); update(); } void IRWidget::SetY(u16 y) { - m_y = std::min(max_y, y); + m_y = std::min(ir_max_y, y); update(); } @@ -41,8 +41,8 @@ void IRWidget::paintEvent(QPaintEvent* event) painter.drawLine(width() / 2, 0, width() / 2, height()); // convert from value space to widget space - u16 x = width() - (m_x * width()) / max_x; - u16 y = (m_y * height()) / max_y; + u16 x = width() - (m_x * width()) / ir_max_x; + u16 y = (m_y * height()) / ir_max_y; painter.drawLine(width() / 2, height() / 2, x, y); @@ -65,11 +65,11 @@ void IRWidget::mouseMoveEvent(QMouseEvent* event) void IRWidget::handleMouseEvent(QMouseEvent* event) { // convert from widget space to value space - int new_x = max_x - (event->x() * max_x) / width(); - int new_y = (event->y() * max_y) / height(); + int new_x = ir_max_x - (event->x() * ir_max_x) / width(); + int new_y = (event->y() * ir_max_y) / height(); - m_x = std::max(0, std::min(static_cast(max_x), new_x)); - m_y = std::max(0, std::min(static_cast(max_y), new_y)); + m_x = std::max(0, std::min(static_cast(ir_max_x), new_x)); + m_y = std::max(0, std::min(static_cast(ir_max_y), new_y)); emit ChangedX(m_x); emit ChangedY(m_y); diff --git a/Source/Core/DolphinQt2/TAS/IRWidget.h b/Source/Core/DolphinQt2/TAS/IRWidget.h index c81bb18d46..abf8ffdb92 100644 --- a/Source/Core/DolphinQt2/TAS/IRWidget.h +++ b/Source/Core/DolphinQt2/TAS/IRWidget.h @@ -28,11 +28,11 @@ protected: void mouseMoveEvent(QMouseEvent* event) override; void handleMouseEvent(QMouseEvent* event); -public: - static constexpr u16 max_x = 1023; - static constexpr u16 max_y = 767; - private: u16 m_x = 0; u16 m_y = 0; }; + +// Should be part of class but fails to compile on mac os +static const u16 ir_max_x = 1023; +static const u16 ir_max_y = 767; diff --git a/Source/Core/DolphinQt2/TAS/WiiTASInputWindow.cpp b/Source/Core/DolphinQt2/TAS/WiiTASInputWindow.cpp index 5793eef47e..c077b667a4 100644 --- a/Source/Core/DolphinQt2/TAS/WiiTASInputWindow.cpp +++ b/Source/Core/DolphinQt2/TAS/WiiTASInputWindow.cpp @@ -28,11 +28,11 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : QDialog(parent) m_ir_box = new QGroupBox(tr("IR (ALT+F/G)")); auto* x_layout = new QHBoxLayout; - m_ir_x_value = CreateSliderValuePair(this, x_layout, IRWidget::max_x, Qt::Key_F, Qt::Horizontal, + m_ir_x_value = CreateSliderValuePair(this, x_layout, ir_max_x, Qt::Key_F, Qt::Horizontal, m_ir_box, true); auto* y_layout = new QVBoxLayout; - m_ir_y_value = CreateSliderValuePair(this, y_layout, IRWidget::max_y, Qt::Key_G, Qt::Vertical, + m_ir_y_value = CreateSliderValuePair(this, y_layout, ir_max_y, Qt::Key_G, Qt::Vertical, m_ir_box, true); m_ir_y_value->setMaximumWidth(60); @@ -44,10 +44,10 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : QDialog(parent) connect(visual, &IRWidget::ChangedX, m_ir_x_value, &QSpinBox::setValue); connect(visual, &IRWidget::ChangedY, m_ir_y_value, &QSpinBox::setValue); - m_ir_x_value->setValue(IRWidget::max_x / 2); - m_ir_y_value->setValue(IRWidget::max_y / 2); + m_ir_x_value->setValue(ir_max_x / 2); + m_ir_y_value->setValue(ir_max_y / 2); - auto* visual_ar = new AspectRatioWidget(visual, IRWidget::max_x, IRWidget::max_y); + auto* visual_ar = new AspectRatioWidget(visual, ir_max_x, ir_max_y); auto* visual_layout = new QHBoxLayout; visual_layout->addWidget(visual_ar);