From 9f18c2d448f7c0d8e1588b5ac701fda4cb7e85bb Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Wed, 18 Apr 2007 04:51:17 +0000 Subject: [PATCH] Fixed hidden cursor on right click Originally committed to SVN as r1093. --- aegisub/video_display.cpp | 30 +++++++++++++++++++++++++++--- aegisub/video_display.h | 1 + aegisub/video_display_visual.cpp | 18 ++---------------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/aegisub/video_display.cpp b/aegisub/video_display.cpp index cc69e9b57..010134cc7 100644 --- a/aegisub/video_display.cpp +++ b/aegisub/video_display.cpp @@ -132,6 +132,26 @@ VideoDisplay::~VideoDisplay () { } +/////////////// +// Show cursor +void VideoDisplay::ShowCursor(bool show) { + // Show + if (show) SetCursor(wxNullCursor); + + // Hide + else { + // Bleeeh! Hate this 'solution': + #if __WXGTK__ + static char cursor_image[] = {0}; + wxCursor cursor(cursor_image, 8, 1, -1, -1, cursor_image); + #else + wxCursor cursor(wxCURSOR_BLANK); + #endif // __WXGTK__ + SetCursor(cursor); + } +} + + ////////// // Render void VideoDisplay::Render() { @@ -345,9 +365,6 @@ void VideoDisplay::OnMouseEvent(wxMouseEvent& event) { // Disable when playing if (VideoContext::Get()->IsPlaying()) return; - // Set mode, for whatever reason this is needed - visual->SetMode(visual->mode); - // OnMouseLeave isn't called as long as we have an OnMouseEvent // Just check for it and call it manually instead if (event.Leaving()) { @@ -358,6 +375,7 @@ void VideoDisplay::OnMouseEvent(wxMouseEvent& event) { // Right click if (event.ButtonUp(wxMOUSE_BTN_RIGHT)) { + // Create menu wxMenu menu; menu.Append(VIDEO_MENU_SAVE_SNAPSHOT,_("Save PNG snapshot")); menu.Append(VIDEO_MENU_COPY_TO_CLIPBOARD,_("Copy image to Clipboard")); @@ -367,10 +385,16 @@ void VideoDisplay::OnMouseEvent(wxMouseEvent& event) { menu.Append(VIDEO_MENU_COPY_TO_CLIPBOARD_RAW,_("Copy image to Clipboard (no subtitles)"))->Enable(canDoRaw); menu.AppendSeparator(); menu.Append(VIDEO_MENU_COPY_COORDS,_("Copy coordinates to Clipboard")); + + // Show cursor and popup + ShowCursor(true); PopupMenu(&menu); return; } + // Enforce correct cursor display + ShowCursor(visual->mode != 0); + // Click? if (event.ButtonDown(wxMOUSE_BTN_ANY)) { SetFocus(); diff --git a/aegisub/video_display.h b/aegisub/video_display.h index ab1cb365c..06e671d24 100644 --- a/aegisub/video_display.h +++ b/aegisub/video_display.h @@ -104,6 +104,7 @@ public: void Render(); + void ShowCursor(bool show); void ConvertMouseCoords(int &x,int &y); void DrawText(wxPoint Pos, wxString Text); void UpdatePositionDisplay(); diff --git a/aegisub/video_display_visual.cpp b/aegisub/video_display_visual.cpp index c2fde30b8..0f778c127 100644 --- a/aegisub/video_display_visual.cpp +++ b/aegisub/video_display_visual.cpp @@ -84,22 +84,8 @@ void VideoDisplayVisual::SetMode(int _mode) { // Set mode mode = _mode; - // Hide cursor - if (mode == 0) { - // Bleeeh! Hate this 'solution': - #if __WXGTK__ - static char cursor_image[] = {0}; - wxCursor cursor(cursor_image, 8, 1, -1, -1, cursor_image); - #else - wxCursor cursor(wxCURSOR_BLANK); - #endif // __WXGTK__ - parent->SetCursor(cursor); - } - - // Show cursor - else { - parent->SetCursor(wxNullCursor); - } + // Display cursor or not + parent->ShowCursor(mode != 0); }