mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-05-04 20:55:43 -04:00
Qt: Hook up mouse wheel to ImGui
This commit is contained in:
parent
9425f34ceb
commit
52c842e3b3
@ -177,6 +177,13 @@ bool QtDisplayWidget::event(QEvent* event)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case QEvent::Wheel:
|
||||||
|
{
|
||||||
|
const QWheelEvent* wheel_event = static_cast<QWheelEvent*>(event);
|
||||||
|
emit windowMouseWheelEvent(wheel_event->angleDelta());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
case QEvent::Resize:
|
case QEvent::Resize:
|
||||||
{
|
{
|
||||||
QWidget::event(event);
|
QWidget::event(event);
|
||||||
|
@ -30,6 +30,7 @@ Q_SIGNALS:
|
|||||||
void windowKeyEvent(int key_code, bool pressed);
|
void windowKeyEvent(int key_code, bool pressed);
|
||||||
void windowMouseMoveEvent(int x, int y);
|
void windowMouseMoveEvent(int x, int y);
|
||||||
void windowMouseButtonEvent(int button, bool pressed);
|
void windowMouseButtonEvent(int button, bool pressed);
|
||||||
|
void windowMouseWheelEvent(const QPoint& angle_delta);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent* event) override;
|
bool event(QEvent* event) override;
|
||||||
|
@ -413,7 +413,35 @@ void QtHostInterface::onDisplayWindowMouseButtonEvent(int button, bool pressed)
|
|||||||
HandleHostMouseEvent(button, pressed);
|
HandleHostMouseEvent(button, pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtHostInterface::onHostDisplayWindowResized(int width, int height)
|
void QtHostInterface::onDisplayWindowMouseWheelEvent(const QPoint& delta_angle)
|
||||||
|
{
|
||||||
|
DebugAssert(isOnWorkerThread());
|
||||||
|
|
||||||
|
if (ImGui::GetCurrentContext())
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
if (delta_angle.x() > 0)
|
||||||
|
io.MouseWheelH += 1.0f;
|
||||||
|
else if (delta_angle.x() < 0)
|
||||||
|
io.MouseWheelH -= 1.0f;
|
||||||
|
|
||||||
|
if (delta_angle.y() > 0)
|
||||||
|
io.MouseWheel += 1.0f;
|
||||||
|
else if (delta_angle.y() < 0)
|
||||||
|
io.MouseWheel -= 1.0f;
|
||||||
|
|
||||||
|
if (io.WantCaptureMouse)
|
||||||
|
{
|
||||||
|
// don't consume input events if it's hitting the UI instead
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandleHostMouseWheelEvent(delta_angle.x(), delta_angle.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtHostInterface::onDisplayWindowResized(int width, int height)
|
||||||
{
|
{
|
||||||
Log_WarningPrintf("resize %dx%d", width, height);
|
Log_WarningPrintf("resize %dx%d", width, height);
|
||||||
// this can be null if it was destroyed and the main thread is late catching up
|
// this can be null if it was destroyed and the main thread is late catching up
|
||||||
@ -441,7 +469,7 @@ void QtHostInterface::onHostDisplayWindowResized(int width, int height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtHostInterface::onHostDisplayWindowFocused()
|
void QtHostInterface::onDisplayWindowFocused()
|
||||||
{
|
{
|
||||||
if (!m_display || !m_lost_exclusive_fullscreen)
|
if (!m_display || !m_lost_exclusive_fullscreen)
|
||||||
return;
|
return;
|
||||||
@ -539,14 +567,15 @@ void QtHostInterface::connectDisplaySignals(QtDisplayWidget* widget)
|
|||||||
{
|
{
|
||||||
widget->disconnect(this);
|
widget->disconnect(this);
|
||||||
|
|
||||||
connect(widget, &QtDisplayWidget::windowFocusEvent, this, &QtHostInterface::onHostDisplayWindowFocused);
|
connect(widget, &QtDisplayWidget::windowFocusEvent, this, &QtHostInterface::onDisplayWindowFocused);
|
||||||
connect(widget, &QtDisplayWidget::windowResizedEvent, this, &QtHostInterface::onHostDisplayWindowResized);
|
connect(widget, &QtDisplayWidget::windowResizedEvent, this, &QtHostInterface::onDisplayWindowResized);
|
||||||
connect(widget, &QtDisplayWidget::windowRestoredEvent, this, &QtHostInterface::redrawDisplayWindow);
|
connect(widget, &QtDisplayWidget::windowRestoredEvent, this, &QtHostInterface::redrawDisplayWindow);
|
||||||
connect(widget, &QtDisplayWidget::windowClosedEvent, this, &QtHostInterface::powerOffSystem,
|
connect(widget, &QtDisplayWidget::windowClosedEvent, this, &QtHostInterface::powerOffSystem,
|
||||||
Qt::BlockingQueuedConnection);
|
Qt::BlockingQueuedConnection);
|
||||||
connect(widget, &QtDisplayWidget::windowKeyEvent, this, &QtHostInterface::onDisplayWindowKeyEvent);
|
connect(widget, &QtDisplayWidget::windowKeyEvent, this, &QtHostInterface::onDisplayWindowKeyEvent);
|
||||||
connect(widget, &QtDisplayWidget::windowMouseMoveEvent, this, &QtHostInterface::onDisplayWindowMouseMoveEvent);
|
connect(widget, &QtDisplayWidget::windowMouseMoveEvent, this, &QtHostInterface::onDisplayWindowMouseMoveEvent);
|
||||||
connect(widget, &QtDisplayWidget::windowMouseButtonEvent, this, &QtHostInterface::onDisplayWindowMouseButtonEvent);
|
connect(widget, &QtDisplayWidget::windowMouseButtonEvent, this, &QtHostInterface::onDisplayWindowMouseButtonEvent);
|
||||||
|
connect(widget, &QtDisplayWidget::windowMouseWheelEvent, this, &QtHostInterface::onDisplayWindowMouseWheelEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtHostInterface::updateDisplayState()
|
void QtHostInterface::updateDisplayState()
|
||||||
|
@ -143,9 +143,6 @@ public Q_SLOTS:
|
|||||||
void applySettings(bool display_osd_messages = false);
|
void applySettings(bool display_osd_messages = false);
|
||||||
void updateInputMap();
|
void updateInputMap();
|
||||||
void applyInputProfile(const QString& profile_path);
|
void applyInputProfile(const QString& profile_path);
|
||||||
void onDisplayWindowKeyEvent(int key, bool pressed);
|
|
||||||
void onDisplayWindowMouseMoveEvent(int x, int y);
|
|
||||||
void onDisplayWindowMouseButtonEvent(int button, bool pressed);
|
|
||||||
void bootSystem(std::shared_ptr<const SystemBootParameters> params);
|
void bootSystem(std::shared_ptr<const SystemBootParameters> params);
|
||||||
void resumeSystemFromState(const QString& filename, bool boot_on_failure);
|
void resumeSystemFromState(const QString& filename, bool boot_on_failure);
|
||||||
void resumeSystemFromMostRecentState();
|
void resumeSystemFromMostRecentState();
|
||||||
@ -179,8 +176,12 @@ public Q_SLOTS:
|
|||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void doStopThread();
|
void doStopThread();
|
||||||
void onHostDisplayWindowResized(int width, int height);
|
void onDisplayWindowMouseMoveEvent(int x, int y);
|
||||||
void onHostDisplayWindowFocused();
|
void onDisplayWindowMouseButtonEvent(int button, bool pressed);
|
||||||
|
void onDisplayWindowMouseWheelEvent(const QPoint& delta_angle);
|
||||||
|
void onDisplayWindowResized(int width, int height);
|
||||||
|
void onDisplayWindowFocused();
|
||||||
|
void onDisplayWindowKeyEvent(int key, bool pressed);
|
||||||
void doBackgroundControllerPoll();
|
void doBackgroundControllerPoll();
|
||||||
void doSaveSettings();
|
void doSaveSettings();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user