Lephisto/src/gui_button.h

48 lines
1.2 KiB
C++

#pragma once
#include <string>
#include "gui_widget.h"
namespace Gui {
class Button: public Widget {
public:
Button(void);
virtual ~Button(void) {}
virtual bool OnMouseDown(MouseButtonEvent* e);
virtual bool OnMouseUp(MouseButtonEvent* e);
virtual void OnActivate(void);
/*
* onClick only happens when press and release are both on widget,
* (release can be elsewhere).
*/
sigc::signal<void> onPress;
sigc::signal<void> onRelease;
sigc::signal<void> onClick;
bool IsPressed(void) { return m_isPressed; }
private:
void OnRawMouseUp(SDL_MouseButtonEvent* e);
void OnRawKeyUp(SDL_KeyboardEvent* e);
bool m_isPressed;
sigc::connection _m_release;
sigc::connection _m_kbrelease;
};
class SolidButton: public Button {
public:
SolidButton(void) : Button() {}
virtual ~SolidButton(void) {}
virtual void GetSizeRequested(float size[2]);
virtual void Draw(void);
};
class TransparentButton : public Button {
public:
TransparentButton(void) : Button() {}
virtual ~TransparentButton(void) {}
virtual void GetSizeRequested(float size[2]);
virtual void Draw(void);
};
}