Files
AronaImGui/Arona/src/arona_application.cpp

85 lines
3.7 KiB
C++

#include "arona_application.h"
#include "window/window_manager.h"
#include "imgui.h"
#include "widget/widgets.h"
#include "audio/plugin_host/plugin_host_manager.h"
#include "audio/plugin_host/plugin_host.h"
application* g_application = nullptr;
std::string get_window_title() {
return "Arona";
}
void configure_imgui(ImGuiIO& io) {
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
io.ConfigViewportsNoAutoMerge = true;
// io.ConfigFlags |= ImGuiConfigFlags_DpiEnableScaleFonts; // Enable DPI scaling
// io.ConfigFlags |= ImGuiConfigFlags_DpiEnableScaleViewports; // Enable DPI scaling
// Setup Dear ImGui style
ImGui::StyleColorsClassic();
ImGuiStyle* style = &ImGui::GetStyle();
// style->TabRounding = 0;
// style->Colors[ImGuiCol_ButtonActive] = ImVec4(0.2f, 0.2f, 0.2f, 0.0f); // hide tab bar小三角使用此颜色, 如果想要隐藏, 就需要更改这个颜色
// ImGui::StyleColorsDark();
//ImGui::StyleColorsLight();
// get dpi scale
float dpi_scale = 1.5f;
// Load Fonts
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
// - Read 'docs/FONTS.md' for more instructions and details.
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
//io.Fonts->AddFontDefault();
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf", 24.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, nullptr, io.Fonts->GetGlyphRangesJapanese());
//IM_ASSERT(font != nullptr);
auto font = io.Fonts->AddFontFromFileTTF("resources/GenJyuuGothic-Normal-2.ttf", 18.f * dpi_scale);
}
void draw_imgui(float delta_time) {
// 全局dockspace
ImGui::DockSpaceOverViewport();
draw_instrument_track();
draw_mixer();
draw_selected_mixer_track_effect_list();
}
void tick_imgui(float delta_time) {
g_application->update_application();
}
arona_application::arona_application() {
g_application = this;
}
void arona_application::init() {
application::init();
}
void arona_application::shutdown() {
application::shutdown();
}
void arona_application::test() {
const char* path = R"(F:\VST\VST64\Serum_x64.dll)";
plugin_host* host = get_plugin_host_manager()->create_instrument_plugin_host(path);
host->try_open_editor();
}
arona_application* get_arona_application() {
return static_cast<arona_application*>(g_application);
}