fix green backgrund problem

This commit is contained in:
chenhuan 2019-12-12 00:02:59 +01:00
parent b1552db800
commit aa511a2315
4 changed files with 24 additions and 24 deletions

View File

@ -25,7 +25,7 @@ auto GUI_run(int argc, char **argv) -> int {
redraw(image);
});
vkvm::registerEvent(vkvm::EventType::UpdateControlRegisters, [image]() {
image->setDelay(vkvm::getRedrawInterval();
image->setDelay(vkvm::getRedrawInterval());
});
Fl::repeat_timeout(image->getDelay(), get_new_image, image);
window->end();

View File

@ -20,7 +20,7 @@
* @param button The button that was pushed last.
*/
class GUI_Window : public Fl_Window {
int x{}, y{}, button{};
int x, y, button,lastX,lastY;
vkvm::KeyCode keyCode;
int handle(int e) override;

View File

@ -51,16 +51,19 @@ auto GUI_Window::handle(int e) -> int {
this->child(2)->label("Event:Mouse Middle Drag");
vkvm::callEvent(vkvm::EventType::MouseMove);
}
return 1;
/*Mousemovement*/
case FL_MOVE:
x = Fl::event_x();
y = Fl::event_y();
if (lastX != x || lastY != y) {
lastX = x;
lastY = y;
vkvm::setMousePosition(x, y);
vkvm::callEvent(vkvm::EventType::MouseMove);
this->child(2)->label("Event:Mouse Move");
this->child(3)->label(position_to_string(x, y));
}
return 1;
/*keyboardbutton*/
case FL_KEYBOARD:
@ -82,7 +85,10 @@ auto GUI_Window::handle(int e) -> int {
return -1;
}
GUI_Window::GUI_Window(int x, int y, const char *l) : Fl_Window(x, y, l) {}
GUI_Window::GUI_Window(int x, int y, const char *l) : Fl_Window(x, y, l) {
lastX = 0;
lastY = 0;
}
auto GUI_Window::position_to_string(int x, int y) -> char * {
auto *str = new char[25];

View File

@ -14,12 +14,6 @@ Image::Image(int x, int y, int w, int h) :
Fl_Widget(x, y, w, h, nullptr) {
buf = new uchar[w * h * 3];
delay = ((double)vkvm::getRedrawInterval())/1000;
/*Just an example.*/
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
buf[(j + (i * w)) * 3 + 1] = 0xff;
}
}
}
/*A function to change the colors of the image-class. It reads the colors from the Shared Memory-Class*/