fix redraw

This commit is contained in:
chenhuan 2019-11-28 13:48:58 +01:00
parent 4fda57b6e6
commit 124275f1a7
2 changed files with 20 additions and 5 deletions

View File

@ -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);

View File

@ -4,6 +4,7 @@
#include <Fl/Fl_Export.H>
#include <FL/Fl_Window.H>
#include <FL/fl_draw.H>
#include <unistd.h>
#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);
public:
GUI_Window(int x, int y, const char *l);
};
@ -55,8 +59,13 @@ public:
};
char *get_resolusion(int window_height, int window_width);
void refresh_image(void *pointer);
void get_new_image(void *pointer);
void redraw(Image *image);
int GUI_run(int argc, char **argv);
#endif //GUI_GUI_HPP