// Copyright (c) 2013 - 2026 kio@little-bat.de
// BSD-2-Clause license
// https://opensource.org/licenses/BSD-2-Clause

#pragma once
#include "kio/kio.h"
#include <QImage>
#include <QPixmap>
#include <QWidget>
#include <functional>


namespace zxsp
{

class MySimpleToggleButton : public QWidget
{
	Q_OBJECT

	QImage image_up;
	QImage image_down;
	bool   state;
	enum { up = 0, down = 1 };
	bool sticky; // sticky: radio button behaviour, else the button can be toggle down and up again

public:
	MySimpleToggleButton(QWidget* parent, int x, int y, cstr filepath_up, cstr filepath_down, bool sticky = no);
	MySimpleToggleButton(
		QWidget* parent, int x, int y, cstr basepath, cstr ppath_up, cstr ppath_down, bool sticky = no);

	bool isDown() const { return state == down; }
	void setDown(bool); // no signal
	void click();		// emits signal if successfully toggled (except if sticky & already down)

protected:
	void paintEvent(QPaintEvent*) override;
	void mousePressEvent(QMouseEvent*) override;
	void mouseReleaseEvent(QMouseEvent*) override;
	// void	mouseMoveEvent(QMouseEvent*) override;
	// void	showEvent(QShowEvent*) override;
	// void	hideEvent (QHideEvent*) override;

signals:
	void toggled(bool);
};

} // namespace zxsp
