feat: Implement comprehensive mouse event system
Implements multiple mouse event improvements for UI elements: - Mouse enter/exit events (#140): on_enter, on_exit callbacks and hovered property for all UIDrawable types (Frame, Caption, Sprite, Grid) - Headless click events (#111): Track simulated mouse position for automation testing in headless mode - Mouse move events (#141): on_move callback fires continuously while mouse is within element bounds - Grid cell events (#142): on_cell_enter, on_cell_exit, on_cell_click callbacks with cell coordinates (x, y), plus hovered_cell property Includes comprehensive tests for all new functionality. Closes #140, closes #111, closes #141, closes #142 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
6d5a5e9e16
commit
6c496b8732
14 changed files with 1353 additions and 27 deletions
|
|
@ -36,12 +36,29 @@ public:
|
|||
virtual void render(sf::Vector2f, sf::RenderTarget&) = 0;
|
||||
virtual PyObjectsEnum derived_type() = 0;
|
||||
|
||||
// Mouse input handling - callable object, methods to find event's destination
|
||||
// Mouse input handling - callable objects for click, enter, exit, move events
|
||||
std::unique_ptr<PyClickCallable> click_callable;
|
||||
std::unique_ptr<PyClickCallable> on_enter_callable; // #140
|
||||
std::unique_ptr<PyClickCallable> on_exit_callable; // #140
|
||||
std::unique_ptr<PyClickCallable> on_move_callable; // #141
|
||||
|
||||
virtual UIDrawable* click_at(sf::Vector2f point) = 0;
|
||||
void click_register(PyObject*);
|
||||
void click_unregister();
|
||||
|
||||
// #140 - Mouse enter/exit callbacks
|
||||
void on_enter_register(PyObject*);
|
||||
void on_enter_unregister();
|
||||
void on_exit_register(PyObject*);
|
||||
void on_exit_unregister();
|
||||
|
||||
// #141 - Mouse move callback
|
||||
void on_move_register(PyObject*);
|
||||
void on_move_unregister();
|
||||
|
||||
// #140 - Hovered state (set by GameEngine)
|
||||
bool hovered = false;
|
||||
|
||||
UIDrawable();
|
||||
virtual ~UIDrawable();
|
||||
|
||||
|
|
@ -55,6 +72,15 @@ public:
|
|||
|
||||
static PyObject* get_click(PyObject* self, void* closure);
|
||||
static int set_click(PyObject* self, PyObject* value, void* closure);
|
||||
// #140 - Python API for on_enter/on_exit callbacks
|
||||
static PyObject* get_on_enter(PyObject* self, void* closure);
|
||||
static int set_on_enter(PyObject* self, PyObject* value, void* closure);
|
||||
static PyObject* get_on_exit(PyObject* self, void* closure);
|
||||
static int set_on_exit(PyObject* self, PyObject* value, void* closure);
|
||||
static PyObject* get_hovered(PyObject* self, void* closure);
|
||||
// #141 - Python API for on_move callback
|
||||
static PyObject* get_on_move(PyObject* self, void* closure);
|
||||
static int set_on_move(PyObject* self, PyObject* value, void* closure);
|
||||
static PyObject* get_int(PyObject* self, void* closure);
|
||||
static int set_int(PyObject* self, PyObject* value, void* closure);
|
||||
static PyObject* get_name(PyObject* self, void* closure);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue