]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins/src/window.cpp
* src/theme.cpp, src/event.* : no more VLC_SHOW event
[vlc] / modules / gui / skins / src / window.cpp
index e2001dbb8d4633570bf71360d6fa9346a29270e2..4e38c35e8e4c637c6d0b183813861f6e93e8e306 100644 (file)
@@ -2,10 +2,11 @@
  * window.cpp: Window class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: window.cpp,v 1.22 2003/04/30 21:16:24 asmax Exp $
+ * $Id: window.cpp,v 1.31 2003/06/22 00:00:28 asmax Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
+ *          Cyril Deguet     <asmax@videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -38,6 +39,7 @@
 #include "banks.h"
 #include "theme.h"
 #include "skin_common.h"
+#include "dialogs.h"
 
 #include <stdio.h>
 
@@ -86,6 +88,10 @@ SkinWindow::SkinWindow( intf_thread_t *_p_intf, int x, int y, bool visible,
 //---------------------------------------------------------------------------
 SkinWindow::~SkinWindow()
 {
+    if( Image )
+    {
+        delete Image;
+    }
     // Destroy the controls
     for( unsigned int i = 0; i < ControlList.size(); i++ )
         delete ControlList[i];
@@ -290,12 +296,12 @@ void SkinWindow::RefreshImage( int x, int y, int w, int h )
     unsigned int i;
 
     // Create Bitmap Buffer
-//    Graphics *Buffer = (Graphics *)new OSGraphics( p_intf, w, h, this );
-    Graphics *Buffer = (Graphics *)new OSGraphics( w, h, this );
+    Graphics *Buffer = (Graphics *)new OSGraphics( p_intf, w, h, this );
+//    Graphics *Buffer = (Graphics *)new OSGraphics( w, h, this );
 
     // Draw every control
-        for( i = 0; i < ControlList.size(); i++ )
-            ControlList[i]->Draw( x, y, w, h, Buffer );
+    for( i = 0; i < ControlList.size(); i++ )
+        ControlList[i]->Draw( x, y, w, h, Buffer );
 
     // Copy buffer in Image
     Image->CopyFrom( x, y, w, h, Buffer, 0, 0, SRC_COPY );
@@ -317,7 +323,6 @@ void SkinWindow::Refresh( int x, int y, int w, int h )
 
     // And copy buffer to window
     RefreshFromImage( x, y, w, h );
-
 }
 //---------------------------------------------------------------------------
 void SkinWindow::RefreshAll()
@@ -328,14 +333,16 @@ void SkinWindow::RefreshAll()
 void SkinWindow::MouseDown( int x, int y, int button )
 {
     // Checking event in controls
-    for( int i = ControlList.size() - 1; i >= 0 ; i-- )
+    for( int i = ControlList.size() - 1; i >= 0; i-- )
     {
-        if( ControlList[i]->MouseDown( x, y, button ) )
+        if( ControlList[i]->IsVisible() &&
+            ControlList[i]->MouseDown( x, y, button ) )
         {
-            return;
+            msg_Dbg( p_intf, "Mouse down (ID=%s)",
+                     ControlList[i]->GetId().c_str() );
+            break;
         }
     }
-
 }
 //---------------------------------------------------------------------------
 void SkinWindow::MouseMove( int x, int y, int button  )
@@ -349,20 +356,22 @@ void SkinWindow::MouseMove( int x, int y, int button  )
     }
 
     // Checking event in controls
-    for( i = ControlList.size() - 1; i >= 0 ; i-- )
+    for( i = ControlList.size() - 1; i >= 0; i-- )
     {
-        ControlList[i]->MouseMove( x, y, button );
+        if( ControlList[i]->IsVisible() &&
+            ControlList[i]->MouseMove( x, y, button ) )
+        {
+            break;
+        }
     }
 
     // Checking help text
-    for( i = ControlList.size() - 1; i >= 0 ; i-- )
+    for( i = ControlList.size() - 1; i >= 0; i-- )
     {
-        if( ControlList[i]->MouseOver( x, y ) )
+        if( ControlList[i]->IsVisible() && ControlList[i]->MouseOver( x, y ) )
         {
-            if( ControlList[i]->SendNewHelpText() )
-            {
-                break;
-            }
+            ControlList[i]->SendNewHelpText();
+            break;
         }
     }
 
@@ -374,10 +383,13 @@ void SkinWindow::MouseMove( int x, int y, int button  )
     }
 
     // Checking for change in Tool Tip
-    for( i = ControlList.size() - 1; i >= 0 ; i-- )
+    for( i = ControlList.size() - 1; i >= 0; i-- )
     {
-        if( ControlList[i]->ToolTipTest( x, y ) )
+        if( ControlList[i]->IsVisible() &&
+            ControlList[i]->ToolTipTest( x, y ) )
+        {
             break;
+        }
     }
 
     // If no change, delete tooltip text
@@ -402,13 +414,21 @@ void SkinWindow::MouseUp( int x, int y, int button )
     }
 
     // Checking event in controls
-    for( i = ControlList.size() - 1; i >= 0 ; i-- )
+    for( i = ControlList.size() - 1; i >= 0; i-- )
     {
-        if( ControlList[i]->MouseUp( x, y, button ) )
+        if( ControlList[i]->IsVisible() &&
+            ControlList[i]->MouseUp( x, y, button ) )
         {
-            return;
+            msg_Dbg( p_intf, "Mouse up (ID=%s)",
+                     ControlList[i]->GetId().c_str() );
+            break;
         }
     }
+
+    if( i < 0  && button == MOUSE_RIGHT )
+    {
+        p_intf->p_sys->p_dialogs->ShowPopup();
+    }
 }
 //---------------------------------------------------------------------------
 void SkinWindow::MouseDblClick( int x, int y, int button )
@@ -416,23 +436,39 @@ void SkinWindow::MouseDblClick( int x, int y, int button )
     int i;
 
     // Checking event in controls
-    for( i = ControlList.size() - 1; i >= 0 ; i-- )
+    for( i = ControlList.size() - 1; i >= 0; i-- )
     {
-        if( ControlList[i]->MouseDblClick( x, y, button ) )
-            return;
+        if( ControlList[i]->IsVisible() &&
+            ControlList[i]->MouseDblClick( x, y, button ) )
+        {
+            msg_Dbg( p_intf, "Double click (ID=%s)",
+                     ControlList[i]->GetId().c_str() );
+        }
     }
 }
 //---------------------------------------------------------------------------
 void SkinWindow::MouseScroll( int x, int y, int direction )
 {
     // Checking event in controls
-    for( int i = ControlList.size() - 1; i >= 0 ; i-- )
+    for( int i = ControlList.size() - 1; i >= 0; i-- )
+    {
+        if( ControlList[i]->IsVisible() &&
+            ControlList[i]->MouseScroll( x, y, direction ) )
+        {
+            break;
+        }
+    } 
+    
+    // Checking for change in Tool Tip
+    for( int i = ControlList.size() - 1; i >= 0; i-- )
     {
-        if( ControlList[i]->MouseScroll( x, y, direction ) )
+        if( ControlList[i]->IsVisible() &&
+            ControlList[i]->ToolTipTest( x, y ) )
         {
-            return;
+            break;
         }
     }
+
 }
 //---------------------------------------------------------------------------
 void SkinWindow::Init()
@@ -461,10 +497,10 @@ void SkinWindow::ReSize()
     {
 #define min(a,b) ((a)<(b))?(a):(b)
 #define max(a,b) ((a)>(b))?(a):(b)
-        w    = max( w,    ControlList[i]->Left + ControlList[i]->Width );
-        h    = max( h,    ControlList[i]->Top + ControlList[i]->Height );
-        MinX = min( MinX, ControlList[i]->Left );
-        MinY = min( MinY, ControlList[i]->Top );
+        w = max( w, ControlList[i]->GetLeft() + ControlList[i]->GetWidth() );
+        h = max( h, ControlList[i]->GetTop() + ControlList[i]->GetHeight() );
+        MinX = min( MinX, ControlList[i]->GetLeft() );
+        MinY = min( MinY, ControlList[i]->GetTop() );
 #undef max
 #undef min
     }
@@ -491,8 +527,7 @@ void SkinWindow::ReSize()
         // Change image buffer
         if( Image != NULL )
             delete (OSGraphics *)Image;
-//        Image = (Graphics *)new OSGraphics( p_intf, w, h, this );
-        Image = (Graphics *)new OSGraphics( w, h, this );
+        Image = (Graphics *)new OSGraphics( p_intf, w, h, this );
 
         Size( w, h );
     }
@@ -510,5 +545,42 @@ void SkinWindow::GetPos( int &x, int &y )
     x = Left;
     y = Top;
 }
-//---------------------------------------------------------------------------
 
+//---------------------------------------------------------------------------
+// List of all the Skin Windows (singleton)
+//---------------------------------------------------------------------------
+SkinWindowList *SkinWindowList::_instance = NULL;
+//---------------------------------------------------------------------------
+SkinWindowList::SkinWindowList()
+{
+}
+//---------------------------------------------------------------------------
+SkinWindowList *SkinWindowList::Instance()
+{
+    if( _instance == NULL )
+    {
+        _instance = new SkinWindowList;
+    }
+    return _instance;
+}
+//---------------------------------------------------------------------------
+void SkinWindowList::Add( SkinWindow *win )
+{
+    _list.push_back( win );
+}
+//---------------------------------------------------------------------------
+SkinWindow *SkinWindowList::Back()
+{
+    return _list.back();
+}
+//---------------------------------------------------------------------------
+list<SkinWindow*>::const_iterator SkinWindowList::Begin()
+{
+    return _list.begin();
+}
+//---------------------------------------------------------------------------
+list<SkinWindow*>::const_iterator SkinWindowList::End()
+{
+    return _list.end();
+}
+//---------------------------------------------------------------------------