Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ jobs:
name: Windows Installer
path: |
build/packages/*.*
41 changes: 36 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,43 @@ if(Git_FOUND)
add_compile_definitions(GIT_SHA1="${GIT_SHA1}")
endif()

if (WIN32 OR APPLE)
include(glfw)
else() # Linux
find_package(glfw3 REQUIRED)
set(GLFW_LIBRARIES glfw)
# 从源码构建 GLFW
include(ExternalProject)

# 尝试使用 HTTP 下载 GLFW 源码,而不是 Git 克隆
ExternalProject_Add(glfw PREFIX glfw
URL https://github.com/glfw/glfw/archive/refs/tags/3.3.5.zip
URL_HASH SHA256=59977c65188c2a43f2c50a4c6bd8f3a3d31a1761b07c572f40604bcf7123b92d

UPDATE_COMMAND ""

CMAKE_ARGS
"-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
"-DCMAKE_BUILD_TYPE=Release"
"-DGLFW_BUILD_EXAMPLES=OFF"
"-DGLFW_BUILD_TESTS=OFF"
"-DGLFW_BUILD_DOCS=OFF"
"-DUSE_MSVC_RUNTIME_LIBRARY_DLL=OFF"

CMAKE_CACHE_ARGS
"-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}"
"-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}"

LOG_DOWNLOAD 1 LOG_UPDATE 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1
)

ExternalProject_Get_Property(glfw INSTALL_DIR)
set(GLFW_INCLUDE_DIR ${INSTALL_DIR}/include)
set(GLFW_LIBRARIES
${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}glfw3${CMAKE_STATIC_LIBRARY_SUFFIX})

if(APPLE)
list(APPEND GLFW_LIBRARIES "-framework Cocoa" "-framework IOKit" "-framework CoreVideo")
endif()

set(GLFW_INCLUDE_DIR ${GLFW_INCLUDE_DIR} CACHE STRING "")
set(GLFW_LIBRARIES ${GLFW_LIBRARIES} CACHE STRING "")

find_package(OpenGL REQUIRED)
find_package(Threads REQUIRED)

Expand All @@ -41,6 +71,7 @@ if (WIN32)
add_compile_definitions(NOMINMAX)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
add_compile_definitions(_SCL_SECURE_NO_WARNINGS)
add_compile_options(/utf-8)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:mainCRTStartup")
else()
find_program(CCACHE_FOUND ccache)
Expand Down
55 changes: 24 additions & 31 deletions cmake/glfw.cmake
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
# 尝试使用系统已安装的 GLFW 库
find_package(GLFW 3.3.5 QUIET)

if(GLFW_FOUND)
message(STATUS "Found GLFW")
else()
message(STATUS "GLFW not found - will build from source")
include(ExternalProject)

ExternalProject_Add(glfw PREFIX glfw
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG 3.3.5

UPDATE_COMMAND ""

CMAKE_ARGS
"-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
"-DCMAKE_BUILD_TYPE=Release"
"-DGLFW_BUILD_EXAMPLES=OFF"
"-DGLFW_BUILD_TESTS=OFF"
"-DGLFW_BUILD_DOCS=OFF"
"-DUSE_MSVC_RUNTIME_LIBRARY_DLL=OFF"

CMAKE_CACHE_ARGS
"-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}"
"-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}"

LOG_DOWNLOAD 1 LOG_UPDATE 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1
)

ExternalProject_Get_Property(glfw INSTALL_DIR)
set(GLFW_INCLUDE_DIR ${INSTALL_DIR}/include)
set(GLFW_LIBRARIES
${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}glfw3${CMAKE_STATIC_LIBRARY_SUFFIX})

if(APPLE)
list(APPEND GLFW_LIBRARIES "-framework Cocoa" "-framework IOKit" "-framework CoreVideo")
message(STATUS "GLFW not found - will use local source")

# 设置本地 GLFW 源码目录
set(GLFW_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/third-party/glfw")

# 检查 GLFW 源码是否存在
if (EXISTS "${GLFW_SOURCE_DIR}")
# 使用本地 GLFW 源码
add_subdirectory(${GLFW_SOURCE_DIR})
set(GLFW_INCLUDE_DIR ${GLFW_SOURCE_DIR}/include)
set(GLFW_LIBRARIES glfw)
message(STATUS "Using local GLFW source")
else()
# 如果本地没有 GLFW 源码,则尝试使用 VCPKG 安装的 GLFW
if (DEFINED ENV{VCPKG_ROOT})
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")
find_package(glfw3 REQUIRED)
set(GLFW_LIBRARIES glfw)
message(STATUS "Using VCPKG GLFW library")
else()
# 如果本地没有 GLFW 源码,也没有 VCPKG,则显示错误消息
message(FATAL_ERROR "GLFW not found. Please install GLFW or download GLFW source to ${GLFW_SOURCE_DIR}")
endif()
endif()
endif()

Expand Down
11 changes: 11 additions & 0 deletions src/main_glfw_opengl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ int main(int argc, char *argv[])
IMGUI_CHECKVERSION();
ImGui::CreateContext();

// Add Chinese font support
ImGuiIO& io = ImGui::GetIO();
// Add Chinese font as default
#ifdef _WIN32
// Use system Chinese font
io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\simhei.ttf", 14.0f, NULL, io.Fonts->GetGlyphRangesChineseFull());
#else
// Fallback to default font on non-Windows systems
io.Fonts->AddFontDefault();
#endif

MainWindowStyle();

ImGui_ImplGlfw_InitForOpenGL(glwindow, true);
Expand Down
70 changes: 35 additions & 35 deletions src/sources/ims_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ void ImStudio::BufferWindow::drawall()
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.08f, 0.09f, 0.09f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.26f, 0.59f, 0.98f, 0.40f));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.86f, 0.86f, 0.86f, 0.50f));
ImGui::Begin("buffer", &state);
ImGui::Begin("缓冲区", &state);
size = ImGui::GetWindowSize();
pos = ImGui::GetWindowPos();
{
// Draw gl cursor when dragging
// 拖动时绘制光标
if (ImGui::IsMouseDown(0))
{
ImGui::GetIO().MouseDrawCursor = true;
Expand All @@ -28,7 +28,7 @@ void ImStudio::BufferWindow::drawall()
ImGui::GetIO().MouseDrawCursor = false;
}

//HOTKEY: ALT + M - "Add" Context Menu
// 热键: ALT + M - "添加" 上下文菜单
if ((ImGui::IsWindowHovered()) &&
((ImGui::IsKeyDown(ImGuiKey_ModAlt) && (ImGui::IsKeyPressed(ImGuiKey_M))) ||
(ImGui::IsWindowHovered() && ImGui::IsMouseClicked(1))))
Expand All @@ -38,67 +38,67 @@ void ImStudio::BufferWindow::drawall()
}
if (ImGui::BeginPopupContextWindow("bwcontextmenu"))
{
if (ImGui::BeginMenu("Add"))
if (ImGui::BeginMenu("添加"))
{
if (ImGui::BeginMenu("Primitives"))
if (ImGui::BeginMenu("基础组件"))
{
if (ImGui::MenuItem("Button"))
if (ImGui::MenuItem("按钮"))
create("button",1);
if (ImGui::MenuItem("Radio Button"))
if (ImGui::MenuItem("单选按钮"))
create("radio",1);
if (ImGui::MenuItem("Checkbox"))
if (ImGui::MenuItem("复选框"))
create("checkbox",1);
if (ImGui::MenuItem("Text"))
if (ImGui::MenuItem("文本"))
create("text",1);
if (ImGui::MenuItem("Bullet"))
if (ImGui::MenuItem("项目符号"))
create("bullet",1);
if (ImGui::MenuItem("Arrow"))
if (ImGui::MenuItem("箭头"))
create("arrow",1);
if (ImGui::MenuItem("Combo"))
if (ImGui::MenuItem("下拉菜单"))
create("combo",1);
if (ImGui::MenuItem("Listbox"))
if (ImGui::MenuItem("列表框"))
create("listbox",1);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Data Inputs"))
if (ImGui::BeginMenu("数据输入"))
{
if (ImGui::MenuItem("Input Text"))
if (ImGui::MenuItem("文本输入"))
create("textinput",1);
if (ImGui::MenuItem("Input Int"))
if (ImGui::MenuItem("整数输入"))
create("inputint",1);
if (ImGui::MenuItem("Input Float"))
if (ImGui::MenuItem("浮点数输入"))
create("inputfloat",1);
if (ImGui::MenuItem("Input Double"))
if (ImGui::MenuItem("双精度输入"))
create("inputdouble",1);
if (ImGui::MenuItem("Input Scientific"))
if (ImGui::MenuItem("科学计数法输入"))
create("inputscientific",1);
if (ImGui::MenuItem("Input Float3"))
if (ImGui::MenuItem("三维向量输入"))
create("inputfloat3",1);
if (ImGui::MenuItem("Drag Int"))
if (ImGui::MenuItem("拖动整数"))
create("dragint",1);
if (ImGui::MenuItem("Drag Int %"))
if (ImGui::MenuItem("拖动整数百分比"))
create("dragint100",1);
if (ImGui::MenuItem("Drag Float"))
if (ImGui::MenuItem("拖动浮点数"))
create("dragfloat",1);
if (ImGui::MenuItem("Drag Float Small"))
if (ImGui::MenuItem("拖动小浮点数"))
create("dragfloatsmall",1);
if (ImGui::MenuItem("Slider Int"))
if (ImGui::MenuItem("滑块整数"))
create("sliderint",1);
if (ImGui::MenuItem("Slider Float"))
if (ImGui::MenuItem("滑块浮点数"))
create("sliderfloat",1);
if (ImGui::MenuItem("Slider Float Log"))
if (ImGui::MenuItem("对数滑块"))
create("sliderfloatlog",1);
if (ImGui::MenuItem("Slider Angle"))
if (ImGui::MenuItem("角度滑块"))
create("sliderangle",1);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Color Pickers"))
if (ImGui::BeginMenu("颜色选择器"))
{
if (ImGui::MenuItem("Color 1"))
if (ImGui::MenuItem("颜色 1"))
create("color1",1);
if (ImGui::MenuItem("Color 2"))
if (ImGui::MenuItem("颜色 2"))
create("color2",1);
if (ImGui::MenuItem("Color 3"))
if (ImGui::MenuItem("颜色 3"))
create("color3",1);
ImGui::EndMenu();
}
Expand Down Expand Up @@ -175,7 +175,7 @@ void ImStudio::BufferWindow::create(std::string type_, bool atcursor)
(getbaseobj(open_child_id)) &&
(getobj(open_child_id)->child.open)))
{
// no child window open
// 没有打开子窗口
Object widget(idgen, type_);
if (atcursor)
{
Expand All @@ -185,9 +185,9 @@ void ImStudio::BufferWindow::create(std::string type_, bool atcursor)
}
else
{
// child window open
// 打开子窗口
BaseObject childwidget(idgen, type_, open_child_id);
getobj(open_child_id)->child.objects.push_back(childwidget);
}
selected_obj_id = idgen; // select the new object
selected_obj_id = idgen; // 选择新对象
}
Loading