fix redraw
This commit is contained in:
parent
4fda57b6e6
commit
124275f1a7
10
src/GUI.cpp
10
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);
|
||||
|
15
src/GUI.hpp
15
src/GUI.hpp
@ -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);
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user