Mercurial > MadButterfly
comparison pyink/FSM_window.py @ 1516:7d6d77992aba
Fix the bug of deactivating moving state mode.
- It fault to deactivate moving state mode when user is selecting a
transition.
- Since _on_deactivate stack was not handled correctly.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 11 May 2011 01:13:19 +0800 |
parents | e963793c9793 |
children | 80e055978461 |
comparison
equal
deleted
inserted
replaced
1515:e963793c9793 | 1516:7d6d77992aba |
---|---|
1409 _window = None | 1409 _window = None |
1410 _compview = None | 1410 _compview = None |
1411 | 1411 |
1412 _select = None | 1412 _select = None |
1413 | 1413 |
1414 _on_deactivate = None | 1414 _controlling_transition = None |
1415 | 1415 |
1416 def __init__(self, window, compview, select_man): | 1416 def __init__(self, window, compview, select_man): |
1417 super(_FSM_move_state_mode, self).__init__() | 1417 super(_FSM_move_state_mode, self).__init__() |
1418 | 1418 |
1419 self._window = window | 1419 self._window = window |
1420 self._compview = compview | 1420 self._compview = compview |
1421 self._locker = compview | 1421 self._locker = compview |
1422 | 1422 |
1423 self._popup = _FSM_popup(window, compview, select_man) | 1423 self._popup = _FSM_popup(window, compview, select_man) |
1424 self._select = select_man | 1424 self._select = select_man |
1425 | |
1426 self._on_deactivate = [] | |
1427 pass | 1425 pass |
1428 | 1426 |
1429 def _handle_move_state_background(self, item, evtype, button, x, y): | 1427 def _handle_move_state_background(self, item, evtype, button, x, y): |
1430 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE: | 1428 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE: |
1431 self._select.deselect() | 1429 self._select.deselect() |
1567 c2_dragger.connect(c2) | 1565 c2_dragger.connect(c2) |
1568 pass | 1566 pass |
1569 | 1567 |
1570 ## \brief A transition was selected. | 1568 ## \brief A transition was selected. |
1571 # | 1569 # |
1572 def _select_transition(self, trn): | 1570 def _control_transition(self, trn): |
1573 def handle_bg(item, evtype, button, x, y): | 1571 def handle_bg(item, evtype, button, x, y): |
1574 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_PRESS: | 1572 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_PRESS: |
1575 window.pop_grabs() | 1573 window.pop_grabs() |
1576 window.ungrab_bg() | 1574 window.ungrab_bg() |
1577 | 1575 |
1578 self._on_deactivate.pop() | |
1579 self._on_deactivate.pop() | |
1580 | |
1581 select.deselect() | 1576 select.deselect() |
1582 del self._hint_transition | 1577 del self._hint_transition |
1578 | |
1579 self._controlling_transition = None | |
1583 pass | 1580 pass |
1584 pass | 1581 pass |
1585 | 1582 |
1586 select = self._select | 1583 select = self._select |
1587 select.control_transition(trn) | 1584 select.control_transition(trn) |
1592 window.push_grabs() | 1589 window.push_grabs() |
1593 window.ungrab_bg() | 1590 window.ungrab_bg() |
1594 window.grab_bg(handle_bg) | 1591 window.grab_bg(handle_bg) |
1595 | 1592 |
1596 self._install_trn_cps_mouse(trn) | 1593 self._install_trn_cps_mouse(trn) |
1597 self._on_deactivate.append(window.pop_grabs) | |
1598 def del_hint_transition(): | |
1599 del self._hint_transition | |
1600 pass | |
1601 self._on_deactivate.append(del_hint_transition) | |
1602 pass | 1594 pass |
1603 | 1595 |
1604 ## \brief Hint for mouse over a transition. | 1596 ## \brief Hint for mouse over a transition. |
1605 # | 1597 # |
1606 def _hint_transition(self, trn): | 1598 def _hint_transition(self, trn): |
1623 ## \brief Handle mouse events when selecting no transition. | 1615 ## \brief Handle mouse events when selecting no transition. |
1624 # | 1616 # |
1625 def _handle_transitoin_mouse_events(self, trn, evtype, button, x, y): | 1617 def _handle_transitoin_mouse_events(self, trn, evtype, button, x, y): |
1626 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE and \ | 1618 if evtype == pybInkscape.PYSPItem.PYB_EVENT_BUTTON_RELEASE and \ |
1627 button == 1: | 1619 button == 1: |
1628 self._select_transition(trn) | 1620 self._control_transition(trn) |
1629 else: | 1621 else: |
1630 self._popup._handle_transition_mouse_events(trn, evtype, button, | 1622 self._popup._handle_transition_mouse_events(trn, evtype, button, |
1631 x, y) | 1623 x, y) |
1632 pass | 1624 pass |
1633 pass | 1625 pass |
1646 self._popup.popup_install_handler() | 1638 self._popup.popup_install_handler() |
1647 pass | 1639 pass |
1648 | 1640 |
1649 def deactivate(self): | 1641 def deactivate(self): |
1650 self._select.deselect() | 1642 self._select.deselect() |
1651 while self._on_deactivate: | 1643 if self._controlling_transition: |
1652 deactivate = self._on_deactivate.pop() | 1644 window = self._window |
1653 deactivate() | 1645 window.pop_grabs() |
1646 del self._hint_transition | |
1647 | |
1648 self._controlling_transition = None | |
1654 pass | 1649 pass |
1655 pass | 1650 pass |
1656 pass | 1651 pass |
1657 | 1652 |
1658 | 1653 |