Commit 70ff1f16 authored by Olivier Teulière's avatar Olivier Teulière

- doc/skins: some documentation about the skins

 - doc/skins/curve_maker: files for a VB project for easy Bezier curves
   creation
 - share/skins/default: a default skin. It's an awful one made for
   testing purposes, you'll be warned...
parent 0648c70a
Attribute VB_Name = "Bezier"
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public Const SRCCOPY = &HCC0020
Global imgDC As Long
Type pts
x As Single
y As Single
End Type
Global ft(30) As Single
Global Pt(30) As pts
Global MaxPt As Long
Sub bezier_draw(nb As Long, OffX As Long, OffY As Long)
Dim i As Long, pas As Single, t As Single, oldx As Single, oldy As Single, x As Single, y As Single
pas = 1 / nb
Call ini_factorielles
oldx = Pt(0).x
oldy = Pt(0).y
For t = pas To 1 Step pas
x = bezier_ptx(t)
y = bezier_pty(t)
ppal.Line (OffX + oldx, OffY + oldy)-(OffX + x, OffY + y), QBColor(ppal.Color.Value)
oldx = x
oldy = y
Next t
For i = 0 To MaxPt
ppal.PSet (OffX + Pt(i).x, OffY + Pt(i).y), QBColor(ppal.Color.Value)
Next i
End Sub
Function bezier_pty(t As Single) As Single
Dim k As Long, i As Long
k = 0
For i = 0 To MaxPt
bezier_pty = bezier_pty + Pt(i).y * melange(k, MaxPt, t)
k = k + 1
Next i
End Function
Function bezier_ptx(t As Single) As Single
Dim k As Long, i As Long
k = 0
For i = 0 To MaxPt
bezier_ptx = bezier_ptx + Pt(i).x * melange(k, MaxPt, t)
k = k + 1
Next i
End Function
Sub ini_factorielles()
ft(0) = 1
For i& = 1 To 30
ft(i&) = ft(i& - 1) * i&
Next i&
End Sub
Sub make_pt(i As Long, x As Long, y As Long)
Pt(i).x = x
Pt(i).y = y
End Sub
Function melange(i As Long, n As Long, t As Single) As Single
melange = CSng(ft(n) / ft(i) / ft(n - i)) * t ^ i * (1 - t) ^ (n - i)
End Function
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
Begin VB.Form ppal
AutoRedraw = -1 'True
BackColor = &H00FFFFFF&
Caption = "VLC skin Curve Maker"
ClientHeight = 7140
ClientLeft = 165
ClientTop = 450
ClientWidth = 10440
Icon = "Bezier.frx":0000
LinkTopic = "Form1"
ScaleHeight = 476
ScaleMode = 3 'Pixel
ScaleWidth = 696
StartUpPosition = 2 'CenterScreen
Begin VB.PictureBox Pict
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 975
Left = 2640
ScaleHeight = 65
ScaleMode = 3 'Pixel
ScaleWidth = 73
TabIndex = 4
Top = 1800
Visible = 0 'False
Width = 1095
End
Begin VB.PictureBox toolbox
Align = 1 'Align Top
BorderStyle = 0 'None
Height = 900
Left = 0
ScaleHeight = 900
ScaleWidth = 10440
TabIndex = 0
Top = 0
Width = 10440
Begin VB.HScrollBar Size
Height = 255
Left = 4920
Max = 5
Min = 1
TabIndex = 3
Top = 480
Value = 1
Width = 2655
End
Begin VB.HScrollBar Color
Height = 255
Left = 4920
Max = 15
TabIndex = 2
Top = 120
Width = 2655
End
Begin VB.TextBox Result
Height = 615
Left = 120
Locked = -1 'True
MultiLine = -1 'True
TabIndex = 1
Top = 120
Width = 4575
End
End
Begin MSComDlg.CommonDialog Cmd
Left = 7560
Top = 120
_ExtentX = 847
_ExtentY = 847
_Version = 327680
End
Begin VB.Menu m_file
Caption = "&File"
Begin VB.Menu m_load
Caption = "Load..."
End
Begin VB.Menu m_saveas
Caption = "Save as..."
End
Begin VB.Menu m_sep1
Caption = "-"
End
Begin VB.Menu m_quit
Caption = "Quit"
End
End
Begin VB.Menu m_picture
Caption = "Picture"
Begin VB.Menu m_loadpicture
Caption = "Load..."
End
End
Begin VB.Menu m_tool
Caption = "Tool"
Visible = 0 'False
Begin VB.Menu m_addpoint
Caption = "AddPoint"
End
Begin VB.Menu m_center
Caption = "Center"
End
End
Begin VB.Menu m_point
Caption = "Point"
Visible = 0 'False
Begin VB.Menu m_deletept
Caption = "Delete"
End
End
End
Attribute VB_Name = "ppal"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim xe As Single
Dim ye As Single
Dim Sel As Long
Dim MouseX As Long
Dim MouseY As Long
Dim SelectPt As Long
Dim PictureFile As String
Dim CurveFile As String
Dim OffsetX As Long
Dim OffsetY As Long
Sub form_draw()
Dim i As Long
Me.Cls
BitBlt ppal.hdc, OffsetX, OffsetY, Pict.Width, Pict.Height, imgDC, 0, 0, SRCCOPY
If MaxPt < 0 Then Exit Sub
Call bezier_draw(40, OffsetX, OffsetY)
Me.DrawWidth = 1
For i = 0 To MaxPt
Me.Line (OffsetX + Pt(i).x - 6, OffsetY + Pt(i).y - 6)-(OffsetX + Pt(i).x + 6, OffsetY + Pt(i).y + 6), QBColor(Color.Value), B
Next i
Me.DrawWidth = Size.Value
End Sub
Sub RefreshResult()
Dim i As Long
Result.Text = "abs="""
For i = 0 To MaxPt
If i > 0 Then Result.Text = Result.Text & ","
Result.Text = Result.Text & Pt(i).x
Next i
Result.Text = Result.Text & """" & Chr$(13) & Chr$(10) & "ord="""
For i = 0 To MaxPt
If i > 0 Then Result.Text = Result.Text & ","
Result.Text = Result.Text & Pt(i).y
Next i
Result.Text = Result.Text & """"
End Sub
Private Sub Color_Change()
form_draw
End Sub
Private Sub Form_Load()
PictureFile = "none"
MaxPt = -1
OffsetX = 0
OffsetY = 0
'Pict.Width = 0
'Pict.Height = 0
Call m_center_Click
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim i As Long
If Button = 2 Then
For i = 0 To MaxPt
If Pt(i).x + OffsetX > x - 5 And Pt(i).x + OffsetX < x + 5 Then
If Pt(i).y + OffsetY > y - 5 And Pt(i).y + OffsetY < y + 5 Then
SelectPt = i + 1
Me.PopupMenu m_point
Exit Sub
End If
End If
Next i
MouseX = x
MouseY = y
Me.PopupMenu m_tool
ElseIf Button = 1 Then
For i = 0 To MaxPt
If Pt(i).x + OffsetX > x - 5 And Pt(i).x + OffsetX < x + 5 Then
If Pt(i).y + OffsetY > y - 5 And Pt(i).y + OffsetY < y + 5 Then
SelectPt = i + 1
Exit Sub
End If
End If
Next i
SelectPt = 0
Me.MousePointer = 5
MouseX = x
MouseY = y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
If SelectPt > 0 Then
Pt(SelectPt - 1).x = x - OffsetX
Pt(SelectPt - 1).y = y - OffsetY
form_draw
Else
OffsetX = OffsetX - (x - MouseX)
OffsetY = OffsetY - (y - MouseY)
MouseX = x
MouseY = y
form_draw
End If
ElseIf Button = 0 Then
For i = 0 To MaxPt
If Pt(i).x + OffsetX > x - 5 And Pt(i).x + OffsetX < x + 5 Then
If Pt(i).y + OffsetY > y - 5 And Pt(i).y + OffsetY < y + 5 Then
SelectPt = i + 1
Me.MousePointer = 10
Exit Sub
End If
End If
Next i
Me.MousePointer = 0
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
If SelectPt > 0 Then
SelectPt = 0
form_draw
Call RefreshResult
End If
Me.MousePointer = 0
End If
End Sub
Private Sub m_addpoint_Click()
MaxPt = MaxPt + 1
Call make_pt(MaxPt, MouseX - OffsetX, MouseY - OffsetY)
Call form_draw
Call RefreshResult
End Sub
Private Sub m_center_Click()
OffsetX = (Me.ScaleWidth - Pict.Width) / 2
OffsetY = (Me.ScaleHeight - Pict.Height - toolbox.Height) / 2
form_draw
End Sub
Private Sub m_deletept_Click()
Dim i As Long
MaxPt = MaxPt - 1
For i = SelectPt - 1 To MaxPt
Pt(i).x = Pt(i + 1).x
Pt(i).y = Pt(i + 1).y
Next
form_draw
Call RefreshResult
End Sub
Private Sub m_load_Click()
Dim F As FileSystemObject
Set F = New FileSystemObject
Cmd.filename = CurveFile
Cmd.CancelError = False
Cmd.DialogTitle = "Open Curve"
Cmd.Filter = "Fichier VLC curve |*.curve.vlc"
Cmd.FilterIndex = 0
Cmd.InitDir = App.Path
Cmd.ShowOpen
If Not F.FileExists(Cmd.filename) Then Exit Sub
CurveFile = Cmd.filename
Dim i As Long, l As Long
Open CurveFile For Binary As #1
Get #1, , l
PictureFile = Space$(l)
Get #1, , PictureFile
Get #1, , OffsetX
Get #1, , OffsetY
Get #1, , MaxPt
For i = 0 To MaxPt
Get #1, , Pt(i).x
Get #1, , Pt(i).y
Next i
Close #1
If PictureFile <> "none" Then Pict.Picture = LoadPicture(PictureFile)
Call form_draw
Call RefreshResult
End Sub
Private Sub m_loadpicture_Click()
Dim F As FileSystemObject
Set F = New FileSystemObject
Cmd.CancelError = False
Cmd.DialogTitle = "Open picture"
Cmd.Filter = "Fichier bitmap |*.bmp"
Cmd.FilterIndex = 0
Cmd.InitDir = App.Path
Cmd.ShowOpen
If Not F.FileExists(Cmd.filename) Then Exit Sub
PictureFile = Cmd.filename
Pict.Picture = LoadPicture(Cmd.filename)
Dim HBitmap As Long
HBitmap = LoadImage(0, Cmd.filename, 0, 0, 0, 16)
imgDC = CreateCompatibleDC(0)
SelectObject imgDC, HBitmap
Pict.AutoSize = True
Call m_center_Click
End Sub
Private Sub m_quit_Click()
End
End Sub
Private Sub m_saveas_Click()
Dim F As FileSystemObject
Set F = New FileSystemObject
On Error GoTo error
Cmd.CancelError = True
Cmd.DialogTitle = "Save Curve"
Cmd.Filter = "Fichier VLC curve |*.curve.vlc"
Cmd.FilterIndex = 0
Cmd.InitDir = App.Path
Cmd.ShowSave
CurveFile = Cmd.filename
Dim i As Long
Open CurveFile For Binary As #1
Put #1, , CLng(Len(PictureFile))
Put #1, , PictureFile
Put #1, , OffsetX
Put #1, , OffsetY
Put #1, , MaxPt
For i = 0 To MaxPt
Put #1, , Pt(i).x
Put #1, , Pt(i).y
Next i
Close #1
error:
End Sub
Private Sub Size_Change()
Me.DrawWidth = Size.Value
form_draw
End Sub
ppal = 27, 3, 755, 576, , 87, 80, 858, 718,
Bezier = 125, 26, 841, 710, C
Type=Exe
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINNT\System32\stdole2.tlb#OLE Automation
Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0; COMDLG32.OCX
Reference=*\G{420B2830-E718-11CF-893D-00A0C9054228}#1.0#0#C:\WINNT\System32\scrrun.dll#Microsoft Scripting Runtime
Form=Bezier.frm
Module=Bezier; Bezier.bas
IconForm="ppal"
Startup="ppal"
HelpFile=""
Title="VLC Bezier Curve Maker"
ExeName32="VLC-curve-maker.exe"
Command32=""
Name="Projet1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=2
AutoIncrementVer=0
ServerSupportFiles=0
VersionLegalCopyright="VideoLAN"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
ThreadPerObject=0
MaxNumberOfThreads=1
[MS Transaction Server]
AutoRefresh=1
Before reading this document, you should first take a look at skins-howto.txt
to understand general purpose about VLC skins.
What is an event ?
==================
Events are the dynamic part of the skins. It means that beyond visual aspect,
the interface must react with the user actions. An event describes a simple
interaction, in fact one simple action such as playing a file, hiding a
window...
So when designing a skin you will have to specify what those interactions are.
For this you will use simple actions that are described in event tags and you
would be able to add them and associate them to controls.
How to create an event ?
========================
An event describes a simple action as seen above.
All attibutes are explained in the 'skins-howto.txt' file except the 'event'
attribute wich is a bit special.
In the 'event' attribute you will enter a simple script with the following
syntax :
"EVENT(parameter1,parameter2,...)"
The number of parameters depends on EVENT.
All this is case sensitive.
Don't add spaces.
EVENT is the action to execute, it can be one of the followings
- VLC_NOTHING:
Action : none, it executes nothing so don't use it !
Parameters: none.
- VLC_SHOW:
Action : Open all windows of the interface with a fading effect if
selected.
Parameters: none.
- VLC_HIDE:
Action : Close all windows of the interface with a fading effect if
selected.
Parameters:
- First 1 is an EVENT to execute when all windows have been closed.
- VLC_QUIT:
Action : Quit the interface
Parameters: none.
- VLC_OPEN:
Action : Open an "open file dialog box" to open a file to play.
Parameters: none.
- VLC_LOAD_SKIN:
Action : Open an "open file dialog box" to change the current skin.
Parameters: none.
- VLC_LOG_SHOW:
Not supported yet
- VLC_LOG_CLEAR:
Not supported yet.
- VLC_INTF_REFRESH:
Action : Force refreshing of the interface.
Parameters: none.
- VLC_CHANGE_TRAY:
Action : if VLC is not visible in system tray, show it, else, hide it.
Parameters: none.
- VLC_CHANGE_TASKBAR:
Action : if VLC is not visible in taskbar, show it, else, hide it.
Parameters: none.
- VLC_FULLSCREEN:
Action : switch current playing file to fullscreen mode.
Parameters: none.
- VLC_PLAY:
Action : play stream.
Parameters: none.
- VLC_STOP:
Action : stop playing stream.
Parameters: none.
- VLC_PAUSE:
Action : pause the stream.
Parameters: none.
- VLC_NEXT:
Action : go to next file in playlist.
Parameters: none.
- VLC_PREV:
Action : go to previous file in playlist.
Parameters: none.
- VLC_STREAMPOS:
Not supported yet.
- VLC_VOLUME_CHANGE:
Action : change sound volume.
Parameters:
1: - VLC_VOLUME_MUTE: switch to mute mode.
- VLC_VOLUME_UP: raise sounds volume.
- VLC_VOLUME_DOWN:
- VLC_VOLUME_SET: set sound volume to second parameter
2: if first parameter is VLC_VOLUME_SET only, an integer between 0 and 100.
- VLC_PLAYLIST_ADD_FILE:
Action : Open an "open file dialog box" to add files to playlist.
Parameters: none.
- VLC_WINDOW_MOVE:
Action : initiate manual window movement.
Parameters: only one which must match the ID of a window. It should be
used with image controls.
- VLC_WINDOW_OPEN:
Action : open a window with a fading effect if selected.
Parameters: only one which must match the ID of a window.
- VLC_WINDOW_CLOSE:
Action : close a window with a fading effect if selected.
Parameters: only one who must match the ID of a window.
- CTRL_SET_SLIDER:
Not supported yet.
- CTRL_SET_TEXT:
Not supported yet.
- CTRL_ID_VISIBLE:
Action : hide/show a control.
Parameters:
1: ID of the control to hide/show.
2: Describe what to do. Nothing is showing control. TRUE is the same. FALSE
is hiding control. CHANGE is switching between this to state.
- CTRL_ID_ENABLED:
Not supported yet.
- CTRL_ID_MOVE:
Action : moves a control.
Parameters:
1: ID of the control to move.
2: horizontal offset of movement.
3: vertical offset of movement.
- PLAYLIST_ID_DEL:
Action : remove items from playlist.
Parameters:
1: ID of the playlist.
What to do with event ?
=======================
When creating your event, you must assign an ID to each of them.
Now you have to associate events with controls.
Some attributes of some controls are supposed to be filled with those IDs. That
is to say that when the action correspounding to the attribute will be done,
the event associated will be executed. The best exemple is assigning an event
to the 'onclick' attribute of a button control. The event will be executed when
clicking on the button.
You can execute several events. To do this you just have to separate them with
semicolon.
Exemple:
<ButtonControl [...] onclick="event1;event2;event3"/>
Do I have to create every event for each skin ?
===============================================
No, a set of predefined events are present. Here they are with their ID and
shortcut.
ID Shortcut Description
tray CTRL+T Hide or show in the system tray.
taskbar CTRL+B Hide or show in the taskbar.
play X Play.
pause C Pause.
stop V Stop.
next B Next file.
prev Z Previous file.
fullscreen F Switch to fullscreen mode.
mute Mute the sound.
volume_up
volume_down
quit CTRL+C Quit VLC.
open CTRL+O Open a file.
add_file CTRL+A Add a file.
load_skin CTRL+S Change skin.
Note: This document is short and highly incomplete. If you want to write a new,
decent one, it will be more than welcome!
Basic principles
================
A skin (or theme, the two words have almost the same meaning) for VLC is made
of many BMP files (Windows Bitmap format) containing all the images needed, and
of an XML file describing how these images should be displayed, what happens
when the user clicks on a button, etc.
Those of you who have already done skins for other softwares shouldn't have too
many difficulties to understand how all this works.
Bezier curves
=============
One cool thing with VLC sliders is that they are not necessarily rectilinear,
but they can follow any Bezier curve. So if you want to have a slider moving
on a half-circle, or even doing a loop, you can !
This is not the place to explain how these curves work, the only thing to know
is that a Bezier curve can be caracterised by a set of points. Once you have
them (thanks to the graphical utility presented at the end of this file, for
example), you just need to enter the list of abscissas in the 'abs' attribute
and the list of ordinates (in the same order...) in the 'ord' attribute. The
separator is the coma. Example: abs="2,45,88" ord="50,120,50"
Bezier curves are used for the SliderControl and the PlaylistControl tags.
The bitmaps
===========
Basically, you need one bitmap file by state of control. For example, with a
image control you'll need 1 image, with a button 2 images (or 3 if you provide
the disabled state). A slider will also need 2, one for the static part and
another for the mobile part. Of course, the same bitmap file can be used for
many controls, provided you want to display the same image!
The bitmap format doesn't allow a transparent color, but in the XML file you
can specify a color that will be considered as transparent wherever it appears
in the bitmap file.
The XML file
============
XML is a markup language, like HTML. It won't be explained here any further,