Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

261 standardize font selector window #262

Merged
merged 13 commits into from
Jul 4, 2022
2 changes: 1 addition & 1 deletion Source/Core/Editor/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ GUISystem::GUISystem(ERS_STRUCT_SystemUtils* SystemUtils, GLFWwindow* Window, Cu

// Setup WindowManager Class
WindowManager_ = std::make_unique<ERS_CLASS_WindowManager>(SystemUtils_);
WindowManager_->GenerateWindowStruct(ProjectUtils_, HIDUtils_, VisualRenderer_, ThemeManager_.get(), Cursors3D_, SceneManager_);
WindowManager_->GenerateWindowStruct(ProjectUtils_, HIDUtils_, VisualRenderer_, ThemeManager_.get(), FontManager_.get(), Cursors3D_, SceneManager_);


// Initialize Windows
Expand Down
4 changes: 1 addition & 3 deletions Source/Core/Editor/Menus/GUI_Menu_View/GUI_Menu_View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void GUI_Menu_View::Draw() {
}

if (ImGui::MenuItem("System Font")) {
ShowFontPicker_ = true;
Windows_->GUI_Window_FontSelector_->Enabled_ = !Windows_->GUI_Window_FontSelector_->Enabled_;
}

ImGui::Separator();
Expand All @@ -47,7 +47,5 @@ void GUI_Menu_View::Draw() {
}


// Draw Windows
FontManager_->FontSelectorWindow(&ShowFontPicker_);

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ class ERS_CLASS_FontManager {
ERS_CLASS_LoggingSystem* Logger_; /**<ERS_CLASS_LoggingSystem Instance Pointer*/
const char* FontsDirectoryPath_; /**<Path where fonts are to be searched for */

bool EndsWith(const std::string& Input, const std::string& Ending);

public:

std::vector<std::string> FontPathList_; /**<List of fonts located at the given paths*/
std::vector<std::string> FontNameList_; /**<List of font names for gui rendering*/

float FontSize_ = 14; /**<Set Default Font Size In Pixels*/
int FontSelector_ = 0; /**<Set Font Selector Int*/
bool UpdateFont_ = false; /**<Indicate If Font Needs To Be Updated*/

bool EndsWith(const std::string& Input, const std::string& Ending);

public:

ERS_CLASS_FontManager(ERS_CLASS_LoggingSystem* Logger, const char* FontsDirPath = "EditorAssets/Fonts");
~ERS_CLASS_FontManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ target_link_libraries(ERS_Editor_WindowManager
GUI_Window_SystemLog
GUI_Window_TestEditor
GUI_Window_ThemeSelector
GUI_Window_FontSelector

)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ERS_CLASS_WindowManager::~ERS_CLASS_WindowManager() {

// Setup Window Struct
void ERS_CLASS_WindowManager::GenerateWindowStruct(ERS_STRUCT_ProjectUtils* ProjectUtils, ERS_STRUCT_HumanInputDeviceUtils* HIDUtils, ERS_CLASS_VisualRenderer* VisualRenderer,
ERS_CLASS_ThemeManager* ThemeManager, Cursors3D* Gizmo, ERS_CLASS_SceneManager* SceneManager) {
ERS_CLASS_ThemeManager* ThemeManager, ERS_CLASS_FontManager* FontManager, Cursors3D* Gizmo, ERS_CLASS_SceneManager* SceneManager) {

// Setup Window System
SystemUtils_->Logger_->Log("WindowManager Subsystem Setting Up Window Struct", 4);
Expand All @@ -54,6 +54,7 @@ ERS_CLASS_ThemeManager* ThemeManager, Cursors3D* Gizmo, ERS_CLASS_SceneManager*
Windows_->GUI_Window_SystemLog_ = std::make_unique<GUI_Window_SystemLog>(SystemUtils_);
Windows_->GUI_Window_TestEditor_ = std::make_unique<GUI_Window_TestEditor>(SystemUtils_);
Windows_->GUI_Window_ThemeSelector_ = std::make_unique<GUI_Window_ThemeSelector>(ThemeManager);
Windows_->GUI_Window_FontSelector_ = std::make_unique<GUI_Window_FontSelector>(FontManager);

SystemUtils_->Logger_->Log("WindowManager Subsystem Finished Setting Up Window Struct", 3);
SystemUtils_->Logger_->Log("WindowManager Subsystem Setting Up Window Index", 4);
Expand All @@ -77,6 +78,7 @@ ERS_CLASS_ThemeManager* ThemeManager, Cursors3D* Gizmo, ERS_CLASS_SceneManager*
WindowNames_.push_back("SystemLog");
WindowNames_.push_back("TestEditor");
WindowNames_.push_back("ThemeSelector");
WindowNames_.push_back("FontSelector");

SystemUtils_->Logger_->Log("WindowManager Subsystem Finished Setting Up Window Index", 3);

Expand Down Expand Up @@ -107,7 +109,8 @@ void ERS_CLASS_WindowManager::UpdateAllWindows() {
Windows_->GUI_Window_SystemLog_->Draw();
Windows_->GUI_Window_TestEditor_->Draw();
Windows_->GUI_Window_ThemeSelector_->Draw();

Windows_->GUI_Window_FontSelector_->Draw();

}

bool ERS_CLASS_WindowManager::SetWindowStatus(std::string WindowName, bool Status) {
Expand Down Expand Up @@ -171,6 +174,9 @@ bool ERS_CLASS_WindowManager::SetWindowStatus(std::string WindowName, bool Statu
} else if (WindowName == "ThemeSelector") {
Windows_->GUI_Window_ThemeSelector_->Enabled_ = Status;
return true;
} else if (WindowName == "FontSelector") {
Windows_->GUI_Window_FontSelector_->Enabled_ = Status;
return true;
} else {
return false;
}
Expand Down Expand Up @@ -238,6 +244,9 @@ bool ERS_CLASS_WindowManager::GetWindowStatus(std::string WindowName, bool* Stat
} else if (WindowName == "ThemeSelector") {
*Status = Windows_->GUI_Window_ThemeSelector_->Enabled_;
return true;
} else if (WindowName == "FontSelector") {
*Status = Windows_->GUI_Window_FontSelector_->Enabled_;
return true;
} else {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <ERS_CLASS_VisualRenderer.h>

#include <ERS_Editor_ThemeManager.h>
#include <ERS_Editor_FontManager.h>
#include <ERS_Editor_3DCursor.h>


Expand All @@ -41,6 +42,7 @@
#include <GUI_Window_SystemLog.h>
#include <GUI_Window_TestEditor.h>
#include <GUI_Window_ThemeSelector.h>
#include <GUI_Window_FontSelector.h>



Expand Down Expand Up @@ -81,7 +83,7 @@ class ERS_CLASS_WindowManager {
*
*/
void GenerateWindowStruct(ERS_STRUCT_ProjectUtils* ProjectUtils, ERS_STRUCT_HumanInputDeviceUtils* HIDUtils, ERS_CLASS_VisualRenderer* VisualRenderer,
ERS_CLASS_ThemeManager* ThemeManager, Cursors3D* Gizmo, ERS_CLASS_SceneManager* SceneManager);
ERS_CLASS_ThemeManager* ThemeManager, ERS_CLASS_FontManager* FontManager, Cursors3D* Gizmo, ERS_CLASS_SceneManager* SceneManager);


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <GUI_Window_SystemLog.h>
#include <GUI_Window_TestEditor.h>
#include <GUI_Window_ThemeSelector.h>
#include <GUI_Window_FontSelector.h>

/**
* @brief This structure holds unique pointers to all windows that are instantiated by the GUI.
Expand Down Expand Up @@ -57,5 +58,6 @@ struct ERS_STRUCT_Windows {
std::unique_ptr<GUI_Window_SystemLog> GUI_Window_SystemLog_;
std::unique_ptr<GUI_Window_TestEditor> GUI_Window_TestEditor_;
std::unique_ptr<GUI_Window_ThemeSelector> GUI_Window_ThemeSelector_;
std::unique_ptr<GUI_Window_FontSelector> GUI_Window_FontSelector_;

};
5 changes: 4 additions & 1 deletion Source/Core/Editor/Windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# Add Window Subdirs
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_ProjectSettings)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_SceneTree)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_ThemeSelector)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_ImportProgressBar)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_About)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_SystemLog)
Expand All @@ -20,6 +19,10 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_TestEditor)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_ShaderEditor)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_ScriptEditor)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_ThemeSelector)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_FontSelector)


add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_RAMGraph)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_ObjectProperties)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_RenderingSettings)
Expand Down
30 changes: 30 additions & 0 deletions Source/Core/Editor/Windows/GUI_Window_FontSelector/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
########################################################################
# This file is part of the BrainGenix-ERS Environment Rendering System #
########################################################################



# Create Library (Name Should Be Parent Dir Name)
add_library(GUI_Window_FontSelector

# Add Source Files (.cpp)
"GUI_Window_FontSelector.cpp"

# Add Header Files (.h)
"GUI_Window_FontSelector.h"


${BACKWARD_ENABLE}
)

# Link 3rd Party Libs
target_link_libraries(GUI_Window_FontSelector
IMGUI
)

# Link Internal Libs
target_link_libraries(GUI_Window_FontSelector
ERS_Editor_FontManager
)

target_include_directories(GUI_Window_FontSelector PUBLIC ./)
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//======================================================================//
// This file is part of the BrainGenix-ERS Environment Rendering System //
//======================================================================//


#include <GUI_Window_FontSelector.h>


GUI_Window_FontSelector::GUI_Window_FontSelector(ERS_CLASS_FontManager* FontManager) {

FontManager_ = FontManager;

}

GUI_Window_FontSelector::~GUI_Window_FontSelector() {

}


void GUI_Window_FontSelector::Draw() {

if (Enabled_) {

ImGuiWindowFlags Flags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse;
if (ImGui::Begin("Font Selector", &Enabled_, Flags)) {
ImGui::SetWindowSize(ImVec2(0,0));

ImGui::BeginChild("Font Radio Buttons", ImVec2(300, 400), true);

for (int i = 0; (long)i < (long)FontManager_->FontNameList_.size(); i++) {
ImGui::RadioButton(FontManager_->FontNameList_[i].c_str(), &FontManager_->FontSelector_, i);
}

ImGui::EndChild();

ImGui::Separator();

ImGui::SliderFloat("Font Size", &FontManager_->FontSize_, 5.0f, 30.0f);

ImGui::Separator();

if (ImGui::Button("Reload")) {
FontManager_->IndexFonts();
}
ImGui::SameLine();

if (ImGui::Button("Apply")) {
FontManager_->UpdateFont_ = true;
}
ImGui::SameLine();

if (ImGui::Button("Close")) {
Enabled_ = false;
}


ImGui::End();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//======================================================================//
// This file is part of the BrainGenix-ERS Environment Rendering System //
//======================================================================//

#pragma once


// Standard Libraries (BG convention: use <> instead of "")

// Third-Party Libraries (BG convention: use <> instead of "")
#include <imgui.h>

// Internal Libraries (BG convention: use <> instead of "")
#include <ERS_Editor_FontManager.h>


/**
* @brief This Class Provides The Font Selector Window.
*
*/
class GUI_Window_FontSelector {

private:

ERS_CLASS_FontManager* FontManager_; /**<Font Manager Instance*/


public:

bool Enabled_ = false; /**<Show/Hide Window*/


public:

/**
* @brief Construct a new Window_FontSelector object
*
* @param FontManager
*/
GUI_Window_FontSelector(ERS_CLASS_FontManager* FontManager);

/**
* @brief Destroy the Window_FontSelector object
*
*/
~GUI_Window_FontSelector();

/**
* @brief Update the window contents, Call This Every Frame.
*
*/
void Draw();



};