* X11 skins now use imlib2 -> you need to bootstrap

wxwindows dialogs are not supposed to work yet, if they do you are
  lucky ;)
This commit is contained in:
Cyril Deguet 2003-05-29 21:40:27 +00:00
parent e950e33879
commit f574db4940
5 changed files with 82 additions and 120 deletions

View File

@ -1706,8 +1706,6 @@ dnl MP4 module
dnl
AC_CHECK_HEADERS(zlib.h, [
LDFLAGS_mp4="${LDFLAGS_mp4} -lz"
LDFLAGS_skins="${LDFLAGS_skins} -lz"
LDFLAGS_basic_skins="${LDFLAGS_basic_skins} -lz"
] )
@ -2440,9 +2438,11 @@ if test "x${enable_skins}" != "xno"; then
CPPFLAGS_skins="${CPPFLAGS_skins} -O2 -fno-rtti -Imodules/gui/skins ${GTK2_CFLAGS} -DGTK2_SKINS"
LDFLAGS_skins="${LDFLAGS_skins} -lstdc++ ${GTK2_LIBS}"
else
IMLIB2_PATH="${PATH}"
AC_PATH_PROG(IMLIB2_CONFIG_SKINS, imlib2-config, no, ${IMLIB2_PATH})
PLUGINS="${PLUGINS} skins"
CPPFLAGS_skins="${CPPFLAGS_skins} -O2 -fno-rtti -Imodules/gui/skins -I${x_includes} -DX11_SKINS"
LDFLAGS_skins="${LDFLAGS_skins} -lstdc++ -L${x_libraries} -lXext -lX11"
CPPFLAGS_skins="${CPPFLAGS_skins} -O2 -fno-rtti -Imodules/gui/skins -I${x_includes} `${IMLIB2_CONFIG_SKINS} --cflags` -DX11_SKINS"
LDFLAGS_skins="${LDFLAGS_skins} -lstdc++ -L${x_libraries} -lXext -lX11 `${IMLIB2_CONFIG_SKINS} --libs`"
fi
PLUGINS="${PLUGINS} skins"
@ -2471,8 +2471,10 @@ if test "x${enable_basic_skins}" = "xyes"; then
CPPFLAGS_basic_skins="${CPPFLAGS_basic_skins} -O2 -fno-rtti -Imodules/gui/skins ${GTK2_CFLAGS} -DGTK2_SKINS"
LDFLAGS_basic_skins="${LDFLAGS_basic_skins} -lstdc++ ${GTK2_LIBS}"
else
CPPFLAGS_basic_skins="${CPPFLAGS_basic_skins} -O2 -fno-rtti -Imodules/gui/skins -I${x_includes} -DX11_SKINS"
LDFLAGS_basic_skins="${LDFLAGS_basic_skins} -lstdc++ -L${x_libraries} -lXext -lX11"
IMLIB2_PATH="${PATH}"
AC_PATH_PROG(IMLIB2_CONFIG_SKINS, imlib2-config, no, ${IMLIB2_PATH})
CPPFLAGS_basic_skins="${CPPFLAGS_basic_skins} -O2 -fno-rtti -Imodules/gui/skins -I${x_includes} `${IMLIB2_CONFIG_SKINS} --cflags` -DX11_SKINS"
LDFLAGS_basic_skins="${LDFLAGS_basic_skins} -lstdc++ -L${x_libraries} -lXext -lX11 `${IMLIB2_CONFIG_SKINS} --libs`"
fi
fi

View File

@ -2,7 +2,7 @@
* vlcproc.cpp: VlcProc class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: vlcproc.cpp,v 1.26 2003/05/29 16:48:29 asmax Exp $
* $Id: vlcproc.cpp,v 1.27 2003/05/29 21:40:27 asmax Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
@ -102,7 +102,10 @@ bool VlcProc::EventProc( Event *evt )
return true;
case VLC_OPEN:
// FIXME: just for testing
wxMutexGuiEnter();
OpenFile( true );
wxMutexGuiLeave();
return true;
case VLC_LOAD_SKIN:
@ -134,26 +137,38 @@ bool VlcProc::EventProc( Event *evt )
return true;
case VLC_PLAYLIST_ADD_FILE:
// FIXME: just for testing
wxMutexGuiEnter();
OpenFile( false );
wxMutexGuiLeave();
return true;
#ifndef BASIC_SKINS
case VLC_LOG_SHOW:
// FIXME: just for testing
wxMutexGuiEnter();
p_intf->p_sys->MessagesDlg->Show(
!p_intf->p_sys->MessagesDlg->IsShown() );
wxMutexGuiLeave();
return true;
case VLC_LOG_CLEAR:
return true;
case VLC_PREFS_SHOW:
// FIXME: just for testing
wxMutexGuiEnter();
p_intf->p_sys->PrefsDlg->Show(
!p_intf->p_sys->PrefsDlg->IsShown() );
wxMutexGuiLeave();
return true;
case VLC_INFO_SHOW:
// FIXME: just for testing
wxMutexGuiEnter();
p_intf->p_sys->InfoDlg->Show(
!p_intf->p_sys->InfoDlg->IsShown() );
wxMutexGuiLeave();
return true;
#endif
@ -394,13 +409,7 @@ void VlcProc::LoadSkin()
void VlcProc::OpenFile( bool play )
{
#ifndef BASIC_SKINS
int iRc;
// FIXME: just for testing
wxMutexGuiEnter();
iRc = p_intf->p_sys->OpenDlg->ShowModal();
wxMutexGuiLeave();
if( iRc != wxID_OK )
if( p_intf->p_sys->OpenDlg->ShowModal() != wxID_OK )
{
return;
}
@ -414,7 +423,6 @@ void VlcProc::OpenFile( bool play )
if( play )
{
wxMutexGuiEnter();
// Append and play
for( size_t i = 0; i < p_intf->p_sys->OpenDlg->mrl.GetCount(); i++ )
{
@ -422,13 +430,10 @@ void VlcProc::OpenFile( bool play )
(const char *)p_intf->p_sys->OpenDlg->mrl[i].mb_str(),
PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
}
wxMutexGuiLeave();
p_intf->p_sys->p_theme->EvtBank->Get( "play" )->SendEvent();
}
else
{
wxMutexGuiEnter();
// Append only
for( size_t i = 0; i < p_intf->p_sys->OpenDlg->mrl.GetCount(); i++ )
{
@ -436,7 +441,6 @@ void VlcProc::OpenFile( bool play )
(const char *)p_intf->p_sys->OpenDlg->mrl[i].mb_str(),
PLAYLIST_APPEND, PLAYLIST_END );
}
wxMutexGuiLeave();
}
// Refresh interface !

View File

@ -2,10 +2,9 @@
* x11_bitmap.cpp: X11 implementation of the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_bitmap.cpp,v 1.6 2003/05/24 21:28:29 asmax Exp $
* $Id: x11_bitmap.cpp,v 1.7 2003/05/29 21:40:27 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
@ -28,6 +27,7 @@
//--- X11 -------------------------------------------------------------------
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <Imlib2.h>
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
@ -62,24 +62,51 @@ X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, string FileName, int AColor )
int depth = DefaultDepth( display, screen );
Screen *screenptr = DefaultScreenOfDisplay( display );
Visual *visual = DefaultVisualOfScreen( screenptr );
char *data = NULL;
Img = NULL;
Width = 0;
Height = 0;
// TODO: check for endianness issues
if( FileName == "" )
{
return;
}
AlphaColor = (AColor & 0xff) << 16 | (AColor & 0xff00) |
(AColor & 0xff0000) >> 16;
if( FileName != "" )
{
data = LoadFromFile( FileName, depth, AlphaColor, Width, Height );
}
imlib_context_set_display( display );
imlib_context_set_visual( visual );
imlib_context_set_colormap( DefaultColormap( display, screen ) );
imlib_context_set_dither( 1 );
imlib_context_set_blend( 1 );
// Create the image
Bmp = XCreateImage( display, visual, depth, ZPixmap, 0, data, Width,
Height, 32, 4 * Width );
XInitImage( Bmp );
Img = imlib_load_image_immediately( FileName.c_str() );
imlib_context_set_image( Img );
Width = imlib_image_get_width();
Height = imlib_image_get_height();
// Add an alpha layer
DATA32 *data = imlib_image_get_data();
DATA32 *ptr = data;
for( int j = 0; j < Height; j++)
{
for( int i = 0; i < Width; i++)
{
if( AlphaColor != 0 && *ptr == 0xff000000 )
{
// Avoid transparency for black pixels
*ptr = 0xff00000c;
}
else if( (*ptr & 0xffffff) == AlphaColor )
{
*ptr &= 0x00ffffff;
}
ptr++;
}
}
imlib_image_set_has_alpha( 1 );
imlib_image_set_irrelevant_alpha( 0 );
imlib_image_put_back_data( data );
}
//---------------------------------------------------------------------------
X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, Graphics *from, int x, int y,
@ -122,15 +149,23 @@ X11Bitmap::X11Bitmap( intf_thread_t *_p_intf, Bitmap *c )
//---------------------------------------------------------------------------
X11Bitmap::~X11Bitmap()
{
XDestroyImage( Bmp );
if( Img )
{
imlib_context_set_image( Img );
imlib_free_image();
}
}
//---------------------------------------------------------------------------
void X11Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
Graphics *dest )
{
Drawable destImg = ( (X11Graphics *)dest )->GetImage();
GC destGC = ( (X11Graphics *)dest )->GetGC();
XPutImage( display, destImg, destGC, Bmp, x, y, xRef, yRef, w, h );
if( Img )
{
Drawable destImg = ( (X11Graphics *)dest )->GetImage();
imlib_context_set_image( Img );
imlib_context_set_drawable( destImg );
imlib_render_image_part_on_drawable_at_size( x, y, w, h, xRef, yRef, w, h );
}
}
//---------------------------------------------------------------------------
bool X11Bitmap::Hit( int x, int y)
@ -145,7 +180,7 @@ bool X11Bitmap::Hit( int x, int y)
//---------------------------------------------------------------------------
int X11Bitmap::GetBmpPixel( int x, int y )
{
if( !Bmp || x < 0 || x >= Width || y < 0 || y >= Height )
if( !Img || x < 0 || x >= Width || y < 0 || y >= Height )
return -1;
return 42;
@ -171,81 +206,5 @@ void X11Bitmap::SetBmpPixel( int x, int y, int color )
// SetPixelV( bmpDC, x, y, color );
}
//---------------------------------------------------------------------------
char *X11Bitmap::LoadFromFile( string fileName, int depth, int AColor,
int &width, int &height )
{
// BMP header fields
uint32_t fileSize;
uint32_t dataOffset;
uint32_t headerSize;
uint16_t planes;
uint16_t bpp;
uint32_t compression;
uint32_t dataSize;
uint32_t nColors;
FILE *file = fopen( fileName.c_str(), "ro" );
if( !file )
{
msg_Warn( p_intf, "Cannot open %s", fileName.c_str() );
return NULL;
}
// Read the headers
char headers[54];
fread( headers, 54, 1, file );
fileSize = U32( headers + 2 );
dataOffset = U32( headers + 10 );
headerSize = U32( headers + 14 );
width = (int32_t) U32( headers + 18 );
height = (int32_t) U32( headers + 22 );
planes = U32( headers + 26 );
bpp = U32( headers + 28 );
compression = U32( headers + 30 );
dataSize = U32( headers + 34 );
nColors = U32( headers + 50 );
switch( bpp )
{
case 24:
// 24 bits per pixel
{
// Pad to a 32bit boundary
int pad = ((3 * width - 1) / 4) * 4 + 4 - 3 * width;
uint32_t *data = new uint32_t[height * width];
uint32_t *ptr;
for( int j = 0; j < height; j++ )
{
ptr = data + width * (height - j - 1);
for( int i = 0; i < width; i++ )
{
// Read a pixel
uint32_t pixel = 0;
fread( &pixel, 3, 1, file );
pixel = U32( &pixel );
// Handle transparency
if( pixel == 0 && AColor != 0 )
{
pixel = 10; // slight blue
}
else if( pixel == AColor )
{
pixel = 0; // global alpha color is black
}
*(ptr++) = pixel;
}
fseek( file, pad, SEEK_CUR );
}
return (char*)data;
}
default:
msg_Warn( p_intf, "%s : %d bbp not supported !", fileName.c_str(),
bpp );
return NULL;
}
}
//---------------------------------------------------------------------------
#endif

View File

@ -2,7 +2,7 @@
* x11_bitmap.h: X11 implementation of the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_bitmap.h,v 1.3 2003/05/18 17:48:05 asmax Exp $
* $Id: x11_bitmap.h,v 1.4 2003/05/29 21:40:27 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
@ -28,6 +28,7 @@
//--- X11 -------------------------------------------------------------------
#include <X11/Xlib.h>
#include <Imlib2.h>
//--- GENERAL ---------------------------------------------------------------
#include <string>
@ -44,7 +45,7 @@ class X11Bitmap : public Bitmap
private:
intf_thread_t *p_intf;
Display *display;
XImage *Bmp;
Imlib_Image Img;
public:
// Constructors
@ -63,9 +64,6 @@ class X11Bitmap : public Bitmap
virtual int GetBmpPixel( int x, int y );
virtual void SetBmpPixel( int x, int y, int color );
protected:
char *LoadFromFile( string fileName, int depth, int AColor, int &width,
int &height);
};
//---------------------------------------------------------------------------

View File

@ -2,7 +2,7 @@
* x11_theme.cpp: X11 implementation of the Theme class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_theme.cpp,v 1.6 2003/05/29 16:48:29 asmax Exp $
* $Id: x11_theme.cpp,v 1.7 2003/05/29 21:40:27 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
@ -187,7 +187,6 @@ void X11Theme::AddWindow( string name, int x, int y, bool visible,
motifWmHints.flags = 2; // MWM_HINTS_DECORATIONS;
motifWmHints.decorations = 0;
XChangeProperty( display, wnd, hints_atom, hints_atom, 32,
PropModeReplace, (unsigned char *)&motifWmHints,
sizeof( motifWmHints ) / sizeof( long ) );