1
0
Fork 0
mirror of https://github.com/gwm17/Specter.git synced 2024-11-22 18:28:52 -05:00

Added Font Awesome icons, as well as icon header library. Editor now has icons for various actions

This commit is contained in:
Gordon McCann 2022-01-29 20:15:13 -05:00
parent 3049ee7025
commit 8c6fce5220
13 changed files with 111 additions and 39 deletions

3
.gitmodules vendored
View File

@ -17,3 +17,6 @@
[submodule "Navigator/vendor/asio"]
path = Navigator/vendor/asio
url = https://github.com/chriskohlhoff/asio.git
[submodule "Navigator/vendor/IconFontCppHeaders"]
path = Navigator/vendor/IconFontCppHeaders
url = https://github.com/juliettef/IconFontCppHeaders.git

View File

@ -0,0 +1,34 @@
Font Awesome Free License
-------------------------
Font Awesome Free is free, open source, and GPL friendly. You can use it for
commercial projects, open source projects, or really almost whatever you want.
Full Font Awesome Free license: https://fontawesome.com/license/free.
# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
In the Font Awesome Free download, the CC BY 4.0 license applies to all icons
packaged as SVG and JS file types.
# Fonts: SIL OFL 1.1 License (https://scripts.sil.org/OFL)
In the Font Awesome Free download, the SIL OFL license applies to all icons
packaged as web and desktop font files.
# Code: MIT License (https://opensource.org/licenses/MIT)
In the Font Awesome Free download, the MIT license applies to all non-font and
non-icon files.
# Attribution
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
Awesome Free files already contain embedded comments with sufficient
attribution, so you shouldn't need to do anything additional when using these
files normally.
We've kept attribution comments terse, so we ask that you do not actively work
to remove them from files, especially code. They're a great way for folks to
learn about Font Awesome.
# Brand Icons
All brand icons are trademarks of their respective owners. The use of these
trademarks does not indicate endorsement of the trademark holder by Font
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
to represent the company, product, or service to which they refer.**

Binary file not shown.

Binary file not shown.

View File

@ -20,5 +20,8 @@
#include "Navigator/Logger.h"
#include "Navigator/Application.h"
#include "Navigator/Physics/PhysicsLayer.h"
#include "Navigator/Layer.h"
#include "Navigator/Events/Event.h"
#include "Navigator/Renderer/Renderer.h"
#endif

View File

@ -5,6 +5,8 @@
#include "Navigator/Application.h"
#include "Navigator/SpectrumSerializer.h"
#include "IconsFontAwesome5.h"
namespace Navigator {
EditorLayer::EditorLayer() :
@ -81,15 +83,15 @@ namespace Navigator {
{
if(ImGui::BeginMenu("File"))
{
if(ImGui::MenuItem("Open"))
if(ImGui::MenuItem(ICON_FA_FOLDER_OPEN "\tOpen"))
{
m_fileDialog.SetOpenFileDialog(true);
}
if(ImGui::MenuItem("Save"))
if(ImGui::MenuItem(ICON_FA_SAVE "\tSave"))
{
m_fileDialog.SetSaveFileDialog(true);
}
if (ImGui::MenuItem("Exit"))
if (ImGui::MenuItem(ICON_FA_TIMES_CIRCLE "\tExit"))
{
Application::Get().Close();
}
@ -97,11 +99,11 @@ namespace Navigator {
}
if (ImGui::BeginMenu("Data Source"))
{
if (ImGui::MenuItem("Attach Source"))
if (ImGui::MenuItem(ICON_FA_LINK "\tAttach Source"))
{
m_sourceDialog.OpenSourceDialog();
}
if (ImGui::MenuItem("Detach Source"))
if (ImGui::MenuItem(ICON_FA_UNLINK "\tDetach Source"))
{
PhysicsStopEvent event;
m_callbackFunc(event);
@ -110,7 +112,7 @@ namespace Navigator {
}
if (ImGui::BeginMenu("Add"))
{
if (ImGui::MenuItem("Spectrum"))
if (ImGui::MenuItem(ICON_FA_CHART_BAR "\tSpectrum"))
{
m_spectrumDialog.SetSpectrumDialog();
}
@ -118,11 +120,11 @@ namespace Navigator {
}
if (ImGui::BeginMenu("Remove"))
{
if (ImGui::MenuItem("Spectrum"))
if (ImGui::MenuItem(ICON_FA_CHART_BAR "\tSpectrum"))
{
m_removeHistogram = true;
}
if (ImGui::MenuItem("Cut"))
if (ImGui::MenuItem(ICON_FA_CUT "\tCut"))
{
m_removeCut = true;
}
@ -156,7 +158,7 @@ namespace Navigator {
m_spectrumPanel.OnImGuiRender();
if (ImGui::Begin("Spectra"))
if (ImGui::Begin(ICON_FA_CHART_BAR " Spectra"))
{
for (auto& gram : histoMap)
{
@ -188,7 +190,7 @@ namespace Navigator {
ImGui::End();
}
if(ImGui::Begin("Cuts"))
if(ImGui::Begin(ICON_FA_CUT " Cuts"))
{
for(auto& cut : cutMap)
{
@ -233,6 +235,7 @@ namespace Navigator {
histMap.RemoveHistogram(selectedGram);
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("Cancel"))
{
ImGui::CloseCurrentPopup();
@ -269,6 +272,7 @@ namespace Navigator {
cutMap.RemoveCut(selectedCut);
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("Cancel"))
{
ImGui::CloseCurrentPopup();

View File

@ -1,5 +1,6 @@
#include "FileDialog.h"
#include "misc/cpp/imgui_stdlib.h"
#include "IconsFontAwesome5.h"
namespace Navigator {
@ -14,7 +15,7 @@ namespace Navigator {
}
FileDialog::FileDialog() :
m_currentPath(std::filesystem::current_path()), m_openFileName("Open File"), m_saveFileName("Save File"), m_openDirName("Open Directory"),
m_currentPath(std::filesystem::current_path()), m_openFileName(ICON_FA_FILE " Open File"), m_saveFileName(ICON_FA_SAVE " Save File"), m_openDirName(ICON_FA_FOLDER " Open Directory"),
m_selectedItem(""), m_openFileFlag(false), m_openDirFlag(false), m_saveFileFlag(false)
{
table_flags = ImGuiTableFlags_BordersH | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_BordersOuterV | ImGuiTableFlags_RowBg;
@ -56,7 +57,7 @@ namespace Navigator {
ImGui::TableHeadersRow();
ImGui::TableNextRow();
ImGui::TableNextColumn();
if (ImGui::Selectable("[DIR] ..", false, select_flags))
if (ImGui::Selectable(ICON_FA_FOLDER " ..", false, select_flags))
{
m_selectedItem.clear();
m_currentPath.append("..");
@ -68,7 +69,7 @@ namespace Navigator {
if (entry.is_directory())
{
ImGui::TableNextRow();
text = "[DIR] " + std::filesystem::relative(entry.path(), m_currentPath).string();
text = ICON_FA_FOLDER " " + std::filesystem::relative(entry.path(), m_currentPath).string();
ImGui::TableNextColumn();
if (ImGui::Selectable(text.c_str(), false, select_flags))
{
@ -81,7 +82,7 @@ namespace Navigator {
else if(entry.path().filename().extension() == ext)
{
ImGui::TableNextRow();
text = "[FILE] " + entry.path().filename().string();
text = ICON_FA_FILE " " + entry.path().filename().string();
ImGui::TableNextColumn();
if (ImGui::Selectable(text.c_str(), false, select_flags))
m_selectedItem = entry.path().filename().string();
@ -131,7 +132,7 @@ namespace Navigator {
ImGui::TableHeadersRow();
ImGui::TableNextRow();
ImGui::TableNextColumn();
if (ImGui::Selectable("[DIR] ..", false, select_flags))
if (ImGui::Selectable(ICON_FA_FOLDER " ..", false, select_flags))
{
m_selectedItem.clear();
m_currentPath.append("..");
@ -143,7 +144,7 @@ namespace Navigator {
if (entry.is_directory())
{
ImGui::TableNextRow();
text = "[DIR] " + std::filesystem::relative(entry.path(), m_currentPath).string();
text = ICON_FA_FOLDER " " + std::filesystem::relative(entry.path(), m_currentPath).string();
ImGui::TableNextColumn();
if (ImGui::Selectable(text.c_str(), false, select_flags))
{
@ -156,7 +157,7 @@ namespace Navigator {
else if (entry.path().filename().extension() == ext)
{
ImGui::TableNextRow();
text = "[FILE] " + entry.path().filename().string();
text = ICON_FA_FILE " " + entry.path().filename().string();
ImGui::TableNextColumn();
if (ImGui::Selectable(text.c_str(), false, select_flags))
m_selectedItem = entry.path().filename().string();
@ -201,7 +202,7 @@ namespace Navigator {
ImGui::TableHeadersRow();
ImGui::TableNextRow();
ImGui::TableNextColumn();
if (ImGui::Selectable("[DIR] ..", false, select_flags))
if (ImGui::Selectable(ICON_FA_FOLDER " ..", false, select_flags))
{
m_currentPath.append("..");
m_selectedItem = m_currentPath.string();
@ -213,7 +214,7 @@ namespace Navigator {
ImGui::TableNextRow();
if (entry.is_directory())
{
text = "[DIR] " + std::filesystem::relative(entry.path(), m_currentPath).string();
text = ICON_FA_FOLDER " " + std::filesystem::relative(entry.path(), m_currentPath).string();
ImGui::TableNextColumn();
if (ImGui::Selectable(text.c_str(), false, select_flags))
{
@ -225,7 +226,7 @@ namespace Navigator {
}
else
{
text = "[FILE] " + entry.path().filename().string();
text = ICON_FA_FILE " " + entry.path().filename().string();
ImGui::TableNextColumn();
ImGui::Text(text.c_str());
ImGui::TableNextColumn();

View File

@ -5,6 +5,7 @@
#include "imgui.h"
#include "misc/cpp/imgui_stdlib.h"
#include "IconsFontAwesome5.h"
namespace Navigator {
@ -32,9 +33,9 @@ namespace Navigator {
m_chosenLocation = "";
m_chosenPort = "51489";
m_chosenWindow = 2000000;
ImGui::OpenPopup("Attach Source");
ImGui::OpenPopup(ICON_FA_LINK " Attach Source");
}
if (ImGui::BeginPopupModal("Attach Source"))
if (ImGui::BeginPopupModal(ICON_FA_LINK " Attach Source"))
{
if (ImGui::BeginCombo("Source Type", ConvertDataSourceTypeToString(m_chosenType).c_str()))
{
@ -64,7 +65,7 @@ namespace Navigator {
if (temp != "")
m_chosenLocation = temp;
}
ImGui::InputInt("Coincidence Window (ps)", &m_chosenWindow);
ImGui::InputInt("Coinc. Window (ps)", &m_chosenWindow);
if (ImGui::Button("Ok"))
@ -73,6 +74,7 @@ namespace Navigator {
Application::Get().OnEvent(event);
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("Cancel"))
{
ImGui::CloseCurrentPopup();

View File

@ -2,6 +2,8 @@
#include "misc/cpp/imgui_stdlib.h"
#include "IconsFontAwesome5.h"
namespace Navigator {
SpectrumDialog::SpectrumDialog()
@ -22,10 +24,10 @@ namespace Navigator {
m_newParams = m_blank;
m_openFlag = false;
dims = 1;
ImGui::OpenPopup("New Spectrum Dialog");
ImGui::OpenPopup(ICON_FA_CHART_BAR " New Spectrum Dialog");
}
if (ImGui::BeginPopupModal("New Spectrum Dialog"))
if (ImGui::BeginPopupModal(ICON_FA_CHART_BAR " New Spectrum Dialog"))
{
ParameterMap& parMap = ParameterMap::GetInstance();
ImGui::InputText("Spectrum Name", &m_newParams.name);
@ -36,7 +38,7 @@ namespace Navigator {
ImGui::TableNextRow();
ImGui::TableNextColumn();
if (ImGui::BeginCombo("X Parameter", m_newParams.x_par.c_str()))
if (ImGui::BeginCombo("X Param.", m_newParams.x_par.c_str()))
{
for (auto& params : parMap)
{
@ -57,7 +59,7 @@ namespace Navigator {
ImGui::TableNextRow();
ImGui::TableNextColumn();
if (ImGui::BeginCombo("Y Parameter", m_newParams.y_par.c_str()))
if (ImGui::BeginCombo("Y Param.", m_newParams.y_par.c_str()))
{
for (auto& params : parMap)
{

View File

@ -1,6 +1,7 @@
#include "SpectrumPanel.h"
#include "implot.h"
#include "misc/cpp/imgui_stdlib.h"
#include "IconsFontAwesome5.h"
namespace Navigator {
@ -24,14 +25,14 @@ namespace Navigator {
{
if (m_zoomedFlag && m_zoomedGram != "")
{
if(ImGui::Button("Draw Cut"))
if(ImGui::Button(ICON_FA_CUT " Draw Cut"))
{
m_newCutParams = CutParams();
m_newCutX.resize(0);
m_newCutY.resize(0);
ImGui::OpenPopup("New Cut Dialog");
ImGui::OpenPopup(ICON_FA_CUT " New Cut Dialog");
}
if(ImGui::BeginPopupModal("New Cut Dialog"))
if(ImGui::BeginPopupModal(ICON_FA_CUT " New Cut Dialog"))
{
auto& zoomed_params = histMap.GetHistogramParams(m_zoomedGram);
m_newCutParams.x_par = zoomed_params.x_par;
@ -44,6 +45,7 @@ namespace Navigator {
m_cutModeFlag = true;
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if(ImGui::Button("Cancel"))
{
ImGui::CloseCurrentPopup();
@ -114,6 +116,7 @@ namespace Navigator {
histMap.AddCutToHistogramDraw(m_newCutParams.name, m_zoomedGram);
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("No"))
{
ImGui::CloseCurrentPopup();

View File

@ -9,6 +9,7 @@
#include <GLFW/glfw3.h>
#include <glad/glad.h>
#include "IconsFontAwesome5.h"
namespace Navigator {
@ -46,6 +47,15 @@ namespace Navigator {
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
io.Fonts->AddFontDefault();
ImFontConfig config;
config.MergeMode = true;
config.GlyphMinAdvanceX = 13.0f; // Use if you want to make the icon monospaced
config.PixelSnapH = true;
static const ImWchar icon_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
io.Fonts->AddFontFromFileTTF("fonts/fa-solid-900.ttf", 15.0f, &config, icon_ranges);
Application& app = Application::Get();
GLFWwindow* window = static_cast<GLFWwindow*>(app.GetWindow().GetNativeWindow());

@ -0,0 +1 @@
Subproject commit 8a7a57fa7b4b39b9f8436e3227ced13624028568

View File

@ -17,6 +17,7 @@ IncludeDirs["glad"] = "Navigator/vendor/glad/include"
IncludeDirs["ImPlot"] = "Navigator/vendor/implot"
IncludeDirs["glm"] = "Navigator/vendor/glm"
IncludeDirs["asio"] = "Navigator/vendor/asio/asio/include"
IncludeDirs["IconFonts"] = "Navigator/vendor/IconFontCppHeaders"
include "Navigator/vendor/glfw"
include "Navigator/vendor/imgui"
@ -46,7 +47,8 @@ project "Navigator"
"%{IncludeDirs.glad}",
"%{IncludeDirs.ImPlot}",
"%{IncludeDirs.glm}",
"%{IncludeDirs.asio}"
"%{IncludeDirs.asio}",
"%{IncludeDirs.IconFonts}"
}
filter {}
@ -58,7 +60,8 @@ project "Navigator"
"%{IncludeDirs.glad}",
"%{IncludeDirs.ImPlot}",
"%{IncludeDirs.glm}",
"%{IncludeDirs.asio}"
"%{IncludeDirs.asio}",
"%{IncludeDirs.IconFonts}"
}
@ -133,7 +136,6 @@ project "NavProject"
kind "ConsoleApp"
language "C++"
cppdialect "C++17"
staticruntime "on"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
@ -141,24 +143,29 @@ project "NavProject"
"NavProject/main.cpp"
}
includedirs {
"Navigator/src",
"Navigator/src/Navigator",
"Navigator/vendor/spdlog/include/",
"Navigator/vendor/implot/",
"Navigator/vendor",
"%{IncludeDirs.ImPlot}",
"%{IncludeDirs.ImGui}",
"%{IncludeDirs.glad}",
"%{IncludeDirs.glfw}",
"%{IncludeDirs.glm}",
"%{IncludeDirs.asio}"
"%{IncludeDirs.asio}",
"%{IncludeDirs.IconFonts}"
}
links {
"Navigator"
}
systemversion "latest"
postbuildcommands {
(" {COPYDIR} fonts %{cfg.targetdir} ")
}
filter "system:macosx"
defines "NAV_APPLE"
sysincludedirs {
@ -167,7 +174,9 @@ project "NavProject"
"%{IncludeDirs.ImGui}",
"%{IncludeDirs.glad}",
"%{IncludeDirs.ImPlot}",
"%{IncludeDirs.glm}"
"%{IncludeDirs.glm}",
"%{IncludeDirs.asio}",
"%{IncludeDirs.IconFonts}"
}
filter "system:windows"
defines "NAV_WINDOWS"