objmap_object.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Flexlay - A Generic 2D Game Editor
  2. # Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com>
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. from typing import Any, Optional
  17. from flexlay.util.signal import Signal
  18. from flexlay.math import Pointf, Rectf
  19. from flexlay.graphic_context import GraphicContext
  20. class ObjMapObject:
  21. def __init__(self, pos: Pointf, metadata: Any) -> None:
  22. self.to_draw: bool = True
  23. self.pos: Pointf = pos
  24. self.metadata: Any = metadata
  25. self.sig_select = Signal()
  26. self.sig_deselect = Signal()
  27. self.sig_move = Signal()
  28. def draw(self, gc: GraphicContext) -> None:
  29. pass
  30. def is_inside(self, click_pos: Pointf) -> bool:
  31. rect = self.get_bound_rect()
  32. if rect is None:
  33. return False
  34. return rect.is_inside(click_pos)
  35. def get_bound_rect(self) -> Optional[Rectf]:
  36. return None
  37. def get_pos(self) -> Pointf:
  38. return self.pos
  39. def set_pos(self, pos: Pointf) -> None:
  40. self.pos = pos
  41. def add_control_points(self) -> None:
  42. pass
  43. def update_control_points(self) -> None:
  44. pass
  45. # EOF #