From 8221fd5451f094defa9866f98026b74a969f7693 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Mon, 8 Mar 2021 14:46:19 -0500 Subject: resizable widgets, default widget implementation for some functions, reimplementing meminfo in raleigh --- src/user/raleigh/window.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/user/raleigh/window.cpp') diff --git a/src/user/raleigh/window.cpp b/src/user/raleigh/window.cpp index 052422e..5d1a3de 100644 --- a/src/user/raleigh/window.cpp +++ b/src/user/raleigh/window.cpp @@ -1,7 +1,6 @@ #include #include -#include -#include +#include #include @@ -44,8 +43,16 @@ namespace raleigh { root.handle_click(coord(wa.as_mouse.x, wa.as_mouse.y), wa.as_mouse.which, false); else if (wa.action_type == wa.MOUSE_UP) root.handle_click(coord(wa.as_mouse.x, wa.as_mouse.y), wa.as_mouse.which, true); - else if (wa.action_type == wa.KEY_DOWN) + else if (wa.action_type == wa.KEY_DOWN) { + for (dllist>::node *n = keybinds.first; n; n = n->next) + if (match_side_agnostic(wa.as_key, n->d.a)) { + n->d.b(*this); + goto next_loop; + } focussed->handle_key(wa.as_key); + next_loop: + ; + } else if (wa.action_type == wa.FOCUS_ENTER) focussed->on_focus(); else if (wa.action_type == wa.FOCUS_LEAVE) @@ -83,4 +90,22 @@ namespace raleigh { focussed->on_focus(); } } + + void window::notify_widget_size_change(widget &from, coord old_size) { + if (from.parent) + from.parent->notify_child_size_change(from, old_size); + else { + size = root.size; + delete[] pixbuf; + pixbuf = new _pixel_t[size.x * size.y]; + if (!pixbuf) + show_error_and_quitf("Failed to allocate %u byte buffer while\nresizing window to %ux%u pixels.", size.x * size.y, size.x, size.y); + paint_full(); + _resize_window(handle, size.x, size.y, pixbuf); + } + } + + void window::add_keybind(struct key_packet kp, void (*handler)(window &)) { + keybinds.add_front(duple(kp, handler)); + } } \ No newline at end of file -- cgit v1.2.3