Settings fix
This commit is contained in:
@@ -81,6 +81,9 @@ namespace anm2ed::imgui
|
||||
constexpr auto FRAME_DRAG_PAYLOAD_ID = "Frame Drag Drop";
|
||||
constexpr auto FRAME_TOOLTIP_HOVER_DELAY = 0.75f; // Extra delay for frame info tooltip.
|
||||
|
||||
#define ITEM_FRAME_CHILD_HEIGHT ImGui::GetTextLineHeightWithSpacing() + (ImGui::GetStyle().WindowPadding.y * 1.5)
|
||||
#define ITEM_CHILD_WIDTH ImGui::GetTextLineHeightWithSpacing() * 12.5
|
||||
|
||||
void Timeline::update(Manager& manager, Settings& settings, Resources& resources, Clipboard& clipboard)
|
||||
{
|
||||
auto& document = *manager.get();
|
||||
@@ -573,8 +576,7 @@ namespace anm2ed::imgui
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, style.WindowPadding);
|
||||
|
||||
auto itemSize = ImVec2(ImGui::GetContentRegionAvail().x,
|
||||
ImGui::GetTextLineHeightWithSpacing() + (ImGui::GetStyle().WindowPadding.y * 2));
|
||||
auto itemSize = ImVec2(ImGui::GetContentRegionAvail().x, ITEM_FRAME_CHILD_HEIGHT);
|
||||
|
||||
if (ImGui::BeginChild(label.c_str(), itemSize, ImGuiChildFlags_Borders, ImGuiWindowFlags_NoScrollWithMouse))
|
||||
{
|
||||
@@ -818,7 +820,7 @@ namespace anm2ed::imgui
|
||||
|
||||
auto items_child = [&]()
|
||||
{
|
||||
auto itemsChildSize = ImVec2(ImGui::GetTextLineHeightWithSpacing() * 15, ImGui::GetContentRegionAvail().y);
|
||||
auto itemsChildSize = ImVec2(ITEM_CHILD_WIDTH, ImGui::GetContentRegionAvail().y);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2());
|
||||
bool isItemsChildOpen = ImGui::BeginChild("##Items Child", itemsChildSize, ImGuiChildFlags_Borders);
|
||||
@@ -938,7 +940,7 @@ namespace anm2ed::imgui
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, style.WindowPadding);
|
||||
|
||||
auto childSize = ImVec2(width, ImGui::GetTextLineHeightWithSpacing() + (ImGui::GetStyle().WindowPadding.y * 2));
|
||||
auto childSize = ImVec2(width, ITEM_FRAME_CHILD_HEIGHT);
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
@@ -1468,10 +1470,8 @@ namespace anm2ed::imgui
|
||||
|
||||
auto frames_child = [&]()
|
||||
{
|
||||
auto itemsChildWidth = ImGui::GetTextLineHeightWithSpacing() * 15;
|
||||
|
||||
auto cursorPos = ImGui::GetCursorPos();
|
||||
ImGui::SetCursorPos(ImVec2(cursorPos.x + itemsChildWidth, cursorPos.y));
|
||||
ImGui::SetCursorPos(ImVec2(cursorPos.x + ITEM_CHILD_WIDTH, cursorPos.y));
|
||||
|
||||
auto framesChildSize = ImVec2(ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y);
|
||||
|
||||
|
||||
@@ -212,7 +212,8 @@ namespace anm2ed
|
||||
ImGui::GetStyle().FontScaleMain = settings.uiScale;
|
||||
io.ConfigWindowsMoveFromTitleBarOnly = true;
|
||||
|
||||
ImGui::LoadIniSettingsFromDisk(settings_path().string().c_str());
|
||||
if (auto imguiData = Settings::imgui_data_load(settings_path()); !imguiData.empty())
|
||||
ImGui::LoadIniSettingsFromMemory(imguiData.c_str(), imguiData.size());
|
||||
|
||||
if (isSocketThread)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include "settings.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "filesystem_.h"
|
||||
#include "log.h"
|
||||
|
||||
@@ -9,9 +12,7 @@ namespace filesystem = anm2ed::util::filesystem;
|
||||
|
||||
namespace anm2ed
|
||||
{
|
||||
constexpr auto IMGUI_DEFAULT = R"(
|
||||
# Dear ImGui
|
||||
[Window][##DockSpace]
|
||||
constexpr auto IMGUI_DEFAULT = R"([Window][##DockSpace]
|
||||
Pos=0,54
|
||||
Size=1918,1010
|
||||
Collapsed=0
|
||||
@@ -268,6 +269,51 @@ DockSpace ID=0x123F8F08 Window=0x6D581B32 Pos=8,62 Size=1902,994 Spl
|
||||
file.close();
|
||||
}
|
||||
|
||||
std::string Settings::imgui_data_load(const std::filesystem::path& path)
|
||||
{
|
||||
auto pathUtf8 = filesystem::path_to_utf8(path);
|
||||
std::ifstream file(path, std::ios::in | std::ios::binary);
|
||||
if (!file.is_open())
|
||||
{
|
||||
logger.error(
|
||||
std::format("Failed to open settings file for Dear ImGui data: {}; using Dear ImGui defaults", pathUtf8));
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string line{};
|
||||
std::ostringstream dataStream;
|
||||
bool isImGuiSection = false;
|
||||
bool isContent = false;
|
||||
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
if (!isImGuiSection)
|
||||
{
|
||||
if (line == "# Dear ImGui") isImGuiSection = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isContent) dataStream << "\n";
|
||||
dataStream << line;
|
||||
isContent = true;
|
||||
}
|
||||
|
||||
if (!isImGuiSection)
|
||||
{
|
||||
logger.warning(
|
||||
std::format("Dear ImGui section missing from settings file: {}; using Dear ImGui defaults", pathUtf8));
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!isContent)
|
||||
{
|
||||
logger.warning(std::format("Dear ImGui section empty in settings file: {}; using Dear ImGui defaults", pathUtf8));
|
||||
return {};
|
||||
}
|
||||
|
||||
return dataStream.str();
|
||||
}
|
||||
|
||||
void Settings::save(const std::filesystem::path& path, const std::string& imguiData)
|
||||
{
|
||||
std::ofstream file(path, std::ios::out | std::ios::binary);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
@@ -250,6 +251,7 @@ namespace anm2ed
|
||||
|
||||
Settings(const std::filesystem::path&);
|
||||
void save(const std::filesystem::path&, const std::string&);
|
||||
static std::string imgui_data_load(const std::filesystem::path&);
|
||||
};
|
||||
|
||||
constexpr StringType SHORTCUT_STRING_TYPES[] = {
|
||||
|
||||
Reference in New Issue
Block a user