~ 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
script:
- 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
- ls | grep -v current | xargs mv -t current
- git clone https://github.com/catchorg/Catch2.git
@ -57,7 +57,7 @@ cmake_build:
- docker-ci
script:
- 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
- ls | grep -v current | xargs mv -t current
- git clone https://github.com/catchorg/Catch2.git

View File

@ -13,25 +13,25 @@ int width;
int height;
static void redrawCallback(void * pointer);
static void refreshCallback(void * pointer);
int GUI_run(int argc, char **argv) {
vkvm::initialize(0);
//vkvm::setLogLevel(vkvm::LogLevel::DEBUG);
width = vkvm::getWidth();
height = vkvm::getHeight();
redrawInterval = vkvm::getRedrawInterval();
char *resolution = get_resolution(width, height);
std::cout << resolution << std::endl;
auto *window = new GUI_Window(width, height + 30, "vKVM GUI");
char * resolution = get_resolution(width, height);
vkvm::log(vkvm::LogLevel::DEBUG, resolution);
auto * window = new GUI_Window(width, height + 30, "vKVM GUI");
Statusbar *status[5];
window->begin();
auto *image = new Image(0, 30, width, height);
status[0] = new Statusbar(0, 0, 300, 30, resolution);
status[1] = new Statusbar(300, 0, 170, 30, "Event:");
status[2] = new Statusbar(470, 0, 200, 30, "Mouse Position:");
status[0] = new Statusbar(0, 0, 200, 30, resolution);
status[1] = new Statusbar(200, 0, 170, 30, "Event:");
status[2] = new Statusbar(400, 0, 170, 30, "Mouse Position:");
vkvm::registerEvent(vkvm::EventType::Redraw, [image]() {
image->getPixels();
image->redraw();
@ -39,9 +39,14 @@ int GUI_run(int argc, char **argv) {
vkvm::registerEvent(vkvm::EventType::UpdateControlRegisters, [image, window, status]() {
int newRedrawInterval = vkvm::getRedrawInterval();
if(newRedrawInterval != redrawInterval) {
/*if(redrawInterval == -1 && newRedrawInterval != -1) {
refreshCallback(image);
}*/
if(redrawInterval == -1 && newRedrawInterval != -1) {
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;
}
@ -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->show(argc, argv);
return Fl::run();
}
static void refreshCallback(void * pointer) {
static void redrawCallback(void * pointer) {
auto *image = static_cast<Image*>(pointer);
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();
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;
this->child(2)->label("Event:Mouse Left Down");
vkvm::callEvent(vkvm::EventType::MouseLeftDown);
// std::cout<<mouse_status<<std::endl;
} else if (Fl::event_button() == FL_RIGHT_MOUSE) {
mouse_status |= Mouse_Status::right_down;
this->child(2)->label("Event:Mouse Right Down");
vkvm::callEvent(vkvm::EventType::MouseRightDown);
// std::cout<<mouse_status<<std::endl;
} else {
mouse_status |= Mouse_Status::middle_down;
this->child(2)->label("Event:Mouse Middle Down");
vkvm::callEvent(vkvm::EventType::MouseMiddleDown);
// std::cout<<mouse_status<<std::endl;
}
return 1;
/*Mousebutton and movement*/
@ -35,17 +32,14 @@ auto GUI_Window::handle(int e) -> int {
mouse_status &= Mouse_Status::left_up;
this->child(2)->label("Event:Mouse Left Up");
vkvm::callEvent(vkvm::EventType::MouseLeftUp);
// std::cout<<mouse_status<<std::endl;
} else if (Fl::event_button() == FL_RIGHT_MOUSE) {
mouse_status &= Mouse_Status::right_up;
this->child(2)->label("Event:Mouse Right Up");
vkvm::callEvent(vkvm::EventType::MouseRightUp);
// std::cout<<mouse_status<<std::endl;
} else {
mouse_status &= Mouse_Status::middle_up;
this->child(2)->label("Event:Mouse Middle Up");
vkvm::callEvent(vkvm::EventType::MouseMiddleUp);
// std::cout<<mouse_status<<std::endl;
}
return 1;
case FL_DRAG:
@ -95,7 +89,6 @@ auto GUI_Window::handle(int e) -> int {
return 1;
case FL_KEYUP:
button = Fl::event_button();
std::cout << button << std::endl;
keyCode = vkvm::KeyCode(button);
vkvm::buttonPressed(keyCode);
vkvm::callEvent(vkvm::EventType::KeyUp);