#pragma once

#include <string>

#include <QFrame>

#include "SelectionContext.h"

class QVBoxLayout;

// The tooltip an item chip shows on hover: the item's name, and every way the player
// can currently produce it, each drawn as a recipe line (REQ-UI-ITEM-TOOLTIP).
//
// A window of its own rather than a Qt tooltip, because Qt's are text and this one is
// drawn -- item squares, building chips and all. It is a Qt::ToolTip window, so it
// floats above everything and takes no input.
class ItemTooltip : public QFrame
{
    Q_OBJECT

public:
    ItemTooltip(const SelectionContext& context, const std::string& itemId,
                QWidget* parent = nullptr);

    // Rebuilds the content and shows the tooltip near the given screen position, kept
    // inside the screen. Rebuilt on every show because what produces an item changes as
    // the player unlocks recipes (REQ-LOCK-UI-RECIPE).
    void showAt(const QPoint& globalPos);

private:
    void rebuild();

    SelectionContext m_context;
    std::string      m_itemId;
    QVBoxLayout*     m_layout;
};
