# Path: src/view/display_sprite_object.py
# class DisplaySpriteObject(QGraphicsItem):
#     def __init__(self):
# 
#         super(DisplaySpriteObject, self).__init__()
# 
#         self._sprite = None
# 
#         self._displayFrameIndex = -1
# 
#         self.prepareGeometryChange()
# 
#         self._boundingRect = QRectF()
# 
#         self._backgroundPixmap = None
# 
#         self._enableOnionSkin = True
# 
#     @property
#     def sprite(self):
#         return self._sprite
# 
#     @property
#     def active_surface(self):
#         return self._sprite.active_surface
# 
#     @property
#     def active_surface_pixel_data(self):
#         return self._sprite.active_surface_pixel_data
# 
#     @property
#     def display_frame_index(self):
#         return self._displayFrameIndex
# 
#     @display_frame_index.setter
#     def display_frame_index(self, value):
#         self._displayFrameIndex = value
# 
#     @property
#     def background_pixmap(self):
#         return self._backgroundPixmap
# 
#     @property
#     def is_empty(self):
#         return self._sprite is None
# 
#     @background_pixmap.setter
#     def background_pixmap(self, value):
#         self._backgroundPixmap = value
# 
#     def boundingRect(self):
#         return self._boundingRect
# 
#     @property
#     def bounding_rect_i(self):
#         return QRect(self._boundingRect.left(),
#                      self._boundingRect.top(),
#                      self._boundingRect.width(),
#                      self._boundingRect.height())
# 
#     @property
#     def area_rect(self):
#         return QRect(0, 0, self._boundingRect.width(), self._boundingRect.height())
# 
#     @property
#     def width(self):
#         return self.boundingRect().width()
# 
#     @property
#     def height(self):
#         return self.boundingRect().height()
# 
#     @property
#     def enable_onion_skin(self):
#         return self._enableOnionSkin
# 
#     @enable_onion_skin.setter
#     def enable_onion_skin(self, value):
#         self._enableOnionSkin = value
# 
#     def set_sprite(self, sprite):
# 
#         self._sprite = sprite
# 
#         self.update_bounding_rect()
# 
#     def update_bounding_rect(self):
# 
#         if self._boundingRect.size != self._sprite.size:
#             self.prepareGeometryChange()
#             self._boundingRect = QRectF(-self._sprite.width / 2, -self._sprite.height / 2,
#                                         self._sprite.width, self._sprite.height)
# 
#     def unload_sprite(self):
# 
#         self._sprite = None
#         self._displayFrameIndex = -1
#         self.prepareGeometryChange()
#         self._boundingRect = QRectF()
# 
#     def paint(self, painter, option, widget=None):
# 
#         painter.setClipRect(option.exposedRect)
# 
#         if self._backgroundPixmap is not None:
#             painter.drawTiledPixmap(option.rect, self._backgroundPixmap)
# 
#         if self._sprite is not None:
# 
#             frame_index = self._displayFrameIndex \
#                 if self._displayFrameIndex != -1 \
#                 else self._sprite.current_animation.current_frame_index
# 
#             if self._enableOnionSkin:
# 
#                 last_frame_index = frame_index - 1
# 
#                 if last_frame_index >= 0:
# 
#                     last_frame_layers = self._sprite.current_animation. \
#                         frame_at(last_frame_index).surfaces
# 
#                     painter.setOpacity(0.2)
# 
#                     for layer in last_frame_layers:
#                         painter.drawImage(option.rect, layer.image)
# 
#                     painter.setOpacity(1.0)
# 
#             layers = self._sprite.current_animation.frame_at(frame_index).surfaces
# 
#             for layer in layers:
#                 painter.drawImage(option.rect, layer.image)
# 
# Path: src/model/resources_cache.py
# class ResourcesCache(object):
#     _resources = {}
# 
#     @staticmethod
#     def get(name):
#         return ResourcesCache._resources[name]
# 
#     @staticmethod
#     def register_resource(name, resource):
#         ResourcesCache._resources[name] = resource
# 
#     @staticmethod
#     def dispose():
#         ResourcesCache._resources.clear()


from PyQt5.QtCore import Qt, QPoint, QRectF
from PyQt5.QtGui import QPainter, QTransform
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene
from src.view.display_sprite_object import DisplaySpriteObject
from src.model.resources_cache import ResourcesCache
import src.helpers.utils as utils
# Purpose:     Represents the base transformable display that is inherited by the Canvas
# and the AnimationDisplay
#
# Author:      Rafael Vasco
#
# Created:     31/03/2013
# Copyright:   (c) Rafael Vasco 2014
# Licence:     <your licence>
#------------------------------------------------------------------------------




class Display(QGraphicsView):
    def __init__(self):

        super(Display, self).__init__()

        self.setScene(QGraphicsScene())

        self._spriteObject = DisplaySpriteObject()

        self.scene().addItem(self._spriteObject)

        self._backgroundColor = None

        self._backLightOn = True

        self._lightBackgroundPixmap = ResourcesCache.get("CheckerTileLight")


# Path: src/view/display_sprite_object.py
# class DisplaySpriteObject(QGraphicsItem):
#     def __init__(self):
# 
#         super(DisplaySpriteObject, self).__init__()
# 
#         self._sprite = None
# 
#         self._displayFrameIndex = -1
# 
#         self.prepareGeometryChange()
# 
#         self._boundingRect = QRectF()
# 
#         self._backgroundPixmap = None
# 
#         self._enableOnionSkin = True
# 
#     @property
#     def sprite(self):
#         return self._sprite
# 
#     @property
#     def active_surface(self):
#         return self._sprite.active_surface
# 
#     @property
#     def active_surface_pixel_data(self):
#         return self._sprite.active_surface_pixel_data
# 
#     @property
#     def display_frame_index(self):
#         return self._displayFrameIndex
# 
#     @display_frame_index.setter
#     def display_frame_index(self, value):
#         self._displayFrameIndex = value
# 
#     @property
#     def background_pixmap(self):
#         return self._backgroundPixmap
# 
#     @property
#     def is_empty(self):
#         return self._sprite is None
# 
#     @background_pixmap.setter
#     def background_pixmap(self, value):
#         self._backgroundPixmap = value
# 
#     def boundingRect(self):
#         return self._boundingRect
# 
#     @property
#     def bounding_rect_i(self):
#         return QRect(self._boundingRect.left(),
#                      self._boundingRect.top(),
#                      self._boundingRect.width(),
#                      self._boundingRect.height())
# 
#     @property
#     def area_rect(self):
#         return QRect(0, 0, self._boundingRect.width(), self._boundingRect.height())
# 
#     @property
#     def width(self):
#         return self.boundingRect().width()
# 
#     @property
#     def height(self):
#         return self.boundingRect().height()
# 
#     @property
#     def enable_onion_skin(self):
#         return self._enableOnionSkin
# 
#     @enable_onion_skin.setter
#     def enable_onion_skin(self, value):
#         self._enableOnionSkin = value
# 
#     def set_sprite(self, sprite):
# 
#         self._sprite = sprite
# 
#         self.update_bounding_rect()
# 
#     def update_bounding_rect(self):
# 
#         if self._boundingRect.size != self._sprite.size:
#             self.prepareGeometryChange()
#             self._boundingRect = QRectF(-self._sprite.width / 2, -self._sprite.height / 2,
#                                         self._sprite.width, self._sprite.height)
# 
#     def unload_sprite(self):
# 
#         self._sprite = None
#         self._displayFrameIndex = -1
#         self.prepareGeometryChange()
#         self._boundingRect = QRectF()
# 
#     def paint(self, painter, option, widget=None):
# 
#         painter.setClipRect(option.exposedRect)
# 
#         if self._backgroundPixmap is not None:
#             painter.drawTiledPixmap(option.rect, self._backgroundPixmap)
# 
#         if self._sprite is not None:
# 
#             frame_index = self._displayFrameIndex \
#                 if self._displayFrameIndex != -1 \
#                 else self._sprite.current_animation.current_frame_index
# 
#             if self._enableOnionSkin:
# 
#                 last_frame_index = frame_index - 1
# 
#                 if last_frame_index >= 0:
# 
#                     last_frame_layers = self._sprite.current_animation. \
#                         frame_at(last_frame_index).surfaces
# 
#                     painter.setOpacity(0.2)
# 
#                     for layer in last_frame_layers:
#                         painter.drawImage(option.rect, layer.image)
# 
#                     painter.setOpacity(1.0)
# 
#             layers = self._sprite.current_animation.frame_at(frame_index).surfaces
# 
#             for layer in layers:
#                 painter.drawImage(option.rect, layer.image)
# 
# Path: src/model/resources_cache.py
# class ResourcesCache(object):
#     _resources = {}
# 
#     @staticmethod
#     def get(name):
#         return ResourcesCache._resources[name]
# 
#     @staticmethod
#     def register_resource(name, resource):
#         ResourcesCache._resources[name] = resource
# 
#     @staticmethod
#     def dispose():
#         ResourcesCache._resources.clear()


# Path: src/view/display_base_widget.py
from PyQt5.QtCore import Qt, QPoint, QRectF
from PyQt5.QtGui import QPainter, QTransform
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene
from src.view.display_sprite_object import DisplaySpriteObject
from src.model.resources_cache import ResourcesCache
import src.helpers.utils as utils

# Purpose:     Represents the base transformable display that is inherited by the Canvas
# and the AnimationDisplay
#
# Author:      Rafael Vasco
#
# Created:     31/03/2013
# Copyright:   (c) Rafael Vasco 2014
# Licence:     <your licence>
#------------------------------------------------------------------------------




class Display(QGraphicsView):
    def __init__(self):

        super(Display, self).__init__()

        self.setScene(QGraphicsScene())

        self._spriteObject = DisplaySpriteObject()

        self.scene().addItem(self._spriteObject)

        self._backgroundColor = None

        self._backLightOn = True

        self._lightBackgroundPixmap = ResourcesCache.get("CheckerTileLight")


        self._darkBackgroundPixmap = ResourcesCache.get("CheckerTileDark")