~ disabling redrawing now possible

~ move statusbar elements a bit
~ use clang not g++
This commit is contained in:
Johannes Theiner 2020-01-08 22:26:07 +01:00
parent 174a02468c
commit 6ae920c7b3
3 changed files with 21 additions and 30 deletions

View File

@ -31,7 +31,7 @@ make_test:
- docker-ci - docker-ci
script: script:
- apt-get update - apt-get update
- apt-get install -y g++ make cmake clang-tidy libfltk1.3 libfltk1.3-dev - apt-get install -y clang make cmake clang-tidy libfltk1.3 libfltk1.3-dev
- mkdir current - mkdir current
- ls | grep -v current | xargs mv -t current - ls | grep -v current | xargs mv -t current
- git clone https://github.com/catchorg/Catch2.git - git clone https://github.com/catchorg/Catch2.git
@ -57,7 +57,7 @@ cmake_build:
- docker-ci - docker-ci
script: script:
- apt-get update - apt-get update
- apt-get install -y g++ make cmake clang-tidy libfltk1.3 libfltk1.3-dev - apt-get install -y clang make cmake clang-tidy libfltk1.3 libfltk1.3-dev
- mkdir current - mkdir current
- ls | grep -v current | xargs mv -t current - ls | grep -v current | xargs mv -t current
- git clone https://github.com/catchorg/Catch2.git - git clone https://github.com/catchorg/Catch2.git

View File

@ -13,25 +13,25 @@ int width;
int height; int height;
static void redrawCallback(void * pointer); static void redrawCallback(void * pointer);
static void refreshCallback(void * pointer);
int GUI_run(int argc, char **argv) { int GUI_run(int argc, char **argv) {
vkvm::initialize(0); vkvm::initialize(0);
//vkvm::setLogLevel(vkvm::LogLevel::DEBUG);
width = vkvm::getWidth(); width = vkvm::getWidth();
height = vkvm::getHeight(); height = vkvm::getHeight();
redrawInterval = vkvm::getRedrawInterval(); redrawInterval = vkvm::getRedrawInterval();
char *resolution = get_resolution(width, height); char * resolution = get_resolution(width, height);
std::cout << resolution << std::endl; vkvm::log(vkvm::LogLevel::DEBUG, resolution);
auto *window = new GUI_Window(width, height + 30, "vKVM GUI"); auto * window = new GUI_Window(width, height + 30, "vKVM GUI");
Statusbar *status[5]; Statusbar *status[5];
window->begin(); window->begin();
auto *image = new Image(0, 30, width, height); auto *image = new Image(0, 30, width, height);
status[0] = new Statusbar(0, 0, 300, 30, resolution); status[0] = new Statusbar(0, 0, 200, 30, resolution);
status[1] = new Statusbar(300, 0, 170, 30, "Event:"); status[1] = new Statusbar(200, 0, 170, 30, "Event:");
status[2] = new Statusbar(470, 0, 200, 30, "Mouse Position:"); status[2] = new Statusbar(400, 0, 170, 30, "Mouse Position:");
vkvm::registerEvent(vkvm::EventType::Redraw, [image]() { vkvm::registerEvent(vkvm::EventType::Redraw, [image]() {
image->getPixels(); image->getPixels();
image->redraw(); image->redraw();
@ -39,9 +39,14 @@ int GUI_run(int argc, char **argv) {
vkvm::registerEvent(vkvm::EventType::UpdateControlRegisters, [image, window, status]() { vkvm::registerEvent(vkvm::EventType::UpdateControlRegisters, [image, window, status]() {
int newRedrawInterval = vkvm::getRedrawInterval(); int newRedrawInterval = vkvm::getRedrawInterval();
if(newRedrawInterval != redrawInterval) { if(newRedrawInterval != redrawInterval) {
/*if(redrawInterval == -1 && newRedrawInterval != -1) { if(redrawInterval == -1 && newRedrawInterval != -1) {
refreshCallback(image); vkvm::log(vkvm::LogLevel::DEBUG, "adding timeout");
}*/ Fl::add_timeout(1.0, redrawCallback, image);
}
if(newRedrawInterval == -1) {
vkvm::log(vkvm::LogLevel::DEBUG, "removing timeout");
Fl::remove_timeout(redrawCallback);
}
redrawInterval = newRedrawInterval; redrawInterval = newRedrawInterval;
} }
@ -59,24 +64,17 @@ int GUI_run(int argc, char **argv) {
} }
}); });
Fl::repeat_timeout((double) redrawInterval / 1000, refreshCallback, image); Fl::add_timeout(1.0, redrawCallback, image);
window->end(); window->end();
window->show(argc, argv); window->show(argc, argv);
return Fl::run(); return Fl::run();
} }
static void refreshCallback(void * pointer) { static void redrawCallback(void * pointer) {
auto *image = static_cast<Image*>(pointer); auto *image = static_cast<Image*>(pointer);
image->getPixels(); image->getPixels();
if(redrawInterval != -1) {
Fl::repeat_timeout((double) redrawInterval / 1000, redrawCallback, image);
}
}
static void redrawCallback(void * pointer) {
auto *image = static_cast<Image*>(pointer);
image->redraw(); image->redraw();
refreshCallback(image); Fl::repeat_timeout(redrawInterval / 1000.0, redrawCallback, image);
} }

View File

@ -13,17 +13,14 @@ auto GUI_Window::handle(int e) -> int {
mouse_status |= Mouse_Status::left_down; 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; 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; 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*/
@ -35,17 +32,14 @@ auto GUI_Window::handle(int e) -> int {
mouse_status &= Mouse_Status::left_up; 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; 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; 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:
@ -95,7 +89,6 @@ auto GUI_Window::handle(int e) -> int {
return 1; return 1;
case FL_KEYUP: case FL_KEYUP:
button = Fl::event_button(); button = Fl::event_button();
std::cout << button << std::endl;
keyCode = vkvm::KeyCode(button); keyCode = vkvm::KeyCode(button);
vkvm::buttonPressed(keyCode); vkvm::buttonPressed(keyCode);
vkvm::callEvent(vkvm::EventType::KeyUp); vkvm::callEvent(vkvm::EventType::KeyUp);