comparison pyink/domview_ui.py @ 1273:1d0474f2f6fa

Make public APIs being public for frameline_stack - Since the functions prefixed with a underline '_' is supposed a private, we should make all public function not prefixed with a underline. - Remove all prefixed underline from type name of public methods for frameline_stack.
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 12 Jan 2011 21:18:23 +0800
parents 32a73093a3de
children a4d3838264dd
comparison
equal deleted inserted replaced
1272:32a73093a3de 1273:1d0474f2f6fa
70 pass 70 pass
71 pass 71 pass
72 72
73 ## \brief Add a frameline into the frameline box for the given layer. 73 ## \brief Add a frameline into the frameline box for the given layer.
74 # 74 #
75 def _add_frameline(self, layer_idx): 75 def add_frameline(self, layer_idx):
76 if layer_idx > len(self._framelines): 76 if layer_idx > len(self._framelines):
77 raise ValueError, 'layer number should be a consequence' 77 raise ValueError, 'layer number should be a consequence'
78 vbox = self._frameline_vbox 78 vbox = self._frameline_vbox
79 79
80 line = frameline(self._num_frames_of_line) 80 line = frameline(self._num_frames_of_line)
102 line.connect(frameline.FRAME_BUT_PRESS, self._change_active_frame) 102 line.connect(frameline.FRAME_BUT_PRESS, self._change_active_frame)
103 pass 103 pass
104 104
105 ## \brief Remove the given frameline from the frameline box. 105 ## \brief Remove the given frameline from the frameline box.
106 # 106 #
107 def _remove_frameline(self, layer_idx): 107 def remove_frameline(self, layer_idx):
108 vbox = self._frameline_vbox 108 vbox = self._frameline_vbox
109 line = self._framelines[layer_idx] 109 line = self._framelines[layer_idx]
110 110
111 hbox = line.parent 111 hbox = line.parent
112 vbox.remove(hbox) 112 vbox.remove(hbox)
115 for idx in range(layer_idx, len(self._framelines)): 115 for idx in range(layer_idx, len(self._framelines)):
116 self._framelines[idx].layer_idx = idx 116 self._framelines[idx].layer_idx = idx
117 pass 117 pass
118 pass 118 pass
119 119
120 def _remove_all_framelines(self): 120 def remove_all_framelines(self):
121 num = len(self._framelines) 121 num = len(self._framelines)
122 122
123 for idx in range(0, num): 123 for idx in range(0, num):
124 line = self._framelines[idx] 124 line = self._framelines[idx]
125 hbox = line.parent 125 hbox = line.parent
130 self._last_mouse_over_frameline = None 130 self._last_mouse_over_frameline = None
131 self._last_active_frameline = None 131 self._last_active_frameline = None
132 self._active_frame_callback = None 132 self._active_frame_callback = None
133 pass 133 pass
134 134
135 def _init_framelines(self): 135 def init_framelines(self):
136 if self._framelines!= None: 136 if self._framelines!= None:
137 return 137 return
138 self._framelines = [] 138 self._framelines = []
139 139
140 box = gtk.ScrolledWindow() 140 box = gtk.ScrolledWindow()
141 self._frameline_box = box 141 self.frameline_box = box
142 box.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) 142 box.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
143 box.set_size_request(-1, 150) 143 box.set_size_request(-1, 150)
144 vbox = gtk.VBox() 144 vbox = gtk.VBox()
145 self._frameline_vbox = vbox 145 self._frameline_vbox = vbox
146 box.add_with_viewport(vbox) 146 box.add_with_viewport(vbox)
164 ## \brief Show framelines on the screen. 164 ## \brief Show framelines on the screen.
165 # 165 #
166 # When a frameline was inserted or removed, it would not be showed 166 # When a frameline was inserted or removed, it would not be showed
167 # immediately. This function is used to notify toolkit to update the 167 # immediately. This function is used to notify toolkit to update the
168 # screen and drawing framelines. 168 # screen and drawing framelines.
169 def _show_framelines(self): 169 def show_framelines(self):
170 self._frameline_vbox.show_all() 170 self._frameline_vbox.show_all()
171 pass 171 pass
172 172
173 ## \brief Make given frame as current active frame. 173 ## \brief Make given frame as current active frame.
174 # 174 #
406 def _add_frameline_for_every_layer(self): 406 def _add_frameline_for_every_layer(self):
407 for layer_idx in range(self._dom.get_layer_num()): 407 for layer_idx in range(self._dom.get_layer_num()):
408 layer_group_node = self._dom.get_layer_group(layer_idx) 408 layer_group_node = self._dom.get_layer_group(layer_idx)
409 label = layer_group_node.getAttribute('inkscape:label') 409 label = layer_group_node.getAttribute('inkscape:label')
410 410
411 self._fl_stack._add_frameline(layer_idx) 411 self._fl_stack.add_frameline(layer_idx)
412 self._fl_stack.set_layer_label(layer_idx, label) 412 self._fl_stack.set_layer_label(layer_idx, label)
413 413
414 self._update_frameline_content(layer_idx) 414 self._update_frameline_content(layer_idx)
415 pass 415 pass
416 pass 416 pass
417 417
418 ## \brief This method is called to handle a new document. 418 ## \brief This method is called to handle a new document.
419 # 419 #
420 def handle_doc_root(self, doc, root): 420 def handle_doc_root(self, doc, root):
421 self._dom.handle_doc_root(doc, root) 421 self._dom.handle_doc_root(doc, root)
422 self._fl_stack._init_framelines() 422 self._fl_stack.init_framelines()
423 self._add_frameline_for_every_layer() 423 self._add_frameline_for_every_layer()
424 self._fl_stack._show_framelines() 424 self._fl_stack.show_framelines()
425 425
426 self._doc = doc 426 self._doc = doc
427 self._root = root 427 self._root = root
428 pass 428 pass
429 429
430 ## \brief Reload the document. 430 ## \brief Reload the document.
431 # 431 #
432 def reset(self): 432 def reset(self):
433 self._fl_stack._remove_all_framelines() 433 self._fl_stack.remove_all_framelines()
434 self.handle_doc_root(self._doc, self._root) 434 self.handle_doc_root(self._doc, self._root)
435 pass 435 pass
436 436
437 ## \brief Mark given frame as a key frame. 437 ## \brief Mark given frame as a key frame.
438 # 438 #
521 # Original layer \ref layer_idx and later ones would be shifted to make a 521 # Original layer \ref layer_idx and later ones would be shifted to make a
522 # space for the new layer. 522 # space for the new layer.
523 # 523 #
524 def insert_layer(self, layer_idx): 524 def insert_layer(self, layer_idx):
525 self._dom.insert_layer(layer_idx) 525 self._dom.insert_layer(layer_idx)
526 self._fl_stack._add_frameline(layer_idx) 526 self._fl_stack.add_frameline(layer_idx)
527 self._fl_stack._show_framelines() 527 self._fl_stack.show_framelines()
528 pass 528 pass
529 529
530 ## \brief Remove given layer. 530 ## \brief Remove given layer.
531 # 531 #
532 def rm_layer(self, layer_idx): 532 def rm_layer(self, layer_idx):
533 self._dom.rm_layer(layer_idx) 533 self._dom.rm_layer(layer_idx)
534 self._fl_stack._remove_frameline(layer_idx) 534 self._fl_stack.remove_frameline(layer_idx)
535 self._fl_stack._show_framelines() 535 self._fl_stack.show_framelines()
536 pass 536 pass
537 537
538 def set_active_layer_frame(self, layer_idx, frame_idx): 538 def set_active_layer_frame(self, layer_idx, frame_idx):
539 self._fl_stack.active_frame(layer_idx, frame_idx) 539 self._fl_stack.active_frame(layer_idx, frame_idx)
540 pass 540 pass
604 pass 604 pass
605 605
606 ## \brief Return widget showing frames and layers. 606 ## \brief Return widget showing frames and layers.
607 # 607 #
608 def get_frame_ui_widget(self): 608 def get_frame_ui_widget(self):
609 return self._fl_stack._frameline_box 609 return self._fl_stack.frameline_box
610 610
611 ## \brief Register a callback for activating a frame event. 611 ## \brief Register a callback for activating a frame event.
612 # 612 #
613 # The callback function is called when a frame is activated. 613 # The callback function is called when a frame is activated.
614 # 614 #
741 741
742 layer_idx = self._dom.manage_layer_group(layer_group_id) 742 layer_idx = self._dom.manage_layer_group(layer_group_id)
743 if layer_idx == -1: 743 if layer_idx == -1:
744 return 744 return
745 745
746 self._fl_stack._add_frameline(layer_idx) 746 self._fl_stack.add_frameline(layer_idx)
747 self._fl_stack._show_framelines() 747 self._fl_stack.show_framelines()
748 try: 748 try:
749 label = layer_group.getAttribute('inkscape:label') 749 label = layer_group.getAttribute('inkscape:label')
750 except: 750 except:
751 label = layer_group.getAttribute('id') 751 label = layer_group.getAttribute('id')
752 pass 752 pass