Mercurial > MadButterfly
comparison pyink/MBScene.py @ 1214:e55499f7505a
Fix the issues with multiple framelines
- For multiple framelines, user move mouse from one frameline to
another, the frame is not showed correctly.
- Old implementation always draw normal frame on the frameline
where mouse just leaving.
- It is fixed by detecting leave-notify event and removing hover
mark.
- When user active a frame on a frameline that is not what old active
frame is at, the old active frame is not deactivated.
- It is fixed by calling frameline.deactive() of a frameline when a
frame is activated on another frameline.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 05 Jan 2011 17:56:14 +0800 |
parents | 86428aa657ab |
children | 61f1b3d424cf |
comparison
equal
deleted
inserted
replaced
1213:86428aa657ab | 1214:e55499f7505a |
---|---|
446 ## \brief Change attributes of a scene node. | 446 ## \brief Change attributes of a scene node. |
447 # | 447 # |
448 # This is here to monitor changes of scene node. | 448 # This is here to monitor changes of scene node. |
449 def chg_scene_node(self, scene_node, start=None, end=None, | 449 def chg_scene_node(self, scene_node, start=None, end=None, |
450 tween_type=None, ref=None): | 450 tween_type=None, ref=None): |
451 if start: | 451 if start is not None: |
452 scene_node.setAttribute('start', str(start)) | 452 scene_node.setAttribute('start', str(start)) |
453 pass | 453 pass |
454 if end: | 454 if end is not None: |
455 scene_node.setAttribute('end', str(end)) | 455 scene_node.setAttribute('end', str(end)) |
456 pass | 456 pass |
457 if tween_type: | 457 if tween_type is not None: |
458 scene_node.setAttribute('type', tween_type) | 458 scene_node.setAttribute('type', tween_type) |
459 pass | 459 pass |
460 if ref: | 460 if ref is not None: |
461 scene_node.setAttribute('ref', ref) | 461 scene_node.setAttribute('ref', ref) |
462 pass | 462 pass |
463 pass | 463 pass |
464 | 464 |
465 def rm_scene_node(self, scene_node): | 465 def rm_scene_node(self, scene_node): |
535 | 535 |
536 _framelines = None | 536 _framelines = None |
537 | 537 |
538 def __init__(self, *args, **kws): | 538 def __init__(self, *args, **kws): |
539 super(MBScene_framelines, self).__init__(*args, **kws) | 539 super(MBScene_framelines, self).__init__(*args, **kws) |
540 pass | 540 |
541 | 541 self._last_mouse_over_frameline = None |
542 def _remove_active_frame(self,widget,event): | 542 self._last_active_frameline = None |
543 pass | |
544 | |
545 def _change_hover_frameline(self, widget, event): | |
543 """ | 546 """ |
544 Hide all hover frames. This is a hack. We should use the lost focus | 547 Hide all hover frames. This is a hack. We should use the lost focus |
545 event instead in the future to reduce the overhead. | 548 event instead in the future to reduce the overhead. |
546 """ | 549 """ |
547 for f in self._framelines: | 550 if self._last_mouse_over_frameline and \ |
548 if f != widget: | 551 widget != self._last_mouse_over_frameline: |
549 f.hide_hover() | 552 self._last_mouse_over_frameline.mouse_leave() |
550 pass | 553 pass |
551 pass | 554 self._last_mouse_over_frameline = widget |
555 pass | |
556 | |
557 ## \brief Called for changing of active frame. | |
558 # | |
559 # This handle deactive previous frameline that owns an active frame when a | |
560 # frame in another frameline is activated. | |
561 def _change_active_frame(self, widget, frame, button): | |
562 if self._last_active_frameline and \ | |
563 self._last_active_frameline != widget: | |
564 self._last_active_frameline.deactive() | |
565 pass | |
566 self._last_active_frameline = widget | |
552 pass | 567 pass |
553 | 568 |
554 ## \brief Add a frameline into the frameline box for the given layer. | 569 ## \brief Add a frameline into the frameline box for the given layer. |
555 # | 570 # |
556 def _add_frameline(self, layer_idx): | 571 def _add_frameline(self, layer_idx): |
576 self._framelines[layer_idx: layer_idx] = [line] | 591 self._framelines[layer_idx: layer_idx] = [line] |
577 | 592 |
578 line.label = label | 593 line.label = label |
579 line.layer_idx = layer_idx | 594 line.layer_idx = layer_idx |
580 line.connect(line.FRAME_BUT_PRESS, self.onCellClick) | 595 line.connect(line.FRAME_BUT_PRESS, self.onCellClick) |
581 line.connect('motion-notify-event', self._remove_active_frame) | 596 line.connect('motion-notify-event', self._change_hover_frameline) |
597 line.connect(frameline.FRAME_BUT_PRESS, self._change_active_frame) | |
582 pass | 598 pass |
583 | 599 |
584 ## \brief Remove the given frameline from the frameline box. | 600 ## \brief Remove the given frameline from the frameline box. |
585 # | 601 # |
586 def _remove_frameline(self, layer_idx): | 602 def _remove_frameline(self, layer_idx): |