]> git.sesse.net Git - vlc/commitdiff
* skins2/win32/win32_window.cpp: Transparency works correctly (this is
authorOlivier Teulière <ipkiss@videolan.org>
Thu, 8 Apr 2004 17:54:03 +0000 (17:54 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Thu, 8 Apr 2004 17:54:03 +0000 (17:54 +0000)
   controlled by the 'alpha' and 'movealpha' attributes of the 'Theme'
   tag). Win32 only.
   Note: It is advised to use 255 for the alpha value, otherwise resizing
   will be slowed down a lot...

modules/gui/skins2/src/os_window.hpp
modules/gui/skins2/win32/win32_window.cpp
modules/gui/skins2/win32/win32_window.hpp
modules/gui/skins2/x11/x11_window.cpp
modules/gui/skins2/x11/x11_window.hpp

index adea9d25b82af0281ef2b9a4f820877a8aa0be09..c0875c36a2b42113345d1c239ab2824e69b97741 100644 (file)
@@ -51,7 +51,7 @@ class OSWindow: public SkinObject
         virtual void raise() const = 0;
 
         /// Set the opacity of the window (0 = transparent, 255 = opaque)
-        virtual void setOpacity( uint8_t value ) = 0;
+        virtual void setOpacity( uint8_t value ) const = 0;
 
         /// Toggle the window on top
         virtual void toggleOnTop( bool onTop ) const = 0;
index d9bb964107fbf851bf33ff9ab7cea6cd39c95b3c..4905835e4f80df8631c7d2c2109fb8039f43569f 100644 (file)
 
 
 /// Fading API
-#define LWA_COLORKEY  0x00000001
-#define LWA_ALPHA     0x00000002
+#ifndef LWA_COLORKEY
+#   define LWA_COLORKEY  0x00000001
+#   define LWA_ALPHA     0x00000002
+#endif
 
 
 Win32Window::Win32Window( intf_thread_t *pIntf, GenericWindow &rWindow,
                           HINSTANCE hInst, HWND hParentWindow,
                           bool dragDrop, bool playOnDrop,
                           Win32Window *pParentWindow ):
-    OSWindow( pIntf ), m_dragDrop( dragDrop ), m_mm( false )
+    OSWindow( pIntf ), m_dragDrop( dragDrop )
 {
     // Create the window
     if( pParentWindow )
@@ -66,8 +68,8 @@ Win32Window::Win32Window( intf_thread_t *pIntf, GenericWindow &rWindow,
 
     // We do it this way otherwise CreateWindowEx will fail if WS_EX_LAYERED
     // is not supported
-//    SetWindowLongPtr( m_hWnd, GWL_EXSTYLE,
-//                      GetWindowLong( m_hWnd, GWL_EXSTYLE ) | WS_EX_LAYERED );
+    SetWindowLongPtr( m_hWnd, GWL_EXSTYLE,
+                      GetWindowLong( m_hWnd, GWL_EXSTYLE ) | WS_EX_LAYERED );
 
     // Store a pointer to the GenericWindow in a map
     Win32Factory *pFactory = (Win32Factory*)Win32Factory::instance( getIntf() );
@@ -134,52 +136,37 @@ void Win32Window::raise() const
 }
 
 
-void Win32Window::setOpacity( uint8_t value )
+void Win32Window::setOpacity( uint8_t value ) const
 {
     Win32Factory *pFactory = (Win32Factory*)Win32Factory::instance( getIntf() );
-#if 0
+
     if( value == 255 )
     {
         // If the window is opaque, we remove the WS_EX_LAYERED attribute
         // which slows resizing for nothing
-        if( m_mm )
-        {
-            SetWindowLongPtr( m_hWnd, GWL_EXSTYLE,
-                GetWindowLong( m_hWnd, GWL_EXSTYLE ) & !WS_EX_LAYERED );
-            SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0,
-                SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED );
-            m_mm = false;
-        }
-//    GenericWindow *pWin = pFactory->m_windowMap[m_hWnd];
-//    pWin->refresh( pWin->getLeft(), pWin->getTop(), pWin->getWidth(), pWin->getHeight() );
-
+        SetWindowLongPtr( m_hWnd, GWL_EXSTYLE,
+            GetWindowLong( m_hWnd, GWL_EXSTYLE ) & !WS_EX_LAYERED );
+        SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0,
+            SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED );
     }
     else
-#endif
     {
         if( pFactory->SetLayeredWindowAttributes )
         {
-#if 0
             // (Re)Add the WS_EX_LAYERED attribute.
             // Resizing will be very slow, now :)
-            if( !m_mm )
-            {
-                SetWindowLongPtr( m_hWnd, GWL_EXSTYLE,
-                    GetWindowLong( m_hWnd, GWL_EXSTYLE ) | WS_EX_LAYERED );
-                SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0,
-                    SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED );
-                m_mm = true;
-            }
-//    GenericWindow *pWin = pFactory->m_windowMap[m_hWnd];
-//    pWin->refresh( pWin->getLeft(), pWin->getTop(), pWin->getWidth(), pWin->getHeight() );
-#endif
+            SetWindowLongPtr( m_hWnd, GWL_EXSTYLE,
+                GetWindowLong( m_hWnd, GWL_EXSTYLE ) | WS_EX_LAYERED );
+            SetWindowPos( m_hWnd, HWND_TOP, 0, 0, 0, 0,
+                SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED );
+
             // Change the opacity
             pFactory->SetLayeredWindowAttributes(
                 m_hWnd, 0, value, LWA_ALPHA|LWA_COLORKEY );
         }
     }
 
-//    UpdateWindow( m_hWnd );
+   UpdateWindow( m_hWnd );
 }
 
 
index 76a895d339a4993d0aa276596e3c310f6010e8e4..8dc561a847c94e8bfc1df1605a8e9343b6d227a7 100644 (file)
@@ -54,7 +54,7 @@ class Win32Window: public OSWindow
         virtual void raise() const;
 
         /// Set the opacity of the window (0 = transparent, 255 = opaque)
-        virtual void setOpacity( uint8_t value );
+        virtual void setOpacity( uint8_t value ) const;
 
         /// Toggle the window on top
         virtual void toggleOnTop( bool onTop ) const;
@@ -69,7 +69,6 @@ class Win32Window: public OSWindow
         bool m_dragDrop;
         /// Drop target
         LPDROPTARGET m_pDropTarget;
-        bool m_mm;
 };
 
 
index a241108cfda56e1017397d87bd5347ad66d1d106..dac7f95367a019cbd00f042dce7e699894371487 100644 (file)
@@ -168,7 +168,7 @@ void X11Window::raise() const
 }
 
 
-void X11Window::setOpacity( uint8_t value )
+void X11Window::setOpacity( uint8_t value ) const
 {
     // Sorry, the opacity cannot be changed :)
 }
index ce08775f544b99ca2242d0a5930f4163a3f5f978..25335d010c42ea9f58cde64cf6f6cd340b14c3b5 100644 (file)
@@ -57,7 +57,7 @@ class X11Window: public OSWindow
         virtual void raise() const;
 
         /// Set the opacity of the window (0 = transparent, 255 = opaque)
-        virtual void setOpacity( uint8_t value );
+        virtual void setOpacity( uint8_t value ) const;
 
         /// Toggle the window on top
         virtual void toggleOnTop( bool onTop ) const;