//------------------------------------------------------------------------------//
bool InventoryItem::isHit(const glm::vec2& position, const bool allow_disabled) const
{
    if (!DragContainer::isHit(position, allow_disabled))
        return false;

    int gx = gridXLocationFromPixelPosition(position.x);
    int gy = gridYLocationFromPixelPosition(position.y);

    if (gx < 0 || gx >= d_content.width() || gy < 0 || gy >= d_content.height())
        return false;

    return d_content.elementAtLocation(gx, gy);
}
//------------------------------------------------------------------------------//
void InventoryReceiver::onDragDropItemDropped(DragDropEventArgs &e)
{
    InventoryItem* item = dynamic_cast<InventoryItem*>(e.dragDropItem);

    if (!item)
        return;

    const Sizef square_size(squarePixelSize());

    Rectf item_area(item->getUnclippedOuterRect().get());
    item_area.offset(Vector2f(square_size.d_width / 2, square_size.d_height / 2));

    const int drop_x = gridXLocationFromPixelPosition(item_area.left());
    const int drop_y = gridYLocationFromPixelPosition(item_area.top());

    addItemAtLocation(*item, drop_x, drop_y);
}