initial port for Cevo game in C++ (libs)
This commit is contained in:
commit
8436242032
375 files changed
+46282
No files matched your search
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dpi/DpiGraphics.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <functional>
|
||||
|
||||
namespace Cevo {
|
||||
|
||||
// TButtonBase equivalent: a lightweight, sprite-painted push button with
|
||||
// manual mouse tracking (no native QAbstractButton state machine), matching
|
||||
// the original TGraphicControl-based design and its Down/Permanent model.
|
||||
class ButtonBase : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ButtonBase(QWidget *parent = nullptr);
|
||||
|
||||
bool down() const { return m_down; }
|
||||
void setDown(bool value);
|
||||
bool permanent() const { return m_permanent; }
|
||||
void setPermanent(bool value) { m_permanent = value; }
|
||||
|
||||
Dpi::Bitmap *graphic() const { return m_graphic; }
|
||||
void setGraphic(Dpi::Bitmap *value) { m_graphic = value; }
|
||||
|
||||
std::function<void()> onClick;
|
||||
std::function<void()> onDownChanged;
|
||||
|
||||
protected:
|
||||
virtual void paint(Dpi::Canvas &canvas) { Q_UNUSED(canvas); }
|
||||
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
|
||||
Dpi::Bitmap *m_graphic = nullptr;
|
||||
bool m_down = false;
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *event) override final;
|
||||
void trackMouse(const QPoint &pos, bool leftPressed);
|
||||
void setDownState(bool value);
|
||||
|
||||
bool m_permanent = false;
|
||||
bool m_active = false;
|
||||
};
|
||||
|
||||
} // namespace Cevo
|
||||
Reference in new issue
Block a user