Mercurial > nagslang
comparison tools/area_editor.py @ 414:060420389033
more zooming
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 07 Sep 2013 12:49:27 +0200 |
parents | c5a3ed165df9 |
children | 3f15e071614f |
comparison
equal
deleted
inserted
replaced
413:c5a3ed165df9 | 414:060420389033 |
---|---|
596 -self.mouse_pos[1] + old_pos[1]) | 596 -self.mouse_pos[1] + old_pos[1]) |
597 self._move_view(diff) | 597 self._move_view(diff) |
598 self.invalidate() | 598 self.invalidate() |
599 | 599 |
600 def mouse_down(self, ev): | 600 def mouse_down(self, ev): |
601 corrected_pos = ev.pos[0] + self.pos[0], ev.pos[1] + self.pos[1] | 601 corrected_pos = self._level_coordinates(ev.pos) |
602 if self.sel_mode and ev.button == 1: | 602 if self.sel_mode and ev.button == 1: |
603 obj = self.level.find_obj_at_pos(corrected_pos) | 603 obj = self.level.find_obj_at_pos(corrected_pos) |
604 if obj is not None: | 604 if obj is not None: |
605 self._edit_selected(obj) | 605 self._edit_selected(obj) |
606 elif self._move_point_mode and ev.button == 1: | 606 elif self._move_point_mode and ev.button == 1: |
613 # find the current point | 613 # find the current point |
614 self._move_point = self.level.find_vertex(corrected_pos) | 614 self._move_point = self.level.find_vertex(corrected_pos) |
615 elif ev.button == 1: | 615 elif ev.button == 1: |
616 if self._draw_lines: | 616 if self._draw_lines: |
617 if self._start_pos is None: | 617 if self._start_pos is None: |
618 self._start_pos = ev.pos | 618 self._start_pos = corrected_pos |
619 else: | 619 else: |
620 self.level.add_line(self._start_pos, ev.pos) | 620 self.level.add_line(self._start_pos, corrected_pos) |
621 self._start_pos = None | 621 self._start_pos = None |
622 else: | 622 else: |
623 print "Click: %r" % ( | 623 print "Click: %r" % ( |
624 self.level.point_to_pymunk( | 624 self.level.point_to_pymunk(corrected_pos),) |
625 self._level_coordinates(ev.pos)),) | |
626 if ev.button == 4: # Scroll up | 625 if ev.button == 4: # Scroll up |
627 self._move_view((0, -10)) | 626 self._move_view((0, -10)) |
628 elif ev.button == 5: # Scroll down | 627 elif ev.button == 5: # Scroll down |
629 self._move_view((0, 10)) | 628 self._move_view((0, 10)) |
630 elif ev.button == 6: # Scroll left | 629 elif ev.button == 6: # Scroll left |
631 self._move_view((-10, 0)) | 630 self._move_view((-10, 0)) |
632 elif ev.button == 7: # Scroll right | 631 elif ev.button == 7: # Scroll right |
633 self._move_view((10, 0)) | 632 self._move_view((10, 0)) |
634 elif self.cur_poly and ev.button == 1: | 633 elif self.cur_poly and ev.button == 1: |
635 # Add a point | 634 # Add a point |
636 self.level.add_point(self.cur_poly, | 635 self.level.add_point(self.cur_poly, corrected_pos) |
637 self._level_coordinates(ev.pos)) | |
638 elif ev.button == 3: | 636 elif ev.button == 3: |
639 self._mouse_drag = True | 637 self._mouse_drag = True |
640 | 638 |
641 def mouse_up(self, ev): | 639 def mouse_up(self, ev): |
642 if ev.button == 3: | 640 if ev.button == 3: |
1018 save_but.rect = BUTTON_RECT.copy() | 1016 save_but.rect = BUTTON_RECT.copy() |
1019 save_but.rect.move_ip(MENU_LEFT, y) | 1017 save_but.rect.move_ip(MENU_LEFT, y) |
1020 widgets.append(save_but) | 1018 widgets.append(save_but) |
1021 y += MENU_BUTTON_HEIGHT + MENU_PAD | 1019 y += MENU_BUTTON_HEIGHT + MENU_PAD |
1022 | 1020 |
1021 zoom_out = Button('Zoom out', action=self.level_widget.zoom_out) | |
1022 zoom_out.rect = BUTTON_RECT.copy() | |
1023 zoom_out.rect.move_ip(MENU_LEFT, y) | |
1024 widgets.append(zoom_out) | |
1025 y += MENU_BUTTON_HEIGHT + MENU_PAD | |
1026 | |
1027 zoom_in = Button('Zoom in', action=self.level_widget.zoom_in) | |
1028 zoom_in.rect = BUTTON_RECT.copy() | |
1029 zoom_in.rect.move_ip(MENU_LEFT, y) | |
1030 widgets.append(zoom_in) | |
1031 | |
1023 y = SCREEN[1] - MENU_BUTTON_HEIGHT - MENU_PAD | 1032 y = SCREEN[1] - MENU_BUTTON_HEIGHT - MENU_PAD |
1024 quit_but = Button('Quit', action=self.quit) | 1033 quit_but = Button('Quit', action=self.quit) |
1025 quit_but.rect = BUTTON_RECT.copy() | 1034 quit_but.rect = BUTTON_RECT.copy() |
1026 quit_but.rect.move_ip(MENU_LEFT, y) | 1035 quit_but.rect.move_ip(MENU_LEFT, y) |
1027 widgets.append(quit_but) | 1036 widgets.append(quit_but) |