Skip to content
Browse files

first launch of a frame timeline and validate to pychecker

  • Loading branch information...
1 parent c73a685 commit 5d5a730a08333841070677466049972891c417f1 Ferry Jérémie committed Dec 7, 2011
Showing with 59 additions and 17 deletions.
  1. +27 −11 utils/c_editor/__init__.py
  2. +32 −6 utils/c_editor/remote.py
View
38 utils/c_editor/__init__.py
@@ -31,8 +31,8 @@ def __init__(self):
window = gtk.Window()
window.set_title(_('Character Editor'))
window.set_size_request(800, 600)
- vbox = gtk.VBox()
- window.add(vbox)
+ self.vbox = gtk.VBox()
+ window.add(self.vbox)
# UIManager
ui = gtk.UIManager()
@@ -79,9 +79,6 @@ def __init__(self):
)
self.image.show()
- character_s.connect('changed', self.__character_s)
- self.movements.connect('changed', self.__movements)
-
self.remote = RC(self.image, self.project_path, self.cp)
# actions
self.actions_g.add_actions([
@@ -115,7 +112,7 @@ def __init__(self):
ui.add_ui_from_string(self.ui)
menu_bar = ui.get_widget('/Menu_Bar')
- vbox.pack_start(menu_bar, False)
+ self.vbox.pack_start(menu_bar, False)
toolbar = ui.get_widget('/ToolBar')
tool_item = gtk.ToolItem()
@@ -125,13 +122,19 @@ def __init__(self):
tool_item.add(self.movements)
toolbar.insert(tool_item, 5)
- vbox.pack_start(toolbar, False)
+ self.vbox.pack_start(toolbar, False)
+
+ self.vbox.pack_start(self.image, expand=True)
- vbox.pack_start(self.image, expand=True)
+ self.timeline = self.remote.timeline
+ self.vbox.pack_start(self.timeline, False)
remoteC = ui.get_widget('/RemoteControl')
- vbox.pack_end(remoteC, False)
+ self.vbox.pack_end(remoteC, False)
+ character_s.connect('changed', self.__character_s)
+ self.movements.connect('changed', self.__movements)
+ self.window = window
window.show_all()
window.connect('destroy', self.quit)
#self.connect('event-after', gtk.main_quit)
@@ -163,6 +166,7 @@ def reload_file(self, action):
pass
def __character_s(self, action):
+ #print '---->', action
new_c = action.get_model()[action.get_property('active')][0]
self.project_path = CHARACTER_PATH + new_c + '/'
new_xml = self.project_path + new_c + '.xml'
@@ -178,21 +182,33 @@ def __character_s(self, action):
self.image.set_from_file(
self.cp.get_picture(self.movements.get_active())
)
- print 'delete?', self.project_path
- print self.remote
+
self.remote.img = self.image
self.remote.project_path = self.project_path
self.remote.frames = self.cp.get_frames()
self.remote.stop(self.actions_g.get_action("Play"))
+ self.remote.cp = self.cp
+
+ self.__timeline()
def __movements(self, action):
+ #print 'mov...'
self.image.set_from_file(
self.cp.get_picture(action.get_active())
)
self.remote.img = self.image
self.remote.project_path = self.project_path
self.remote.frames = self.cp.get_frames()
self.remote.stop(self.actions_g.get_action("Play"))
+ self.remote.cp = self.cp
+ self.__timeline()
+
+ def __timeline(self):
+ self.vbox.remove(self.timeline)
+ self.timeline = self.remote.timeline
+ self.vbox.pack_start(self.timeline, False)
+ self.timeline.show_all()
+ self.vbox.show_all()
def main():
View
38 utils/c_editor/remote.py
@@ -10,6 +10,7 @@
class Frame(threading.Thread):
+ '''Process thread to return the proper frame of the character'''
#Thread event, stops the thread if it is set.
stopthread = threading.Event()
frames = None
@@ -42,7 +43,22 @@ def restart(self):
self.start()
+class TimeLine(gtk.ScrolledWindow):
+ def __init__(self, cp):
+ gtk.ScrolledWindow.__init__(self)
+ self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
+ hbox = gtk.HBox()
+ for frame in cp.get_frames():
+ button = gtk.Button()
+ button.set_label(frame[1])
+ #print frame[0] * 1000
+ button.set_size_request(int(frame[0] * 1000), 100)
+ hbox.pack_start(button, False)
+ self.add_with_viewport(hbox)
+
+
class RemoteControl():
+ '''Class that orchestrates all animate frame interaction'''
def __init__(self, img, project_path, cp):
self.img = img
self.project_path = project_path
@@ -55,19 +71,26 @@ def __init__(self, img, project_path, cp):
self.frame.frames = itertools.cycle(self.frames)
self.frame.frames.next()
+ self.timeline = TimeLine(self.cp)
+
def __del__(self):
if self.frame.isAlive():
self.frame.stop()
+ def _pause(self):
+ self.frame = Frame()
+ self.frame.img = self.img
+ self.frame.path = self.project_path
+ self.frame.frames = itertools.cycle(self.frames)
+
def stop(self, action):
if self.frame.isAlive():
self.frame.stop()
action.set_stock_id(gtk.STOCK_MEDIA_PLAY)
action.set_tooltip(_('Play animation'))
- self.frame = Frame()
- self.frame.img = self.img
- self.frame.path = self.project_path
- self.frame.frames = itertools.cycle(self.frames)
+ self._pause()
+ #print 'timeline'
+ self.timeline = TimeLine(self.cp)
def begin(self, action):
frames = itertools.cycle(self.frames)
@@ -87,9 +110,12 @@ def previous(self, action):
def play(self, action):
action.set_stock_id(gtk.STOCK_MEDIA_STOP)
action.set_tooltip(_('Stop animation'))
- iter_frames = self.frame.frames
if self.frame.isAlive():
- self.stop(action)
+ iter_frames = self.frame.frames
+ self.frame.stop()
+ action.set_stock_id(gtk.STOCK_MEDIA_PLAY)
+ action.set_tooltip(_('Play animation'))
+ self._pause()
self.frame.frames = iter_frames
return
self.frame.frames = itertools.cycle(self.frames)

0 comments on commit 5d5a730

Please sign in to comment.
Something went wrong with that request. Please try again.