#ifndef TITAN_PCBCAM_POPVIEWWINDOW_H
#define TITAN_PCBCAM_POPVIEWWINDOW_H
#include "../titanpcbcamglobal.h"
#include <QFrame>
#include <QResizeEvent>
#include <QCloseEvent>
#include <QMoveEvent>
#include <QMouseEvent>

class PcbCamCanvas;

class PcbCamPopViewWindowPrivate;
class TITAN_PCBCAM_EXPORT PcbCamPopViewWindow : public QFrame
{
    Q_OBJECT
    friend class PcbCamCanvas;
public:
    explicit PcbCamPopViewWindow(const QRectF &iSourceRect, const QRect &iTargetRect, PcbCamCanvas *iCanvas);
    ~PcbCamPopViewWindow();
    void setSourceRect(const QRectF &iSourceRect);
    QRectF sourceRect() const;
    QRect viewRect() const;

public slots:
    void refresh();

signals:
    void aboutToClose();
    void geometryChanged();

protected:
    void resizeEvent(QResizeEvent *event) override;
    void closeEvent(QCloseEvent *event) override;
    void moveEvent(QMoveEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;

private slots:
    void onPanUpClicked();
    void onPanDownClicked();
    void onPanLeftClicked();
    void onPanRightClicked();
    void onZoomInClicked();
    void onZoomOutClicked();

private:
    void resizeWidget(const QPoint &globalMousePos, int direction);

protected:
    const QScopedPointer<PcbCamPopViewWindowPrivate> d_ptr;

private:
    Q_DECLARE_PRIVATE(PcbCamPopViewWindow)
    Q_DISABLE_COPY(PcbCamPopViewWindow)

};


#endif // TITAN_PCBCAM_POPVIEWWINDOW_H
