From 920f1f010284d59bad86f78355ed90ac2f3e1d2c Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Mon, 8 Mar 2021 16:46:22 -0500 Subject: mouse movement in raleigh, with colorpicker dragging example --- src/user/include/cxx/raleigh/w/button.h | 1 + src/user/include/cxx/raleigh/w/colorpicker.h | 3 +++ src/user/include/cxx/raleigh/w/padding.h | 1 + src/user/include/cxx/raleigh/w/vbox.h | 1 + src/user/include/cxx/raleigh/widget.h | 1 + src/user/include/pland/syscall.h | 7 ++++++- 6 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src/user/include') diff --git a/src/user/include/cxx/raleigh/w/button.h b/src/user/include/cxx/raleigh/w/button.h index 71ccae2..0e40f81 100644 --- a/src/user/include/cxx/raleigh/w/button.h +++ b/src/user/include/cxx/raleigh/w/button.h @@ -14,6 +14,7 @@ namespace raleigh { void handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override; void notify_child_size_change(widget &child, coord old_size) override; void notify_has_opaque_parent(widget *parent) override; + void on_mouse_move(coord window_coords) override; private: widget &inner; void (*on_click)(button &); diff --git a/src/user/include/cxx/raleigh/w/colorpicker.h b/src/user/include/cxx/raleigh/w/colorpicker.h index c33288e..a282c9e 100644 --- a/src/user/include/cxx/raleigh/w/colorpicker.h +++ b/src/user/include/cxx/raleigh/w/colorpicker.h @@ -12,11 +12,14 @@ namespace raleigh { void paint(_pixel_t *pixbuf, uint32_t pitch) override; void handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override; void notify_has_opaque_parent(widget *parent) override; + void on_mouse_move(coord window_coords) override; private: _pixel_t picked_color; uint8_t resolution; uint8_t inv_res; + + enum {NO, R, G, B} selected; }; } diff --git a/src/user/include/cxx/raleigh/w/padding.h b/src/user/include/cxx/raleigh/w/padding.h index 1bdb9ee..ab732f1 100644 --- a/src/user/include/cxx/raleigh/w/padding.h +++ b/src/user/include/cxx/raleigh/w/padding.h @@ -13,6 +13,7 @@ namespace raleigh { void handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override; void notify_has_opaque_parent(widget *parent) override; void notify_child_size_change(widget &child, coord old_size) override; + void on_mouse_move(coord window_coords) override; private: widget &inner; uint32_t pad_by; diff --git a/src/user/include/cxx/raleigh/w/vbox.h b/src/user/include/cxx/raleigh/w/vbox.h index f715f95..39f89e9 100644 --- a/src/user/include/cxx/raleigh/w/vbox.h +++ b/src/user/include/cxx/raleigh/w/vbox.h @@ -15,6 +15,7 @@ namespace raleigh { void handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override; void notify_has_opaque_parent(widget *parent) override; void notify_child_size_change(widget &from, coord old_size) override; + void on_mouse_move(coord window_coords) override; private: dllist widgets; }; diff --git a/src/user/include/cxx/raleigh/widget.h b/src/user/include/cxx/raleigh/widget.h index 1b2cf6f..d499ed4 100644 --- a/src/user/include/cxx/raleigh/widget.h +++ b/src/user/include/cxx/raleigh/widget.h @@ -36,6 +36,7 @@ namespace raleigh { virtual void handle_key(struct key_packet kp); virtual void on_focus(); virtual void on_unfocus(); + virtual void on_mouse_move(coord window_coords); //this next one is not to be called by child widgets //they should call window::notify_widget_size_change(widget &), which will call this if necessary virtual void notify_child_size_change(widget &child, coord old_size); diff --git a/src/user/include/pland/syscall.h b/src/user/include/pland/syscall.h index d7dfd77..1e040f4 100644 --- a/src/user/include/pland/syscall.h +++ b/src/user/include/pland/syscall.h @@ -57,7 +57,8 @@ enum _scn { _SCN_IS_TASK_RUNNING, _SCN_GET_TIMESTAMP, _SCN_FILE_WRITE, - _SCN_SET_FILE_SIZE + _SCN_SET_FILE_SIZE, + _SCN_WANTS_MOUSE_MOVES }; static inline uint32_t _sc0(enum _scn eax) { @@ -254,6 +255,10 @@ static inline void _set_file_size(_file_handle_t handle, uint32_t new_size) { _sc2(_SCN_SET_FILE_SIZE, handle, new_size); } +static inline void _wants_mouse_moves(_window_handle_t window) { + _sc1(_SCN_WANTS_MOUSE_MOVES, (uint32_t)window); +} + #ifdef __cplusplus } #endif -- cgit v1.2.3