2007/03/08

Freevo2 UI guide


  • Who use Fade?
    • ui/src/plugins/idlebar.py
    • ui/src/gui/animation/transition.py
    • ui/src/gui/areas/handler.py
    • ui/src/gui/compat.py


  • Who has Area?
    • ui/src/gui/areas/tvlisting_area.py
    • ui/src/gui/areas/progress_area.py
    • ui/src/gui/areas/listing_area.py
    • ui/src/gui/areas/view_area.py
    • ui/src/gui/areas/info_area.py
    • ui/src/gui/theme.py
    • ui/src/input/linux_input.py
    • ui/src/menu/menu.py


  • What is Menu?
    • A Menu page with Items for the MenuStack. It is not allowed to change the selected item or the internal choices directly, use 'select', 'set_items' or 'change_item' to do this.

    • Inherited from:
      • from kaa.weakref import weakref
      • from item import Item


      Menu(heading, choices=[], reload_func = None, type = None)
      Global Variable: next_id, start from 1

    • Attributes:
      • . heading
      • stack
      • id = next_id (automate increase)
      • state
      • pos(in menu stack)
      • choices(items)
      • selected
      • infoitem
      • viewitem
      • type
      • submenu
      • tem
      • autoselect
      • cols
      • rows


    • Methods:
      • set_items(items, refresh=True)
      • select(item)
      • get_items()
      • get_selection()
      • change_item(old, new)
      • eventhandler(event): event :

        MENU_LEFT, MENU_BACK_ONE_MENU, MENU_RIGHT, MENU_SELECT, MENU_PAGEUP,
        MENU_PAGEDOWN, MENU_UP, MENU_DOWN, MENU_PLAY_ITEM, MENU_CHANGE_SELECTION,
        MENU_SUBMENU, MENU_CALL_ITEM_ACTION


  • What is ActionItem?
    • A simple item with one action. The first parameter of the function passed to this action is always the parent item if not None.

    • Attributes:
      • item: parent


    • Inherited from:
      • from files import Files
      • from item import Item
      • from mediaitem import MediaItem
      • from action import Action
      • from menu import Menu
      • from stack import MenuStack
      • from plugin import ItemPlugin, MediaPlugin


  • What is Action?
    • Action for item.actions()

      An action has a name and a function to call. Optional parameter is a shortcut name to be placed into the config for mapping an action to a button. It also has an optional description.

      To set parameters for the function call, use the parameter function of the action object. The function itself has always one or two parameters. If the function is defined inside the item, no extra parameters are used. If it is outside the item, the first parameter is the item.

      Action(name, function, shortcut=None, description=None)
      Action.parameter(*args, **kwargs)


    • Attributes:
      • name,
      • function,
      • shortcut
      • description
      • args
      • kwargs
      • item


  • What is the Files in UI?
    • File operations for an item.

    • Attributes:
      • files
      • fxd_file
      • image
      • read_only


    • Methods:
      • append(filename)
      • get()
      • copy_possible()
      • copy(dest)
      • move_possible()
      • move(dest)
      • delete_possible() == move_possible()
      • delete()


  • What is Item?
    • Item class. This is the base class for all items in the menu. It's a template for other info items like VideoItem, AudioItem and ImageItem

    • Inherited from:
      • from kaa.weakref import weakref
      • import kaa.beacon
      • from plugin import ItemPlugin


    • Item(parent=None, action=None, type=None)


    • Attributes:
      • icon
      • info: a hash of key:value
      • menu
      • type
      • _image
      • action
      • name == action.name
      • description = action.description
      • parent
      • iscopy
      • fxd_file


    • Methods:
      • _get_image()
      • _set_image()
      • __setitem__(key, value)
      • copy()
      • __id__()
      • sort(mode): mode = name, smart
      • actions()
      • get_actions()
      • get_menustack()
      • pushmenu(menu)
      • show_menu(refresh=True)
      • replace(item)
      • get_playlist()
      • eventhandler(event)
      • __getitem__(attr): attr could be:
        parent(),len(),name, or the key of info


  • What is MediaItem?
    • This item is for a media. It's only a template for image, video or audio items

    • Inherited from
      • import kaa.beacon
      • from kaa.strutils import str_to_unicode
      • from freevo.ui.event import PLAY_START, STOP
      • from item import Item
      • from files import Files


    • Attributes:
      • url: for player, such as dvd://
      • filename
      • fxdinfo


    • Methods:
      • set_url(url): url must be an instance of beacon
      • __getitem__(attr): attr could be length, length:min, elapsed:percent,
        or in fxdinfo, or come from Item
      • __id__(): == url
      • __repr__()
      • sort(mode): mode: name, filename, date
      • cache()
      • play()
      • stop()
      • eventhandler(event): event: PLAY_START, STOP


  • Plugin V.S. Menu?
    • Plugin class to add something to the item action list

      The plugin can also have an eventhandler. All events passed to the item
      will also be passed to this plugin. This works only for VideoItems right
      now (each item type must support it directly). If the function returns
      True, the event won't be passed to other eventhandlers and also not to
      the item itself.

    • Inherited from
      • from freevo.ui import plugin


    • ItemPlugin(name)


    • Attributes:
      • _plugin_type = "item"


    • Methods:
      • actions()
      • eventhandler(item, event)


    • MediaPlugin(name)


    • Attributes:
      • _plugin_type = "item"


    • Methods:
      • suffix()
      • get(parent, files)
      • count(parent, listing)
      • dirinfo(diritem)
      • database()


  • MenuStack
    • The MenuStack handles a stack of Menus.
      Stack 是為了讓選單能順利返回上一層,現在要慢慢搞懂其運作,每個 menu 會有個 menu.stack, 估計只是指向它在 MenuStack 的位置

    • Inherited from
      • from kaa.weakref import weakref
      • from freevo.ui.event import *
      • from menu import Menu
      • from item import Item


    • When __init__(), clear menustack

    • Attributes:
      • menustack


    • Methods:
      • back_to_menu(menu, refresh=True)
      • back_one_menu(refresh=True)
      • delete_submenu(refresh=True, reload=False, osd_message='')
      • pushmenu(menu): push and show
      • refresh(): 搞不懂為何 len(menu.choices) == 1 且 menu.autoselect 要刪除它
      • __getitem__(attr)
      • __setitem__(attr, value)
      • get_selected()
      • get_menu()
      • eventhendler(event): MENU_GOTO_MAINMENU, MENU_BACK_ONE_MENU,
        MENU_GOTO_MEDIA, MENU_SELECT, MENU_SUBMENU, MENU_PLAY_ITEM


  • What is MainMenu System?
    • MainMenu system contains three parts: MainMenuItem, MainMenuPlugin, MainMenu

    • Inherited from
      • from menu import Item, Action, Menu
      • from application.menuw import MenuWidget


  • What is MainMenuItem?
    • This class is a main menu item. Items of this type can be returned by a MainMenuPlugin.

      MainMenuItem(parent=None, name=u'', type=None, image=None, icon=None, skin_type=None)

      skin_info = theme.mainmenu.items 從 theme.mainmenu 中取出 skin_info
      用來設定 name, image, icon 等等

    • Attributes:
      • name
      • icon
      • image
      • type: == "main"
      • skin_type


    • Methods:
      • actions()
      • select()


  • What is MainMenuPlugin?
    • Plugin class for plugins to add something to the main menu

      MainMenuPlugin(name)


    • Attributes:
      • _plugin_type = "mainmenu"
      • _plugin_special = True
      • plugins


    • Methods:
      • items(parent)
      • plugins(subtype)


  • What is MainMenu?
    • MainMenu is an Item.

      This class handles the main menu. It will start the main menu widget and the first menu page based on the main menu plugins.

      它從每個 plugin 取得 items 再透過 Menu 變成主選單,最後利用 MenuWidget(menu)
      來產生畫面的 widget

    • Attributes:
      • menuw : menu widget

    • Methods:
      • get_menustack(): 竟然是傳回 menuw?


  • What is MenuWidget?
    • The MenuWidget is an Application for GUI and event handling and also an instance of MenuStack defined in menu.stack.

      重點在於它是 Application, 另外它的 refresh(reload=False) 只有兩行:

      MenuStack.refresh(self, reload)
      self.engine.update(self.menustack[-1])


  • What is an Application?
    • Inherited from
      • from kaa.notifier import Signal
      • from freevo.ui import gui
      • from handler import handler


    • Application(name, eventmap, capabilities)


    • Atrributes:
      • __name
      • _eventmap
      • _visible
      • engine = gui.Application(name)
      • signals = show, hide, start, stop
      • _status
      • _capabilities


    • Methods:
      • has_capabilities(capabilities)
      • get_status()
      • set_status(status)
      • _show_app(): emit a signal.show then call engine.show()
      • _hide_app()
      • eventhandler(event)
      • stop()
      • is_visible()
      • set_eventmap(eventmap)
      • get_eventmap()
      • get_name()
      • get_resources(*resources): 目前不知道 resources 的機制
      • free_resources(*resources)
      • __repr__()

0 意見: