Commit a64501fd authored by Olivier Teulière's avatar Olivier Teulière

Keep quiet, explanations will follow.

parent 71dfd6a5
......@@ -1669,8 +1669,19 @@ dnl MP4 module
dnl
AC_CHECK_HEADERS(zlib.h, [
LDFLAGS_mp4="${LDFLAGS_mp4} -lz"
LDFLAGS_skins="${LDFLAGS_skins} -lz"
] )
dnl
dnl skins module
dnl
AC_CHECK_HEADERS(libtar.h, [
LDFLAGS_skins="${LDFLAGS_skins} -ltar"
] )
dnl
dnl a52 AC3 decoder plugin
dnl
......@@ -2229,6 +2240,19 @@ then
PLUGINS="${PLUGINS} beos"
fi
dnl
dnl Skins module
dnl
AC_ARG_ENABLE(skins,
[ --enable-skins Win32 skins module (default enabled on Win32)])
if test "x${enable_skins}" != "xno"; then
if test "x${SYS}" = "xmingw32" -o "x${SYS}" = "xcygwin"; then
PLUGINS="${PLUGINS} skins"
CPPFLAGS_skins="${CPPFLAGS_skins} -Imodules/gui/skins -Imodules/gui/skins/src -Imodules/gui/skins/win32 -Imodules/gui/skins/controls"
LDFLAGS_skins="${LDFLAGS_skins} -lgdi32 -lcomdlg32 -lole32 -luuid -lcomctl32 -lmsimg32"
fi
fi
dnl
dnl Gtk+ module
dnl
......
......@@ -50,6 +50,7 @@ EXTRA_DIST = \
gui/ncurses/Modules.am \
gui/qnx/Modules.am \
gui/qt/Modules.am \
gui/skins/Modules.am \
gui/win32/Modules.am \
gui/wxwindows/Modules.am \
misc/Modules.am \
......
.deps
.dirstamp
*.dll
*.dylib
*.sl
*.so
SOURCES_skins = \
modules/gui/skins/os_api.h \
modules/gui/skins/os_bitmap.h \
modules/gui/skins/os_dialog.h \
modules/gui/skins/os_event.h \
modules/gui/skins/os_font.h \
modules/gui/skins/os_graphics.h \
modules/gui/skins/os_theme.h \
modules/gui/skins/os_window.h \
\
modules/gui/skins/controls/controls.h \
modules/gui/skins/controls/button.cpp \
modules/gui/skins/controls/button.h \
modules/gui/skins/controls/checkbox.cpp \
modules/gui/skins/controls/checkbox.h \
modules/gui/skins/controls/generic.cpp \
modules/gui/skins/controls/generic.h \
modules/gui/skins/controls/image.cpp \
modules/gui/skins/controls/image.h \
modules/gui/skins/controls/playlist.cpp \
modules/gui/skins/controls/playlist.h \
modules/gui/skins/controls/rectangle.cpp \
modules/gui/skins/controls/rectangle.h \
modules/gui/skins/controls/slider.cpp \
modules/gui/skins/controls/slider.h \
modules/gui/skins/controls/text.cpp \
modules/gui/skins/controls/text.h \
\
modules/gui/skins/parser/flex.c \
modules/gui/skins/parser/skin.h \
modules/gui/skins/parser/skin.c \
modules/gui/skins/parser/wrappers.h \
modules/gui/skins/parser/wrappers.cpp \
\
modules/gui/skins/src/anchor.cpp \
modules/gui/skins/src/anchor.h \
modules/gui/skins/src/banks.cpp \
modules/gui/skins/src/banks.h \
modules/gui/skins/src/bezier.cpp \
modules/gui/skins/src/bezier.h \
modules/gui/skins/src/bitmap.cpp \
modules/gui/skins/src/bitmap.h \
modules/gui/skins/src/dialog.cpp \
modules/gui/skins/src/dialog.h \
modules/gui/skins/src/event.cpp \
modules/gui/skins/src/event.h \
modules/gui/skins/src/font.cpp \
modules/gui/skins/src/font.h \
modules/gui/skins/src/graphics.cpp \
modules/gui/skins/src/graphics.h \
modules/gui/skins/src/skin_main.cpp \
modules/gui/skins/src/skin-common.h \
modules/gui/skins/src/theme.cpp \
modules/gui/skins/src/theme.h \
modules/gui/skins/src/themeloader.cpp \
modules/gui/skins/src/themeloader.h \
modules/gui/skins/src/vlcproc.cpp \
modules/gui/skins/src/vlcproc.h \
modules/gui/skins/src/window.cpp \
modules/gui/skins/src/window.h \
\
modules/gui/skins/win32/win32_api.cpp \
modules/gui/skins/win32/win32_bitmap.cpp \
modules/gui/skins/win32/win32_bitmap.h \
modules/gui/skins/win32/win32_dialog.cpp \
modules/gui/skins/win32/win32_dialog.h \
modules/gui/skins/win32/win32_dragdrop.cpp \
modules/gui/skins/win32/win32_dragdrop.h \
modules/gui/skins/win32/win32_event.cpp \
modules/gui/skins/win32/win32_event.h \
modules/gui/skins/win32/win32_font.cpp \
modules/gui/skins/win32/win32_font.h \
modules/gui/skins/win32/win32_graphics.cpp \
modules/gui/skins/win32/win32_graphics.h \
modules/gui/skins/win32/win32_run.cpp \
modules/gui/skins/win32/win32_theme.cpp \
modules/gui/skins/win32/win32_theme.h \
modules/gui/skins/win32/win32_window.cpp \
modules/gui/skins/win32/win32_window.h \
$(NULL)
EXTRA_DIST += \
modules/gui/skins/parser/skin.dtd \
modules/gui/skins/parser/skin.act
.deps
.dirstamp
*.dll
*.dylib
*.sl
*.so
/*****************************************************************************
* button.cpp: Button control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: button.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "bitmap.h"
#include "banks.h"
#include "generic.h"
#include "button.h"
#include "event.h"
#include "theme.h"
#include "window.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// Control Button
//---------------------------------------------------------------------------
ControlButton::ControlButton( string id, bool visible, int x, int y, string Up,
string Down, string Disabled, string click, string tooltiptext, string help,
Window *Parent ) : GenericControl( id, visible, help, Parent )
{
Left = x;
Top = y;
State = 1; // 1 = up - 0 = down
Selected = false;
Enabled = true;
ClickActionName = click;
this->Up = Up;
this->Down = Down;
this->Disabled = Disabled;
ToolTipText = tooltiptext;
}
//---------------------------------------------------------------------------
ControlButton::~ControlButton()
{
}
//---------------------------------------------------------------------------
void ControlButton::Init()
{
// Init bitmaps
Img = new (Bitmap*)[3];
Img[0] = p_intf->p_sys->p_theme->BmpBank->Get( Up );
Img[1] = p_intf->p_sys->p_theme->BmpBank->Get( Down );
if( Disabled == "none" )
Img[2] = p_intf->p_sys->p_theme->BmpBank->Get( Up );
else
Img[2] = p_intf->p_sys->p_theme->BmpBank->Get( Disabled );
// Get size of control
Img[0]->GetSize( Width, Height );
// Create script
ClickAction = new Action( p_intf, ClickActionName );
}
//---------------------------------------------------------------------------
bool ControlButton::ProcessEvent( Event *evt )
{
switch( evt->GetMessage() )
{
case CTRL_ENABLED:
Enable( (Event*)evt->GetParam1(), (bool)evt->GetParam2() );
break;
}
return false;
}
//---------------------------------------------------------------------------
void ControlButton::MoveRelative( int xOff, int yOff )
{
Left += xOff;
Top += yOff;
}
//---------------------------------------------------------------------------
void ControlButton::Draw( int x, int y, int w, int h, Graphics *dest )
{
if( !Visible )
return;
int xI, yI, wI, hI;
if( GetIntersectRgn( x,y,w,h,Left,Top,Width,Height, xI, yI, wI, hI ) )
{
// Button is in down state
if( State == 0 && Enabled )
Img[1]->DrawBitmap( xI-Left, yI-Top, wI, hI, xI-x, yI-y, dest );
// Button is in up state
if( State == 1 && Enabled )
Img[0]->DrawBitmap( xI-Left, yI-Top, wI, hI, xI-x, yI-y, dest );
// Button is disabled
if( !Enabled )
Img[2]->DrawBitmap( xI-Left, yI-Top, wI, hI, xI-x, yI-y, dest );
}
}
//---------------------------------------------------------------------------
bool ControlButton::MouseUp( int x, int y, int button )
{
if( !Enabled )
return false;
if( Img[1]->Hit( x - Left, y - Top ) && button == 1 && Selected )
{
State = 1;
Selected = false;
ClickAction->SendEvent();
ParentWindow->Refresh( Left, Top, Width, Height );
return true;
}
if( button == 1 )
Selected = false;
return false;
}
//---------------------------------------------------------------------------
bool ControlButton::MouseDown( int x, int y, int button )
{
if( !Enabled )
return false;
if( Img[0]->Hit( x - Left, y - Top ) && button == 1 )
{
State = 0;
Selected = true;
ParentWindow->Refresh( Left, Top, Width, Height );
return true;
}
return false;
}
//---------------------------------------------------------------------------
bool ControlButton::MouseMove( int x, int y, int button )
{
if( !Enabled || !Selected || !button )
return false;
if( MouseOver( x, y ) )
{
if( State == 1 )
{
State = 0;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
else
{
if( State == 0 )
{
State = 1;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
return true;
}
//---------------------------------------------------------------------------
bool ControlButton::MouseOver( int x, int y )
{
if( Img[1 - State]->Hit( x - Left, y - Top ) )
{
return true;
}
else
{
return false;
}
}
//---------------------------------------------------------------------------
bool ControlButton::ToolTipTest( int x, int y )
{
if( MouseOver( x, y ) && Enabled )
{
ParentWindow->ChangeToolTipText( ToolTipText );
return true;
}
return false;
}
//---------------------------------------------------------------------------
void ControlButton::Enable( Event *event, bool enabled )
{
if( !ClickAction->MatchEvent( event, ACTION_MATCH_ONE ) )
return;
if( enabled != Enabled )
{
Enabled = enabled;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
//---------------------------------------------------------------------------
/*****************************************************************************
* button.h: Button control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: button.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_CONTROL_BUTTON
#define VLC_SKIN_CONTROL_BUTTON
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
class Action;
class Graphics;
class Window;
//---------------------------------------------------------------------------
class ControlButton : public GenericControl
{
private:
// Image IDs
string Up;
string Down;
string Disabled;
// Control behaviour
bool Selected;
bool Enabled;
// List of actions to execute when clicking
Action *ClickAction;
string ClickActionName;
// ToolTip text
string ToolTipText;
public:
// Constructor
ControlButton( string id, bool visible, int x, int y, string Up,
string Down, string Disabled, string click,
string tooltiptext, string help, Window *Parent );
// Destructor
virtual ~ControlButton();
// Initializations
virtual void Init();
virtual bool ProcessEvent( Event *evt );
// Draw button
virtual void Draw( int x1, int y1, int x2, int y2, Graphics *dest );
// Mouse events
virtual bool MouseUp( int x, int y, int button );
virtual bool MouseDown( int x, int y, int button );
virtual bool MouseMove( int x, int y, int button );
virtual bool MouseOver( int x, int y );
virtual bool ToolTipTest( int x, int y );
// Translate control
virtual void MoveRelative( int xOff, int yOff );
// Enabling control
virtual void Enable( Event *event, bool enabled );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* checkbox.cpp: Checkbox control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: checkbox.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "bitmap.h"
#include "banks.h"
#include "generic.h"
#include "checkbox.h"
#include "event.h"
#include "theme.h"
#include "window.h"
#include "skin_common.h"
#include "os_event.h"
#include "os_window.h"
//---------------------------------------------------------------------------
// Checkbox Button
//---------------------------------------------------------------------------
ControlCheckBox::ControlCheckBox( string id, bool visible, int x, int y,
string img1, string img2, string click1, string click2, string disabled1,
string disabled2, string action1, string action2, string tooltiptext1,
string tooltiptext2, string help,
Window *Parent ) : GenericControl( id, visible, help, Parent )
{
Left = x;
Top = y;
State = 1; // 1 = up - 0 = down
Selected = false;
Act = 1;
Enabled1 = true;
Enabled2 = true;
Img1 = img1;
Img2 = img2;
Click1 = click1;
Click2 = click2;
Disabled1 = disabled1;
Disabled2 = disabled2;
ClickActionName1 = action1;
ClickActionName2 = action2;
ToolTipText1 = tooltiptext1;
ToolTipText2 = tooltiptext2;
}
//---------------------------------------------------------------------------
ControlCheckBox::~ControlCheckBox()
{
}
//---------------------------------------------------------------------------
void ControlCheckBox::Init()
{
Img = new (Bitmap*)[6];
// Images for position 1
Img[0] = p_intf->p_sys->p_theme->BmpBank->Get( Img1 );
if( Click1 == "none" )
Img[1] = p_intf->p_sys->p_theme->BmpBank->Get( Img2 );
else
Img[1] = p_intf->p_sys->p_theme->BmpBank->Get( Click1 );
// Images for position 2
Img[2] = p_intf->p_sys->p_theme->BmpBank->Get( Img2 );
if( Click2 == "none" )
Img[3] = p_intf->p_sys->p_theme->BmpBank->Get( Img1 );
else
Img[3] = p_intf->p_sys->p_theme->BmpBank->Get( Click2 );
// Disabled images
if( Disabled1 == "none" )
Img[4] = p_intf->p_sys->p_theme->BmpBank->Get( Img1 );
else
Img[4] = p_intf->p_sys->p_theme->BmpBank->Get( Disabled1 );
if( Disabled2 == "none" )
Img[5] = p_intf->p_sys->p_theme->BmpBank->Get( Img2 );
else
Img[5] = p_intf->p_sys->p_theme->BmpBank->Get( Disabled2 );
// Get Size of control
Img[0]->GetSize( Width, Height );
// Create script
ClickAction1 = new Action( p_intf, ClickActionName1 );
ClickAction2 = new Action( p_intf, ClickActionName2 );
}
//---------------------------------------------------------------------------
bool ControlCheckBox::ProcessEvent( Event *evt )
{
switch( evt->GetMessage() )
{
case CTRL_ENABLED:
Enable( (Event*)evt->GetParam1(), (bool)evt->GetParam2() );
break;
case CTRL_SYNCHRO:
if( ClickAction1->MatchEvent( (Event*)evt->GetParam1(),
ACTION_MATCH_ONE ) )
{
Act = 2;
ParentWindow->Refresh( Left, Top, Width, Height );
}
else if( ClickAction2->MatchEvent( (Event*)evt->GetParam1(),
ACTION_MATCH_ONE ) )
{
Act = 1;
ParentWindow->Refresh( Left, Top, Width, Height );
}
break;
}
return false;
}
//---------------------------------------------------------------------------
void ControlCheckBox::MoveRelative( int xOff, int yOff )
{
Left += xOff;
Top += yOff;
}
//---------------------------------------------------------------------------
void ControlCheckBox::Draw( int x, int y, int w, int h, Graphics *dest )
{
if( !Visible )
return;
int xI, yI, wI, hI;
if( GetIntersectRgn( x,y,w,h,Left,Top,Width,Height, xI, yI, wI, hI ) )
{
if( Act == 1 )
{
if( State == 1 && Enabled1 )
Img[0]->DrawBitmap( xI-Left,yI-Top,wI,hI,xI-x,yI-y,dest );
else if( State == 0 && Enabled1 )
Img[1]->DrawBitmap( xI-Left,yI-Top,wI,hI,xI-x,yI-y,dest );
else
Img[4]->DrawBitmap( xI-Left,yI-Top,wI,hI,xI-x,yI-y,dest );
}
else if( Act == 2 )
{
if( State == 1 && Enabled2 )
Img[2]->DrawBitmap( xI-Left,yI-Top,wI,hI,xI-x,yI-y,dest );
else if( State == 0 && Enabled2 )
Img[3]->DrawBitmap( xI-Left,yI-Top,wI,hI,xI-x,yI-y,dest );
else
Img[5]->DrawBitmap( xI-Left,yI-Top,wI,hI,xI-x,yI-y,dest );
}
}
}
//---------------------------------------------------------------------------
bool ControlCheckBox::MouseUp( int x, int y, int button )
{
// Test enabled
if( ( !Enabled1 && Act == 1 ) || ( !Enabled2 && Act == 2 ) )
return false;
if( button == 1 && Selected )
{
if( Act == 1 && Img[1]->Hit( x - Left, y - Top ) )
{
State = 1;
Selected = false;
Act = 2;
ParentWindow->Refresh( Left, Top, Width, Height );
ClickAction1->SendEvent();
return true;
}
else if( Act == 2 && Img[3]->Hit( x - Left, y - Top ) )
{
State = 1;
Selected = false;
Act = 1;
ParentWindow->Refresh( Left, Top, Width, Height );
ClickAction2->SendEvent();
return true;
}
}
Selected = false;
return false;
}
//---------------------------------------------------------------------------
bool ControlCheckBox::MouseDown( int x, int y, int button )
{
// Test enabled
if( ( !Enabled1 && Act == 1 ) || ( !Enabled2 && Act == 2 ) )
return false;
if( button == 1 )
{
if( Act == 1 && Img[0]->Hit( x - Left, y - Top ) )
{
State = 0;
Selected = true;
ParentWindow->Refresh( Left, Top, Width, Height );
return true;
}
else if( Act == 2 && Img[2]->Hit( x - Left, y - Top ) )
{
State = 0;
Selected = true;
ParentWindow->Refresh( Left, Top, Width, Height );
return true;
}
}
return false;
}
//---------------------------------------------------------------------------
bool ControlCheckBox::MouseMove( int x, int y, int button )
{
// Test enabled
if( !Selected || !button )
return false;
if( ( !Enabled1 && Act == 1 ) || ( !Enabled2 && Act == 2 ) )
return false;