comparison pyink/domview_ui.py @ 1262:2f861eea1214

Make domview_ui manages scenes and layers found by checker
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 12 Jan 2011 01:03:33 +0800
parents 6177f5d0ef01
children ca301f6abef7
comparison
equal deleted inserted replaced
1261:6177f5d0ef01 1262:2f861eea1214
663 self._lock = False 663 self._lock = False
664 return True 664 return True
665 pass 665 pass
666 666
667 667
668 ## \brief Expose some internal interface.
669 #
670 # This is a mix-in to provide API for internal using, for example,
671 # consistency_checker.
672 #
673 class domview_internal(object):
674 ## \brief Search a node by a ID.
675 #
676 def get_node(self, node_id):
677 node = self._dom.get_node(node_id)
678 return node
679
680 ## \brief Search scene node by scene group ID.
681 #
682 def get_scene_by_group(self, scene_group_id):
683 scene_node = self._dom.get_scene(scene_group_id)
684 return scene_node
685
686 ## \brief Manage a scene node that is unknown by domview_ui before.
687 #
688 def manage_scene_node(self, scene_node, scene_group):
689 layer_group = scene_group.parent()
690 layer_group_id = layer_group.getAttribute('id')
691 layer_idx = self.find_layer_from_group(layer_group_id)
692 self._dom.manage_scene_node(layer_idx, scene_node)
693
694 start, end, tween_name = \
695 self._dom._parse_one_scene(scene_node)
696 tween_type = self._tween_type_names.index(tween_name)
697
698 tween_len = end - start + 1
699 self._fl_stack.mark_keyframe(layer_idx, start)
700 self._fl_stack.set_keyframe_data(layer_idx, start, scene_node)
701 self._fl_stack.tween(layer_idx, start, tween_len, tween_type)
702 pass
703
704 ## \brief Manage a layer group that is unknown by domview_ui before.
705 #
706 def manage_layer_group(self, layer_group):
707 try:
708 layer_group_id = layer_group.getAttribute('id')
709 except:
710 return
711
712 layer_idx = self._dom.manage_layer_group(layer_group_id)
713 if layer_idx == -1:
714 return
715
716 self._fl_stack._add_frameline(layer_idx)
717 self._fl_stack._show_framelines()
718 try:
719 label = layer_group.getAttribute('inkscape:label')
720 except:
721 label = layer_group.getAttribute('id')
722 pass
723 self._fl_stack.set_layer_label(layer_idx, label)
724 pass
725 pass
726
727
668 ## \brief A mix-in to enable workers for a domview_ui. 728 ## \brief A mix-in to enable workers for a domview_ui.
669 # 729 #
670 class domview_ui_with_workers(domview_ui): 730 class domview_ui_with_workers(domview_ui, domview_internal):
671 def __init__(self): 731 def __init__(self):
672 super(domview_ui_with_workers, self).__init__() 732 super(domview_ui_with_workers, self).__init__()
673 733
674 self._consistency_checker = consistency.consistency_checker(self) 734 self._consistency_checker = consistency.consistency_checker(self)
675 pass 735 pass