]> git.sesse.net Git - vlc/blob - modules/gui/skins2/parser/builder.cpp
* moved the default font in share/skins2/fonts
[vlc] / modules / gui / skins2 / parser / builder.cpp
1 /*****************************************************************************
2  * builder.cpp
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #include <string.h>
26 #include "builder.hpp"
27 #include "builder_data.hpp"
28 #include "interpreter.hpp"
29 #include "../src/png_bitmap.hpp"
30 #include "../src/os_factory.hpp"
31 #include "../src/generic_bitmap.hpp"
32 #include "../src/top_window.hpp"
33 #include "../src/anchor.hpp"
34 #include "../src/ft2_font.hpp"
35 #include "../src/theme.hpp"
36 #include "../controls/ctrl_button.hpp"
37 #include "../controls/ctrl_checkbox.hpp"
38 #include "../controls/ctrl_image.hpp"
39 #include "../controls/ctrl_list.hpp"
40 #include "../controls/ctrl_move.hpp"
41 #include "../controls/ctrl_resize.hpp"
42 #include "../controls/ctrl_slider.hpp"
43 #include "../controls/ctrl_radialslider.hpp"
44 #include "../controls/ctrl_text.hpp"
45 #include "../controls/ctrl_video.hpp"
46 #include "../utils/position.hpp"
47 #include "../utils/var_bool.hpp"
48 #include "../utils/var_text.hpp"
49
50
51 Builder::Builder( intf_thread_t *pIntf, const BuilderData &rData):
52     SkinObject( pIntf ), m_rData( rData ), m_pTheme( NULL )
53 {
54 }
55
56
57 CmdGeneric *Builder::parseAction( const string &rAction )
58 {
59     return Interpreter::instance( getIntf() )->parseAction( rAction, m_pTheme );
60 }
61
62
63 // Useful macro
64 #define ADD_OBJECTS( type ) \
65     list<BuilderData::type>::const_iterator it##type; \
66     for( it##type = m_rData.m_list##type.begin(); \
67          it##type != m_rData.m_list##type.end(); it##type++ ) \
68     { \
69         add##type( *it##type ); \
70     }
71
72
73 Theme *Builder::build()
74 {
75     m_pTheme = new Theme( getIntf() );
76     if( m_pTheme == NULL )
77     {
78         return NULL;
79     }
80
81     // Create everything from the data in the XML
82     ADD_OBJECTS( Theme );
83     ADD_OBJECTS( Bitmap );
84     ADD_OBJECTS( Font );
85     ADD_OBJECTS( Window );
86     ADD_OBJECTS( Layout );
87     ADD_OBJECTS( Anchor );
88     ADD_OBJECTS( Button );
89     ADD_OBJECTS( Checkbox );
90     ADD_OBJECTS( Image );
91     ADD_OBJECTS( Text );
92     ADD_OBJECTS( RadialSlider );
93     ADD_OBJECTS( Slider );
94     ADD_OBJECTS( List );
95     ADD_OBJECTS( Video );
96
97     return m_pTheme;
98 }
99
100
101 // Macro to get a bitmap by its ID in the builder
102 #define GET_BMP( pBmp, id ) \
103     if( id != "none" ) \
104     { \
105         pBmp = m_pTheme->m_bitmaps[id].get(); \
106         if( pBmp == NULL ) \
107         { \
108             msg_Err( getIntf(), "unknown bitmap id: %s", id.c_str() ); \
109             return; \
110         } \
111     }
112
113 void Builder::addTheme( const BuilderData::Theme &rData )
114 {
115     WindowManager &rManager = m_pTheme->getWindowManager();
116     rManager.setMagnetValue( rData.m_magnet );
117     rManager.setAlphaValue( rData.m_alpha );
118     rManager.setMoveAlphaValue( rData.m_moveAlpha );
119     GenericFont *pFont = getFont( rData.m_tooltipfont );
120     if( pFont )
121     {
122         rManager.createTooltip( *pFont );
123     }
124     else
125     {
126         msg_Warn( getIntf(), "Invalid tooltip font: %s",
127                   rData.m_tooltipfont.c_str() );
128     }
129 }
130
131
132 void Builder::addBitmap( const BuilderData::Bitmap &rData )
133 {
134     GenericBitmap *pBmp = new PngBitmap( getIntf(), rData.m_fileName,
135                                          rData.m_alphaColor );
136     m_pTheme->m_bitmaps[rData.m_id] = GenericBitmapPtr( pBmp );
137 }
138
139
140 void Builder::addFont( const BuilderData::Font &rData )
141 {
142     GenericFont *pFont = new FT2Font( getIntf(), rData.m_fontName,
143                                       rData.m_size );
144     if( pFont->init() )
145     {
146         m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont );
147     }
148     else
149     {
150         delete pFont;
151     }
152 }
153
154
155 void Builder::addWindow( const BuilderData::Window &rData )
156 {
157     TopWindow *pWin =
158         new TopWindow( getIntf(), rData.m_xPos, rData.m_yPos,
159                            m_pTheme->getWindowManager(),
160                            rData.m_dragDrop, rData.m_playOnDrop );
161
162     m_pTheme->m_windows[rData.m_id] = TopWindowPtr( pWin );
163 }
164
165
166 void Builder::addLayout( const BuilderData::Layout &rData )
167 {
168     TopWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get();
169     if( pWin == NULL )
170     {
171         msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
172         return;
173     }
174
175     int minWidth = rData.m_minWidth != -1 ? rData.m_minWidth : rData.m_width;
176     int maxWidth = rData.m_maxWidth != -1 ? rData.m_maxWidth : rData.m_width;
177     int minHeight = rData.m_minHeight != -1 ? rData.m_minHeight :
178                     rData.m_height;
179     int maxHeight = rData.m_maxHeight != -1 ? rData.m_maxHeight :
180                     rData.m_height;
181     GenericLayout *pLayout = new GenericLayout( getIntf(), rData.m_width,
182                                                 rData.m_height,
183                                                 minWidth, maxWidth, minHeight,
184                                                 maxHeight );
185     m_pTheme->m_layouts[rData.m_id] = GenericLayoutPtr( pLayout );
186
187     // Attach the layout to its window
188     pWin->setActiveLayout( pLayout );
189 }
190
191
192 void Builder::addAnchor( const BuilderData::Anchor &rData )
193 {
194     TopWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get();
195     if( pWin == NULL )
196     {
197         msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
198         return;
199     }
200
201     Bezier *pCurve = getPoints( rData.m_points.c_str() );
202     if( pCurve == NULL )
203     {
204         msg_Err( getIntf(), "Invalid format in tag points=\"%s\"",
205                  rData.m_points.c_str() );
206         return;
207     }
208     m_pTheme->m_curves.push_back( BezierPtr( pCurve ) );
209
210     Anchor *pAnc = new Anchor( getIntf(), rData.m_xPos, rData.m_yPos,
211                                rData.m_range, rData.m_priority,
212                                *pCurve, *pWin );
213     pWin->addAnchor( pAnc );
214 }
215
216
217 void Builder::addButton( const BuilderData::Button &rData )
218 {
219     // Get the bitmaps of the button
220     GenericBitmap *pBmpUp = NULL;
221     GET_BMP( pBmpUp, rData.m_upId );
222
223     GenericBitmap *pBmpDown = pBmpUp;
224     GET_BMP( pBmpDown, rData.m_downId );
225
226     GenericBitmap *pBmpOver = pBmpUp;
227     GET_BMP( pBmpOver, rData.m_overId );
228
229     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
230     if( pLayout == NULL )
231     {
232         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
233         return;
234     }
235
236     CmdGeneric *pCommand = parseAction( rData.m_actionId );
237     if( pCommand == NULL )
238     {
239         msg_Err( getIntf(), "Invalid action: %s", rData.m_actionId.c_str() );
240         return;
241     }
242
243     CtrlButton *pButton = new CtrlButton( getIntf(), *pBmpUp, *pBmpOver,
244         *pBmpDown, *pCommand, UString( getIntf(), rData.m_tooltip.c_str() ),
245         UString( getIntf(), rData.m_help.c_str() ), NULL );
246
247     // Compute the position of the control
248     // XXX (we suppose all the images have the same size...)
249     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
250                                        rData.m_xPos, rData.m_yPos,
251                                        pBmpUp->getWidth(),
252                                        pBmpUp->getHeight(), *pLayout );
253
254     pLayout->addControl( pButton, pos, rData.m_layer );
255
256     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pButton );
257 }
258
259
260 void Builder::addCheckbox( const BuilderData::Checkbox &rData )
261 {
262     // Get the bitmaps of the checkbox
263     GenericBitmap *pBmpUp1 = NULL;
264     GET_BMP( pBmpUp1, rData.m_up1Id );
265
266     GenericBitmap *pBmpDown1 = pBmpUp1;
267     GET_BMP( pBmpDown1, rData.m_down1Id );
268
269     GenericBitmap *pBmpOver1 = pBmpUp1;
270     GET_BMP( pBmpOver1, rData.m_over1Id );
271
272     GenericBitmap *pBmpUp2 = NULL;
273     GET_BMP( pBmpUp2, rData.m_up2Id );
274
275     GenericBitmap *pBmpDown2 = pBmpUp2;
276     GET_BMP( pBmpDown2, rData.m_down2Id );
277
278     GenericBitmap *pBmpOver2 = pBmpUp2;
279     GET_BMP( pBmpOver2, rData.m_over2Id );
280
281     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
282     if( pLayout == NULL )
283     {
284         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
285         return;
286     }
287
288     CmdGeneric *pCommand1 = parseAction( rData.m_action1 );
289     if( pCommand1 == NULL )
290     {
291         msg_Err( getIntf(), "Invalid action: %s", rData.m_action1.c_str() );
292         return;
293     }
294
295     CmdGeneric *pCommand2 = parseAction( rData.m_action2 );
296     if( pCommand2 == NULL )
297     {
298         msg_Err( getIntf(), "Invalid action: %s", rData.m_action2.c_str() );
299         return;
300     }
301
302     // Get the state variable
303     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
304     VarBool *pVar = pInterpreter->getVarBool( rData.m_state, m_pTheme );
305     if( pVar == NULL )
306     {
307         // TODO: default state
308         return;
309     }
310
311     // Create the control
312     CtrlCheckbox *pCheckbox = new CtrlCheckbox( getIntf(), *pBmpUp1,
313         *pBmpOver1, *pBmpDown1, *pBmpUp2, *pBmpOver2, *pBmpDown2, *pCommand1,
314         *pCommand2, UString( getIntf(), rData.m_tooltip1.c_str() ),
315         UString( getIntf(), rData.m_tooltip2.c_str() ), *pVar,
316         UString( getIntf(), rData.m_help.c_str() ), NULL );
317
318     // Compute the position of the control
319     // XXX (we suppose all the images have the same size...)
320     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
321                                        rData.m_xPos, rData.m_yPos,
322                                        pBmpUp1->getWidth(),
323                                        pBmpUp1->getHeight(), *pLayout );
324
325     pLayout->addControl( pCheckbox, pos, rData.m_layer );
326
327     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCheckbox );
328 }
329
330
331 void Builder::addImage( const BuilderData::Image &rData )
332 {
333     GenericBitmap *pBmp = NULL;
334     GET_BMP( pBmp, rData.m_bmpId );
335
336     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
337     if( pLayout == NULL )
338     {
339         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
340         return;
341     }
342
343     TopWindow *pWindow = m_pTheme->m_windows[rData.m_windowId].get();
344     if( pWindow == NULL )
345     {
346         msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
347         return;
348     }
349
350     CtrlImage *pImage = new CtrlImage( getIntf(), *pBmp,
351                                 UString( getIntf(), rData.m_help.c_str() ),
352                                 NULL);
353
354     // Compute the position of the control
355     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
356                                        rData.m_xPos,
357                                        rData.m_yPos, pBmp->getWidth(),
358                                        pBmp->getHeight(), *pLayout );
359
360     // XXX: test to be changed! XXX
361     if( rData.m_actionId == "move" )
362     {
363         CtrlMove *pMove = new CtrlMove( getIntf(), m_pTheme->getWindowManager(),
364              *pImage, *pWindow, UString( getIntf(), rData.m_help.c_str() ),
365              NULL);
366         pLayout->addControl( pMove, pos, rData.m_layer );
367     }
368     else if( rData.m_actionId == "resize" )
369     {
370         CtrlResize *pResize = new CtrlResize( getIntf(), *pImage, *pLayout,
371                 UString( getIntf(), rData.m_help.c_str() ), NULL );
372         pLayout->addControl( pResize, pos, rData.m_layer );
373     }
374     else
375     {
376         pLayout->addControl( pImage, pos, rData.m_layer );
377     }
378
379     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pImage );
380 }
381
382
383 void Builder::addText( const BuilderData::Text &rData )
384 {
385     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
386     if( pLayout == NULL )
387     {
388         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
389         return;
390     }
391
392     GenericFont *pFont = getFont( rData.m_fontId );
393     if( pFont == NULL )
394     {
395         msg_Err( getIntf(), "Unknown font id: %s", rData.m_fontId.c_str() );
396         return;
397     }
398
399     // Create a text variable
400     VarText *pVar = new VarText( getIntf() );
401     UString msg( getIntf(), rData.m_text.c_str() );
402     pVar->set( msg );
403     m_pTheme->m_vars.push_back( VariablePtr( pVar ) );
404
405     CtrlText *pText = new CtrlText( getIntf(), *pVar, *pFont,
406             UString( getIntf(), rData.m_help.c_str() ), rData.m_color, NULL );
407
408     int height = pFont->getSize();
409
410     pLayout->addControl( pText, Position( rData.m_xPos, rData.m_yPos,
411                                           rData.m_xPos + rData.m_width,
412                                           rData.m_yPos + height, *pLayout ),
413                          rData.m_layer );
414
415     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pText );
416 }
417
418
419 void Builder::addRadialSlider( const BuilderData::RadialSlider &rData )
420 {
421     // Get the bitmaps of the slider
422     GenericBitmap *pSeq = NULL;
423     GET_BMP( pSeq, rData.m_sequence );
424
425     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
426     if( pLayout == NULL )
427     {
428         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
429         return;
430     }
431
432     // Get the variable associated to the slider
433     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
434     VarPercent *pVar = pInterpreter->getVarPercent( rData.m_value, m_pTheme );
435     if( pVar == NULL )
436     {
437         msg_Err( getIntf(), "Unknown slider value: %s", rData.m_value.c_str() );
438         return;
439     }
440
441     // Create the control
442     CtrlRadialSlider *pRadial =
443         new CtrlRadialSlider( getIntf(), *pSeq, rData.m_nbImages, *pVar,
444                               rData.m_minAngle, rData.m_maxAngle,
445                               UString( getIntf(), rData.m_help.c_str() ),
446                               NULL );
447
448     // XXX: resizing is not supported
449     // Compute the position of the control
450     const Position pos =
451         makePosition( rData.m_leftTop, rData.m_rightBottom, rData.m_xPos,
452                       rData.m_yPos, pSeq->getWidth(),
453                       pSeq->getHeight() / rData.m_nbImages, *pLayout );
454
455     pLayout->addControl( pRadial, pos, rData.m_layer );
456
457     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pRadial );
458 }
459
460
461 void Builder::addSlider( const BuilderData::Slider &rData )
462 {
463     // Get the bitmaps of the slider
464     GenericBitmap *pBmpUp = NULL;
465     GET_BMP( pBmpUp, rData.m_upId );
466
467     GenericBitmap *pBmpDown = pBmpUp;
468     GET_BMP( pBmpDown, rData.m_downId );
469
470     GenericBitmap *pBmpOver = pBmpUp;
471     GET_BMP( pBmpOver, rData.m_overId );
472
473     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
474     if( pLayout == NULL )
475     {
476         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
477         return;
478     }
479
480     Bezier *pCurve = getPoints( rData.m_points.c_str() );
481     if( pCurve == NULL )
482     {
483         msg_Err( getIntf(), "Invalid format in tag points=\"%s\"",
484                  rData.m_points.c_str() );
485         return;
486     }
487     m_pTheme->m_curves.push_back( BezierPtr( pCurve ) );
488
489     // Get the visibility variable
490     // XXX check when it is null
491     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
492     VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
493
494     // Get the variable associated to the slider
495     VarPercent *pVar = pInterpreter->getVarPercent( rData.m_value, m_pTheme );
496     if( pVar == NULL )
497     {
498         msg_Err( getIntf(), "Unknown slider value: %s", rData.m_value.c_str() );
499         return;
500     }
501
502     // Create the cursor and background controls
503     CtrlSliderCursor *pCursor = new CtrlSliderCursor( getIntf(), *pBmpUp,
504         *pBmpOver, *pBmpDown, *pCurve, *pVar, pVisible,
505         UString( getIntf(), rData.m_tooltip.c_str() ),
506         UString( getIntf(), rData.m_help.c_str() ) );
507
508     CtrlSliderBg *pBackground = new CtrlSliderBg( getIntf(), *pCursor,
509         *pCurve, *pVar, rData.m_thickness, pVisible,
510         UString( getIntf(), rData.m_help.c_str() ) );
511
512     // Compute the position of the control
513     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
514                                        rData.m_xPos, rData.m_yPos,
515                                        pCurve->getWidth(), pCurve->getHeight(),
516                                        *pLayout );
517
518     pLayout->addControl( pBackground, pos, rData.m_layer );
519     pLayout->addControl( pCursor, pos, rData.m_layer );
520
521     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCursor );
522     m_pTheme->m_controls[rData.m_id + "_bg"] = CtrlGenericPtr( pBackground );
523 }
524
525
526 void Builder::addList( const BuilderData::List &rData )
527 {
528     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
529     if( pLayout == NULL )
530     {
531         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
532         return;
533     }
534
535     GenericFont *pFont = getFont( rData.m_fontId );
536     if( pFont == NULL )
537     {
538         msg_Err( getIntf(), "Unknown font id: %s", rData.m_fontId.c_str() );
539         return;
540     }
541
542     // Get the list variable
543     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
544     VarList *pVar = pInterpreter->getVarList( rData.m_var, m_pTheme );
545     if( pVar == NULL )
546     {
547         msg_Err( getIntf(), "No such list variable: %s", rData.m_var.c_str() );
548         return;
549     }
550
551     // Create the list control
552     CtrlList *pList = new CtrlList( getIntf(), *pVar, *pFont,
553        rData.m_fgColor, rData.m_playColor, rData.m_bgColor1,
554        rData.m_bgColor2, rData.m_selColor,
555        UString( getIntf(), rData.m_help.c_str() ), NULL );
556
557     // Compute the position of the control
558     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
559                                        rData.m_xPos, rData.m_yPos,
560                                        rData.m_width, rData.m_height,
561                                        *pLayout );
562
563     pLayout->addControl( pList, pos, rData.m_layer );
564
565     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pList );
566 }
567
568
569 void Builder::addVideo( const BuilderData::Video &rData )
570 {
571     GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
572     if( pLayout == NULL )
573     {
574         msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
575         return;
576     }
577
578     CtrlVideo *pVideo = new CtrlVideo( getIntf(),
579         UString( getIntf(), rData.m_help.c_str() ), NULL);
580
581     // Compute the position of the control
582     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
583                                        rData.m_xPos, rData.m_yPos,
584                                        rData.m_width, rData.m_height,
585                                        *pLayout );
586
587     pLayout->addControl( pVideo, pos, rData.m_layer );
588
589     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pVideo );
590 }
591
592
593 const Position Builder::makePosition( const string &rLeftTop,
594                                       const string &rRightBottom,
595                                       int xPos, int yPos, int width,
596                                       int height, const Box &rBox ) const
597 {
598     int left = 0, top = 0, right = 0, bottom = 0;
599     Position::Ref_t refLeftTop = Position::kLeftTop;
600     Position::Ref_t refRightBottom = Position::kLeftTop;
601
602     int boxWidth = rBox.getWidth();
603     int boxHeight = rBox.getHeight();
604
605     // Position of the left top corner
606     if( rLeftTop == "lefttop" )
607     {
608         left = xPos;
609         top = yPos;
610         refLeftTop = Position::kLeftTop;
611     }
612     else if( rLeftTop == "righttop" )
613     {
614         left = xPos - boxWidth + 1;
615         top = yPos;
616         refLeftTop = Position::kRightTop;
617     }
618     else if( rLeftTop == "leftbottom" )
619     {
620         left = xPos;
621         top = yPos - boxHeight + 1;
622         refLeftTop = Position::kLeftBottom;
623     }
624     else if( rLeftTop == "rightbottom" )
625     {
626         left = xPos - boxWidth + 1;
627         top = yPos - boxHeight + 1;
628         refLeftTop = Position::kRightBottom;
629     }
630
631     // Position of the right bottom corner
632     if( rRightBottom == "lefttop" )
633     {
634         right = xPos + width - 1;
635         bottom = yPos + height - 1;
636         refRightBottom = Position::kLeftTop;
637     }
638     else if( rRightBottom == "righttop" )
639     {
640         right = xPos + width - boxWidth;
641         bottom = yPos + height - 1;
642         refRightBottom = Position::kRightTop;
643     }
644     else if( rRightBottom == "leftbottom" )
645     {
646         right = xPos + width - 1;
647         bottom = yPos + height - boxHeight;
648         refRightBottom = Position::kLeftBottom;
649     }
650     else if( rRightBottom == "rightbottom" )
651     {
652         right = xPos + width - boxWidth;
653         bottom = yPos + height - boxHeight;
654         refRightBottom = Position::kRightBottom;
655     }
656
657     return Position( left, top, right, bottom, rBox, refLeftTop,
658                      refRightBottom );
659 }
660
661
662 GenericFont *Builder::getFont( const string &fontId )
663 {
664     GenericFont *pFont = m_pTheme->m_fonts[fontId].get();
665     if( !pFont && fontId == "defaultfont" )
666     {
667 #ifdef WIN32_SKINS
668         string defaultFont = (string)getIntf()->p_libvlc->psz_vlcpath +
669                              "\\skins2\\fonts\\FreeSans.ttf";
670 #else
671         string defaultFont = (string)DATA_PATH + "/skins2/fonts/FreeSans.ttf";
672 #endif
673         pFont = new FT2Font( getIntf(), defaultFont, 12 );
674         if( pFont->init() )
675         {
676             m_pTheme->m_fonts["defaultfont"] = GenericFontPtr( pFont );
677         }
678         else
679         {
680             delete pFont;
681             pFont = NULL;
682         }
683     }
684     return pFont;
685 }
686
687
688 Bezier *Builder::getPoints( const char *pTag ) const
689 {
690     vector<float> xBez, yBez;
691     int x, y, n;
692     while( 1 )
693     {
694         if( sscanf( pTag, "(%d,%d)%n", &x, &y, &n ) < 1 )
695         {
696             return NULL;
697         }
698 #if 0
699         if( x < 0 || y < 0 )
700         {
701             msg_Err( getIntf(),
702                      "Slider points cannot have negative coordinates!" );
703             return NULL;
704         }
705 #endif
706         xBez.push_back( x );
707         yBez.push_back( y );
708         pTag += n;
709         if( *pTag == '\0' )
710         {
711             break;
712         }
713         if( *(pTag++) != ',' )
714         {
715             return NULL;
716         }
717     }
718
719     // Create the Bezier curve
720     return new Bezier( getIntf(), xBez, yBez );
721 }
722