forked from mia/Aegisub
Factor out the mouse wheel forwarding code in the audio display to a function used by the audio display, video display and subtitles grid, and make it actually work
Originally committed to SVN as r5781.
This commit is contained in:
parent
be75262f73
commit
1741ce93f6
5 changed files with 31 additions and 28 deletions
|
@ -1003,30 +1003,8 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event)
|
||||||
// Check for mouse wheel scrolling
|
// Check for mouse wheel scrolling
|
||||||
if (event.GetWheelRotation() != 0)
|
if (event.GetWheelRotation() != 0)
|
||||||
{
|
{
|
||||||
// First check if the cursor is inside or outside the display.
|
if (!ForwardMouseWheelEvent(this, event))
|
||||||
// If it's outside, we want to send the event to the control it's over instead.
|
return;
|
||||||
/// @todo Factor this into a reusable function
|
|
||||||
{
|
|
||||||
wxWindow *targetwindow = wxFindWindowAtPoint(event.GetPosition());
|
|
||||||
if (targetwindow && targetwindow != this)
|
|
||||||
{
|
|
||||||
wxWindow *parent = GetParent();
|
|
||||||
while (parent && parent != targetwindow)
|
|
||||||
{
|
|
||||||
parent = parent->GetParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't forward scroll wheel events to parents of this as the
|
|
||||||
// target is sometimes reported as a parent even when the mouse
|
|
||||||
// is over the audio display
|
|
||||||
if (!parent)
|
|
||||||
{
|
|
||||||
targetwindow->GetEventHandler()->ProcessEvent(event);
|
|
||||||
event.Skip(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool zoom = event.CmdDown();
|
bool zoom = event.CmdDown();
|
||||||
if (OPT_GET("Audio/Wheel Default to Zoom")->GetBool()) zoom = !zoom;
|
if (OPT_GET("Audio/Wheel Default to Zoom")->GetBool()) zoom = !zoom;
|
||||||
|
|
|
@ -714,8 +714,10 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
|
||||||
|
|
||||||
// Mouse wheel
|
// Mouse wheel
|
||||||
if (event.GetWheelRotation() != 0) {
|
if (event.GetWheelRotation() != 0) {
|
||||||
int step = 3 * event.GetWheelRotation() / event.GetWheelDelta();
|
if (ForwardMouseWheelEvent(this, event)) {
|
||||||
ScrollTo(yPos - step);
|
int step = 3 * event.GetWheelRotation() / event.GetWheelDelta();
|
||||||
|
ScrollTo(yPos - step);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -448,4 +448,18 @@ void RestartAegisub() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ForwardMouseWheelEvent(wxWindow *source, wxMouseEvent &evt) {
|
||||||
|
wxWindow *target = wxFindWindowAtPoint(wxGetMousePosition());
|
||||||
|
if (!target || target == source) return true;
|
||||||
|
|
||||||
|
// If the mouse is over a parent of the source window just pretend it's
|
||||||
|
// over the source window, so that the mouse wheel works on borders and such
|
||||||
|
wxWindow *parent = source->GetParent();
|
||||||
|
while (parent && parent != target) parent = parent->GetParent();
|
||||||
|
if (parent == target) return true;
|
||||||
|
|
||||||
|
// Otherwise send it to the new target
|
||||||
|
target->GetEventHandler()->ProcessEvent(evt);
|
||||||
|
evt.Skip(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -69,6 +69,12 @@ int AegiStringToFix(const wxString &str,size_t decimalPlaces,int start=0,int end
|
||||||
wxIcon BitmapToIcon(wxBitmap bmp);
|
wxIcon BitmapToIcon(wxBitmap bmp);
|
||||||
void RestartAegisub();
|
void RestartAegisub();
|
||||||
|
|
||||||
|
/// Forward a mouse wheel event to the window under the mouse if needed
|
||||||
|
/// @param source The initial target of the wheel event
|
||||||
|
/// @param evt The event
|
||||||
|
/// @return Should the calling code process the event?
|
||||||
|
bool ForwardMouseWheelEvent(wxWindow *source, wxMouseEvent &evt);
|
||||||
|
|
||||||
|
|
||||||
/// @brief Templated abs() function
|
/// @brief Templated abs() function
|
||||||
template <typename T> T tabs(T x) { return x < 0 ? -x : x; }
|
template <typename T> T tabs(T x) { return x < 0 ? -x : x; }
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
#include "ass_file.h"
|
#include "ass_file.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "threaded_frame_source.h"
|
#include "threaded_frame_source.h"
|
||||||
|
#include "utils.h"
|
||||||
#include "video_out_gl.h"
|
#include "video_out_gl.h"
|
||||||
#include "video_box.h"
|
#include "video_box.h"
|
||||||
#include "video_context.h"
|
#include "video_context.h"
|
||||||
|
@ -420,8 +421,10 @@ void VideoDisplay::OnMouseLeave(wxMouseEvent& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoDisplay::OnMouseWheel(wxMouseEvent& event) {
|
void VideoDisplay::OnMouseWheel(wxMouseEvent& event) {
|
||||||
if (int wheel = event.GetWheelRotation())
|
if (int wheel = event.GetWheelRotation()) {
|
||||||
SetZoom (zoomValue + .125 * (wheel / event.GetWheelDelta()));
|
if (ForwardMouseWheelEvent(this, event))
|
||||||
|
SetZoom (zoomValue + .125 * (wheel / event.GetWheelDelta()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoDisplay::OnContextMenu(wxContextMenuEvent&) {
|
void VideoDisplay::OnContextMenu(wxContextMenuEvent&) {
|
||||||
|
|
Loading…
Reference in a new issue