diff --git a/src/Gui/GuiLayout.cpp b/src/Gui/GuiLayout.cpp index 5241d2b..76c6872 100644 --- a/src/Gui/GuiLayout.cpp +++ b/src/Gui/GuiLayout.cpp @@ -28,7 +28,7 @@ #include "Panes/FinalFontPane.h" #include "Panes/GlyphPane.h" #include "Panes/GeneratorPane.h" - +#include "Panes/FontStructurePane.h" #ifdef _DEBUG #include "Panes/DebugPane.h" #endif @@ -46,6 +46,7 @@ void GuiLayout::Init() if (!FileHelper::Instance()->IsFileExist("imgui.ini")) { m_FirstLayout = true; // need default layout + LogStr("We will apply default layout :)"); } } @@ -94,6 +95,7 @@ void GuiLayout::ApplyInitialDockingLayout(ImVec2 vSize) ImGui::DockBuilderDockWindow(GENERATOR_PANE, dockRightID); // dockGeneratorID ImGui::DockBuilderDockWindow(CURRENT_FONT_PANE, dockRightID); // dockSelectionID ImGui::DockBuilderDockWindow(GLYPH_PANE, dockMainID); + ImGui::DockBuilderDockWindow(FONT_STRUCTURE_PANE, dockMainID); #ifdef _DEBUG ImGui::DockBuilderDockWindow(DEBUG_PANE, dockRightID); #endif @@ -122,6 +124,7 @@ void GuiLayout::DisplayMenu(ImVec2 vSize) ImGui::MenuItem("Show/Hide Final Pane", "", &m_Pane_Shown, PaneFlags::PANE_FINAL); ImGui::MenuItem("Show/Hide Generator Pane", "", &m_Pane_Shown, PaneFlags::PANE_GENERATOR); ImGui::MenuItem("Show/Hide Glyph Pane", "", &m_Pane_Shown, PaneFlags::PANE_GLYPH); + ImGui::MenuItem("Show/Hide Font Structure Pane", "", &m_Pane_Shown, PaneFlags::PANE_FONT_STRUCTURE); #ifdef _DEBUG ImGui::MenuItem("Show/Hide Debug Pane", "", &m_Pane_Shown, PaneFlags::PANE_DEBUG); #endif @@ -137,6 +140,7 @@ int GuiLayout::DisplayPanes(ProjectFile *vProjectFile, int vWidgetId) vWidgetId = FinalFontPane::Instance()->DrawCurrentFontPane(vProjectFile, vWidgetId); vWidgetId = GeneratorPane::Instance()->DrawGeneratorPane(vProjectFile, vWidgetId); vWidgetId = GlyphPane::Instance()->DrawGlyphPane(vProjectFile, vWidgetId); + vWidgetId = FontStructurePane::Instance()->DrawFontStructurePane(vProjectFile, vWidgetId); #ifdef _DEBUG vWidgetId = DebugPane::Instance()->DrawDebugPane(vProjectFile, vWidgetId); #endif @@ -154,6 +158,7 @@ void GuiLayout::ShowAndFocusPane(PaneFlags vPane) else if (vPane == PaneFlags::PANE_PARAM) ActivePane(PARAM_PANE); else if (vPane == PaneFlags::PANE_GENERATOR) ActivePane(GENERATOR_PANE); else if (vPane == PaneFlags::PANE_GLYPH) ActivePane(GLYPH_PANE); + else if (vPane == PaneFlags::PANE_FONT_STRUCTURE) ActivePane(FONT_STRUCTURE_PANE); #ifdef _DEBUG else if (vPane == PaneFlags::PANE_DEBUG) ActivePane(DEBUG_PANE); #endif @@ -167,6 +172,7 @@ bool GuiLayout::IsPaneActive(PaneFlags vPane) else if (vPane == PaneFlags::PANE_PARAM) return IsPaneActive(PARAM_PANE); else if (vPane == PaneFlags::PANE_GENERATOR) return IsPaneActive(GENERATOR_PANE); else if (vPane == PaneFlags::PANE_GLYPH) return IsPaneActive(GLYPH_PANE); + else if (vPane == PaneFlags::PANE_FONT_STRUCTURE) return IsPaneActive(FONT_STRUCTURE_PANE); #ifdef _DEBUG else if (vPane == PaneFlags::PANE_DEBUG) return IsPaneActive(DEBUG_PANE); #endif @@ -213,14 +219,14 @@ std::string GuiLayout::getXml(const std::string& vOffset) void GuiLayout::setFromXml(tinyxml2::XMLElement* vElem, tinyxml2::XMLElement* vParent) { // The value of this child identifies the name of this element - std::string strName = ""; - std::string strValue = ""; - std::string strParentName = ""; + std::string strName; + std::string strValue; + std::string strParentName; strName = vElem->Value(); if (vElem->GetText()) strValue = vElem->GetText(); - if (vParent != 0) + if (vParent != nullptr) strParentName = vParent->Value(); if (strParentName == "layout") diff --git a/src/Gui/GuiLayout.h b/src/Gui/GuiLayout.h index 65cd3ae..a92e019 100644 --- a/src/Gui/GuiLayout.h +++ b/src/Gui/GuiLayout.h @@ -25,6 +25,7 @@ #define GENERATOR_PANE "Generator" #define CURRENT_FONT_PANE "Current Font" #define GLYPH_PANE "Glyph Edition" +#define FONT_STRUCTURE_PANE "Font Structure" #ifdef _DEBUG #define DEBUG_PANE "Debug" #endif @@ -38,6 +39,7 @@ enum PaneFlags PANE_PARAM = (1 << 4), PANE_GENERATOR = (1 << 5), PANE_GLYPH = (1 << 6), + PANE_FONT_STRUCTURE = (1 << 7), #ifdef _DEBUG PANE_DEBUG = (1 << 7), #endif diff --git a/src/Panes/FontStructurePane.cpp b/src/Panes/FontStructurePane.cpp new file mode 100644 index 0000000..da521c7 --- /dev/null +++ b/src/Panes/FontStructurePane.cpp @@ -0,0 +1,88 @@ +// This is an open source non-commercial project. Dear PVS-Studio, please check it. +// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + +/* + * Copyright 2020 Stephane Cuillerdier (aka Aiekick) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "FontStructurePane.h" + +#include "MainFrame.h" + +#include "Gui/GuiLayout.h" +#include "Gui/ImGuiWidgets.h" + +#define IMGUI_DEFINE_MATH_OPERATORS +#include "imgui_internal.h" + +#include +#include + +#include // printf zu + +static int FontStructurePane_WidgetId = 0; + +FontStructurePane::FontStructurePane() = default; +FontStructurePane::~FontStructurePane() = default; + +/////////////////////////////////////////////////////////////////////////////////// +//// IMGUI PANE /////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////// + +int FontStructurePane::DrawFontStructurePane(ProjectFile *vProjectFile, int vWidgetId) +{ + FontStructurePane_WidgetId = vWidgetId; + + if (GuiLayout::m_Pane_Shown & PaneFlags::PANE_FONT_STRUCTURE) + { + if (ImGui::Begin(FONT_STRUCTURE_PANE, + &GuiLayout::m_Pane_Shown, PaneFlags::PANE_DEBUG, + //ImGuiWindowFlags_NoTitleBar | + //ImGuiWindowFlags_MenuBar | + //ImGuiWindowFlags_NoMove | + ImGuiWindowFlags_NoCollapse | + //ImGuiWindowFlags_NoResize | + ImGuiWindowFlags_NoBringToFrontOnFocus)) + { + if (vProjectFile && vProjectFile->IsLoaded()) + { + if (ImGui::Button("Analyse Font")) + { + AnalyzeFont(vProjectFile->m_ProjectFilePathName); + } + + FontStructurePane_WidgetId = DisplayAnalyze(FontStructurePane_WidgetId); + } + } + + ImGui::End(); + } + + return FontStructurePane_WidgetId; +} + +/////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////// + +void FontStructurePane::AnalyzeFont(const std::string& vFilePathName) +{ + +} + +int FontStructurePane::DisplayAnalyze(int vWidgetId) +{ + +} \ No newline at end of file diff --git a/src/Panes/FontStructurePane.h b/src/Panes/FontStructurePane.h new file mode 100644 index 0000000..f4ea829 --- /dev/null +++ b/src/Panes/FontStructurePane.h @@ -0,0 +1,44 @@ +/* + * Copyright 2020 Stephane Cuillerdier (aka Aiekick) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +class ProjectFile; +class FontInfos; +class FontStructurePane +{ + public: + int DrawFontStructurePane(ProjectFile *vProjectFile, int vWidgetId); + + private: + void AnalyzeFont(const std::string& vFilePathName); + int DisplayAnalyze(int vWidgetId); + + public: // singleton + static FontStructurePane *Instance() + { + static auto *_instance = new FontStructurePane(); + return _instance; + } + + protected: + FontStructurePane(); // Prevent construction + FontStructurePane(const FontStructurePane&) = default; // Prevent construction by copying + FontStructurePane& operator =(const FontStructurePane&) { return *this; }; // Prevent assignment + ~FontStructurePane(); // Prevent unwanted destruction +};