Commit 5e0f6df7 authored by Emmanuel Puig's avatar Emmanuel Puig

* gtk2_bitmap.cpp: fixed constructor bug

* Events work better: controls are working, not still perfectly...
parent 88e6ced2
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* button.cpp: Button control * button.cpp: Button control
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * 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 Teulire <ipkiss@via.ecp.fr> * Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -137,6 +137,7 @@ bool ControlButton::MouseUp( int x, int y, int button ) ...@@ -137,6 +137,7 @@ bool ControlButton::MouseUp( int x, int y, int button )
// If hit in the button // If hit in the button
if( Img[1]->Hit( x - Left, y - Top ) ) if( Img[1]->Hit( x - Left, y - Top ) )
{ {
fprintf( stderr, " Button up ! (%i;%i)\n", button, (int)Selected );
if( !Enabled ) if( !Enabled )
return true; return true;
...@@ -160,17 +161,20 @@ bool ControlButton::MouseDown( int x, int y, int button ) ...@@ -160,17 +161,20 @@ bool ControlButton::MouseDown( int x, int y, int button )
{ {
if( Img[0]->Hit( x - Left, y - Top ) ) if( Img[0]->Hit( x - Left, y - Top ) )
{ {
fprintf( stderr, " Button down ! (%i)\n", button );
if( !Enabled ) if( !Enabled )
return true; return true;
fprintf( stderr, " Button down ! (%i)\n", button );
if( button == 1 ) if( button == 1 )
{ {
State = 0; State = 0;
Selected = true; Selected = true;
fprintf( stderr, " Button down ! (%i)\n", (int)Selected );
ParentWindow->Refresh( Left, Top, Width, Height ); ParentWindow->Refresh( Left, Top, Width, Height );
fprintf( stderr, " Button down ! (%i)\n", (int)Selected );
return true; return true;
} }
fprintf( stderr, "button\n" );
} }
return false; return false;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_api.cpp: Various gtk2-specific functions * gtk2_api.cpp: Various gtk2-specific functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * 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> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -65,11 +65,6 @@ void OSAPI_PostMessage( Window *win, unsigned int message, unsigned int param1, ...@@ -65,11 +65,6 @@ void OSAPI_PostMessage( Window *win, unsigned int message, unsigned int param1,
event->data.l[1] = param1; event->data.l[1] = param1;
event->data.l[2] = param2; event->data.l[2] = param2;
if( message == VLC_HIDE )
{
fprintf( stderr, "======= message %i %x\n", message, event );
}
gdk_event_put( (GdkEvent *)event ); gdk_event_put( (GdkEvent *)event );
delete event; delete event;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_bitmap.cpp: GTK2 implementation of the Bitmap class * gtk2_bitmap.cpp: GTK2 implementation of the Bitmap class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * 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> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -50,7 +50,6 @@ GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, string FileName, int AColor ) ...@@ -50,7 +50,6 @@ GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, string FileName, int AColor )
HBITMAP HBuf; HBITMAP HBuf;
BITMAP Bmp; BITMAP Bmp;
HDC bufDC; HDC bufDC;
AlphaColor = AColor;
// Create image from file if it exists // Create image from file if it exists
HBitmap = (HBITMAP) LoadImage( NULL, FileName.c_str(), IMAGE_BITMAP, HBitmap = (HBITMAP) LoadImage( NULL, FileName.c_str(), IMAGE_BITMAP,
...@@ -169,10 +168,19 @@ void GTK2Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef, ...@@ -169,10 +168,19 @@ void GTK2Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool GTK2Bitmap::Hit( int x, int y) 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; 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; guchar *pixels;
int rowstride, offset; int rowstride, offset;
gboolean has_alpha; gboolean has_alpha;
...@@ -184,21 +192,10 @@ bool GTK2Bitmap::Hit( int x, int y) ...@@ -184,21 +192,10 @@ bool GTK2Bitmap::Hit( int x, int y)
offset = y * rowstride + ( x * (has_alpha ? 4 : 3) ); offset = y * rowstride + ( x * (has_alpha ? 4 : 3) );
int r = pixels [offset]; int r = pixels [offset];
int g = pixels [offset + 1]; int g = pixels [offset + 1] << 8;
int b = pixels [offset + 2]; int b = pixels [offset + 2] << 16;
unsigned int c = r + g * 256 + b * 65536;
/* If has_alpha == TRUE, then the alpha component is in
pixels [offset + 3] */
if( c == AlphaColor ) return r + g + b;
return false;
else
return true;
}
//---------------------------------------------------------------------------
int GTK2Bitmap::GetBmpPixel( int x, int y )
{
// return GetPixel( bmpDC, x, y );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void GTK2Bitmap::SetBmpPixel( int x, int y, int color ) void GTK2Bitmap::SetBmpPixel( int x, int y, int color )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_event.cpp: GTK2 implementation of the Event class * gtk2_event.cpp: GTK2 implementation of the Event class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * 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> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -92,9 +92,9 @@ bool GTK2Event::SendEvent() ...@@ -92,9 +92,9 @@ bool GTK2Event::SendEvent()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool GTK2Event::IsEqual( Event *evt ) bool GTK2Event::IsEqual( Event *evt )
{ {
/* GTK2Event *WinEvt = (GTK2Event *)evt; GTK2Event *GTKEvt = (GTK2Event *)evt;
return( WinEvt->GetWindow() == hWnd && WinEvt->GetMessage() == Message && return( GTKEvt->GetWindow() == gWnd && GTKEvt->GetMessage() == Message &&
WinEvt->GetParam1() == Param1 && WinEvt->GetParam2() == Param2 );*/ GTKEvt->GetParam1() == Param1 && GTKEvt->GetParam2() == Param2 );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void GTK2Event::CreateOSEvent( string para1, string para2, string para3 ) void GTK2Event::CreateOSEvent( string para1, string para2, string para3 )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_run.cpp: * gtk2_run.cpp:
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * 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> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -95,11 +95,16 @@ void GTK2Proc( GdkEvent *event, gpointer data ) ...@@ -95,11 +95,16 @@ void GTK2Proc( GdkEvent *event, gpointer data )
((GdkEventAny *)event)->window, msg, 0, (long)event ); ((GdkEventAny *)event)->window, msg, 0, (long)event );
} }
// Send event
if( IsVLCEvent( msg ) ) if( IsVLCEvent( msg ) )
{ {
if( !proc->EventProc( evt ) ) if( !proc->EventProc( evt ) )
{
fprintf( stderr, "Quit\n" );
g_main_context_unref( g_main_context_default() );
return; // Exit VLC ! return; // Exit VLC !
} }
}
else if( gwnd == NULL ) else if( gwnd == NULL )
{ {
for( win = p_intf->p_sys->p_theme->WindowList.begin(); for( win = p_intf->p_sys->p_theme->WindowList.begin();
...@@ -131,8 +136,12 @@ void GTK2Proc( GdkEvent *event, gpointer data ) ...@@ -131,8 +136,12 @@ void GTK2Proc( GdkEvent *event, gpointer data )
} }
} }
evt->DestructParameters();
delete (OSEvent *)evt; delete (OSEvent *)evt;
// Check if vlc is closing
proc->IsClosing();
#if 0 #if 0
// If Window is parent window // If Window is parent window
if( hwnd == ( (GTK2Theme *)p_intf->p_sys->p_theme )->GetParentWindow() ) if( hwnd == ( (GTK2Theme *)p_intf->p_sys->p_theme )->GetParentWindow() )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* bitmap.cpp: Bitmap class * bitmap.cpp: Bitmap class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * 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 Teulire <ipkiss@via.ecp.fr> * Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -38,12 +38,14 @@ ...@@ -38,12 +38,14 @@
Bitmap::Bitmap( intf_thread_t *_p_intf, string FileName, int AColor ) 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, Bitmap::Bitmap( intf_thread_t *_p_intf, Graphics *from, int x, int y,
int w, int h, int AColor ) 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 ) Bitmap::Bitmap( intf_thread_t *_p_intf, Bitmap *c )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* event.cpp: Event class * event.cpp: Event class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * 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 Teulire <ipkiss@via.ecp.fr> * Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -103,9 +103,7 @@ void Event::PostTextMessage( string text ) ...@@ -103,9 +103,7 @@ void Event::PostTextMessage( string text )
{ {
char *txt = new char[text.size()+1]; char *txt = new char[text.size()+1];
strcpy( txt, text.c_str() ); strcpy( txt, text.c_str() );
// OSAPI_PostMessage( NULL, CTRL_SET_TEXT, (unsigned int)this, (long)txt ); OSAPI_PostMessage( NULL, CTRL_SET_TEXT, (unsigned int)this, (long)txt );
/* FIXME */
fprintf(stderr, "posttext %s\n", text.c_str());
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
unsigned int Event::GetMessageType( string Desc ) unsigned int Event::GetMessageType( string Desc )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* window.cpp: Window class * window.cpp: Window class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * 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 Teulire <ipkiss@via.ecp.fr> * Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -297,6 +297,8 @@ void Window::Refresh( int x, int y, int w, int h ) ...@@ -297,6 +297,8 @@ void Window::Refresh( int x, int y, int w, int h )
if( Hidden ) if( Hidden )
return; return;
fprintf( stderr, "Refresh: %i %i %i %i\n", x, y, w, h );
// And copy buffer to window // And copy buffer to window
RefreshFromImage( x, y, w, h ); RefreshFromImage( x, y, w, h );
...@@ -386,9 +388,17 @@ void Window::MouseUp( int x, int y, int button ) ...@@ -386,9 +388,17 @@ void Window::MouseUp( int x, int y, int button )
// Checking event in controls // Checking event in controls
for( i = ControlList.size() - 1; i >= 0 ; i-- ) for( i = ControlList.size() - 1; i >= 0 ; i-- )
{ {
fprintf( stderr, " -> Control\n" );
if( ControlList[i]->MouseUp( x, y, button ) ) 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; return;
} }
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void Window::MouseDblClick( int x, int y, int button ) void Window::MouseDblClick( int x, int y, int button )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* win32_bitmap.cpp: Win32 implementation of the Bitmap class * win32_bitmap.cpp: Win32 implementation of the Bitmap class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * 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 Teulire <ipkiss@via.ecp.fr> * Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -52,7 +52,6 @@ Win32Bitmap::Win32Bitmap( intf_thread_t *p_intf, string FileName, int AColor ) ...@@ -52,7 +52,6 @@ Win32Bitmap::Win32Bitmap( intf_thread_t *p_intf, string FileName, int AColor )
HBITMAP HBuf; HBITMAP HBuf;
BITMAP Bmp; BITMAP Bmp;
HDC bufDC; HDC bufDC;
AlphaColor = AColor;
// Create image from file if it exists // Create image from file if it exists
HBitmap = (HBITMAP) LoadImage( NULL, FileName.c_str(), IMAGE_BITMAP, HBitmap = (HBITMAP) LoadImage( NULL, FileName.c_str(), IMAGE_BITMAP,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment