summaryrefslogtreecommitdiff
path: root/src/user/raleigh/window.cpp
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-03-08 14:46:19 -0500
committerBenji Dial <benji6283@gmail.com>2021-03-08 14:46:19 -0500
commit8221fd5451f094defa9866f98026b74a969f7693 (patch)
tree9f0e9595fd15bdecbe667f823deded7428547b44 /src/user/raleigh/window.cpp
parent1a5ece4f52ef17c7c868e95eb26e98137d5cab6f (diff)
downloadportland-os-8221fd5451f094defa9866f98026b74a969f7693.tar.gz
resizable widgets, default widget implementation for some functions, reimplementing meminfo in raleigh
Diffstat (limited to 'src/user/raleigh/window.cpp')
-rw-r--r--src/user/raleigh/window.cpp31
1 files changed, 28 insertions, 3 deletions
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 <raleigh/runtime.h>
#include <raleigh/window.h>
-#include <popups/info.h>
-#include <knob/heap.h>
+#include <knob/key.h>
#include <knob/format.h>
@@ -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<duple<struct key_packet, void (*)(window &)>>::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<struct key_packet, void (*)(window &)>(kp, handler));
+ }
} \ No newline at end of file