]> git.sesse.net Git - vlc/commitdiff
* skins2/*: Change mouse cursor above a Resize control (win32 only)
authorOlivier Teulière <ipkiss@videolan.org>
Fri, 5 Mar 2004 20:56:39 +0000 (20:56 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Fri, 5 Mar 2004 20:56:39 +0000 (20:56 +0000)
modules/gui/skins2/controls/ctrl_resize.cpp
modules/gui/skins2/controls/ctrl_resize.hpp
modules/gui/skins2/src/os_factory.hpp
modules/gui/skins2/win32/win32_factory.cpp
modules/gui/skins2/win32/win32_factory.hpp
modules/gui/skins2/x11/x11_factory.hpp

index 2dc06876721959fbed145324dea94b4ba1fab040..4a52e7881c2b9be552741ca09e632f991ab8a121 100755 (executable)
@@ -2,7 +2,7 @@
  * ctrl_resize.cpp
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: ctrl_resize.cpp,v 1.2 2004/02/29 16:49:55 asmax Exp $
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *          Olivier Teulière <ipkiss@via.ecp.fr>
@@ -27,6 +27,7 @@
 #include "../events/evt_mouse.hpp"
 #include "../events/evt_motion.hpp"
 #include "../src/generic_layout.hpp"
+#include "../src/os_factory.hpp"
 #include "../utils/position.hpp"
 #include "../commands/async_queue.hpp"
 #include "../commands/cmd_resize.hpp"
@@ -36,19 +37,26 @@ CtrlResize::CtrlResize( intf_thread_t *pIntf, CtrlFlat &rCtrl,
                         GenericLayout &rLayout, const UString &rHelp,
                         VarBool *pVisible ):
     CtrlFlat( pIntf, rHelp, pVisible ), m_fsm( pIntf ), m_rCtrl( rCtrl ),
-    m_rLayout( rLayout ), m_cmdResizeResize( this, &transResizeResize ),
+    m_rLayout( rLayout ), m_cmdOutStill( this, &transOutStill ),
+    m_cmdStillOut( this, &transStillOut ),
+    m_cmdStillStill( this, &transStillStill ),
     m_cmdStillResize( this, &transStillResize ),
-    m_cmdResizeStill( this, &transResizeStill )
+    m_cmdResizeStill( this, &transResizeStill ),
+    m_cmdResizeResize( this, &transResizeResize )
 {
     m_pEvt = NULL;
     m_xPos = 0;
     m_yPos = 0;
 
     // States
-    m_fsm.addState( "resize" );
+    m_fsm.addState( "out" );
     m_fsm.addState( "still" );
+    m_fsm.addState( "resize" );
 
     // Transitions
+    m_fsm.addTransition( "out", "enter", "still", &m_cmdOutStill );
+    m_fsm.addTransition( "still", "leave", "out", &m_cmdStillOut );
+    m_fsm.addTransition( "still", "motion", "still", &m_cmdStillStill );
     m_fsm.addTransition( "resize", "mouse:left:up:none", "still",
                          &m_cmdResizeStill );
     m_fsm.addTransition( "still", "mouse:left:down:none", "resize",
@@ -95,11 +103,39 @@ void CtrlResize::handleEvent( EvtGeneric &rEvent )
 }
 
 
+void CtrlResize::transOutStill( SkinObject *pCtrl )
+{
+    CtrlResize *pThis = (CtrlResize*)pCtrl;
+    OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
+    pOsFactory->changeCursor( OSFactory::kResizeNWSE );
+}
+
+
+void CtrlResize::transStillOut( SkinObject *pCtrl )
+{
+    CtrlResize *pThis = (CtrlResize*)pCtrl;
+    OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
+    pOsFactory->changeCursor( OSFactory::kDefaultArrow );
+}
+
+
+void CtrlResize::transStillStill( SkinObject *pCtrl )
+{
+    CtrlResize *pThis = (CtrlResize*)pCtrl;
+    OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
+    pOsFactory->changeCursor( OSFactory::kResizeNWSE );
+}
+
+
 void CtrlResize::transStillResize( SkinObject *pCtrl )
 {
     CtrlResize *pThis = (CtrlResize*)pCtrl;
     EvtMouse *pEvtMouse = (EvtMouse*)pThis->m_pEvt;
 
+    // Set the cursor
+    OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
+    pOsFactory->changeCursor( OSFactory::kResizeNWSE );
+
     pThis->m_xPos = pEvtMouse->getXPos();
     pThis->m_yPos = pEvtMouse->getYPos();
 
@@ -110,11 +146,27 @@ void CtrlResize::transStillResize( SkinObject *pCtrl )
 }
 
 
+void CtrlResize::transResizeStill( SkinObject *pCtrl )
+{
+    CtrlResize *pThis = (CtrlResize*)pCtrl;
+
+    // Set the cursor
+    OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
+    pOsFactory->changeCursor( OSFactory::kResizeNWSE );
+
+    pThis->releaseMouse();
+}
+
+
 void CtrlResize::transResizeResize( SkinObject *pCtrl )
 {
     CtrlResize *pThis = (CtrlResize*)pCtrl;
     EvtMotion *pEvtMotion = (EvtMotion*)pThis->m_pEvt;
 
+    // Set the cursor
+    OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
+    pOsFactory->changeCursor( OSFactory::kResizeNWSE );
+
     int newWidth = pEvtMotion->getXPos() - pThis->m_xPos + pThis->m_width;
     int newHeight = pEvtMotion->getYPos() - pThis->m_yPos + pThis->m_height;
 
@@ -144,12 +196,3 @@ void CtrlResize::transResizeResize( SkinObject *pCtrl )
     pQueue->remove( "resize" );
     pQueue->push( CmdGenericPtr( pCmd ) );
 }
-
-
-void CtrlResize::transResizeStill( SkinObject *pCtrl )
-{
-    CtrlResize *pThis = (CtrlResize*)pCtrl;
-
-    pThis->releaseMouse();
-}
-
index 0423d42e036c1946268b94cace5e035cc72e69a3..fff8cac15a926a84079f79d8205dc486a616a9ce 100644 (file)
@@ -2,7 +2,7 @@
  * ctrl_resize.hpp
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: ctrl_resize.hpp,v 1.2 2004/02/29 16:49:55 asmax Exp $
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *          Olivier Teulière <ipkiss@via.ecp.fr>
@@ -57,9 +57,12 @@ class CtrlResize: public CtrlFlat
         /// Get the position of the decorated control in the layout, if any
         virtual const Position *getPosition() const;
 
-        static void transResizeResize( SkinObject *pCtrl );
+        static void transOutStill( SkinObject *pCtrl );
+        static void transStillOut( SkinObject *pCtrl );
+        static void transStillStill( SkinObject *pCtrl );
         static void transStillResize( SkinObject *pCtrl );
         static void transResizeStill( SkinObject *pCtrl );
+        static void transResizeResize( SkinObject *pCtrl );
 
     private:
         FSM m_fsm;
@@ -72,9 +75,12 @@ class CtrlResize: public CtrlFlat
         /// Position of the click that started the resizing
         int m_xPos, m_yPos;
         /// Callbacks
-        Callback m_cmdResizeResize;
+        Callback m_cmdOutStill;
+        Callback m_cmdStillOut;
+        Callback m_cmdStillStill;
         Callback m_cmdStillResize;
         Callback m_cmdResizeStill;
+        Callback m_cmdResizeResize;
 
         // Size of the layout, before resizing
         int m_width, m_height;
index d1c26daa5d56d96eb975eee3457b0db76acf5b7d..9bcb039484736d615f27c10e759d3d6e52c38732 100644 (file)
@@ -2,7 +2,7 @@
  * os_factory.hpp
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: os_factory.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *          Olivier Teulière <ipkiss@via.ecp.fr>
@@ -42,6 +42,15 @@ class OSTimer;
 class OSFactory: public SkinObject
 {
     public:
+        typedef enum
+        {
+            kDefaultArrow,
+            kResizeNS,
+            kResizeWE,
+            kResizeNWSE,
+            kResizeNESW
+        } CursorType_t;
+
         /// Initialization method overloaded in derived classes.
         /// It must return false if the init failed.
         virtual bool init() { return true; }
@@ -85,6 +94,9 @@ class OSFactory: public SkinObject
         /// Get the position of the mouse
         virtual void getMousePos( int &rXPos, int &rYPos ) const = 0;
 
+        /// Change the cursor
+        virtual void changeCursor( CursorType_t type ) const = 0;
+
         /// Delete a directory recursively
         virtual void rmDir( const string &rPath ) = 0;
 
index 7427c9332273051c8a238ffaf10d5887a4684e7b..99acc294b55f4395702574494ec879107b2dfb56 100644 (file)
@@ -2,7 +2,7 @@
  * win32_factory.cpp
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: win32_factory.cpp,v 1.2 2004/01/27 17:01:51 gbazin Exp $
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *          Olivier Teulière <ipkiss@via.ecp.fr>
@@ -271,6 +271,36 @@ void Win32Factory::getMousePos( int &rXPos, int &rYPos ) const
 }
 
 
+void Win32Factory::changeCursor( CursorType_t type ) const
+{
+    LPCTSTR id;
+    switch( type )
+    {
+        case kDefaultArrow:
+            id = IDC_ARROW;
+            break;
+        case kResizeNWSE:
+            id = IDC_SIZENWSE;
+            break;
+        case kResizeNS:
+            id = IDC_SIZENS;
+            break;
+        case kResizeWE:
+            id = IDC_SIZEWE;
+            break;
+        case kResizeNESW:
+            id = IDC_SIZENESW;
+            break;
+        default:
+            id = IDC_ARROW;
+            break;
+    }
+
+    HCURSOR hCurs = LoadCursor( NULL, id );
+    SetCursor( hCurs );
+}
+
+
 void Win32Factory::rmDir( const string &rPath )
 {
     WIN32_FIND_DATA find;
index 573e285a3eff87049df27fbf32635feb0a43a3aa..526929a19a492067f5890a0b1616b0e44e012a40 100644 (file)
@@ -2,7 +2,7 @@
  * win32_factory.hpp
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: win32_factory.hpp,v 1.3 2004/02/27 13:24:12 gbazin Exp $
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *          Olivier Teulière <ipkiss@via.ecp.fr>
@@ -25,7 +25,9 @@
 #ifndef WIN32_FACTORY_HPP
 #define WIN32_FACTORY_HPP
 
-#define _WIN32_WINNT 0x0500
+#ifndef _WIN32_WINNT
+#   define _WIN32_WINNT 0x0500
+#endif
 
 #include <windows.h>
 #include "../src/os_factory.hpp"
@@ -74,6 +76,9 @@ class Win32Factory: public OSFactory
         /// Get the position of the mouse
         virtual void getMousePos( int &rXPos, int &rYPos ) const;
 
+        /// Change the cursor
+        virtual void changeCursor( CursorType_t type ) const;
+
         /// Delete a directory recursively
         virtual void rmDir( const string &rPath );
 
@@ -86,8 +91,8 @@ class Win32Factory: public OSFactory
         // We dynamically load msimg32.dll to get a pointer to TransparentBlt()
         BOOL (WINAPI *TransparentBlt)( HDC, int, int, int, int,
                                        HDC, int, int, int, int, UINT );
-        BOOL (WINAPI *AlphaBlend)( HDC, int, int, int, int, HDC, int, int,
-                                   int, int, BLENDFUNCTION );
+        BOOL (WINAPI *AlphaBlend)( HDC, int, int, int, int,
+                                   HDC, int, int, int, int, BLENDFUNCTION );
 
         // Idem for user32.dll and SetLayeredWindowAttributes()
         BOOL (WINAPI *SetLayeredWindowAttributes)( HWND, COLORREF,
index 9deb73dc00e2454e54d09320b7829ba8463a2dfa..b3cfd0c600e5632adad021293509767b1f2140fd 100644 (file)
@@ -2,7 +2,7 @@
  * x11_factory.hpp
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: x11_factory.hpp,v 1.2 2004/01/18 00:25:02 asmax Exp $
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *          Olivier Teulière <ipkiss@via.ecp.fr>
@@ -82,6 +82,9 @@ class X11Factory: public OSFactory
         /// Get the position of the mouse
         virtual void getMousePos( int &rXPos, int &rYPos ) const;
 
+        /// Change the cursor
+        virtual void changeCursor( CursorType_t type ) const { /*TODO*/ }
+
         /// Delete a directory recursively
         virtual void rmDir( const string &rPath );