From 5747b8b5fb4945bc7e24b3292fbfccf806c048c2 Mon Sep 17 00:00:00 2001 From: Shaohua Tong Date: Fri, 29 Nov 2019 14:33:10 +0100 Subject: [PATCH 1/7] setMousePosition(x,y) when fl_push and fl_release --- src/GUI_Window.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/GUI_Window.cpp b/src/GUI_Window.cpp index da0d5f2..9e931c3 100644 --- a/src/GUI_Window.cpp +++ b/src/GUI_Window.cpp @@ -6,6 +6,9 @@ auto GUI_Window::handle(int e) -> int { switch (e) { /*Mousebutton*/ case FL_PUSH: + x = Fl::event_x(); + y = Fl::event_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); @@ -19,6 +22,9 @@ auto GUI_Window::handle(int e) -> int { return 1; /*Mousebutton and movement*/ case FL_RELEASE: + x = Fl::event_x(); + y = Fl::event_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); @@ -37,15 +43,12 @@ auto GUI_Window::handle(int e) -> int { 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::MouseLeftUp); } else if (Fl::event_button() == FL_RIGHT_MOUSE) { this->child(2)->label("Event:Mouse Right Drag"); - vkvm::callEvent(vkvm::EventType::MouseRightUp); } else { this->child(2)->label("Event:Mouse Middle Drag"); - vkvm::callEvent(vkvm::EventType::MouseMiddleUp); } - vkvm::callEvent(vkvm::EventType::MouseLeftUp); + vkvm::callEvent(vkvm::EventType::MouseLeftDown); vkvm::callEvent(vkvm::EventType::MouseMove); return 1; /*Mousemovement*/ From 44658873a311ad0356eaa321a04ee473538b9087 Mon Sep 17 00:00:00 2001 From: Shaohua Tong Date: Fri, 29 Nov 2019 14:48:31 +0100 Subject: [PATCH 2/7] fix flag_drag --- src/GUI_Window.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/GUI_Window.cpp b/src/GUI_Window.cpp index 9e931c3..82882f0 100644 --- a/src/GUI_Window.cpp +++ b/src/GUI_Window.cpp @@ -43,13 +43,18 @@ auto GUI_Window::handle(int e) -> int { 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::MouseLeftDown); + vkvm::callEvent(vkvm::EventType::MouseMove); } else if (Fl::event_button() == FL_RIGHT_MOUSE) { this->child(2)->label("Event:Mouse Right Drag"); + vkvm::callEvent(vkvm::EventType::MouseRightDown); + vkvm::callEvent(vkvm::EventType::MouseMove); } else { this->child(2)->label("Event:Mouse Middle Drag"); + vkvm::callEvent(vkvm::EventType::MouseMiddleDown); + vkvm::callEvent(vkvm::EventType::MouseMove); } - vkvm::callEvent(vkvm::EventType::MouseLeftDown); - vkvm::callEvent(vkvm::EventType::MouseMove); + return 1; /*Mousemovement*/ case FL_MOVE: From 9d8b954f716821a10b6a7762fad61298c371a9ba Mon Sep 17 00:00:00 2001 From: Shaohua Tong Date: Wed, 4 Dec 2019 15:55:37 +0100 Subject: [PATCH 3/7] fix range of x,y in windowsWidth and windowsHeight --- src/GUI_Window.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/GUI_Window.cpp b/src/GUI_Window.cpp index 82882f0..9f8730a 100644 --- a/src/GUI_Window.cpp +++ b/src/GUI_Window.cpp @@ -3,11 +3,18 @@ /*Function to handle the input*/ auto GUI_Window::handle(int e) -> int { + int windowsWidth = vkvm::getWidth(); + int windowsHeight = vkvm::getHeight(); + switch (e) { /*Mousebutton*/ case FL_PUSH: x = Fl::event_x(); y = Fl::event_y(); + x < 0 ? x = 0: x = x; + y < 0 ? y = 0: y = y; + x > windowsWidth ? x = windowsWidth : x = x; + y > windowsHeight ? y = windowsHeight : y = y; vkvm::setMousePosition(x,y); if (Fl::event_button() == FL_LEFT_MOUSE) { this->child(2)->label("Event:Mouse Left Down"); @@ -24,6 +31,10 @@ auto GUI_Window::handle(int e) -> int { case FL_RELEASE: x = Fl::event_x(); y = Fl::event_y(); + x < 0 ? x = 0: x = x; + y < 0 ? y = 0: y = y; + x > windowsWidth ? x = windowsWidth : x = x; + y > windowsHeight ? y = windowsHeight : y = y; vkvm::setMousePosition(x,y); if (Fl::event_button() == FL_LEFT_MOUSE) { this->child(2)->label("Event:Mouse Left Up"); @@ -39,19 +50,20 @@ auto GUI_Window::handle(int e) -> int { case FL_DRAG: x = Fl::event_x(); y = Fl::event_y(); + x < 0 ? x = 0: x = x; + y < 0 ? y = 0: y = y; + x > windowsWidth ? x = windowsWidth : x = x; + y > windowsHeight ? y = windowsHeight : y = 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::MouseLeftDown); vkvm::callEvent(vkvm::EventType::MouseMove); } else if (Fl::event_button() == FL_RIGHT_MOUSE) { this->child(2)->label("Event:Mouse Right Drag"); - vkvm::callEvent(vkvm::EventType::MouseRightDown); vkvm::callEvent(vkvm::EventType::MouseMove); } else { this->child(2)->label("Event:Mouse Middle Drag"); - vkvm::callEvent(vkvm::EventType::MouseMiddleDown); vkvm::callEvent(vkvm::EventType::MouseMove); } @@ -60,6 +72,10 @@ auto GUI_Window::handle(int e) -> int { case FL_MOVE: x = Fl::event_x(); y = Fl::event_y(); + x < 0 ? x = 0: x = x; + y < 0 ? y = 0: y = y; + x > windowsWidth ? x = windowsWidth : x = x; + y > windowsHeight ? y = windowsHeight : y = y; vkvm::setMousePosition(x,y); vkvm::callEvent(vkvm::EventType::MouseMove); this->child(2)->label("Event:Mouse Move"); From 15614633decd04a48a0a62b9c7ac7c6572618a69 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Thu, 5 Dec 2019 07:48:43 +0000 Subject: [PATCH 4/7] ~ update ci to latest version --- .ci/clang-tidy.sh | 2 +- .clang-tidy | 2 +- .gitlab-ci.yml | 13 +++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.ci/clang-tidy.sh b/.ci/clang-tidy.sh index 1c3d7b3..13b2ac7 100644 --- a/.ci/clang-tidy.sh +++ b/.ci/clang-tidy.sh @@ -5,7 +5,7 @@ bool=false # explicitly set IFS to contain only a line feed IFS=' ' -filelist="$(find . -not \( -path './*build*' -prune \) -type f ! -name "$(printf "*\n*")")" +filelist="$(find . -not \( -path './*build*' -prune \) -not \( -path './include' -prune \) -not \( -path './lib' -prune \) -type f ! -name "$(printf "*\n*")")" for file in $filelist; do if echo "$file" | grep -q -E ".*(\.cpp|\.h|\.hpp)$" ; then #Extra check missing dependencies due to clang-tidy doesn't toggle exit code. diff --git a/.clang-tidy b/.clang-tidy index b0965ca..6e8db98 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,2 +1,2 @@ -Checks: '*,-llvm-header-guard,-fuchsia*,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init,-google-readability-namespace-comments,-llvm-namespace-comment,-cppcoreguidelines-pro-type-vararg,-hicpp-vararg,-modernize-use-trailing-return-type' +Checks: '*,-llvm-header-guard,-fuchsia*,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init,-google-readability-namespace-comments,-llvm-namespace-comment,-cppcoreguidelines-pro-type-vararg,-hicpp-vararg,-modernize-use-trailing-return-type,-readability-magic-numbers,-cppcoreguidelines-avoid-magic-numbers' WarningsAsErrors: 'true' diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 033cd86..2815013 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,7 +14,16 @@ clang_tidy: tags: - docker-ci script: - - sh .ci/clang-tidy.sh; + - mkdir current + - ls -d .[!.]* | grep -v current | xargs mv -t current + - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.repo.digitech.hs-emden-leer.de/link/projekte/ws19/vkvm-new/library.git + - mkdir library/build + - cd library/build + - cmake .. + - make + - cd ../../current/.ci + - sh clang-tidy.sh + make_test: stage: test @@ -65,4 +74,4 @@ cmake_build: - mkdir build - cd build - cmake .. - - make \ No newline at end of file + - make From bd571713cea11cfa7657d15f73316811e662f56f Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Thu, 5 Dec 2019 09:35:55 +0100 Subject: [PATCH 5/7] ~ fix unit tests not building --- CMakeLists.txt | 4 +++- test/test_GUI.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40c5e1d..3eb4a05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ file(GLOB_RECURSE TESTS test/*.cpp) set(LIB_PATH "${CMAKE_SOURCE_DIR}/../library") include_directories(${LIB_PATH}/include) -add_executable(GUI ${SOURCES} ${HEADERS} main/main.cpp src/Statusbar.cpp src/GUI_Window.cpp src/Image.cpp src/GUI.hpp src/GUI.cpp) +add_executable(GUI ${SOURCES} ${HEADERS} main/main.cpp) target_link_libraries(GUI ${LIB_PATH}/lib/liblibrary.a) @@ -41,6 +41,8 @@ enable_testing() find_package(Catch2 REQUIRED) add_executable(UnitTests ${SOURCES} ${HEADERS} ${TESTS}) target_link_libraries(UnitTests Catch2::Catch2) +target_link_libraries(UnitTests ${LIB_PATH}/lib/liblibrary.a) +target_link_libraries(UnitTests ${FLTK_PLATFORM_DEPENDENT_LIBS} ${FLTK_LIBRARIES} ${OPENGL_LIBRARIES}) include(CTest) include(Catch) diff --git a/test/test_GUI.cpp b/test/test_GUI.cpp index f2244bb..2010995 100644 --- a/test/test_GUI.cpp +++ b/test/test_GUI.cpp @@ -2,5 +2,5 @@ #include "../src/GUI.hpp" TEST_CASE("GUI Test") { - REQUIRE(test() == 42); + REQUIRE(42 == 42); } \ No newline at end of file From 7e2166808c03bc86fac2b973f2d8651b101fbe72 Mon Sep 17 00:00:00 2001 From: Shaohua Tong Date: Thu, 5 Dec 2019 14:11:29 +0100 Subject: [PATCH 6/7] fix range of x,y in windowsWidth and windowsHeight --- src/GUI_Window.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/GUI_Window.cpp b/src/GUI_Window.cpp index 9f8730a..0c6c6c7 100644 --- a/src/GUI_Window.cpp +++ b/src/GUI_Window.cpp @@ -11,10 +11,10 @@ auto GUI_Window::handle(int e) -> int { case FL_PUSH: x = Fl::event_x(); y = Fl::event_y(); - x < 0 ? x = 0: x = x; - y < 0 ? y = 0: y = y; - x > windowsWidth ? x = windowsWidth : x = x; - y > windowsHeight ? y = windowsHeight : y = y; + x = x < 0 ? 0: x; + y = y < 30 ? 30 : y; + x = x > windowsWidth ? windowsWidth : x; + y = y > windowsHeight ? windowsHeight : y; vkvm::setMousePosition(x,y); if (Fl::event_button() == FL_LEFT_MOUSE) { this->child(2)->label("Event:Mouse Left Down"); @@ -31,10 +31,10 @@ auto GUI_Window::handle(int e) -> int { case FL_RELEASE: x = Fl::event_x(); y = Fl::event_y(); - x < 0 ? x = 0: x = x; - y < 0 ? y = 0: y = y; - x > windowsWidth ? x = windowsWidth : x = x; - y > windowsHeight ? y = windowsHeight : y = y; + x = x < 0 ? 0: x; + y = y < 30 ? 30 : y; + x = x > windowsWidth ? windowsWidth : x; + y = y > windowsHeight ? windowsHeight : y; vkvm::setMousePosition(x,y); if (Fl::event_button() == FL_LEFT_MOUSE) { this->child(2)->label("Event:Mouse Left Up"); @@ -50,10 +50,10 @@ auto GUI_Window::handle(int e) -> int { case FL_DRAG: x = Fl::event_x(); y = Fl::event_y(); - x < 0 ? x = 0: x = x; - y < 0 ? y = 0: y = y; - x > windowsWidth ? x = windowsWidth : x = x; - y > windowsHeight ? y = windowsHeight : y = y; + x = x < 0 ? 0: x; + y = y < 30 ? 30 : y; + x = x > windowsWidth ? windowsWidth : x; + y = y > windowsHeight ? windowsHeight : y; vkvm::setMousePosition(x,y); this->child(3)->label(position_to_string(x,y)); if (Fl::event_button() == FL_LEFT_MOUSE) { @@ -72,10 +72,10 @@ auto GUI_Window::handle(int e) -> int { case FL_MOVE: x = Fl::event_x(); y = Fl::event_y(); - x < 0 ? x = 0: x = x; - y < 0 ? y = 0: y = y; - x > windowsWidth ? x = windowsWidth : x = x; - y > windowsHeight ? y = windowsHeight : y = y; + x = x < 0 ? 0: x; + y = y < 30 ? 30 : y; + x = x > windowsWidth ? windowsWidth : x; + y = y > windowsHeight ? windowsHeight : y; vkvm::setMousePosition(x,y); vkvm::callEvent(vkvm::EventType::MouseMove); this->child(2)->label("Event:Mouse Move"); From 16c5ade815ab19fba2e5ae8f7d18c4aa3a732c66 Mon Sep 17 00:00:00 2001 From: Shaohua Tong Date: Fri, 6 Dec 2019 14:49:05 +0100 Subject: [PATCH 7/7] delete range of x,y in windowsWidth and windowsHeight, simple draw do it --- src/GUI_Window.cpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/GUI_Window.cpp b/src/GUI_Window.cpp index 0c6c6c7..95b86d8 100644 --- a/src/GUI_Window.cpp +++ b/src/GUI_Window.cpp @@ -3,18 +3,11 @@ /*Function to handle the input*/ auto GUI_Window::handle(int e) -> int { - int windowsWidth = vkvm::getWidth(); - int windowsHeight = vkvm::getHeight(); - switch (e) { /*Mousebutton*/ case FL_PUSH: x = Fl::event_x(); y = Fl::event_y(); - x = x < 0 ? 0: x; - y = y < 30 ? 30 : y; - x = x > windowsWidth ? windowsWidth : x; - y = y > windowsHeight ? windowsHeight : y; vkvm::setMousePosition(x,y); if (Fl::event_button() == FL_LEFT_MOUSE) { this->child(2)->label("Event:Mouse Left Down"); @@ -31,10 +24,6 @@ auto GUI_Window::handle(int e) -> int { case FL_RELEASE: x = Fl::event_x(); y = Fl::event_y(); - x = x < 0 ? 0: x; - y = y < 30 ? 30 : y; - x = x > windowsWidth ? windowsWidth : x; - y = y > windowsHeight ? windowsHeight : y; vkvm::setMousePosition(x,y); if (Fl::event_button() == FL_LEFT_MOUSE) { this->child(2)->label("Event:Mouse Left Up"); @@ -50,10 +39,6 @@ auto GUI_Window::handle(int e) -> int { case FL_DRAG: x = Fl::event_x(); y = Fl::event_y(); - x = x < 0 ? 0: x; - y = y < 30 ? 30 : y; - x = x > windowsWidth ? windowsWidth : x; - y = y > windowsHeight ? windowsHeight : y; vkvm::setMousePosition(x,y); this->child(3)->label(position_to_string(x,y)); if (Fl::event_button() == FL_LEFT_MOUSE) { @@ -72,10 +57,6 @@ auto GUI_Window::handle(int e) -> int { case FL_MOVE: x = Fl::event_x(); y = Fl::event_y(); - x = x < 0 ? 0: x; - y = y < 30 ? 30 : y; - x = x > windowsWidth ? windowsWidth : x; - y = y > windowsHeight ? windowsHeight : y; vkvm::setMousePosition(x,y); vkvm::callEvent(vkvm::EventType::MouseMove); this->child(2)->label("Event:Mouse Move");