fix green backgrund problem
fix mouse interrupt problem
This commit is contained in:
parent
aa511a2315
commit
555f5a551d
@ -5,6 +5,7 @@
|
|||||||
#include <FL/Fl_Window.H>
|
#include <FL/Fl_Window.H>
|
||||||
#include <FL/fl_draw.H>
|
#include <FL/fl_draw.H>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include "Mouse_Status.hpp"
|
||||||
#include "vkvm.hpp"
|
#include "vkvm.hpp"
|
||||||
#include "internal.hpp"
|
#include "internal.hpp"
|
||||||
|
|
||||||
@ -20,7 +21,7 @@
|
|||||||
* @param button The button that was pushed last.
|
* @param button The button that was pushed last.
|
||||||
*/
|
*/
|
||||||
class GUI_Window : public Fl_Window {
|
class GUI_Window : public Fl_Window {
|
||||||
int x, y, button,lastX,lastY;
|
int x, y, button,lastX,lastY,mouse_status;
|
||||||
vkvm::KeyCode keyCode;
|
vkvm::KeyCode keyCode;
|
||||||
|
|
||||||
int handle(int e) override;
|
int handle(int e) override;
|
||||||
@ -74,4 +75,5 @@ void redraw(Image *image);
|
|||||||
|
|
||||||
int GUI_run(int argc, char **argv);
|
int GUI_run(int argc, char **argv);
|
||||||
|
|
||||||
|
|
||||||
#endif //GUI_GUI_HPP
|
#endif //GUI_GUI_HPP
|
||||||
|
@ -10,14 +10,20 @@ auto GUI_Window::handle(int e) -> int {
|
|||||||
y = Fl::event_y();
|
y = Fl::event_y();
|
||||||
vkvm::setMousePosition(x, y);
|
vkvm::setMousePosition(x, y);
|
||||||
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
||||||
|
mouse_status |= Mouse_Status::left_down;
|
||||||
this->child(2)->label("Event:Mouse Left Down");
|
this->child(2)->label("Event:Mouse Left Down");
|
||||||
vkvm::callEvent(vkvm::EventType::MouseLeftDown);
|
vkvm::callEvent(vkvm::EventType::MouseLeftDown);
|
||||||
|
std::cout<<mouse_status<<std::endl;
|
||||||
} else if (Fl::event_button() == FL_RIGHT_MOUSE) {
|
} else if (Fl::event_button() == FL_RIGHT_MOUSE) {
|
||||||
|
mouse_status |= Mouse_Status::right_down;
|
||||||
this->child(2)->label("Event:Mouse Right Down");
|
this->child(2)->label("Event:Mouse Right Down");
|
||||||
vkvm::callEvent(vkvm::EventType::MouseRightDown);
|
vkvm::callEvent(vkvm::EventType::MouseRightDown);
|
||||||
|
std::cout<<mouse_status<<std::endl;
|
||||||
} else {
|
} else {
|
||||||
|
mouse_status |= Mouse_Status::middle_down;
|
||||||
this->child(2)->label("Event:Mouse Middle Down");
|
this->child(2)->label("Event:Mouse Middle Down");
|
||||||
vkvm::callEvent(vkvm::EventType::MouseMiddleDown);
|
vkvm::callEvent(vkvm::EventType::MouseMiddleDown);
|
||||||
|
std::cout<<mouse_status<<std::endl;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
/*Mousebutton and movement*/
|
/*Mousebutton and movement*/
|
||||||
@ -26,14 +32,20 @@ auto GUI_Window::handle(int e) -> int {
|
|||||||
y = Fl::event_y();
|
y = Fl::event_y();
|
||||||
vkvm::setMousePosition(x, y);
|
vkvm::setMousePosition(x, y);
|
||||||
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
||||||
|
mouse_status &= Mouse_Status::left_up;
|
||||||
this->child(2)->label("Event:Mouse Left Up");
|
this->child(2)->label("Event:Mouse Left Up");
|
||||||
vkvm::callEvent(vkvm::EventType::MouseLeftUp);
|
vkvm::callEvent(vkvm::EventType::MouseLeftUp);
|
||||||
|
std::cout<<mouse_status<<std::endl;
|
||||||
} else if (Fl::event_button() == FL_RIGHT_MOUSE) {
|
} else if (Fl::event_button() == FL_RIGHT_MOUSE) {
|
||||||
|
mouse_status &= Mouse_Status::right_up;
|
||||||
this->child(2)->label("Event:Mouse Right Up");
|
this->child(2)->label("Event:Mouse Right Up");
|
||||||
vkvm::callEvent(vkvm::EventType::MouseRightUp);
|
vkvm::callEvent(vkvm::EventType::MouseRightUp);
|
||||||
|
std::cout<<mouse_status<<std::endl;
|
||||||
} else {
|
} else {
|
||||||
|
mouse_status &= Mouse_Status::middle_up;
|
||||||
this->child(2)->label("Event:Mouse Middle Up");
|
this->child(2)->label("Event:Mouse Middle Up");
|
||||||
vkvm::callEvent(vkvm::EventType::MouseMiddleUp);
|
vkvm::callEvent(vkvm::EventType::MouseMiddleUp);
|
||||||
|
std::cout<<mouse_status<<std::endl;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
case FL_DRAG:
|
case FL_DRAG:
|
||||||
@ -41,28 +53,36 @@ auto GUI_Window::handle(int e) -> int {
|
|||||||
y = Fl::event_y();
|
y = Fl::event_y();
|
||||||
vkvm::setMousePosition(x, y);
|
vkvm::setMousePosition(x, y);
|
||||||
this->child(3)->label(position_to_string(x, y));
|
this->child(3)->label(position_to_string(x, y));
|
||||||
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
switch (mouse_status) {
|
||||||
this->child(2)->label("Event:Mouse Left Drag");
|
case Mouse_Status::left_down :
|
||||||
vkvm::callEvent(vkvm::EventType::MouseMove);
|
this->child(2)->label("Event:Mouse Left Drag");
|
||||||
} else if (Fl::event_button() == FL_RIGHT_MOUSE) {
|
vkvm::callEvent(vkvm::EventType::MouseMove);
|
||||||
this->child(2)->label("Event:Mouse Right Drag");
|
break;
|
||||||
vkvm::callEvent(vkvm::EventType::MouseMove);
|
case Mouse_Status::right_down :
|
||||||
} else {
|
this->child(2)->label("Event:Mouse Right Drag");
|
||||||
this->child(2)->label("Event:Mouse Middle Drag");
|
vkvm::callEvent(vkvm::EventType::MouseMove);
|
||||||
vkvm::callEvent(vkvm::EventType::MouseMove);
|
break;
|
||||||
|
case Mouse_Status::middle_down :
|
||||||
|
this->child(2)->label("Event:Mouse Middle Drag");
|
||||||
|
vkvm::callEvent(vkvm::EventType::MouseMove);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/*Mousemovement*/
|
/*Mousemovement*/
|
||||||
case FL_MOVE:
|
case FL_MOVE:
|
||||||
x = Fl::event_x();
|
if (mouse_status == 0) {
|
||||||
y = Fl::event_y();
|
x = Fl::event_x();
|
||||||
if (lastX != x || lastY != y) {
|
y = Fl::event_y();
|
||||||
lastX = x;
|
if (lastX != x || lastY != y) {
|
||||||
lastY = y;
|
lastX = x;
|
||||||
vkvm::setMousePosition(x, y);
|
lastY = y;
|
||||||
vkvm::callEvent(vkvm::EventType::MouseMove);
|
vkvm::setMousePosition(x, y);
|
||||||
this->child(2)->label("Event:Mouse Move");
|
vkvm::callEvent(vkvm::EventType::MouseMove);
|
||||||
this->child(3)->label(position_to_string(x, y));
|
this->child(2)->label("Event:Mouse Move");
|
||||||
|
this->child(3)->label(position_to_string(x, y));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
handle(FL_DRAG);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
/*keyboardbutton*/
|
/*keyboardbutton*/
|
||||||
@ -82,12 +102,14 @@ auto GUI_Window::handle(int e) -> int {
|
|||||||
this->child(2)->label("Event:Key Up");
|
this->child(2)->label("Event:Key Up");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
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;
|
lastX = 0;
|
||||||
lastY = 0;
|
lastY = 0;
|
||||||
|
mouse_status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto GUI_Window::position_to_string(int x, int y) -> char * {
|
auto GUI_Window::position_to_string(int x, int y) -> char * {
|
||||||
|
12
src/Mouse_Status.hpp
Normal file
12
src/Mouse_Status.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
enum Mouse_Status {
|
||||||
|
left_down = 0b100,
|
||||||
|
right_down = 0b010,
|
||||||
|
middle_down = 0b001,
|
||||||
|
left_up = 0b011,
|
||||||
|
right_up = 0b101,
|
||||||
|
middle_up = 0b110,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user