home *** CD-ROM | disk | FTP | other *** search
- #
- # This file is part of OpenVIP (http://openvip.sourceforge.net)
- #
- # Copyright (C) 2002-2003
- # Michal Dvorak, Jiri Sedlar, Antonin Slavik, Vaclav Slavik, Jozef Smizansky
- #
- # This program is licensed under GNU General Public License version 2;
- # see file COPYING in the top level directory for details.
- #
- # $Id: TransitionPanel.py,v 1.12 2003/06/18 16:55:08 vaclavslavik Exp $
- #
-
- from wxPython.wx import *
- import globals, openvip, notify, worker
- from ATransitionSettingsDialog import ATransitionSettingsDialog
- from VTransitionSettingsDialog import VTransitionSettingsDialog
-
- ID_LISTBOX = wxNewId()
- ID_PARAMS = wxNewId()
- ID_UP = wxNewId()
- ID_DOWN = wxNewId()
-
- class TransitionPanel(wxPanel):
- """This class implements ObjectPanel's content for transitions on
- timeline. It shows list of available transitions and lets the user
- select one of them. Buttons for setting transition direction (A->B
- or B->A) and setting its parameters (by launching
- VTransitionSettingsDialog or ATransitionSettingsDialog) are provided as
- well."""
- def __init__(self, *args, **kwds):
- # begin wxGlade: TransitionPanel.__init__
- kwds["style"] = wxTAB_TRAVERSAL
- wxPanel.__init__(self, *args, **kwds)
- self.transition_text = wxTextCtrl(self, -1, "", style=wxTE_READONLY)
- self.direction_up = wxBitmapButton(self, ID_UP, wxBitmap("bitmaps/arrow_up.png", wxBITMAP_TYPE_PNG))
- self.direction_down = wxBitmapButton(self, ID_DOWN, wxBitmap("bitmaps/arrow_down.png", wxBITMAP_TYPE_PNG))
- self.settings = wxBitmapButton(self, ID_PARAMS, wxBitmap("bitmaps/filter_settings.png", wxBITMAP_TYPE_PNG))
- self.label_3 = wxStaticText(self, -1, "Available transitions:", style=wxALIGN_CENTRE)
- self.listbox = wxListBox(self, ID_LISTBOX, choices=["choice 1"])
-
- self.__set_properties()
- self.__do_layout()
- # end wxGlade
-
- lib = globals.core
- self.video_transitions = lib.enum_plugins(openvip.PLUGIN_VIDEO_TRANSITION)
- self.audio_transitions = lib.enum_plugins(openvip.PLUGIN_AUDIO_TRANSITION)
- self.video_transitions_desc2name = dict([(p.description, p.name) for p in self.video_transitions])
- self.video_transitions_name2desc = dict([(p.name, p.description) for p in self.video_transitions])
- self.audio_transitions_desc2name = dict([(p.description, p.name) for p in self.audio_transitions])
- self.audio_transitions_name2desc = dict([(p.name, p.description) for p in self.audio_transitions])
- EVT_LISTBOX_DCLICK(self, ID_LISTBOX, self.OnChange)
- EVT_BUTTON(self, ID_PARAMS, self.OnParams)
- EVT_BUTTON(self, ID_UP, self.OnDirUp)
- EVT_BUTTON(self, ID_DOWN, self.OnDirDown)
- self.current_trans=''
-
- def __set_properties(self):
- # begin wxGlade: TransitionPanel.__set_properties
- self.direction_up.SetSize((32, 32))
- self.direction_up.SetToolTipString("Transition direction up")
- self.direction_down.SetSize((32, 32))
- self.direction_down.SetToolTipString("Transition direction down")
- self.settings.SetSize((32, 32))
- self.settings.SetToolTipString("Transition settings")
- self.listbox.SetSelection(0)
- # end wxGlade
-
- def __do_layout(self):
- # begin wxGlade: TransitionPanel.__do_layout
- sizer_2 = wxBoxSizer(wxHORIZONTAL)
- sizer_1 = wxBoxSizer(wxVERTICAL)
- sizer_3 = wxBoxSizer(wxHORIZONTAL)
- sizer_1.Add(self.transition_text, 0, wxALL|wxEXPAND, 5)
- sizer_3.Add(20, 20, 1, wxEXPAND, 0)
- sizer_3.Add(self.direction_up, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_HORIZONTAL, 5)
- sizer_3.Add(self.direction_down, 0, wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5)
- sizer_3.Add(self.settings, 0, wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5)
- sizer_3.Add(20, 20, 1, wxEXPAND, 0)
- sizer_1.Add(sizer_3, 0, wxEXPAND, 0)
- sizer_1.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 10)
- sizer_1.Add(self.listbox, 1, wxALL|wxEXPAND, 5)
- sizer_2.Add(sizer_1, 1, wxEXPAND, 0)
- self.SetAutoLayout(1)
- self.SetSizer(sizer_2)
- sizer_2.Fit(self)
- sizer_2.SetSizeHints(self)
- self.Layout()
- # end wxGlade
-
- def Update(self):
- self.transition_text.SetLabel(self.transitions_name2desc[self.object.name])
-
- def OnChange(self, event):
- f = self.listbox.GetSelection()
- if f>=0:
- self.object.name=self.transitions_desc2name[self.listbox.GetString(f)]
- self.object.params={}
- self.transition_text.SetLabel(self.listbox.GetString(f))
- self.OnParams(None)
-
- def OnParams(self, event):
- if self.object.track[0]=='V':
- dlg = VTransitionSettingsDialog(self, -1, "")
- else:
- dlg = ATransitionSettingsDialog(self, -1, "")
- dlg.SetObject(self.model, self.object)
- if dlg.LoadContent(self.object.name):
- dlg.SetParams(self.object.params)
- dlg.Centre()
- retval = dlg.ShowModal()
- dlg.WaitUntilNotUsed()
- if (retval == wxID_OK):
- self.object.params=dlg.GetParams()
- self.Update()
- notify.notify(self.model)
- else:
- dlg.Destroy()
-
- def OnDirUp(self, event):
- self.object.direction='BA'
- notify.notify(self.model)
-
- def OnDirDown(self, event):
- self.object.direction='AB'
- notify.notify(self.model)
-
- def SetObject(self, modl, obj):
- """Called when selection changes on TimelineWidget to let the panel
- redraw itself to display obj (a model.Transition instance)
- transition."""
- self.model = modl
- self.object = obj
- self.listbox.Clear()
- if obj.track[0]=='V': # video transition
- for p in self.video_transitions:
- self.listbox.Append(p.description)
- self.transitions_desc2name=self.video_transitions_desc2name
- self.transitions_name2desc=self.video_transitions_name2desc
- elif obj.track[0]=='A': # object on audio track - display all audio filters
- for p in self.audio_transitions:
- self.listbox.Append(p.description)
- self.transitions_desc2name=self.audio_transitions_desc2name
- self.transitions_name2desc=self.audio_transitions_name2desc
- self.Update()
-
- # end of class TransitionPanel
-
-
-