]> git.sesse.net Git - vlc/commitdiff
* gtk2_bitmap.cpp: fixed constructor bug
authorEmmanuel Puig <karibu@videolan.org>
Wed, 16 Apr 2003 19:22:53 +0000 (19:22 +0000)
committerEmmanuel Puig <karibu@videolan.org>
Wed, 16 Apr 2003 19:22:53 +0000 (19:22 +0000)
* Events work better: controls are working, not still perfectly...

modules/gui/skins/controls/button.cpp
modules/gui/skins/gtk2/gtk2_api.cpp
modules/gui/skins/gtk2/gtk2_bitmap.cpp
modules/gui/skins/gtk2/gtk2_event.cpp
modules/gui/skins/gtk2/gtk2_run.cpp
modules/gui/skins/src/bitmap.cpp
modules/gui/skins/src/event.cpp
modules/gui/skins/src/window.cpp
modules/gui/skins/win32/win32_bitmap.cpp

index c8b57f86dfaf1662394de50b2a5c2a046fb3157f..f4868c64dfd98791e434ffa30dde1429b1cf7fd1 100644 (file)
@@ -2,7 +2,7 @@
  * button.cpp: Button control
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: button.cpp,v 1.6 2003/04/15 20:33:58 karibu Exp $
+ * $Id: button.cpp,v 1.7 2003/04/16 19:22:53 karibu Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
@@ -137,6 +137,7 @@ bool ControlButton::MouseUp( int x, int y, int button )
     // If hit in the button
     if( Img[1]->Hit( x - Left, y - Top ) )
     {
+        fprintf( stderr, "    Button up ! (%i;%i)\n", button, (int)Selected );
         if( !Enabled )
             return true;
 
@@ -160,17 +161,20 @@ bool ControlButton::MouseDown( int x, int y, int button )
 {
     if( Img[0]->Hit( x - Left, y - Top ) )
     {
+        fprintf( stderr, "    Button down ! (%i)\n", button );
         if( !Enabled )
             return true;
 
+        fprintf( stderr, "    Button down ! (%i)\n", button );
         if( button == 1 )
         {
             State = 0;
             Selected = true;
+            fprintf( stderr, "    Button down ! (%i)\n", (int)Selected );
             ParentWindow->Refresh( Left, Top, Width, Height );
+            fprintf( stderr, "    Button down ! (%i)\n", (int)Selected );
             return true;
         }
-        fprintf( stderr, "button\n" );
     }
 
     return false;
index 7cb3ebccca90b7a873b75588c7a3b81d8ea7a619..4357ee1667e831055dc51122155c0a69a5cc55ca 100644 (file)
@@ -2,7 +2,7 @@
  * gtk2_api.cpp: Various gtk2-specific functions
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: gtk2_api.cpp,v 1.9 2003/04/16 14:38:04 asmax Exp $
+ * $Id: gtk2_api.cpp,v 1.10 2003/04/16 19:22:53 karibu Exp $
  *
  * Authors: Cyril Deguet  <asmax@videolan.org>
  *
@@ -65,11 +65,6 @@ void OSAPI_PostMessage( Window *win, unsigned int message, unsigned int param1,
     event->data.l[1] = param1;
     event->data.l[2] = param2;
 
-    if( message == VLC_HIDE )
-    {
-        fprintf( stderr, "======= message %i %x\n", message, event );
-    }
-
     gdk_event_put( (GdkEvent *)event );
 
     delete event;
index c5978decf6e8b886abc404838dd556163a9d9f54..d3eed58c5f05de53a321f47bfbdff476667316e8 100644 (file)
@@ -2,7 +2,7 @@
  * gtk2_bitmap.cpp: GTK2 implementation of the Bitmap class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: gtk2_bitmap.cpp,v 1.11 2003/04/16 14:38:04 asmax Exp $
+ * $Id: gtk2_bitmap.cpp,v 1.12 2003/04/16 19:22:53 karibu Exp $
  *
  * Authors: Cyril Deguet     <asmax@videolan.org>
  *
@@ -50,7 +50,6 @@ GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, string FileName, int AColor )
     HBITMAP HBuf;
     BITMAP  Bmp;
     HDC     bufDC;
-    AlphaColor = AColor;
 
     // Create image from file if it exists
     HBitmap = (HBITMAP) LoadImage( NULL, FileName.c_str(), IMAGE_BITMAP,
@@ -169,36 +168,34 @@ void GTK2Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
 //---------------------------------------------------------------------------
 bool GTK2Bitmap::Hit( int x, int y)
 {
-    if( x < 0 || x >= Width || y < 0 || y >= Height )
+    unsigned int c = (unsigned int)GetBmpPixel( x, y );
+
+    if( c == -1 || c == AlphaColor )
         return false;
+    else
+        return true;
+}
+//---------------------------------------------------------------------------
+int GTK2Bitmap::GetBmpPixel( int x, int y )
+{
+    if( x < 0 || x >= Width || y < 0 || y >= Height )
+        return -1;
 
-/* FIXME */
     guchar *pixels;
     int rowstride, offset;
     gboolean has_alpha;
 
     rowstride = gdk_pixbuf_get_rowstride( Bmp );
-    pixels    = gdk_pixbuf_get_pixels( Bmp );
+    pixels    = gdk_pixbuf_get_pixels( Bmp ); 
     has_alpha = gdk_pixbuf_get_has_alpha( Bmp );
 
     offset = y * rowstride + ( x * (has_alpha ? 4 : 3) );
 
     int r = pixels [offset];
-    int g = pixels [offset + 1];
-    int b = pixels [offset + 2];
-    unsigned int c = r + g * 256 + b * 65536;
-    /* If has_alpha == TRUE, then the alpha component is in
-       pixels [offset + 3] */
+    int g = pixels [offset + 1] << 8;
+    int b = pixels [offset + 2] << 16;
 
-    if( c == AlphaColor )
-        return false;
-    else
-        return true;
-}
-//---------------------------------------------------------------------------
-int GTK2Bitmap::GetBmpPixel( int x, int y )
-{
-//    return GetPixel( bmpDC, x, y );
+    return r + g + b;
 }
 //---------------------------------------------------------------------------
 void GTK2Bitmap::SetBmpPixel( int x, int y, int color )
index 91fe2d597d871372fb68b94d7ccc058a61b7360b..c80fe773e1376b21fd3beaa89cd4df4dc59bd422 100644 (file)
@@ -2,7 +2,7 @@
  * gtk2_event.cpp: GTK2 implementation of the Event class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: gtk2_event.cpp,v 1.7 2003/04/15 20:54:58 karibu Exp $
+ * $Id: gtk2_event.cpp,v 1.8 2003/04/16 19:22:53 karibu Exp $
  *
  * Authors: Cyril Deguet     <asmax@videolan.org>
  *
@@ -92,9 +92,9 @@ bool GTK2Event::SendEvent()
 //---------------------------------------------------------------------------
 bool GTK2Event::IsEqual( Event *evt )
 {
-/*    GTK2Event *WinEvt = (GTK2Event *)evt;
-    return( WinEvt->GetWindow() == hWnd   && WinEvt->GetMessage() == Message &&
-            WinEvt->GetParam1() == Param1 && WinEvt->GetParam2()  == Param2 );*/
+    GTK2Event *GTKEvt = (GTK2Event *)evt;
+    return( GTKEvt->GetWindow() == gWnd   && GTKEvt->GetMessage() == Message &&
+            GTKEvt->GetParam1() == Param1 && GTKEvt->GetParam2()  == Param2 );
 }
 //---------------------------------------------------------------------------
 void GTK2Event::CreateOSEvent( string para1, string para2, string para3 )
index bc812af251538194616a436b52b8f9316034aadb..6bf4bea1b54d821ca47a576fdfeea833d918bed8 100644 (file)
@@ -2,7 +2,7 @@
  * gtk2_run.cpp:
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: gtk2_run.cpp,v 1.8 2003/04/15 20:42:04 karibu Exp $
+ * $Id: gtk2_run.cpp,v 1.9 2003/04/16 19:22:53 karibu Exp $
  *
  * Authors: Cyril Deguet     <asmax@videolan.org>
  *
@@ -95,10 +95,15 @@ void GTK2Proc( GdkEvent *event, gpointer data )
             ((GdkEventAny *)event)->window, msg, 0, (long)event );
     }
 
+    // Send event
     if( IsVLCEvent( msg ) )
     {
         if( !proc->EventProc( evt ) )
+        {
+            fprintf( stderr, "Quit\n" );
+            g_main_context_unref( g_main_context_default() );
             return;      // Exit VLC !
+        }
     }
     else if( gwnd == NULL )
     {
@@ -131,8 +136,12 @@ void GTK2Proc( GdkEvent *event, gpointer data )
         }
     }
 
+    evt->DestructParameters();
     delete (OSEvent *)evt;
 
+    // Check if vlc is closing
+    proc->IsClosing();
+
 #if 0
     // If Window is parent window
     if( hwnd == ( (GTK2Theme *)p_intf->p_sys->p_theme )->GetParentWindow() )
index 1f7c8d1f0ff06b71c47dde1077f3e7daaf2b1322..03d48eadb72c308453b51a470e4db399470b31c8 100644 (file)
@@ -2,7 +2,7 @@
  * bitmap.cpp: Bitmap class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: bitmap.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
+ * $Id: bitmap.cpp,v 1.2 2003/04/16 19:22:53 karibu Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
 //---------------------------------------------------------------------------
 Bitmap::Bitmap( intf_thread_t *_p_intf, string FileName, int AColor )
 {
-    p_intf = _p_intf;
+    p_intf     = _p_intf;
+    AlphaColor = AColor;
 }
 //---------------------------------------------------------------------------
 Bitmap::Bitmap( intf_thread_t *_p_intf, Graphics *from, int x, int y,
                 int w, int h, int AColor )
 {
-    p_intf = _p_intf;
+    p_intf     = _p_intf;
+    AlphaColor = AColor;
 }
 //---------------------------------------------------------------------------
 Bitmap::Bitmap( intf_thread_t *_p_intf, Bitmap *c )
index 793244d58c00b6df43a99914fa0ad9a83024fb37..1b300cf2c4dad70cff100b2fedc2cd3dca4c64e6 100644 (file)
@@ -2,7 +2,7 @@
  * event.cpp: Event class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: event.cpp,v 1.9 2003/04/16 14:38:04 asmax Exp $
+ * $Id: event.cpp,v 1.10 2003/04/16 19:22:53 karibu Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
@@ -103,9 +103,7 @@ void Event::PostTextMessage( string text )
 {
     char *txt = new char[text.size()+1];
     strcpy( txt, text.c_str() );
-   // OSAPI_PostMessage( NULL, CTRL_SET_TEXT, (unsigned int)this, (long)txt );
-/* FIXME */   
-   fprintf(stderr, "posttext %s\n", text.c_str());
+    OSAPI_PostMessage( NULL, CTRL_SET_TEXT, (unsigned int)this, (long)txt );
 }
 //---------------------------------------------------------------------------
 unsigned int Event::GetMessageType( string Desc )
index 9c52344237cce0b61376bb002f53ac2d190942f9..a529d1d029f68eeef33da0d9e50ded928ad8aac2 100644 (file)
@@ -2,7 +2,7 @@
  * window.cpp: Window class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: window.cpp,v 1.13 2003/04/16 15:34:36 asmax Exp $
+ * $Id: window.cpp,v 1.14 2003/04/16 19:22:53 karibu Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
@@ -297,6 +297,8 @@ void Window::Refresh( int x, int y, int w, int h )
     if( Hidden )
         return;
 
+    fprintf( stderr, "Refresh: %i %i %i %i\n", x, y, w, h );
+
     // And copy buffer to window
     RefreshFromImage( x, y, w, h );
 
@@ -386,8 +388,16 @@ void Window::MouseUp( int x, int y, int button )
     // Checking event in controls
     for( i = ControlList.size() - 1; i >= 0 ; i-- )
     {
+        fprintf( stderr, "  -> Control\n" );
         if( ControlList[i]->MouseUp( x, y, button ) )
+        {
+            int x, y;
+            //ControlList[i]->GetSize( x, y );
+            fprintf( stderr, "    x: %i\n    y: %i\n",
+                ControlList[i]->Left, ControlList[i]->Top );
+                
             return;
+        }
     }
 }
 //---------------------------------------------------------------------------
index c955a0b0b63a6ad924354625ce680f6b4d12eb82..e5096ecb688ff9c84a162043468f6dc00d32a517 100644 (file)
@@ -2,7 +2,7 @@
  * win32_bitmap.cpp: Win32 implementation of the Bitmap class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: win32_bitmap.cpp,v 1.2 2003/04/12 21:43:27 asmax Exp $
+ * $Id: win32_bitmap.cpp,v 1.3 2003/04/16 19:22:53 karibu Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
@@ -52,7 +52,6 @@ Win32Bitmap::Win32Bitmap( intf_thread_t *p_intf, string FileName, int AColor )
     HBITMAP HBuf;
     BITMAP  Bmp;
     HDC     bufDC;
-    AlphaColor = AColor;
 
     // Create image from file if it exists
     HBitmap = (HBITMAP) LoadImage( NULL, FileName.c_str(), IMAGE_BITMAP,