diff --git a/src/GUI.cpp b/src/GUI.cpp index 187b8fa..b104a23 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -22,9 +22,9 @@ auto GUI_run(int argc, char **argv) -> int { status[1] = new Statusbar(300, 0, 170, 30, "Event:"); status[2] = new Statusbar(470, 0, 200, 30, "Mouse Position:"); vkvm::registerEvent(vkvm::EventType::Redraw, [image](){ - image->redraw(); + redraw(image); }); - Fl::repeat_timeout(0.5, refresh_image, image); + Fl::repeat_timeout(0.5, get_new_image, image); window->end(); window->show(argc, argv); return Fl::run(); @@ -42,6 +42,12 @@ char *get_resolusion(int window_height, int window_width) { return resolusion; } +void redraw(Image* image){ + image->getPixels(); + sleep(0.05); + image->redraw(); +} + void get_new_image(void *pointer) { ((Image *) pointer)->getPixels(); Fl::repeat_timeout(0.5, refresh_image, pointer); diff --git a/src/GUI.hpp b/src/GUI.hpp index 50f8706..47dfe9e 100644 --- a/src/GUI.hpp +++ b/src/GUI.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "vkvm.hpp" #include "internal.hpp" @@ -21,8 +22,11 @@ class GUI_Window : public Fl_Window { int x, y, button; vkvm::KeyCode keyCode; + int handle(int e); - char* position_to_string(int x,int y); + + char *position_to_string(int x, int y); + public: GUI_Window(int x, int y, const char *l); }; @@ -54,9 +58,14 @@ public: Statusbar(int x, int y, int w, int h, char *text); }; -char* get_resolusion(int window_height, int window_width); +char *get_resolusion(int window_height, int window_width); + void refresh_image(void *pointer); -void get_new_image(void *pointer) ; + +void get_new_image(void *pointer); + +void redraw(Image *image); + int GUI_run(int argc, char **argv); #endif //GUI_GUI_HPP