Changeset 1900

Show
Ignore:
Timestamp:
19/11/08 20:27:25 (7 weeks ago)
Author:
duncan
svm:headrev:

cc3e1ea1-1e01-0410-8d68-8b121e83a9d5:11182
Message:

[ 2308911 ] Skinable Dialogs
Rather a big patch from Adam Charrett applied

Location:
freevo
Files:
37 added
2 removed
23 modified

Legend:

Unmodified
Added
Removed
  • freevo/ChangeLog

    r1890 r1900  
    1919-------------------------------- 
    2020 
     21 * New skinable dialogues for the OSD (F#2308911) 
    2122 * New wikisubtitles video plug-in to get subtitles for videos (F#2147641) 
    2223 * Updated apple trailers (F#2089598) 
  • freevo/Docs/CREDITS

    r1816 r1900  
    200200 
    201201Adam Charrett <ajmcharrett at hotmail.com> 
     202o Skinable dialogues 
    202203o Buttonbar plug-in 
    203204o Screensaver plug-in 
  • freevo/freevo_config.py

    r1893 r1900  
    926926# plugin.activate('joy') 
    927927 
     928# ====================================================================== 
     929# Dialog Display Plugins 
     930# ====================================================================== 
     931plugin.activate('dialog.osd_display') 
     932if CONF.display in ('x11', 'xv'): 
     933    plugin.activate('dialog.x11_overlay_display') 
     934 
    928935# Speak plugin to output menu items via festival 
    929936# plugin.activate('speak') 
     
    13661373 
    13671374# 
     1375# XML file used for the dialog skins. 
     1376# 
     1377DIALOG_SKIN_XML_FILE = 'base' 
     1378 
     1379# 
    13681380# Select a way when to switch to text view even if a image menu is there 
    13691381# 
  • freevo/share/skins/freevo-osd.dtd

    r1758 r1900  
    44<!ELEMENT freevo (osds)> 
    55 
    6 <!ELEMENT osds ( font*, color*, osd*)> 
    7 <!ATTLIST osds geometry CDATA #REQUIRED> 
    8 <!ATTLIST osds include CDATA #IMPLIED> 
     6<!ELEMENT osds (widgetstyles?, (font|color|osd)*)> 
     7<!ATTLIST osds  
     8    geometry CDATA #REQUIRED 
     9    icontheme CDATA #IMPLIED 
     10    include CDATA #IMPLIED> 
    911 
    10 <!ELEMENT osd ((text|image|percent)*)> 
     12<!ELEMENT osd (navigationmap?, (text|image|percent|button|togglebutton|menu)*)> 
    1113<!ATTLIST osd 
    1214        name ID #REQUIRED 
     
    5355    height CDATA #IMPLIED 
    5456    src CDATA #REQUIRED 
     57    srcexpr CDATA #IMPLIED 
    5558        expression CDATA #REQUIRED 
     59    scale (noscale | horizontal | vertical | both | aspect) "noscale" 
    5660> 
    5761 
     
    6670        expression CDATA #REQUIRED 
    6771> 
     72 
     73<!ELEMENT button EMPTY> 
     74<!ATTLIST button 
     75    name CDATA #REQUIRED 
     76    style CDATA #REQUIRED 
     77    x CDATA #REQUIRED 
     78    y CDATA #REQUIRED 
     79    width CDATA #REQUIRED 
     80    height CDATA #REQUIRED     
     81    > 
     82     
     83<!ELEMENT togglebutton EMPTY> 
     84<!ATTLIST togglebutton 
     85    name CDATA #REQUIRED 
     86    style CDATA #REQUIRED 
     87    x CDATA #REQUIRED 
     88    y CDATA #REQUIRED 
     89    width CDATA #REQUIRED 
     90    height CDATA #REQUIRED     
     91    > 
     92     
     93<!ELEMENT menu EMPTY> 
     94<!ATTLIST menu 
     95    name CDATA #REQUIRED 
     96    style CDATA #REQUIRED 
     97    x CDATA #REQUIRED 
     98    y CDATA #REQUIRED 
     99    width CDATA #REQUIRED 
     100    height CDATA #REQUIRED     
     101    itemsperpage cDATA #REQUIRED 
     102    > 
     103     
     104<!ELEMENT navigationmap (navigation*)> 
     105 
     106<!ELEMENT navigation EMPTY> 
     107<!ATTLIST navigation 
     108    from CDATA #REQUIRED 
     109    left CDATA #REQUIRED 
     110    right CDATA #REQUIRED 
     111    up CDATA #REQUIRED 
     112    down CDATA #REQUIRED> 
     113 
     114<!ELEMENT widgetstyles (widgetstyle*)> 
     115 
     116<!ELEMENT widgetstyle (widgetstate*)> 
     117<!ATTLIST widgetstyle name CDATA #REQUIRED> 
     118 
     119<!ELEMENT widgetstate ((text|image|percent)*)> 
     120<!--  
     121    Standard states are: 
     122     
     123    normal   - Enabled but doesn't have input focus 
     124    active   - Enabled and has input focus 
     125    disabled - Disabled 
     126     
     127    pressed  - Buttons and MenuItems only, after the user has 'pressed' (selected) the item. 
     128     
     129    highlighted - MenuItems only, when the menu doesn't have input focus, but the currently selected item still shows. 
     130     
     131    ToggleButton/ToggleMenuItem only, standard starts but with the state of the toggle appended: 
     132     
     133    normal_selected 
     134    normal_unselected 
     135    active_selected 
     136    active_unselected 
     137    disabled_selected 
     138    disabled_unselected 
     139     
     140    ToggleMenuItem only: 
     141     
     142    highlighted_selected 
     143    highlighted_unselected 
     144 
     145--> 
     146<!ATTLIST widgetstate state CDATA "normal"> 
  • freevo/share/skins/osd/base.fxd

    r1579 r1900  
    11<freevo> 
    2         <osds geometry="800x600"> 
     2        <!-- 
     3     OSDS 
     4     ==== 
     5         Collection of dialogs, common dialogs are: 
     6          - volume 
     7          - message 
     8          - 1button 
     9          - 2button 
     10          - 3button 
     11          - menu 
     12          - play_state 
     13 
     14         Properties 
     15          geometry : (Mandatory) Dimension of freevo display 
     16          icontheme: (Optional)  Directory inside images and icon dirs to look for theme specific images. 
     17          include  : (Optional)  osd skin to load before starting to parse this one, allows inheritance of dialogs, font, colors. 
     18        --> 
     19        <osds geometry="800x600" icontheme="base"> 
     20                <!-- 
     21                  Volume dialog 
     22                  ============= 
     23                  Used to display audio volume status. 
     24 
     25                  Available information: 
     26                   muted   : (boolean) whether the output is muted 
     27                   level   : (int) current level used for output 0-100. 
     28                   channel : (string) The channel being displayed, one of 
     29                                   - main 
     30                           - center 
     31                           - surround 
     32                           - lfe 
     33           channel_name : (unicode string) Translated version of channel 
     34        --> 
     35        <!-- 
    336                <osd name="volume" x="137" y="420" width="525" height="80"> 
    4                         <percent x="0" y="0" width="370" height="80" src="base/volume_bar.png" expression="float(volume)/100.0"/> 
    5                         <text x="0" y="0" width="370" height="80" expression="volume_text" font="Vera/20" fgcolor="white"/> 
     37                        <percent x="0" y="0" width="370" height="80" src="volume_bar.png" expression="float(volume)/100.0"/> 
     38                        <text x="0" y="0" width="370" height="80" expression="channel" font="Vera/20" fgcolor="white"/> 
    639                        <text x="370" y="0" width="155" height="80" expression="'%d%%' % int(volume)" font="Vera/40" fgcolor="white" align="right" valign="bottom"/> 
     40                </osd>--> 
     41                <osd name="volume" x="90" y="460" width="675" height="90" > 
     42            <percent  x="130" y="10" width="370" height="80" src="volume_bar.png" expression="float(volume)/100.0"/> 
     43            <image expression="muted" x="130" y="0" width="370" height="87" src="muted.png"/> 
     44            <text expression="channel_name" x="0" y="0" width="130" height="85" font="Vera/20" fgcolor="white"/> 
     45            <text expression="'%d%%' % volume" x="500" y="0" width="155" height="90" font="Vera/40" fgcolor="white" align="right" valign="bottom"/> 
    746                </osd> 
    8  
     47        <!-- 
     48          Message dialog 
     49          ============== 
     50          Used to display generic messages. 
     51 
     52          Available information: 
     53           message : (unicode string) translated message to display. 
     54        --> 
    955                <osd name="message" x="50" y="50" width="700" height="110"> 
    10                         <image x="0" y="0" width="700" height="110" src="base/details_bg.png" /> 
     56                        <image x="0" y="0" width="700" height="110" src="details_bg.png" /> 
    1157                        <text x="5" y="5" width="690" height="100" expression="message" font="Vera/25" fgcolor="white" /> 
    1258                </osd> 
    1359 
    14                 <osd name="info" x="50" y="400" width="700" height="150"> 
    15                         <!-- Percent through buffer bar --> 
    16                         <percent x="100" y="0" width="500" height="25" src="base/bar.png" expression="percent_buffer_full"/> 
    17                         <percent x="100" y="0" width="500" height="25" src="base/percent_bar.png" expression="percent_through_buffer * percent_buffer_full"/> 
    18                         <text x="0" y="0" width="95" height="25" expression="strftime('%H:%M',start_time)" font="info" align="right" /> 
    19                         <text x="605" y="0" width="95" height="25" expression="strftime('%H:%M',end_time)" font="info" /> 
    20                         <text x="300" y="0" width="100" height="25" expression="strftime('%H:%M',current_time)" font="info" align="center" /> 
    21                         <!-- Details panel --> 
    22                         <image x="0" y="40" width="700" height="110" src="base/details_bg.png" /> 
    23                         <text x="5" y="40" width="290" height="25" font="info" expression="guide_channel" /> 
    24                         <text x="300" y="40" width="100" height="25" font="info" expression="guide_status" /> 
    25                         <text x="550" y="40" width="145" height="25" font="info" expression="guide_program_start + '-' + guide_program_stop" /> 
    26                         <text x="5" y="70" width="690" height="25" font="info" expression="guide_program_title" /> 
    27                         <text x="5" y="100" width="690" height="50" font="description" expression="guide_program_desc" /> 
    28                 </osd> 
    29  
    30                 <font label="info" name="Vera" size="16" color="white" /> 
    31                 <font label="description" name="Vera" size="14" color="white" /> 
     60                <!-- 
     61                  1 button dialog 
     62                  =============== 
     63          Single button message dialog, that doesn't use type info. 
     64 
     65          Available information: 
     66           message : (unicode string) translated message to display. 
     67           button  : (unicode string) translated button text to display. 
     68           dialog_type: Dialog type (error, warning, question) (UNUSED) 
     69        --> 
     70        <osd name="1button" x="150" y="200" width="500" height="250"> 
     71            <image x="0" y="0" width="500" height="250" src="dialog_bg.png" /> 
     72            <text x="5" y="5" width="490" height="180" font="message" expression="message" align="center" valign="center" /> 
     73 
     74            <button x="160" y="160" width="180" height="45" name="button" style="button" /> 
     75        </osd> 
     76 
     77                <!-- 
     78                  2 button dialog 
     79                  =============== 
     80          Two button message dialog, that doesn't use type info. 
     81 
     82          Available information: 
     83           message : (unicode string) translated message to display. 
     84           button1 : (unicode string) translated button text to display. 
     85           button2 : (unicode string) translated button text to display. 
     86           dialog_type: Dialog type (error, warning, question) (UNUSED) 
     87        --> 
     88 
     89        <osd name="2button" x="150" y="200" width="500" height="250"> 
     90            <image x="0" y="0" width="500" height="250" src="dialog_bg.png" /> 
     91            <text x="5" y="5" width="490" height="180" font="message" expression="message" align="center" valign="center" /> 
     92 
     93            <button x="30" y="160" width="180" height="45" name="button1" style="button" /> 
     94            <button x="290" y="160" width="180" height="45" name="button2" style="button" /> 
     95 
     96            <navigationmap> 
     97                <navigation from="button1" right="button2" left="button2"/> 
     98                <navigation from="button2" right="button1" left="button1"/> 
     99            </navigationmap> 
     100        </osd> 
     101 
     102        <!-- 
     103                  3 button dialog 
     104                  =============== 
     105          Three button message dialog, that doesn't use type info. 
     106 
     107          Available information: 
     108           message : (unicode string) translated message to display. 
     109           button1 : (unicode string) translated button text to display. 
     110           button2 : (unicode string) translated button text to display. 
     111           button3 : (unicode string) translated button text to display. 
     112           dialog_type: Dialog type (error, warning, question) (UNUSED) 
     113        --> 
     114                <osd name="3button" x="150" y="200" width="500" height="250"> 
     115            <image x="0" y="0" width="500" height="250" src="dialog_bg.png" /> 
     116            <text x="5" y="5" width="490" height="180" font="message" expression="message" align="center" valign="center" /> 
     117 
     118            <button x="30" y="160" width="140" height="45" name="button1" style="button" /> 
     119            <button x="180" y="160" width="140" height="45" name="button2" style="button" /> 
     120            <button x="330" y="160" width="140" height="45" name="button2" style="button" /> 
     121 
     122            <navigationmap> 
     123                <navigation from="button1" right="button2" left="button3"/> 
     124                <navigation from="button2" right="button3" left="button1"/> 
     125                <navigation from="button3" right="button1" left="button2"/> 
     126            </navigationmap> 
     127        </osd> 
     128 
     129                <!-- Centered Menu --> 
     130        <osd name="menu" x="275" y="135" width="250" height="345" > 
     131            <image  x="0" y="0" width="250" height="345" src="menu_bg.png" /> 
     132                        <text expression="title" font="Vera/14" x="10" y="15" width="230" height="40"/> 
     133            <menu name="menu" style="menu" itemsperpage="6" x="10" y="65" width="230" height="260"/> 
     134        </osd> 
     135 
     136        <!-- Button Bar More Options menu --> 
     137        <osd name="bboptionsmenu" x="584" y="264" width="216" height="275" > 
     138            <image src="bboptionsmenubg.png" x="0" y="0" width="216" height="275"/> 
     139            <image expression="menu.more_down" src="menu_down.png" x="168" y="246" width="22" height="25"/> 
     140            <image expression="menu.more_up" src="menu_up.png" x="191" y="246" width="22" height="25"/> 
     141            <menu name="menu" style="menu" itemsperpage="6" x="4" y="20" width="204" height="222"/> 
     142        </osd> 
     143 
     144                <!-- Play state dialog --> 
     145        <osd name="play_state" x="10" y="10" width="440" height="80" > 
     146            <image  x="0" y="0" width="120" height="80" srcexpr="'%s.png' % state" /> 
     147            <text expression="current_time_str and (current_time_str + ' / '+ total_time_str) or ''" font="message" x="140" y="9" width="300" height="40"/> 
     148        </osd> 
     149 
     150        <!-- 
     151          Widget Style Information 
     152          ======================== 
     153          Determines how to draw widgets in different states. 
     154        --> 
     155        <widgetstyles> 
     156            <widgetstyle name="button"> 
     157                <widgetstate state="normal"> 
     158                    <image x="0" y="0" width="width" height="height" src="button_normal_bg.png" scale="both" /> 
     159                    <image x="5" y="((height - 30) / 2)" width="20" height="20" expression="model.icon" srcexpr="model.icon" scale="aspect"/> 
     160                    <text x="model.icon and 30 or 5" y="5" width="model.icon and (width - 30) or (width-10)" height="height-10" 
     161                          font="button" align="center" valign="center" expression="model.text"/> 
     162                </widgetstate> 
     163                <widgetstate state="active"> 
     164                    <image x="0" y="0" width="width" height="height" src="button_active_bg.png" scale="both" /> 
     165                    <image x="5" y="((height - 30) / 2)" width="20" height="20" expression="model.icon" srcexpr="model.icon" scale="aspect"/> 
     166                    <text x="model.icon and 30 or 5" y="5" width="model.icon and (width - 30) or (width-10)" height="height-10" 
     167                          font="button_selected" align="center" valign="center" expression="model.text"/> 
     168                </widgetstate> 
     169                <widgetstate state="pressed"> 
     170                    <image x="0" y="0" width="width" height="height" src="button_pressed_bg.png" scale="both" /> 
     171                    <image x="5" y="((height - 30) / 2)" width="20" height="20" expression="model.icon" srcexpr="model.icon" scale="aspect"/> 
     172                    <text x="model.icon and 30 or 5" y="5" width="model.icon and (width - 30) or (width-10)" height="height-10" 
     173                          font="button_pressed" align="center" valign="center" expression="model.text"/> 
     174                </widgetstate> 
     175            </widgetstyle> 
     176 
     177            <widgetstyle name="radiobutton"> 
     178                <widgetstate state="normal_unselected"> 
     179                    <image x="5" y="((height - 22) / 2)" width="22" height="22" src="radio_unselected.png" scale="aspect"/> 
     180                    <text x="33" y="5" width="width - 33" height="height-10" 
     181                          font="button" align="left" valign="center" expression="model.text"/> 
     182                </widgetstate> 
     183                <widgetstate state="normal_selected"> 
     184                    <image x="5" y="((height - 22) / 2)" width="22" height="22" src="radio_selected.png" scale="aspect"/> 
     185                    <text x="33" y="5" width="width - 33" height="height-10" 
     186                          font="button" align="left" valign="center" expression="model.text"/> 
     187                </widgetstate> 
     188                <widgetstate state="active_selected"> 
     189                    <image x="0" y="0" width="width" height="height" src="radio_active_bg.png" scale="both" /> 
     190                    <image x="5" y="((height - 22) / 2)" width="22" height="22" src="radio_selected.png" scale="aspect"/> 
     191                    <text x="33" y="5" width="width - 33" height="height-10" 
     192                          font="button" align="left" valign="center" expression="model.text"/> 
     193                </widgetstate> 
     194                <widgetstate state="active_unselected"> 
     195                    <image x="0" y="0" width="width" height="height" src="radio_active_bg.png" scale="both" /> 
     196                    <image x="5" y="((height - 22) / 2)" width="22" height="22" src="radio_unselected.png" scale="aspect"/> 
     197                    <text x="33" y="5" width="width - 33" height="height-10" 
     198                          font="button" align="left" valign="center" expression="model.text"/> 
     199                </widgetstate> 
     200 
     201            </widgetstyle> 
     202 
     203            <widgetstyle name="menu"> 
     204                <widgetstate state="normal"> 
     205                </widgetstate> 
     206                <widgetstate state="active"> 
     207                </widgetstate> 
     208            </widgetstyle> 
     209 
     210            <widgetstyle name="menu_item"> 
     211                <widgetstate state="normal"> 
     212                    <text x="2" y="2" width="width - 4" height="height-4" 
     213                          font="menu" align="left" valign="center" expression="model.text"/> 
     214                </widgetstate> 
     215                <widgetstate state="active"> 
     216                    <image x="0" y="0" width="width" height="height" src="menu_active.png" scale="both" /> 
     217                    <text x="2" y="2" width="width - 4" height="height-4" 
     218                          font="menu_selected" fgcolor="white" align="left" valign="center" expression="model.text"/> 
     219                </widgetstate> 
     220                <widgetstate state="highlighted"> 
     221                    <image x="0" y="0" width="width" height="height" src="menu_active.png" scale="both" /> 
     222                    <text x="2" y="2" width="width - 4" height="height-4" 
     223                          font="menu_selected" fgcolor="white" align="left" valign="center" expression="model.text"/> 
     224                </widgetstate> 
     225                <widgetstate state="pressed"> 
     226                    <image x="0" y="0" width="width" height="height" src="menu_pressed.png" scale="both" /> 
     227                    <text x="2" y="2" width="width - 4" height="height-4" 
     228                          font="menu_pressed" align="left" valign="center" expression="model.text"/> 
     229                </widgetstate> 
     230            </widgetstyle> 
     231        </widgetstyles> 
     232 
     233                <!-- Font section --> 
     234                <!-- Font used in message text. --> 
     235        <font label="message" name="Vera" size="14" color="white" /> 
     236 
     237        <!-- Fonts used by buttons --> 
     238        <font label="button" name="Vera" size="12" color="black" /> 
     239        <font label="button_selected" name="VeraBd" size="14" color="white" /> 
     240        <font label="button_pressed" name="VeraBd" size="14" color="black" /> 
     241 
     242        <!-- Fonts used by menu items --> 
     243        <font label="menu" name="Vera" size="12" color="gray" /> 
     244        <font label="menu_selected" name="VeraBd" size="12" color="white"/> 
     245        <font label="menu_pressed" name="VeraBd" size="12" color="black"/> 
     246 
     247        <!-- Commonly used colors --> 
    32248                <color label="white" value="255,255,255,255" /> 
     249                <color label="gray" value="96,96,96,255" /> 
    33250                <color label="black" value="0,0,0,255" /> 
    34251                <color label="transparent" value="0,0,0,0" /> 
  • freevo/src/main.py

    r1888 r1900  
    113113import osd     # The OSD class, used to communicate with the OSD daemon 
    114114import menu    # The menu widget class 
     115import dialog  # Message/Volume/Dialog display function (must be imported after config) 
    115116try: 
    116117    import skin    # The skin class 
     
    213214        self.bar_position = skin.Rectange(bgcolor=0xa0000000L) 
    214215        self.text         = text 
     216        self.first_draw   = True 
    215217 
    216218 
     
    239241        """ 
    240242        self.pos = pos 
    241         skin.draw('splashscreen', None) 
     243        blend = config.FREEVO_USE_ALPHABLENDING and self.first_draw 
     244        skin.draw('splashscreen', None, blend=blend) 
     245        self.first_draw = False 
    242246 
    243247 
     
    281285        elif event.handler: 
    282286            event.handler(event=event) 
     287 
     288        # Pass the event to the dialog subsystem first incase a dialog is being displayed. 
     289        elif dialog.handle_event(event): 
     290            return 
    283291 
    284292        # Send events to either the current app or the menu handler 
     
    346354    """ 
    347355    _debug_('signal_handler()', 2) 
     356    raise Exception 
    348357    global _shutting_down 
    349358    if _shutting_down: 
     
    460469    skin.register('splashscreen', ('screen', splash)) 
    461470    plugin.init(splash.progress) 
     471    dialog.init() 
    462472    skin.delete('splashscreen') 
    463473 
  • freevo/src/menu.py

    r1864 r1900  
    831831                return 
    832832            menu = self.menustack[-2] 
    833             if hasattr(menu.selected, 'eventhandler') and menu.selected.eventhandler: 
     833            if hasattr(menu, 'selected') and hasattr(menu.selected, 'eventhandler') and menu.selected.eventhandler: 
    834834                if menu.selected.eventhandler(event=event, menuw=self): 
    835835                    return 
  • freevo/src/osd.py

    r1874 r1900  
    385385        self.main_layer = pygame.Surface((self.width, self.height)) 
    386386        self.dialog_layer_enabled = False 
     387        self.screensaver_running = False 
    387388        self.dialog_layer = self.screen.convert_alpha() 
    388389        self.dialog_layer.fill((0,0,0,128)) 
     
    14991500                    for sub_rect in rect: 
    15001501                        self.screen.blit(self.main_layer, (sub_rect[0], sub_rect[1]), sub_rect) 
    1501                     if self.dialog_layer_enabled: 
     1502                    if self.dialog_layer_enabled and not self.screensaver_running: 
    15021503                        for sub_rect in rect: 
    15031504                            self.screen.blit(self.dialog_layer, (sub_rect[0], sub_rect[1]), sub_rect) 
     
    15071508                    except: 
    15081509                        traceback.print_exc() 
    1509                     if self.dialog_layer_enabled: 
     1510                    if self.dialog_layer_enabled and not self.screensaver_running: 
    15101511                        self.screen.blit(self.dialog_layer, (rect[0], rect[1]), rect) 
    15111512                try: