fix green backgrund problem
This commit is contained in:
parent
b1552db800
commit
aa511a2315
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -8,7 +8,7 @@ auto GUI_Window::handle(int e) -> int {
|
|||
case FL_PUSH:
|
||||
x = Fl::event_x();
|
||||
y = Fl::event_y();
|
||||
vkvm::setMousePosition(x,y);
|
||||
vkvm::setMousePosition(x, y);
|
||||
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
||||
this->child(2)->label("Event:Mouse Left Down");
|
||||
vkvm::callEvent(vkvm::EventType::MouseLeftDown);
|
||||
|
@ -24,7 +24,7 @@ auto GUI_Window::handle(int e) -> int {
|
|||
case FL_RELEASE:
|
||||
x = Fl::event_x();
|
||||
y = Fl::event_y();
|
||||
vkvm::setMousePosition(x,y);
|
||||
vkvm::setMousePosition(x, y);
|
||||
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
||||
this->child(2)->label("Event:Mouse Left Up");
|
||||
vkvm::callEvent(vkvm::EventType::MouseLeftUp);
|
||||
|
@ -39,8 +39,8 @@ auto GUI_Window::handle(int e) -> int {
|
|||
case FL_DRAG:
|
||||
x = Fl::event_x();
|
||||
y = Fl::event_y();
|
||||
vkvm::setMousePosition(x,y);
|
||||
this->child(3)->label(position_to_string(x,y));
|
||||
vkvm::setMousePosition(x, y);
|
||||
this->child(3)->label(position_to_string(x, y));
|
||||
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
||||
this->child(2)->label("Event:Mouse Left Drag");
|
||||
vkvm::callEvent(vkvm::EventType::MouseMove);
|
||||
|
@ -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();
|
||||
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));
|
||||
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:
|
||||
|
@ -72,7 +75,7 @@ auto GUI_Window::handle(int e) -> int {
|
|||
return 1;
|
||||
case FL_KEYUP:
|
||||
button = Fl::event_button();
|
||||
std::cout<<button<<std::endl;
|
||||
std::cout << button << std::endl;
|
||||
keyCode = vkvm::KeyCode(button);
|
||||
vkvm::buttonPressed(keyCode);
|
||||
vkvm::callEvent(vkvm::EventType::KeyUp);
|
||||
|
@ -82,17 +85,20 @@ 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 GUI_Window::position_to_string(int x, int y) -> char * {
|
||||
auto *str = new char[25];
|
||||
std::string str_temp;
|
||||
str = strcpy(str,"Mouse Position X:");
|
||||
str = strcpy(str, "Mouse Position X:");
|
||||
str_temp = std::to_string(x);
|
||||
str = strcat(str,str_temp.c_str());
|
||||
str = strcat(str," Y:");
|
||||
str = strcat(str, str_temp.c_str());
|
||||
str = strcat(str, " Y:");
|
||||
str_temp = std::to_string(y);
|
||||
str = strcat(str,str_temp.c_str());
|
||||
str = strcat(str, str_temp.c_str());
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
|
@ -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*/
|
||||
|
|
Loading…
Reference in New Issue