lua+cpp+html+css+js

This commit is contained in:
OSK\schmidt
2024-12-04 14:12:18 +01:00
parent 2a2b0dbbcc
commit 0b04ea0ac2
8 changed files with 76 additions and 9 deletions

8
.gitmodules vendored
View File

@@ -1,3 +1,9 @@
[submodule "lib/saucer"]
path = lib/saucer
url = https://github.com/saucer/saucer.git
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

View File

@@ -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)

30
inc/modules/hwnd_module.h Normal file
View File

@@ -0,0 +1,30 @@
//
// Created by schmidt on 04.12.2024.
//
#ifndef HWND_MODULE_H
#define HWND_MODULE_H
#include <saucer/modules/native/webview2.hpp> // 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<hwnd_module>);
#endif //HWND_MODULE_H

1
lib/lua Submodule

Submodule lib/lua added at ca210c56ae

1
lib/saucer Submodule

Submodule lib/saucer added at 7e9c730adc

1
lib/sol2 Submodule

Submodule lib/sol2 added at 2b0d2fe8ba

View File

@@ -1,10 +1,10 @@
#include <iostream>
#include <saucer/smartview.hpp>
#include <saucer/webview.hpp>
#include <saucer/wv2.webview.impl.hpp>
#include <windows.h>
#include "modules/hwnd_module.h"
#include "all.hpp"
#include <sol/sol.hpp>
int main(int argc, char** argv)
{
@@ -24,14 +24,24 @@ int main(int argc, char** argv)
return 1;
}
saucer::smartview webview{{
saucer::smartview<saucer::default_serializer, hwnd_module> 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<hwnd_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();
}

View File

@@ -0,0 +1,5 @@
//
// Created by schmidt on 04.12.2024.
//
#include "modules/hwnd_module.h"