/*
 * This file is part of Bino, a 3D video player.
 *
 * Copyright (C) 2026
 * Martin Lambers <marlam@marlam.de>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include <QRectF>

#include "overlay.hpp"


class OverlayUI : public Overlay
{
private:
    bool _currentSurround;
    bool _currentStereo3D;
    qint64 _currentPosition;
    qint64 _currentDuration;
    bool _currentSeekable;
    bool _currentPlaying;
    QPointF _currentPointer;
    bool _currentShowPointer;
    bool _lastSurround;
    bool _lastStereo3D;
    qint64 _lastPosition;
    qint64 _lastDuration;
    bool _lastSeekable;
    bool _lastPlaying;
    QPointF _lastPointer;
    bool _lastShowPointer;

    float _buttonSize;
    float _penWidth;
    QRectF _boxes[11];
    bool _boxIsActive[11];

    void computeBoxes();
    QPointF pointerToImage(const QPointF& pointer);
    int boxIndex(const QPointF& pointer);
    float pointerToSeekPos(const QPointF& pointer);

    friend QDataStream &operator<<(QDataStream& ds, const OverlayUI& o);
    friend QDataStream &operator>>(QDataStream& ds, OverlayUI& o);

public:
    OverlayUI();
    ~OverlayUI();

    void updateParameters(bool surround, bool stereo3D,
            qint64 position, qint64 duration, bool seekable,
            bool playing, const QPointF& pointer, bool showPointer);

    virtual bool redraw(int w, int h) override;

    bool pointerPress(const QPointF& pointer);
    void pointerRelease(const QPointF& pointer);
};

QDataStream &operator<<(QDataStream& ds, const OverlayUI& o);
QDataStream &operator>>(QDataStream& ds, OverlayUI& o);
