comparison pyink/FSM_window.py @ 1494:ac390af12152

Add comment and rename methods
author Thinker K.F. Li <thinker@codemud.net>
date Tue, 03 May 2011 01:21:20 +0800
parents b0e113605382
children 75cfacaa106e
comparison
equal deleted inserted replaced
1493:b0e113605382 1494:ac390af12152
780 def on_move_state_background(self, item, evtype, button, x, y): 780 def on_move_state_background(self, item, evtype, button, x, y):
781 if self._selected_cleaner is None: 781 if self._selected_cleaner is None:
782 return 782 return
783 783
784 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE: 784 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE:
785 self._clean_select() 785 self._deselect_state()
786 pass 786 pass
787 pass 787 pass
788 788
789 def _select_state(self, state): 789 def _select_state(self, state):
790 self._clean_select() 790 self._deselect_state()
791 self._selected_cleaner = state.hide_selected 791 self._selected_cleaner = state.hide_selected
792 state.show_selected() 792 state.show_selected()
793 pass 793 pass
794 794
795 def _clean_select(self): 795 def _deselect_state(self):
796 if self._selected_cleaner: 796 if self._selected_cleaner:
797 self._selected_cleaner() 797 self._selected_cleaner()
798 pass 798 pass
799 self._selected_cleaner = None 799 self._selected_cleaner = None
800 pass 800 pass
832 button == 1: 832 button == 1:
833 window.ungrab_mouse() 833 window.ungrab_mouse()
834 pass 834 pass
835 pass 835 pass
836 836
837 def _install_transition_mouse_event_handler(self, trn): 837 ## \brief Install event handler for control points of a transitions.
838 #
839 def _install_trn_cps_mouse(self, trn):
838 c1, l01, c2, l32 = trn._control_points 840 c1, l01, c2, l32 = trn._control_points
839 path = trn.path 841 path = trn.path
840 c0x, c0y, c1x, c1y, c2x, c2y, c3x, c3y = tuple(path) 842 c0x, c0y, c1x, c1y, c2x, c2y, c3x, c3y = tuple(path)
841 843
842 state_src = trn.state 844 state_src = trn.state
929 c2_dragger.start_drag = c2_start 931 c2_dragger.start_drag = c2_start
930 c2_dragger.stop_drag = c2_stop 932 c2_dragger.stop_drag = c2_stop
931 c2_dragger.connect(c2) 933 c2_dragger.connect(c2)
932 pass 934 pass
933 935
936 ## \brief A transition was selected.
937 #
934 def _select_transition(self, trn): 938 def _select_transition(self, trn):
935 def cleaner(): 939 def deselect():
936 trn.hide_control_points() 940 trn.hide_control_points()
937 del self._hint_transition # enable _hint_transition 941 del self._hint_transition # enable _hint_transition
938 pass 942 pass
939 943
940 self._hint_transition = lambda *args: None # disable _hint_transition 944 self._hint_transition = lambda *args: None # disable _hint_transition
941 945
942 self._clean_select() 946 self._deselect_state()
943 self._selected_cleaner = cleaner 947 self._selected_cleaner = deselect
944 trn.show_control_points() 948 trn.show_control_points()
945 949
946 trn.stop_hint() 950 trn.stop_hint()
947 window = self._window 951 window = self._window
948 window.ungrab_bg() 952 window.ungrab_bg()
949 953
950 self._install_transition_mouse_event_handler(trn) 954 self._install_trn_cps_mouse(trn)
951 pass 955 pass
952 956
957 ## \brief Hint for mouse over a transition.
958 #
953 def _hint_transition(self, trn): 959 def _hint_transition(self, trn):
954 def stop_hint(*args): 960 def stop_hint(*args):
955 trn.stop_hint() 961 trn.stop_hint()
956 window.ungrab_bg() 962 window.ungrab_bg()
957 window.grab_bg(self.on_move_state_background) 963 window.grab_bg(self.on_move_state_background)
983 window.grab_state(self._handle_move_state_state) 989 window.grab_state(self._handle_move_state_state)
984 window.grab_transition(self._handle_transitoin_mouse_events) 990 window.grab_transition(self._handle_transitoin_mouse_events)
985 pass 991 pass
986 992
987 def deactivate(self): 993 def deactivate(self):
988 self._clean_select() 994 self._deselect_state()
989 pass 995 pass
990 pass 996 pass
991 997
992 998
993 class _FSM_add_state_mode(object): 999 class _FSM_add_state_mode(object):