From: S?bastien G. <kx...@us...> - 2004-05-11 03:07:48
|
Update of /cvsroot/vba/VisualBoyAdvance/src/gtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9428/src/gtk Modified Files: screenarea.cpp screenarea.h sigccompat.h window.cpp window.h windowcallbacks.cpp Log Message: Now cursor disappears of the game area after 3 seconds. Fixes. Index: sigccompat.h =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/sigccompat.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sigccompat.h 10 May 2004 14:59:43 -0000 1.2 --- sigccompat.h 11 May 2004 03:07:30 -0000 1.3 *************** *** 50,59 **** (dynamic_cast< T_obj1&>(_A_obj), _A_func); } - template <class T_return, class T_arg1,class T_arg2,class T_arg3, class T_obj1, class T_obj2> - inline Slot3<T_return, T_arg1,T_arg2,T_arg3> - slot( T_obj1& _A_obj, T_return (T_obj2::*_A_func)(T_arg1,T_arg2,T_arg3) ) - { return ::sigc::bound_mem_functor3<T_return, T_obj2, T_arg1,T_arg2,T_arg3> - (dynamic_cast< T_obj1&>(_A_obj), _A_func); } - } // namespace SigC --- 50,53 ---- Index: screenarea.h =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/screenarea.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** screenarea.h 2 Apr 2004 01:22:17 -0000 1.2 --- screenarea.h 11 May 2004 03:07:30 -0000 1.3 *************** *** 22,25 **** --- 22,30 ---- #include <gtkmm/drawingarea.h> + #include <gdkmm/cursor.h> + + #ifndef GTKMM20 + # include "sigccompat.h" + #endif // ! GTKMM20 #include "filters.h" *************** *** 43,46 **** --- 48,54 ---- protected: virtual bool on_expose_event(GdkEventExpose * _pstEvent); + virtual bool on_leave_notify_event(GdkEventCrossing * _pstEvent); + virtual bool on_motion_notify_event(GdkEventMotion * _pstEvent); + virtual bool bOnCursorTimeout(); private: *************** *** 56,60 **** --- 64,74 ---- FilterIB m_vFilterIB; + bool m_bShowCursor; + Gdk::Cursor * m_poEmptyCursor; + SigC::Connection m_oCursorSig; + void vUpdateSize(); + void vHideCursor(); + void vShowCursor(); }; Index: window.h =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/window.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** window.h 10 May 2004 22:54:51 -0000 1.19 --- window.h 11 May 2004 03:07:30 -0000 1.20 *************** *** 186,190 **** virtual void vOnJoypadConfigure(int _iJoypad); virtual void vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, int _iJoypad); ! virtual void vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, std::string _sKey, u32 _uiKeyFlag); virtual void vOnGDBWait(); virtual void vOnGDBLoadAndWait(); --- 186,190 ---- virtual void vOnJoypadConfigure(int _iJoypad); virtual void vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, int _iJoypad); ! virtual void vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag); virtual void vOnGDBWait(); virtual void vOnGDBLoadAndWait(); Index: window.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/window.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** window.cpp 10 May 2004 22:54:51 -0000 1.19 --- window.cpp 11 May 2004 03:07:30 -0000 1.20 *************** *** 817,824 **** poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astAutofire[i].m_csName)); poCMI->set_active(m_poInputConfig->oGetKey<bool>(astAutofire[i].m_csKey)); ! vOnAutofireToggled(poCMI, astAutofire[i].m_csKey, astAutofire[i].m_eKeyFlag); ! poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, std::string, u32>( SigC::slot(*this, &Window::vOnAutofireToggled), ! poCMI, astAutofire[i].m_csKey, astAutofire[i].m_eKeyFlag)); } --- 817,824 ---- poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astAutofire[i].m_csName)); poCMI->set_active(m_poInputConfig->oGetKey<bool>(astAutofire[i].m_csKey)); ! vOnAutofireToggled(poCMI, astAutofire[i].m_eKeyFlag); ! poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, u32>( SigC::slot(*this, &Window::vOnAutofireToggled), ! poCMI, astAutofire[i].m_eKeyFlag)); } Index: screenarea.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/screenarea.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** screenarea.cpp 2 Apr 2004 01:22:17 -0000 1.2 --- screenarea.cpp 11 May 2004 03:07:30 -0000 1.3 *************** *** 28,32 **** m_puiDelta(NULL), m_vFilter2x(NULL), ! m_vFilterIB(NULL) { g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1); --- 28,33 ---- m_puiDelta(NULL), m_vFilter2x(NULL), ! m_vFilterIB(NULL), ! m_bShowCursor(true) { g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1); *************** *** 37,41 **** vUpdateSize(); ! set_events(Gdk::EXPOSURE_MASK); } --- 38,55 ---- vUpdateSize(); ! set_events(Gdk::EXPOSURE_MASK ! | Gdk::POINTER_MOTION_MASK ! | Gdk::LEAVE_NOTIFY_MASK); ! ! char aiEmptyData[8]; ! memset(aiEmptyData, 0, sizeof(aiEmptyData)); ! Glib::RefPtr<Gdk::Bitmap> poSource = Gdk::Bitmap::create(aiEmptyData, 8, 8); ! Glib::RefPtr<Gdk::Bitmap> poMask = Gdk::Bitmap::create(aiEmptyData, 8, 8); ! Gdk::Color oFg; ! Gdk::Color oBg; ! oFg.set_rgb(0, 0, 0); ! oBg.set_rgb(0, 0, 0); ! ! m_poEmptyCursor = new Gdk::Cursor(poSource, poMask, oFg, oBg, 0, 0); } *************** *** 51,54 **** --- 65,73 ---- delete[] m_puiDelta; } + + if (m_poEmptyCursor != NULL) + { + delete m_poEmptyCursor; + } } *************** *** 159,162 **** --- 178,217 ---- } + void ScreenArea::vUpdateSize() + { + if (m_puiPixels != NULL) + { + delete[] m_puiPixels; + } + + if (m_puiDelta != NULL) + { + delete[] m_puiDelta; + } + + m_iAreaWidth = m_iScale * m_iWidth; + m_iAreaHeight = m_iScale * m_iHeight; + m_iRowStride = m_iAreaWidth * 4; + + m_puiPixels = new u32[m_iAreaWidth * m_iAreaHeight]; + + m_puiDelta = new u8[(m_iWidth + 2) * (m_iHeight + 2) * 4]; + memset(m_puiDelta, 255, (m_iWidth + 2) * (m_iHeight + 2) * 4); + + set_size_request(m_iAreaWidth, m_iAreaHeight); + } + + void ScreenArea::vHideCursor() + { + get_window()->set_cursor(*m_poEmptyCursor); + m_bShowCursor = false; + } + + void ScreenArea::vShowCursor() + { + get_window()->set_cursor(); + m_bShowCursor = true; + } + bool ScreenArea::on_expose_event(GdkEventExpose * _pstEvent) { *************** *** 190,215 **** } ! void ScreenArea::vUpdateSize() { ! if (m_puiPixels != NULL) ! { ! delete[] m_puiPixels; ! } ! ! if (m_puiDelta != NULL) { ! delete[] m_puiDelta; } ! m_iAreaWidth = m_iScale * m_iWidth; ! m_iAreaHeight = m_iScale * m_iHeight; ! m_iRowStride = m_iAreaWidth * 4; ! ! m_puiPixels = new u32[m_iAreaWidth * m_iAreaHeight]; ! m_puiDelta = new u8[(m_iWidth + 2) * (m_iHeight + 2) * 4]; ! memset(m_puiDelta, 255, (m_iWidth + 2) * (m_iHeight + 2) * 4); ! set_size_request(m_iAreaWidth, m_iAreaHeight); } --- 245,272 ---- } ! bool ScreenArea::on_motion_notify_event(GdkEventMotion * _pstEvent) { ! if (! m_bShowCursor) { ! vShowCursor(); } ! m_oCursorSig.disconnect(); ! m_oCursorSig = Glib::signal_timeout().connect(SigC::slot(*this, &ScreenArea::bOnCursorTimeout), ! 3000, Glib::PRIORITY_DEFAULT_IDLE); ! return false; ! } ! bool ScreenArea::on_leave_notify_event(GdkEventCrossing * _pstEvent) ! { ! m_oCursorSig.disconnect(); ! vShowCursor(); ! return false; ! } ! bool ScreenArea::bOnCursorTimeout() ! { ! vHideCursor(); ! return false; } Index: windowcallbacks.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/windowcallbacks.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** windowcallbacks.cpp 10 May 2004 22:54:51 -0000 1.8 --- windowcallbacks.cpp 11 May 2004 03:07:30 -0000 1.9 *************** *** 1212,1217 **** } ! void Window::vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, std::string _sKey, ! u32 _uiKeyFlag) { if (_poCMI->get_active()) --- 1212,1216 ---- } ! void Window::vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag) { if (_poCMI->get_active()) *************** *** 1223,1227 **** m_uiAutofireState &= ~_uiKeyFlag; } ! m_poInputConfig->vSetKey(_sKey, _poCMI->get_active()); } --- 1222,1244 ---- m_uiAutofireState &= ~_uiKeyFlag; } ! ! std::string sKey; ! if (_uiKeyFlag == KeyFlagA) ! { ! sKey = "autofire_A"; ! } ! else if (_uiKeyFlag == KeyFlagB) ! { ! sKey = "autofire_B"; ! } ! else if (_uiKeyFlag == KeyFlagL) ! { ! sKey = "autofire_L"; ! } ! else if (_uiKeyFlag == KeyFlagR) ! { ! sKey = "autofire_R"; ! } ! m_poInputConfig->vSetKey(sKey, _poCMI->get_active()); } |