xenia/src/poly/ui/ui_event.h

76 lines
1.7 KiB
C
Raw Normal View History

/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2014 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
2014-12-20 22:54:55 +01:00
#ifndef POLY_UI_UI_EVENT_H_
#define POLY_UI_UI_EVENT_H_
2014-12-20 22:54:55 +01:00
namespace poly {
namespace ui {
2014-12-20 22:54:55 +01:00
class Control;
class UIEvent {
2014-08-22 08:10:08 +02:00
public:
2014-12-20 22:54:55 +01:00
UIEvent(Control* control = nullptr) : control_(control) {}
2014-08-22 08:10:08 +02:00
virtual ~UIEvent() = default;
2014-12-20 22:54:55 +01:00
Control* control() const { return control_; }
2014-08-22 08:10:08 +02:00
private:
2014-12-20 22:54:55 +01:00
Control* control_;
};
2014-05-28 22:59:43 +02:00
class KeyEvent : public UIEvent {
2014-08-22 08:10:08 +02:00
public:
2014-12-20 22:54:55 +01:00
KeyEvent(Control* control, int key_code)
: UIEvent(control), key_code_(key_code) {}
2014-08-22 08:10:08 +02:00
~KeyEvent() override = default;
2014-05-28 22:59:43 +02:00
int key_code() const { return key_code_; }
2014-08-22 08:10:08 +02:00
private:
2014-05-28 22:59:43 +02:00
int key_code_;
};
class MouseEvent : public UIEvent {
2014-08-22 08:10:08 +02:00
public:
2014-12-20 22:54:55 +01:00
enum class Button {
kNone = 0,
kLeft,
kRight,
kMiddle,
kX1,
kX2,
};
2014-08-22 08:10:08 +02:00
public:
2014-12-20 22:54:55 +01:00
MouseEvent(Control* control, Button button, int32_t x, int32_t y,
2014-08-22 08:10:08 +02:00
int32_t dx = 0, int32_t dy = 0)
2014-12-20 22:54:55 +01:00
: UIEvent(control), button_(button), x_(x), y_(y), dx_(dx), dy_(dy) {}
2014-08-22 08:10:08 +02:00
~MouseEvent() override = default;
Button button() const { return button_; }
int32_t x() const { return x_; }
int32_t y() const { return y_; }
int32_t dx() const { return dx_; }
int32_t dy() const { return dy_; }
2014-08-22 08:10:08 +02:00
private:
Button button_;
int32_t x_;
int32_t y_;
int32_t dx_;
int32_t dy_;
};
} // namespace ui
2014-12-20 22:54:55 +01:00
} // namespace poly
2014-12-20 22:54:55 +01:00
#endif // POLY_UI_UI_EVENT_H_