Blender  V2.59
MyGlutMouseHandler.h
Go to the documentation of this file.
00001 
00029 #ifndef NAN_INCLUDED_MyGlutMouseHandler_h
00030 #define NAN_INCLUDED_MyGlutMouseHandler_h
00031 
00032 #include "common/GlutMouseManager.h"
00033 #include "GHOST_IWindow.h"
00034 
00035 class MyGlutMouseHandler : public GlutMouseHandler
00036 {
00037 
00038 public :
00039  
00040         static 
00041                 MyGlutMouseHandler *
00042         New(
00043         ) {
00044                 return new MyGlutMouseHandler();
00045         }
00046 
00047                 void
00048         ButtonDown(
00049                 GHOST_IWindow * window,
00050                 GHOST_TButtonMask button_mask,
00051                 int x,
00052                 int y
00053         ){
00054                 if (button_mask == GHOST_kButtonMaskLeft) {
00055                         m_moving = true;
00056                         m_begin_x = x;
00057                         m_begin_y = y;  
00058                 }
00059                 window->invalidate();
00060         }
00061 
00062                 void
00063         ButtonUp(
00064                 GHOST_IWindow * window,
00065                 GHOST_TButtonMask button_mask,
00066                 int x,
00067                 int y
00068         ) {
00069                 if (button_mask == GHOST_kButtonMaskLeft) {
00070                         m_moving = false;
00071                 }
00072                 window->invalidate();
00073         }
00074 
00075                 void
00076         Motion(
00077                 GHOST_IWindow * window,
00078                 int x,
00079                 int y
00080         ){
00081                 if (m_moving) {
00082                         m_angle_x = m_angle_x + (x - m_begin_x);
00083                         m_begin_x = x;
00084 
00085                         m_angle_y = m_angle_y + (y - m_begin_y);
00086                         m_begin_y = y;
00087                 }
00088                 window->invalidate();
00089         }
00090 
00091         const 
00092                 float
00093         AngleX(
00094         ) const {
00095                 return m_angle_x;
00096         }
00097 
00098         const 
00099                 float
00100         AngleY(
00101         ) const {
00102                 return m_angle_y;
00103         }
00104 
00105         
00106 private :
00107 
00108         MyGlutMouseHandler (
00109         ) :  
00110                 m_angle_x(0),
00111                 m_angle_y(0),
00112                 m_begin_x(0),
00113                 m_begin_y(0),
00114                 m_moving (false)
00115         {
00116         };
00117                 
00118         float m_angle_x;
00119         float m_angle_y;
00120         float m_begin_x;
00121         float m_begin_y;
00122 
00123         bool m_moving;
00124         
00125 };
00126 
00127 #endif
00128