def mouse_left_up(self, event): if not self._tilemap: return if not self._select_end: return x1, y1 = self._select_start x2, y2 = self._select_end if x2 < x1: x2, x1 = x1, x2 if y2 < y1: y2, y1 = y1, y2 width = x2 - x1 + 1 height = y2 - y1 + 1 self._select_start = None self._select_end = None self.Viewport.Refresh(False) if width and height: selection = Tilemap.from_tilemap(self._tilemap, x1, y1, x2 + 1, y2 + 1) else: selection = None event = TileSelector.SelectEvent(selection=selection) wx.PostEvent(self.GetEventHandler(), event)
def mouse_left_up(self): if self._state == State.SELECT: x, y, width, height = self.get_selection_rectangle(self._select_start, self._select_end) if width and height: if self._select_type == SelectType.SELECT: self._selection = Tilemap.from_tilemap(self._level.tilemap, x, y, x + width, y + height) elif self._select_type == SelectType.FILL: self._frame.undo_add() self._level.tilemap.fill_with(self._selection, x, y, x + width, y + height) self._frame.set_level_modified(True) self._state = State.NONE self._frame.set_viewport_cursor(wx.CURSOR_DEFAULT) elif self._state == State.DRAW: self._state = State.NONE