优化字体显示效果

This commit is contained in:
Nanako 2024-07-10 22:18:57 +08:00
parent 0c18fe1db7
commit 1ab80e19db
4 changed files with 13 additions and 7 deletions

View File

@ -18,3 +18,8 @@ retrieve_files(${CMAKE_CURRENT_SOURCE_DIR}/src ALL_FILES)
add_executable(${PROJECT_NAME} ${ALL_FILES})
target_link_libraries(${PROJECT_NAME} imgui httplib)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
# windows
add_link_options(-mwindows)
# resourcesbuild
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

View File

@ -14,9 +14,11 @@ void configure_imgui(ImGuiIO& io) {
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
io.ConfigFlags |= ImGuiConfigFlags_DpiEnableScaleFonts;
io.ConfigFlags |= ImGuiConfigFlags_DpiEnableScaleViewports;
io.ConfigViewportsNoAutoMerge = true;
io.ConfigViewportsNoAutoMerge = false;
float dpi_scale = get_dpi_scale();
io.Fonts->AddFontFromFileTTF("resources/GenJyuuGothic-Normal-2.ttf", 18.0f * dpi_scale());
}
// 执行一些数据更新代码在这里

View File

@ -53,16 +53,15 @@ inline void draw_fan_infos() {
{
ImGui::Text("Fan %d: %d RPM", fan_info.id, fan_info.speed_rpm);
std::string label = "Speed##" + std::to_string(fan_info.id);
ImGui::SliderInt(label.c_str(), &fan_info.speed_percent, 0, 100);
ImGui::SliderInt(label.c_str(), &fan_info.speed_percent, 1, 100);
if (ImGui::IsItemDeactivatedAfterEdit()) {
// 更新风扇转速
fan_info.speed_percent = std::clamp(fan_info.speed_percent, 0, 100);
fan_info.speed_percent = std::clamp(fan_info.speed_percent, 1, 100);
task_executor<set_fan_speed_task>::run_task(fan_info.id, fan_info.speed_percent);
}
}
ImGui::EndDisabled();
}
ImGui::PopStyleColor();
}
}

2
third_party/imgui vendored

@ -1 +1 @@
Subproject commit 79b37f14318110c08d72c26003f622bf6bbdcb54
Subproject commit 329ba6af41be5736ff1a82943f746dc176ba9089