diff --git a/.gitmodules b/.gitmodules index 463c9f3..ecc5f3d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,9 @@ [submodule "lib/saucer"] path = lib/saucer - url = https://github.com/saucer/saucer.git \ No newline at end of file + url = https://github.com/saucer/saucer.git +[submodule "lib/sol2"] + path = lib/sol2 + url = https://github.com/ThePhD/sol2.git +[submodule "lib/lua"] + path = lib/lua + url = https://github.com/lubgr/lua-cmake.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 8115741..d764396 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,13 +3,17 @@ project(Toolbox) set(CMAKE_CXX_STANDARD 23) set(saucer_no_version_check ON) +set(BUILD_SHARED_LIBS OFF) + add_subdirectory(lib/saucer) +add_subdirectory(lib/lua) +add_subdirectory(lib/sol2) include_directories(inc) include_directories(out_embed) file(GLOB_RECURSE SOURCES "src/*.cpp" "inc/*.h") -add_executable(Toolbox main.cpp) +add_executable(Toolbox main.cpp ${SOURCES}) -target_link_libraries(Toolbox PRIVATE saucer::saucer) +target_link_libraries(Toolbox PRIVATE saucer::saucer sol2::sol2 lua) diff --git a/inc/modules/hwnd_module.h b/inc/modules/hwnd_module.h new file mode 100644 index 0000000..adca9a5 --- /dev/null +++ b/inc/modules/hwnd_module.h @@ -0,0 +1,30 @@ +// +// Created by schmidt on 04.12.2024. +// + +#ifndef HWND_MODULE_H +#define HWND_MODULE_H + + + +#include // Für Windows mit WebView2 + +class hwnd_module { + saucer::natives m_natives; + saucer::smartview_core *m_smartview; + +public: + hwnd_module(saucer::smartview_core *smartview, saucer::natives natives) + : m_natives(natives), m_smartview(smartview) {} + + HWND get_hwnd() { + auto [window, webview] = m_natives; + return window->hwnd.get(); + } +}; + +static_assert(saucer::Module); + + + +#endif //HWND_MODULE_H diff --git a/lib/lua b/lib/lua new file mode 160000 index 0000000..ca210c5 --- /dev/null +++ b/lib/lua @@ -0,0 +1 @@ +Subproject commit ca210c56ae41ff13b20490cca8be5ead47b24196 diff --git a/lib/saucer b/lib/saucer new file mode 160000 index 0000000..7e9c730 --- /dev/null +++ b/lib/saucer @@ -0,0 +1 @@ +Subproject commit 7e9c730adcb46f90e38e193c2135ae6ed621ec95 diff --git a/lib/sol2 b/lib/sol2 new file mode 160000 index 0000000..2b0d2fe --- /dev/null +++ b/lib/sol2 @@ -0,0 +1 @@ +Subproject commit 2b0d2fe8ba0074e16b499940c4f3126b9c7d3471 diff --git a/main.cpp b/main.cpp index 5b8e37b..fefbb7c 100644 --- a/main.cpp +++ b/main.cpp @@ -1,10 +1,10 @@ #include #include #include -#include #include - +#include "modules/hwnd_module.h" #include "all.hpp" +#include int main(int argc, char** argv) { @@ -24,14 +24,24 @@ int main(int argc, char** argv) return 1; } - saucer::smartview webview{{ + saucer::smartview webview({ .application = app, - }}; + }); webview.set_size(400, 600); webview.set_force_dark_mode(true); - //webview.start_drag(true); - //SendMessage(webview.native(), nullptr,2, 2, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + int screenWidth = GetSystemMetrics(SM_CXSCREEN); + int screenHeight = GetSystemMetrics(SM_CYSCREEN); + int xPos = screenWidth - 400; // 400 ist die Fensterbreite + int yPos = screenHeight - 42 - 600; // 600 ist die Fensterhöhe + + // Zugriff auf das native Fenster-Handle + HWND hwnd = webview.module().get_hwnd(); + if (hwnd) { + // Setze die Fensterposition auf (x: 100, y: 100) + SetWindowPos(hwnd, nullptr, xPos, yPos, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + } + // Erstelle ein WebView-Fenster webview.expose( @@ -50,6 +60,15 @@ int main(int argc, char** argv) // Zeige das Fenster an webview.show(); + // Lua-Umgebung erstellen + sol::state lua; + // Standardbibliotheken öffnen + lua.open_libraries(sol::lib::base); + // Weitere Implementierung folgt... + // Lua-Code ausführen + lua.script("print('Hallo von Lua!')"); + + // Starte die Saucer-Anwendung app->run(); } diff --git a/src/modules/hwnd_module.cpp b/src/modules/hwnd_module.cpp new file mode 100644 index 0000000..1bf0cea --- /dev/null +++ b/src/modules/hwnd_module.cpp @@ -0,0 +1,5 @@ +// +// Created by schmidt on 04.12.2024. +// + +#include "modules/hwnd_module.h"