comparison pyink/FSM_window.py @ 1505:7b8e67b2391b

Hint for user overing a state object
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 09 May 2011 15:20:29 +0800
parents d5b677831671
children f185a9d23a30
comparison
equal deleted inserted replaced
1504:d5b677831671 1505:7b8e67b2391b
881 881
882 self._rm_from_states_for_target(target_name) 882 self._rm_from_states_for_target(target_name)
883 pass 883 pass
884 884
885 def start_hint(self): 885 def start_hint(self):
886 circle_node = self._circle_node
887 circle_node.setAttribute('style', 'stroke: #000000; stroke-width: 3; '
888 'fill: #ffffff')
886 pass 889 pass
887 890
888 def stop_hint(self): 891 def stop_hint(self):
892 circle_node = self._circle_node
893 circle_node.setAttribute('style', 'stroke: #000000; stroke-width: 1; '
894 'fill: #ffffff')
889 pass 895 pass
890 pass 896 pass
891 897
892 898
893 class _select_manager(object): 899 class _select_manager(object):
1003 pass 1009 pass
1004 1010
1005 def _handle_select_transition_target(self, state, evtype, button, x, y): 1011 def _handle_select_transition_target(self, state, evtype, button, x, y):
1006 if self._candidate_target != state and self._menu_state != state: 1012 if self._candidate_target != state and self._menu_state != state:
1007 if self._candidate_target: 1013 if self._candidate_target:
1008 self._candidate_target.hide_selected() 1014 self._candidate_target.stop_hint()
1009 pass 1015 pass
1010 self._candidate_target = state 1016 self._candidate_target = state
1011 state.show_selected() 1017 state.start_hint()
1012 pass 1018 pass
1013 1019
1014 if evtype != pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE: 1020 if evtype != pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE:
1015 return 1021 return
1016 if button != 1: 1022 if button != 1:
1036 1042
1037 trn = src_state.transitions[cond] 1043 trn = src_state.transitions[cond]
1038 window._install_transition_event_handler(trn) 1044 window._install_transition_event_handler(trn)
1039 1045
1040 window.pop_grabs() 1046 window.pop_grabs()
1047
1048 target_state.stop_hint()
1049 select = self._select
1050 select.deselect()
1041 pass 1051 pass
1042 1052
1043 def _handle_add_transition(self, *args): 1053 def _handle_add_transition(self, *args):
1044 def restore_bg(item, evtype, *args): 1054 def restore_bg(item, evtype, *args):
1045 if evtype != pybInkscape.PYSPItem.PYB_EVENT_BUTTON_PRESS: 1055 if evtype != pybInkscape.PYSPItem.PYB_EVENT_BUTTON_PRESS:
1159 1169
1160 def moving_state(item, evtype, button, x, y): 1170 def moving_state(item, evtype, button, x, y):
1161 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE: 1171 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE:
1162 window.ungrab_mouse() 1172 window.ungrab_mouse()
1163 pass 1173 pass
1164 new_state_x = orign_state_x + start_x - x 1174 new_state_x = orign_state_x + x - start_x
1165 new_state_y = orign_state_y + start_y - y 1175 new_state_y = orign_state_y + y - start_y
1166 1176
1167 domview = self._domview 1177 domview = self._domview
1168 domview.set_state_xy(state.state_name, x, y) 1178 domview.set_state_xy(state.state_name, new_state_x, new_state_y)
1169 state.update() 1179 state.update()
1170 state.adjust_transitions() 1180 state.adjust_transitions()
1171 state.show_selected() 1181 state.show_selected()
1172 pass 1182 pass
1173 1183
1348 # 1358 #
1349 def _handle_transitoin_mouse_events(self, trn, evtype, button, x, y): 1359 def _handle_transitoin_mouse_events(self, trn, evtype, button, x, y):
1350 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE and \ 1360 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE and \
1351 button == 1: 1361 button == 1:
1352 self._select_transition(trn) 1362 self._select_transition(trn)
1353 elif evtype == pybInkscape.PYSPItem.PYB_EVENT_MOUSE_ENTER:
1354 self._hint_transition(trn)
1355 pass
1356 else: 1363 else:
1357 self._popup._handle_transition_mouse_events(trn, evtype, button, 1364 self._popup._handle_transition_mouse_events(trn, evtype, button,
1358 x, y) 1365 x, y)
1359 pass 1366 pass
1360 pass 1367 pass