切换到硬件加速的GUI Gtk
This commit is contained in:
parent
5e8552e44b
commit
f94a035408
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
/build
|
||||
/.idea
|
||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,6 +1,3 @@
|
||||
[submodule "AronaCore"]
|
||||
path = AronaCore
|
||||
url = http://www.nanako.site:9004/Nanako/AronaCore.git
|
||||
[submodule "Arona/third_party/wxWidgets"]
|
||||
path = Arona/third_party/wxWidgets
|
||||
url = https://github.com/wxWidgets/wxWidgets.git
|
||||
|
@ -4,14 +4,19 @@ set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# 设置Windows应用程序的入口点
|
||||
if (WIN32)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:WinMainCRTStartup")
|
||||
endif()
|
||||
#if (WIN32)
|
||||
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:WinMainCRTStartup")
|
||||
#endif()
|
||||
|
||||
set(wxBUILD_CXX_STANDARD 20 CACHE STRING "C++ standard to use (20 or 17)" FORCE)
|
||||
set(wxBUILD_SHARED OFF CACHE BOOL "Build shared libraries" FORCE)
|
||||
# 添加wxWidget子目录
|
||||
add_subdirectory(third_party/wxWidgets)
|
||||
# 查找gtkmm库
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTKMM REQUIRED gtkmm-4.0)
|
||||
include_directories(${GTKMM_INCLUDE_DIRS})
|
||||
link_directories(${GTKMM_LIBRARY_DIRS})
|
||||
add_definitions(${GTKMM_CFLAGS_OTHER})
|
||||
|
||||
# 隐藏控制台窗口
|
||||
add_link_options(-mwindows)
|
||||
|
||||
# 遍历添加源文件
|
||||
set(ALL_FILES "")
|
||||
@ -22,15 +27,14 @@ add_executable(${PROJECT_NAME} ${ALL_FILES})
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
|
||||
# 添加链接库
|
||||
target_link_libraries(${PROJECT_NAME} core wx::core wx::base)
|
||||
add_definitions(-DwxUSE_DPI_AWARE_MANIFEST=2)
|
||||
if (WIN32)
|
||||
target_sources(${PROJECT_NAME} PRIVATE "manifest.rc")
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/MANIFEST:NO")
|
||||
endif ()
|
||||
if (APPLE)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/info.plist)
|
||||
endif ()
|
||||
target_link_libraries(${PROJECT_NAME} core ${GTKMM_LIBRARIES})
|
||||
#if (WIN32)
|
||||
# target_sources(${PROJECT_NAME} PRIVATE "manifest.rc")
|
||||
# set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/MANIFEST:NO")
|
||||
#endif ()
|
||||
#if (APPLE)
|
||||
# set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/info.plist)
|
||||
#endif ()
|
||||
#install(
|
||||
# TARGETS ${PROJECT_NAME} DESTINATION
|
||||
# RESOURCE DESTINATION ../bin/resources)
|
||||
|
@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>$(PRODUCT_NAME) version 3.3.0, (c) 2005-2024 wxWidgets</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>wxmac.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleLongVersionString</key>
|
||||
<string>3.3.0, (c) 2005-2024 wxWidgets</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>3.3.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>3.3.0</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright 2005-2024 wxWidgets</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>wxNSApplication</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
@ -1,3 +0,0 @@
|
||||
#include <winuser.h>
|
||||
|
||||
1 24 "manifest.xml"
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity
|
||||
version="1.0.0.0"
|
||||
processorArchitecture="*"
|
||||
name="CompanyName.ProductName.YourApp"
|
||||
type="win32"
|
||||
/>
|
||||
<description>Your application description here.</description>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
</assembly>
|
18
Arona/src/arona_application.cpp
Normal file
18
Arona/src/arona_application.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "arona_application.h"
|
||||
#include "widget/main_frame.h"
|
||||
|
||||
void arona_application::tick(float delta_time) {
|
||||
|
||||
}
|
||||
|
||||
void arona_application::init() {
|
||||
application::init();
|
||||
}
|
||||
|
||||
void arona_application::shutdown() {
|
||||
application::shutdown();
|
||||
}
|
||||
|
||||
arona_application* get_application() {
|
||||
return static_cast<arona_application*>(g_application);
|
||||
}
|
@ -1,35 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "application/application.h"
|
||||
#include "widget/mixer/w_mixer_track.h"
|
||||
|
||||
class arona_application : public application {
|
||||
public:
|
||||
~arona_application() override = default;
|
||||
|
||||
void tick(float delta_time) override {
|
||||
void tick(float delta_time) override;
|
||||
|
||||
}
|
||||
void init() override;
|
||||
|
||||
void init(const char* runtime_dir) override {
|
||||
application::init(runtime_dir);
|
||||
init_window();
|
||||
}
|
||||
void shutdown() override;
|
||||
|
||||
void shutdown() override {
|
||||
application::shutdown();
|
||||
}
|
||||
|
||||
void init_window() {
|
||||
|
||||
}
|
||||
protected:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
inline arona_application* get_application() {
|
||||
return static_cast<arona_application*>(g_application);
|
||||
}
|
||||
inline arona_application* get_application();
|
||||
|
@ -1,84 +1,24 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "arona_application.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/frame.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#include "wx/menu.h"
|
||||
#include "wx/sysopt.h"
|
||||
#include "gtkmm.h"
|
||||
|
||||
enum {
|
||||
ID_Hello = 1
|
||||
};
|
||||
|
||||
class test_frame : public wxFrame {
|
||||
class hello_world : public Gtk::Window {
|
||||
public:
|
||||
test_frame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
: wxFrame(nullptr, wxID_ANY, title, pos, size) {
|
||||
SetFont(wxFont(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, "Arial"));
|
||||
|
||||
auto menu_file = new wxMenu;
|
||||
menu_file->Append(ID_Hello, "&Hello...\tCtrl-H",
|
||||
"Help string shown in status bar for this menu item");
|
||||
menu_file->AppendSeparator();
|
||||
menu_file->Append(wxID_EXIT);
|
||||
|
||||
auto menu_help = new wxMenu;
|
||||
menu_help->Append(wxID_ABOUT);
|
||||
|
||||
auto menu_bar = new wxMenuBar;
|
||||
menu_bar->Append(menu_file, "&File");
|
||||
menu_bar->Append(menu_help, "&Help");
|
||||
|
||||
wxFrameBase::SetMenuBar(menu_bar);
|
||||
wxFrameBase::CreateStatusBar();
|
||||
wxFrameBase::SetStatusText("Welcome to wxWidgets!");
|
||||
GetHandle();
|
||||
hello_world() {
|
||||
button_.set_margin(10);
|
||||
button_.signal_clicked().connect(sigc::mem_fun(*this, &hello_world::on_button_clicked));
|
||||
set_child(button_);
|
||||
}
|
||||
private:
|
||||
void OnHello(wxCommandEvent& event) {
|
||||
wxMessageBox("Hello world from wxWidgets!");
|
||||
void on_button_clicked() {
|
||||
std::cout << "hello, gtk!" << std::endl;
|
||||
}
|
||||
void OnExit(wxCommandEvent& event) {
|
||||
Close(true);
|
||||
}
|
||||
void OnAbout(wxCommandEvent& event) {
|
||||
wxMessageBox("This is a wxWidgets' Hello world sample",
|
||||
"About Hello World", wxOK | wxICON_INFORMATION);
|
||||
}
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
Gtk::Button button_;
|
||||
};
|
||||
wxBEGIN_EVENT_TABLE(test_frame, wxFrame)
|
||||
EVT_MENU(ID_Hello, test_frame::OnHello)
|
||||
EVT_MENU(wxID_EXIT, test_frame::OnExit)
|
||||
EVT_MENU(wxID_ABOUT, test_frame::OnAbout)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
class arona_app : public wxApp {
|
||||
public:
|
||||
bool OnInit() override {
|
||||
if (!wxApp::OnInit())
|
||||
return false;
|
||||
// 设置高DPI支持
|
||||
#if PLATFORM_WINDOWS
|
||||
if (wxPlatformInfo::Get().CheckOSVersion(10, 0)) {
|
||||
wxSystemOptions::SetOption("msw.highdpi.support", 1);
|
||||
}
|
||||
#endif
|
||||
#if PLATFORM_LINUX
|
||||
if (wxPlatformInfo::Get().GetOperatingSystemId() == wxOS_UNIX_LINUX) {
|
||||
wxSystemOptions::SetOption("gtk.window.force-hidpi", 1);
|
||||
}
|
||||
#endif
|
||||
int main(int argc, char* argv[]) {
|
||||
auto app = Gtk::Application::create("org.gtkmm.example");
|
||||
return app->make_window_and_run<hello_world>(argc, argv);
|
||||
}
|
||||
|
||||
arona.init(nullptr);
|
||||
const auto frame = new test_frame(_("Display wxWidgets Sample"), wxPoint(50, 50), wxSize(450, 340));
|
||||
frame->Show(true);
|
||||
return true;
|
||||
}
|
||||
int OnExit() override {
|
||||
arona.shutdown();
|
||||
return wxApp::OnExit();
|
||||
}
|
||||
private:
|
||||
arona_application arona;
|
||||
};
|
||||
wxIMPLEMENT_APP(arona_app);
|
||||
|
4
Arona/src/widget/main_frame.cpp
Normal file
4
Arona/src/widget/main_frame.cpp
Normal file
@ -0,0 +1,4 @@
|
||||
#include "main_frame.h"
|
||||
|
||||
#include "workspace/workspace_window.h"
|
||||
#include "sample_manager/sample_manager_window.h"
|
5
Arona/src/widget/main_frame.h
Normal file
5
Arona/src/widget/main_frame.h
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
class main_frame {
|
||||
|
||||
};
|
@ -0,0 +1 @@
|
||||
#include "sample_manager_window.h"
|
5
Arona/src/widget/sample_manager/sample_manager_window.h
Normal file
5
Arona/src/widget/sample_manager/sample_manager_window.h
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
class sample_manager_window {
|
||||
public:
|
||||
};
|
4
Arona/src/widget/workspace/workspace_window.cpp
Normal file
4
Arona/src/widget/workspace/workspace_window.cpp
Normal file
@ -0,0 +1,4 @@
|
||||
#include "workspace_window.h"
|
||||
|
||||
workspace_window::workspace_window() {
|
||||
}
|
6
Arona/src/widget/workspace/workspace_window.h
Normal file
6
Arona/src/widget/workspace/workspace_window.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
class workspace_window {
|
||||
public:
|
||||
workspace_window();
|
||||
};
|
1
Arona/third_party/wxWidgets
vendored
1
Arona/third_party/wxWidgets
vendored
@ -1 +0,0 @@
|
||||
Subproject commit ffd7e7dc86868f522299f2f0055fd426b89c3517
|
@ -1 +1 @@
|
||||
Subproject commit cb6d4125cfa3ff7b1bd121ddc02c877ac84a4933
|
||||
Subproject commit b1955202cfea31d930e86be69a0ecf2105c9afab
|
Loading…
x
Reference in New Issue
Block a user