Skip to content

Commit

Permalink
Refactor IconFontAwesome5.h into an osc-specific iconset header (for …
Browse files Browse the repository at this point in the history
…custom-icon support)
  • Loading branch information
adamkewley committed Sep 14, 2024
1 parent b51febd commit addce25
Show file tree
Hide file tree
Showing 67 changed files with 378 additions and 363 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
[submodule "third_party/tomlplusplus"]
path = third_party/tomlplusplus
url = https://github.com/ComputationalBiomechanicsLab/tomlplusplus
[submodule "third_party/IconFontCppHeaders"]
path = third_party/IconFontCppHeaders
url = https://github.com/ComputationalBiomechanicsLab/IconFontCppHeaders
[submodule "third_party/opensim-core"]
path = third_party/opensim-core
url = https://github.com/ComputationalBiomechanicsLab/opensim-core
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSimCreator/Documents/MeshImporter/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <OpenSimCreator/Documents/MeshImporter/MIStrings.h>
#include <OpenSimCreator/Utils/OpenSimHelpers.h>

#include <IconsFontAwesome5.h>
#include <oscar/Maths/Transform.h>
#include <oscar/Maths/TransformFunctions.h>
#include <oscar/Platform/IconCodepoints.h>
#include <oscar/Utils/UID.h>

#include <iostream>
Expand Down Expand Up @@ -38,7 +38,7 @@ MIClass osc::mi::Body::CreateClass()
MIStrings::c_BodyLabel,
MIStrings::c_BodyLabelPluralized,
MIStrings::c_BodyLabelOptionallyPluralized,
ICON_FA_CIRCLE,
OSC_ICON_CIRCLE,
MIStrings::c_BodyDescription,
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSimCreator/Documents/MeshImporter/Ground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <OpenSimCreator/Documents/MeshImporter/MIIDs.h>
#include <OpenSimCreator/Documents/MeshImporter/MIStrings.h>

#include <IconsFontAwesome5.h>
#include <oscar/Platform/IconCodepoints.h>
#include <oscar/Utils/CStringView.h>
#include <oscar/Utils/UID.h>

Expand All @@ -21,7 +21,7 @@ MIClass osc::mi::Ground::CreateClass()
MIStrings::c_GroundLabel,
MIStrings::c_GroundLabelPluralized,
MIStrings::c_GroundLabelOptionallyPluralized,
ICON_FA_DOT_CIRCLE,
OSC_ICON_DOT_CIRCLE,
MIStrings::c_GroundDescription,
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSimCreator/Documents/MeshImporter/Joint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include <OpenSimCreator/Documents/MeshImporter/MIStrings.h>
#include <OpenSimCreator/Utils/OpenSimHelpers.h>

#include <IconsFontAwesome5.h>
#include <oscar/Maths/Transform.h>
#include <oscar/Maths/TransformFunctions.h>
#include <oscar/Platform/IconCodepoints.h>
#include <oscar/Utils/CStringView.h>
#include <oscar/Utils/UID.h>

Expand Down Expand Up @@ -42,7 +42,7 @@ MIClass osc::mi::Joint::CreateClass()
MIStrings::c_JointLabel,
MIStrings::c_JointLabelPluralized,
MIStrings::c_JointLabelOptionallyPluralized,
ICON_FA_LINK,
OSC_ICON_LINK,
MIStrings::c_JointDescription,
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSimCreator/Documents/MeshImporter/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include <OpenSimCreator/Documents/MeshImporter/MIStrings.h>
#include <OpenSimCreator/Utils/OpenSimHelpers.h>

#include <IconsFontAwesome5.h>
#include <oscar/Maths/AABB.h>
#include <oscar/Maths/MathHelpers.h>
#include <oscar/Platform/IconCodepoints.h>
#include <oscar/Utils/UID.h>

#include <filesystem>
Expand Down Expand Up @@ -45,7 +45,7 @@ MIClass osc::mi::Mesh::CreateClass()
MIStrings::c_MeshLabel,
MIStrings::c_MeshLabelPluralized,
MIStrings::c_MeshLabelOptionallyPluralized,
ICON_FA_CUBE,
OSC_ICON_CUBE,
MIStrings::c_MeshDescription,
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSimCreator/Documents/MeshImporter/Station.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include <OpenSimCreator/Documents/MeshImporter/MIStrings.h>
#include <OpenSimCreator/Utils/OpenSimHelpers.h>

#include <IconsFontAwesome5.h>
#include <oscar/Maths/VecFunctions.h>
#include <oscar/Maths/Vec3.h>
#include <oscar/Platform/IconCodepoints.h>
#include <oscar/Utils/UID.h>

#include <iostream>
Expand Down Expand Up @@ -49,7 +49,7 @@ MIClass osc::mi::StationEl::CreateClass()
MIStrings::c_StationLabel,
MIStrings::c_StationLabelPluralized,
MIStrings::c_StationLabelOptionallyPluralized,
ICON_FA_MAP_PIN,
OSC_ICON_MAP_PIN,
MIStrings::c_StationDescription,
};
}
Expand Down
12 changes: 6 additions & 6 deletions src/OpenSimCreator/Graphics/OpenSimDecorationOptionFlags.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "OpenSimDecorationOptionFlags.h"

#include <IconsFontAwesome5.h>
#include <oscar/Platform/IconCodepoints.h>
#include <oscar/Shims/Cpp23/utility.h>
#include <oscar/Utils/Algorithms.h>
#include <oscar/Utils/EnumHelpers.h>
Expand Down Expand Up @@ -61,31 +61,31 @@ namespace
OpenSimDecorationOptionMetadata
{
"show_contact_forces",
ICON_FA_MAGIC " Plane Contact Forces",
OSC_ICON_MAGIC " Plane Contact Forces",
"Tries to draw the direction of contact forces on planes in the scene.\n\nEXPERIMENTAL: the implementation of this visualization is work-in-progress and written by someone with a highschool-log_level_ understanding of Torque. Report any bugs or implementation opinions on GitHub.\n\nOpenSim Creator's implementation of this algorithm is very roughly based on Thomas Geijtenbeek's (better) implementation in scone-studio, here:\n\n - https://github.com/tgeijten/scone-studio \n\nThanks to @tgeijten for writing an awesome project (that OSC has probably mis-implemented ;) - again, report any bugs, folks)",
},
OpenSimDecorationOptionMetadata
{
"show_force_linear_component",
ICON_FA_MAGIC " Forces on Bodies",
OSC_ICON_MAGIC " Forces on Bodies",
"Tries to draw the linear component applied by each `OpenSim::Force` in the model.\n\nEXPERIMENTAL: this currently iterates through all the forces and extracts their linear component w.r.t. the body frame, it's probably slow, and probably noisy, but also probably still useful to know (e.g. if you're debugging weird model behavior)",
},
OpenSimDecorationOptionMetadata
{
"show_force_angular_component",
ICON_FA_MAGIC " Torques on Bodies",
OSC_ICON_MAGIC " Torques on Bodies",
"Tries to draw the angular component applied by each `OpenSim::Force` in the model.\n\nEXPERIMENTAL: this currently iterates through all the forces and extracts their angular component w.r.t. the body frame, it's probably slow, and probably noisy, but also probably still useful to know (e.g. if you're debugging weird model behavior)",
},
OpenSimDecorationOptionMetadata
{
"show_point_forces",
ICON_FA_MAGIC " Point Forces",
OSC_ICON_MAGIC " Point Forces",
"Tries to draw the an arrow to the point where point-based linear force component(s) are applied. This only applies to `OpenSim::Force`s that support applying forces to points.\n\nEXPERIMENTAL: for technical reasons, this implementation is ad-hoc: it currently only works for `ExternalForce`s and `GeometryPath`s",
},
OpenSimDecorationOptionMetadata
{
"show_point_torques",
ICON_FA_MAGIC " Point Torques",
OSC_ICON_MAGIC " Point Torques",
"Tries to draw the an arrow to the point where point-based linear force component(s) are applied. This only applies to `OpenSim::Force`s that support applying forces to points.\n\nEXPERIMENTAL: for technical reasons, this implementation is ad-hoc: it currently only works for `ExternalForce`s",
},
});
Expand Down
44 changes: 22 additions & 22 deletions src/OpenSimCreator/UI/FrameDefinition/FrameDefinitionTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <OpenSimCreator/UI/Shared/PropertiesPanel.h>
#include <OpenSimCreator/Utils/OpenSimHelpers.h>

#include <IconsFontAwesome5.h>
#include <SDL_events.h>
#include <OpenSim/Common/Component.h>
#include <OpenSim/Common/ComponentPath.h>
Expand All @@ -38,6 +37,7 @@
#include <oscar/Maths/Vec2.h>
#include <oscar/Maths/Vec3.h>
#include <oscar/Platform/App.h>
#include <oscar/Platform/IconCodepoints.h>
#include <oscar/Platform/Log.h>
#include <oscar/UI/oscimgui.h>
#include <oscar/UI/Panels/LogViewerPanel.h>
Expand Down Expand Up @@ -504,7 +504,7 @@ namespace
const SimTK::State& state,
const Edge& edge)
{
if (ui::begin_menu(ICON_FA_CALCULATOR " Calculate"))
if (ui::begin_menu(OSC_ICON_CALCULATOR " Calculate"))
{
if (ui::begin_menu("Start Point"))
{
Expand Down Expand Up @@ -560,7 +560,7 @@ namespace
const std::optional<ModelEditorViewerPanelRightClickEvent>& maybeSourceEvent,
const OpenSim::Component&)
{
if (maybeSourceEvent && ui::begin_menu(ICON_FA_CAMERA " Focus Camera"))
if (maybeSourceEvent && ui::begin_menu(OSC_ICON_CAMERA " Focus Camera"))
{
if (ui::draw_menu_item("on Ground"))
{
Expand Down Expand Up @@ -591,12 +591,12 @@ namespace
const std::optional<ModelEditorViewerPanelRightClickEvent>& maybeSourceEvent,
const Edge& edge)
{
if (maybeSourceEvent && ui::draw_menu_item(ICON_FA_TIMES " Cross Product Edge"))
if (maybeSourceEvent && ui::draw_menu_item(OSC_ICON_TIMES " Cross Product Edge"))
{
PushCreateCrossProductEdgeLayer(editor, model, edge, *maybeSourceEvent);
}

if (maybeSourceEvent && ui::begin_menu(ICON_FA_ARROWS_ALT " Frame With This Edge as"))
if (maybeSourceEvent && ui::begin_menu(OSC_ICON_ARROWS_ALT " Frame With This Edge as"))
{
ui::push_style_color(ui::ColorVar::Text, Color::muted_red());
if (ui::draw_menu_item("+x"))
Expand Down Expand Up @@ -694,7 +694,7 @@ namespace
groundOrExistingBody = FindFirstDescendentOfType<OpenSim::Body>(frame);
}

if (ui::draw_menu_item(ICON_FA_WEIGHT " Body From This", {}, false, groundOrExistingBody == nullptr))
if (ui::draw_menu_item(OSC_ICON_WEIGHT " Body From This", {}, false, groundOrExistingBody == nullptr))
{
ActionCreateBodyFromFrame(editor, model, maybeSourceEvent, frame);
}
Expand All @@ -710,15 +710,15 @@ namespace
const std::optional<ModelEditorViewerPanelRightClickEvent>& maybeSourceEvent,
const OpenSim::Mesh& mesh)
{
if (ui::draw_menu_item(ICON_FA_CIRCLE " Sphere Landmark"))
if (ui::draw_menu_item(OSC_ICON_CIRCLE " Sphere Landmark"))
{
ActionAddSphereInMeshFrame(
*model,
mesh,
maybeSourceEvent ? maybeSourceEvent->maybeClickPositionInGround : std::nullopt
);
}
if (ui::draw_menu_item(ICON_FA_ARROWS_ALT " Custom (Offset) Frame"))
if (ui::draw_menu_item(OSC_ICON_ARROWS_ALT " Custom (Offset) Frame"))
{
ActionAddOffsetFrameInMeshFrame(
*model,
Expand All @@ -734,11 +734,11 @@ namespace
const std::optional<ModelEditorViewerPanelRightClickEvent>& maybeSourceEvent,
const OpenSim::Point& point)
{
if (maybeSourceEvent && ui::draw_menu_item(ICON_FA_GRIP_LINES " Edge"))
if (maybeSourceEvent && ui::draw_menu_item(OSC_ICON_GRIP_LINES " Edge"))
{
PushCreateEdgeToOtherPointLayer(editor, model, point, *maybeSourceEvent);
}
if (maybeSourceEvent && ui::draw_menu_item(ICON_FA_DOT_CIRCLE " Midpoint"))
if (maybeSourceEvent && ui::draw_menu_item(OSC_ICON_DOT_CIRCLE " Midpoint"))
{
PushCreateMidpointToAnotherPointLayer(editor, model, point, *maybeSourceEvent);
}
Expand All @@ -750,9 +750,9 @@ namespace
DrawNothingRightClickedContextMenuHeader();
DrawContextMenuSeparator();

if (ui::begin_menu(ICON_FA_PLUS " Add"))
if (ui::begin_menu(OSC_ICON_PLUS " Add"))
{
if (ui::draw_menu_item(ICON_FA_CUBES " Meshes"))
if (ui::draw_menu_item(OSC_ICON_CUBES " Meshes"))
{
ActionPromptUserToAddMeshFiles(model);
}
Expand All @@ -769,12 +769,12 @@ namespace
DrawRightClickedComponentContextMenuHeader(mesh);
DrawContextMenuSeparator();

if (ui::begin_menu(ICON_FA_PLUS " Add"))
if (ui::begin_menu(OSC_ICON_PLUS " Add"))
{
DrawMeshAddContextMenuItems(model, maybeSourceEvent, mesh);
ui::end_menu();
}
if (ui::begin_menu(ICON_FA_FILE_EXPORT " Export"))
if (ui::begin_menu(OSC_ICON_FILE_EXPORT " Export"))
{
DrawMeshExportContextMenuContent(*model, mesh);
ui::end_menu();
Expand All @@ -791,7 +791,7 @@ namespace
DrawRightClickedComponentContextMenuHeader(point);
DrawContextMenuSeparator();

if (ui::begin_menu(ICON_FA_PLUS " Add"))
if (ui::begin_menu(OSC_ICON_PLUS " Add"))
{
DrawPointAddContextMenuItems(editor, model, maybeSourceEvent, point);
ui::end_menu();
Expand All @@ -809,12 +809,12 @@ namespace
DrawRightClickedComponentContextMenuHeader(edge);
DrawContextMenuSeparator();

if (ui::begin_menu(ICON_FA_PLUS " Add"))
if (ui::begin_menu(OSC_ICON_PLUS " Add"))
{
DrawEdgeAddContextMenuItems(editor, model, maybeSourceEvent, edge);
ui::end_menu();
}
if (ui::draw_menu_item(ICON_FA_RECYCLE " Swap Direction"))
if (ui::draw_menu_item(OSC_ICON_RECYCLE " Swap Direction"))
{
ActionSwapPointToPointEdgeEnds(*model, edge);
}
Expand All @@ -831,12 +831,12 @@ namespace
DrawRightClickedComponentContextMenuHeader(edge);
DrawContextMenuSeparator();

if (ui::begin_menu(ICON_FA_PLUS " Add"))
if (ui::begin_menu(OSC_ICON_PLUS " Add"))
{
DrawEdgeAddContextMenuItems(editor, model, maybeSourceEvent, edge);
ui::end_menu();
}
if (ui::draw_menu_item(ICON_FA_RECYCLE " Swap Operands"))
if (ui::draw_menu_item(OSC_ICON_RECYCLE " Swap Operands"))
{
ActionSwapCrossProductEdgeOperands(*model, edge);
}
Expand All @@ -853,7 +853,7 @@ namespace
DrawRightClickedComponentContextMenuHeader(frame);
DrawContextMenuSeparator();

if (ui::begin_menu(ICON_FA_PLUS " Add"))
if (ui::begin_menu(OSC_ICON_PLUS " Add"))
{
DrawCreateBodyMenuItem(editor, model, maybeSourceEvent, frame);
ui::end_menu();
Expand Down Expand Up @@ -965,12 +965,12 @@ namespace
{
if (ui::begin_menu("Edit"))
{
if (ui::draw_menu_item(ICON_FA_UNDO " Undo", {}, false, m_Model->canUndo()))
if (ui::draw_menu_item(OSC_ICON_UNDO " Undo", {}, false, m_Model->canUndo()))
{
ActionUndoCurrentlyEditedModel(*m_Model);
}

if (ui::draw_menu_item(ICON_FA_REDO " Redo", {}, false, m_Model->canRedo()))
if (ui::draw_menu_item(OSC_ICON_REDO " Redo", {}, false, m_Model->canRedo()))
{
ActionRedoCurrentlyEditedModel(*m_Model);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include <OpenSimCreator/UI/Shared/BasicWidgets.h>
#include <OpenSimCreator/Utils/OpenSimHelpers.h>

#include <IconsFontAwesome5.h>
#include <OpenSim/Simulation/Model/Model.h>
#include <oscar/Maths/Vec2.h>
#include <oscar/Platform/IconCodepoints.h>
#include <oscar/UI/oscimgui.h>
#include <oscar/UI/Tabs/ITabHost.h>
#include <oscar/Utils/ParentPtr.h>
Expand Down Expand Up @@ -53,7 +53,7 @@ void osc::FrameDefinitionTabToolbar::drawExportToOpenSimButton()
{
ui::begin_disabled();
}
if (ui::draw_button(ICON_FA_FILE_EXPORT " Export to OpenSim"))
if (ui::draw_button(OSC_ICON_FILE_EXPORT " Export to OpenSim"))
{
fd::ActionExportFrameDefinitionSceneModelToEditorTab(m_TabHost, *m_Model);
}
Expand Down
8 changes: 4 additions & 4 deletions src/OpenSimCreator/UI/MainUIScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include <OpenSimCreator/UI/ModelEditor/ModelEditorTab.h>
#include <OpenSimCreator/Utils/ParamBlock.h>

#include <IconsFontAwesome5.h>
#include <oscar/Platform/App.h>
#include <oscar/Platform/AppSettings.h>
#include <oscar/Platform/IconCodepoints.h>
#include <oscar/Platform/Log.h>
#include <oscar/Platform/os.h>
#include <oscar/Platform/Screenshot.h>
Expand Down Expand Up @@ -535,7 +535,7 @@ class osc::MainUIScreen::Impl final :
}

// adding buttons to tab bars: https://github.com/ocornut/imgui/issues/3291
ui::draw_tab_item_button(ICON_FA_PLUS);
ui::draw_tab_item_button(OSC_ICON_PLUS);

if (ui::begin_popup_context_menu("popup", ui::PopupFlag::MouseButtonLeft))
{
Expand Down Expand Up @@ -604,11 +604,11 @@ class osc::MainUIScreen::Impl final :

void drawAddNewTabMenu()
{
if (ui::draw_menu_item(ICON_FA_EDIT " Editor")) {
if (ui::draw_menu_item(OSC_ICON_EDIT " Editor")) {
select_tab(addTab(std::make_unique<ModelEditorTab>(getTabHostAPI(), std::make_unique<UndoableModelStatePair>())));
}

if (ui::draw_menu_item(ICON_FA_CUBE " Mesh Importer")) {
if (ui::draw_menu_item(OSC_ICON_CUBE " Mesh Importer")) {
select_tab(addTab(std::make_unique<mi::MeshImporterTab>(getTabHostAPI())));
}

Expand Down
2 changes: 1 addition & 1 deletion src/OpenSimCreator/UI/MeshImporter/ChooseElLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ namespace osc::mi
ui::push_style_var(ui::StyleVar::FramePadding, {10.0f, 10.0f});
ui::push_style_color(ui::ColorVar::Button, Color::half_grey());

const CStringView text = ICON_FA_ARROW_LEFT " Cancel (ESC)";
const CStringView text = OSC_ICON_ARROW_LEFT " Cancel (ESC)";
const Vec2 margin = {25.0f, 35.0f};
const Vec2 buttonTopLeft = m_Shared->get3DSceneRect().p2 - (ui::calc_button_size(text) + margin);

Expand Down
Loading

0 comments on commit addce25

Please sign in to comment.