Dokumentation | Demos | Andere Bibliotheken
Cross Window ist eine Abstraktionsbibliothek für Cross -Plattform -Systeme zur Verwaltung von Windows und zur Ausführung von Betriebssystemaufgaben. Es ist so konzipiert, dass es einfach zu integrieren, intuitiv zu intuitiv ist und alles unterstützt, was Sie möglicherweise für Ihre Apps benötigen.
? Einfaches Fenster, Dateidialog und Meldungsdialog Erstellung.
⌨️? Mt? ? Grundeingabe (Tastatur, Maus, Berührung und Gamepad).
? Plattformspezifische Funktionen (MAC -Transparenz, mobiles Beschleunigungsmesser usw.).
? Unit-Tests + Testabdeckung (Appveyor für Windows , Circleci für Android / macOS / iOS , [Travis] [Travis-URL] für Linux / Noop ).
Windows - Win32
? MAC - Cocoa
ios - UIKit
? Linux - XCB oder XLib
? Android (in Arbeit)
WebAssembly - Emscripten
Noop (kopflos)
Fügen Sie zuerst das Repo als Submodul in Ihren Abhängigkeitsordner hinzu, wie z. external/ :
# ⤵️ Add your dependency as a git submodule:
git submodule add https://github.com/alaingalvan/crosswindow.git external/crosswindow In Ihrer Datei CMakeLists.txt finden Sie dann Folgendes an:
# ⤵️ Add to your CMake Project:
add_subdirectory (external/crosswindow)
# ❎ When creating your executable use CrossWindow's abstraction function:
xwin_add_executable(
# Target
${PROJECT_NAME}
# Source Files (make sure to surround in quotations so CMake treats it as a list)
" ${SOURCE_FILES} "
)
# ? Link CrossWindow to your project:
target_link_libraries (
${PROJECT_NAME}
CrossWindow
) Füllen Sie den Rest Ihrer Datei CMakeLists.txt mit allen anderen Quelldateien und Abhängigkeiten aus, die Sie möglicherweise haben, und dann in Ihrem Projektroot:
# ?️ To build your Visual Studio solution on Windows x64
cmake -B build -A x64
# ? To build your XCode project On Mac OS for Mac OS
cmake -B build -G Xcode
# To build your XCode project on Mac OS for iOS / iPad OS / tvOS / watchOS
cmake -B build -G Xcode -DCMAKE_SYSTEM_NAME=iOS
# ? To build your .make file on Linux
cmake -B build
# ? Build on any platform:
cmake -B build --buildFür WebAssembly müssen Sie Emscripten installieren lassen. Unter der Annahme, dass die SDK installiert ist, machen Sie Folgendes, um ein WebAssembly -Projekt zu erstellen:
# For WebAssembly Projects
mkdir webassembly
cd webassembly
cmake .. -DXWIN_OS=WASM -DCMAKE_TOOLCHAIN_FILE= " $EMSDK /emscripten/1.38.1/cmake/Modules/Platform/Emscripten.cmake " -DCMAKE_BUILD_TYPE=Release
# Run emconfigure with the normal configure command as an argument.
$EMSDK /emscripten/emconfigure ./configure
# Run emmake with the normal make to generate linked LLVM bitcode.
$EMSDK /emscripten/emmake make
# Compile the linked bitcode generated by make (project.bc) to JavaScript.
# 'project.bc' should be replaced with the make output for your project (e.g. 'yourproject.so')
$EMSDK /emscripten/emcc project.bc -o project.jsWeitere Informationen finden Sie in den EMSCIPTEN -Dokumenten auf CMake.
Für Android Studio müssen Sie ein Projekt erstellen und dann Ihre build.gradle -Datei bearbeiten.
// ? To build your Android Studio project
android {
.. .
externalNativeBuild {
cmake {
.. .
// Use the following syntax when passing arguments to variables:
// arguments "-DVAR_NAME=ARGUMENT".
arguments " -DXWIN_OS=ANDROID " ,
// The following line passes 'rtti' and 'exceptions' to 'ANDROID_CPP_FEATURES'.
" -DANDROID_CPP_FEATURES=rtti exceptions "
}
}
buildTypes { .. . }
// Use this block to link Gradle to your CMake build script.
externalNativeBuild {
cmake { .. . }
}
}Weitere Informationen finden Sie in den Dokios von Android Studios auf CMake.
Erstellen Sie dann eine Hauptdelegate -Funktion void xmain(int argc, const char** argv) in einer .cpp -Datei in Ihrem Projekt (z. B. " XMain.cpp "), in dem Sie Ihre Anwendungslogik einsetzen:
# include " CrossWindow/CrossWindow.h "
void xmain ( int argc, const char ** argv)
{
// ?️ Create Window Description
xwin::WindowDesc windowDesc;
windowDesc. name = " Test " ;
windowDesc. title = " My Title " ;
windowDesc. visible = true ;
windowDesc. width = 1280 ;
windowDesc. height = 720 ;
bool closed = false ;
// ? Initialize
xwin::Window window;
xwin::EventQueue eventQueue;
if (!window. create (windowDesc, eventQueue))
{ return ; }
// ? Engine loop
bool isRunning = true ;
while (isRunning)
{
// ♻️ Update the event queue
eventQueue. update ();
// ? Iterate through that queue:
while (!eventQueue. empty ())
{
const xwin::Event& event = eventQueue. front ();
if (event. type == xwin::EventType::MouseInput)
{
const xwin::MouseInputData mouse = event. data . mouseInput ;
}
if (event. type == xwin::EventType::Close)
{
window. close ();
isRunning = false ;
}
eventQueue. pop ();
}
}
} Diese xmain -Funktion wird von einer plattformspezifischen Hauptfunktion aufgerufen, die von CMake in Ihr Hauptprojekt aufgenommen wird. Wenn Sie aus irgendeinem Grund jemals von der plattformspezifischen Hauptfunktion auf etwas zugreifen müssen, finden Sie es in xwin::getXWinState() .
Achten Sie darauf, dass CMake installiert ist.
| CMAKE -Optionen | Beschreibung |
|---|---|
XWIN_TESTS | Ob Unit -Tests aktiviert sind oder nicht. OFF können ON oder OFF sein. |
XWIN_API | Die OS -API, die für die Fenstergenerierung verwendet werden soll, kann standardmäßig AUTO sein, kann NOOP , WIN32 , COCOA , UIKIT , XCB , ANDROID oder WASM sein. |
XWIN_OS | Optional - für welches Betriebssystem zu erstellen ist, fungiert als schnellere Möglichkeit, Zielplattformen festzulegen. Standardeinstellungen zu AUTO können NOOP , WINDOWS , MACOS , LINUX , ANDROID , IOS , WASM sein. Wenn Ihre Plattform mehrere APIs unterstützt, wird die endgültige API automatisch auf Crosswindow -Standardeinstellungen festgelegt ( WIN32 unter Windows, XCB unter Linux). Wenn XWIN_API festgelegt wird, wird diese Option ignoriert. |
Installieren Sie zuerst Git und öffnen Sie dann ein beliebiges Terminal in einem beliebigen Ordner und Typ: Typ:
# ? Clone the repo
git clone https://github.com/alaingalvan/crosswindow.git --recurse-submodules
# ? go inside the folder
cd crosswindow
# ? If you forget to `recurse-submodules` you can always run:
git submodule update --init
Von dort aus müssen wir unsere Build -Dateien einrichten. Stellen Sie sicher, dass Sie die folgenden Installation haben:
Cmake
Eine IDE wie Visual Studio, Xcode oder ein Compiler wie GCC.
Geben Sie dann Folgendes in Ihr Terminal aus dem Repo -Ordner ein:
# ?️ To build your Visual Studio solution on Windows x64
cmake -B build -A x64 -DXWIN_TESTS=ON
# ? To build your XCode project on Mac OS
cmake -B build -G Xcode -DXWIN_TESTS=ON
# ? To build your .make file on Linux
cmake -B build -DXWIN_TESTS=ON
# ? Build on any platform:
cmake -B build --build Wenn Sie dem Projekt neue Dateien hinzufügen, führen Sie cmake .. Aus Ihrem Lösung/Projektordner /build/ , und wenn Sie die CMakeLists.txt -Datei bearbeiten, löschen Sie die generierten Dateien und führen Sie CMake erneut aus.
Crosswindow ist entweder als MIT oder Apache-2.0 lizenziert, je nachdem, was Sie bevorzugen würden.