Skip to content

Commit

Permalink
Add a pane for analyse Font Structure (just the prototype for now)
Browse files Browse the repository at this point in the history
Can be important for check if Font Format is bad or not.
regarding lat issue #7 on merged font generation.
very difficult to see here is the error
  • Loading branch information
aiekick committed May 15, 2020
1 parent dd530b1 commit 4feb532
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Gui/GuiLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 :)");
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -122,6 +124,7 @@ void GuiLayout::DisplayMenu(ImVec2 vSize)
ImGui::MenuItem<PaneFlags>("Show/Hide Final Pane", "", &m_Pane_Shown, PaneFlags::PANE_FINAL);
ImGui::MenuItem<PaneFlags>("Show/Hide Generator Pane", "", &m_Pane_Shown, PaneFlags::PANE_GENERATOR);
ImGui::MenuItem<PaneFlags>("Show/Hide Glyph Pane", "", &m_Pane_Shown, PaneFlags::PANE_GLYPH);
ImGui::MenuItem<PaneFlags>("Show/Hide Font Structure Pane", "", &m_Pane_Shown, PaneFlags::PANE_FONT_STRUCTURE);
#ifdef _DEBUG
ImGui::MenuItem<PaneFlags>("Show/Hide Debug Pane", "", &m_Pane_Shown, PaneFlags::PANE_DEBUG);
#endif
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions src/Gui/GuiLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
88 changes: 88 additions & 0 deletions src/Panes/FontStructurePane.cpp
Original file line number Diff line number Diff line change
@@ -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 <cTools.h>
#include <FileHelper.h>

#include <cinttypes> // 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<PaneFlags>(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)
{

}
44 changes: 44 additions & 0 deletions src/Panes/FontStructurePane.h
Original file line number Diff line number Diff line change
@@ -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 <string>

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
};

0 comments on commit 4feb532

Please sign in to comment.