diff --git a/src/OpenSimCreator/CMakeLists.txt b/src/OpenSimCreator/CMakeLists.txt index 3f8b0b66ee..baf97a90ea 100644 --- a/src/OpenSimCreator/CMakeLists.txt +++ b/src/OpenSimCreator/CMakeLists.txt @@ -267,6 +267,7 @@ add_library(OpenSimCreator STATIC UI/MeshWarper/MeshWarpingTabResultMeshPanel.h UI/MeshWarper/MeshWarpingTabSharedState.h UI/MeshWarper/MeshWarpingTabStatusBar.h + UI/MeshWarper/MeshWarpingTabToolbar.cpp UI/MeshWarper/MeshWarpingTabToolbar.h UI/MeshWarper/MeshWarpingTabUserSelection.h diff --git a/src/OpenSimCreator/UI/MeshWarper/MeshWarpingTabToolbar.cpp b/src/OpenSimCreator/UI/MeshWarper/MeshWarpingTabToolbar.cpp new file mode 100644 index 0000000000..fae1c021db --- /dev/null +++ b/src/OpenSimCreator/UI/MeshWarper/MeshWarpingTabToolbar.cpp @@ -0,0 +1,147 @@ +#include "MeshWarpingTabToolbar.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +class osc::MeshWarpingTabToolbar::Impl final { +public: + Impl( + std::string_view label, + std::shared_ptr tabState_) : + + m_Label{label}, + m_State{std::move(tabState_)} + {} + + void onDraw() + { + if (BeginToolbar(m_Label)) + { + drawContent(); + } + ui::end_panel(); + } + +private: + void drawContent() + { + // document-related stuff + drawNewDocumentButton(); + ui::same_line(); + drawOpenDocumentButton(); + ui::same_line(); + drawSaveLandmarksButton(); + ui::same_line(); + + ui::draw_separator(ImGuiSeparatorFlags_Vertical); + ui::same_line(); + + // undo/redo-related stuff + m_UndoButton.on_draw(); + ui::same_line(); + m_RedoButton.onDraw(); + ui::same_line(); + + ui::draw_separator(ImGuiSeparatorFlags_Vertical); + ui::same_line(); + + // camera stuff + drawCameraLockCheckbox(); + ui::same_line(); + + ui::draw_separator(ImGuiSeparatorFlags_Vertical); + ui::same_line(); + } + + void drawNewDocumentButton() + { + if (ui::draw_button(ICON_FA_FILE)) + { + ActionCreateNewDocument(m_State->updUndoable()); + } + ui::draw_tooltip_if_item_hovered( + "Create New Document", + "Creates the default scene (undoable)" + ); + } + + void drawOpenDocumentButton() + { + ui::draw_button(ICON_FA_FOLDER_OPEN); + if (ui::begin_popup_context_menu("##OpenFolder", ImGuiPopupFlags_MouseButtonLeft)) + { + if (ui::draw_menu_item("Load Source Mesh")) + { + ActionLoadMeshFile(m_State->updUndoable(), TPSDocumentInputIdentifier::Source); + } + if (ui::draw_menu_item("Load Destination Mesh")) + { + ActionLoadMeshFile(m_State->updUndoable(), TPSDocumentInputIdentifier::Destination); + } + ui::end_popup(); + } + ui::draw_tooltip_if_item_hovered( + "Open File", + "Open Source/Destination data" + ); + } + + void drawSaveLandmarksButton() + { + if (ui::draw_button(ICON_FA_SAVE)) + { + ActionSavePairedLandmarksToCSV(m_State->getScratch(), lm::LandmarkCSVFlags::NoNames); + } + ui::draw_tooltip_if_item_hovered( + "Save Landmarks to CSV (no names)", + "Saves all pair-able landmarks to a CSV file, for external processing\n\n(legacy behavior: does not export names: use 'File' menu if you want the names)" + ); + } + + void drawCameraLockCheckbox() + { + ui::draw_checkbox("link cameras", &m_State->linkCameras); + ui::same_line(); + if (!m_State->linkCameras) + { + ui::begin_disabled(); + } + ui::draw_checkbox("only link rotation", &m_State->onlyLinkRotation); + if (!m_State->linkCameras) + { + ui::end_disabled(); + } + } + + std::string m_Label; + std::shared_ptr m_State; + UndoButton m_UndoButton{m_State->editedDocument}; + RedoButton m_RedoButton{m_State->editedDocument}; +}; + +osc::MeshWarpingTabToolbar::MeshWarpingTabToolbar( + std::string_view label, + std::shared_ptr sharedState) : + m_Impl{std::make_unique(label, std::move(sharedState))} +{} +osc::MeshWarpingTabToolbar::MeshWarpingTabToolbar(MeshWarpingTabToolbar&&) noexcept = default; +osc::MeshWarpingTabToolbar& osc::MeshWarpingTabToolbar::operator=(MeshWarpingTabToolbar&&) noexcept = default; +osc::MeshWarpingTabToolbar::~MeshWarpingTabToolbar() noexcept = default; + +void osc::MeshWarpingTabToolbar::onDraw() +{ + m_Impl->onDraw(); +} diff --git a/src/OpenSimCreator/UI/MeshWarper/MeshWarpingTabToolbar.h b/src/OpenSimCreator/UI/MeshWarper/MeshWarpingTabToolbar.h index 61af5000d4..1dbf90eb90 100644 --- a/src/OpenSimCreator/UI/MeshWarper/MeshWarpingTabToolbar.h +++ b/src/OpenSimCreator/UI/MeshWarper/MeshWarpingTabToolbar.h @@ -1,23 +1,9 @@ #pragma once -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - #include -#include #include -#include -using osc::lm::LandmarkCSVFlags; +namespace osc { struct MeshWarpingTabSharedState; } namespace osc { @@ -26,116 +12,18 @@ namespace osc public: MeshWarpingTabToolbar( std::string_view label, - std::shared_ptr tabState_) : + std::shared_ptr + ); + MeshWarpingTabToolbar(const MeshWarpingTabToolbar&) = delete; + MeshWarpingTabToolbar(MeshWarpingTabToolbar&&) noexcept; + MeshWarpingTabToolbar& operator=(const MeshWarpingTabToolbar&) = delete; + MeshWarpingTabToolbar& operator=(MeshWarpingTabToolbar&&) noexcept; + ~MeshWarpingTabToolbar() noexcept; - m_Label{label}, - m_State{std::move(tabState_)} - { - } - - void onDraw() - { - if (BeginToolbar(m_Label)) - { - drawContent(); - } - ui::end_panel(); - } + void onDraw(); private: - void drawContent() - { - // document-related stuff - drawNewDocumentButton(); - ui::same_line(); - drawOpenDocumentButton(); - ui::same_line(); - drawSaveLandmarksButton(); - ui::same_line(); - - ui::draw_separator(ImGuiSeparatorFlags_Vertical); - ui::same_line(); - - // undo/redo-related stuff - m_UndoButton.on_draw(); - ui::same_line(); - m_RedoButton.onDraw(); - ui::same_line(); - - ui::draw_separator(ImGuiSeparatorFlags_Vertical); - ui::same_line(); - - // camera stuff - drawCameraLockCheckbox(); - ui::same_line(); - - ui::draw_separator(ImGuiSeparatorFlags_Vertical); - ui::same_line(); - } - - void drawNewDocumentButton() - { - if (ui::draw_button(ICON_FA_FILE)) - { - ActionCreateNewDocument(m_State->updUndoable()); - } - ui::draw_tooltip_if_item_hovered( - "Create New Document", - "Creates the default scene (undoable)" - ); - } - - void drawOpenDocumentButton() - { - ui::draw_button(ICON_FA_FOLDER_OPEN); - if (ui::begin_popup_context_menu("##OpenFolder", ImGuiPopupFlags_MouseButtonLeft)) - { - if (ui::draw_menu_item("Load Source Mesh")) - { - ActionLoadMeshFile(m_State->updUndoable(), TPSDocumentInputIdentifier::Source); - } - if (ui::draw_menu_item("Load Destination Mesh")) - { - ActionLoadMeshFile(m_State->updUndoable(), TPSDocumentInputIdentifier::Destination); - } - ui::end_popup(); - } - ui::draw_tooltip_if_item_hovered( - "Open File", - "Open Source/Destination data" - ); - } - - void drawSaveLandmarksButton() - { - if (ui::draw_button(ICON_FA_SAVE)) - { - ActionSavePairedLandmarksToCSV(m_State->getScratch(), LandmarkCSVFlags::NoNames); - } - ui::draw_tooltip_if_item_hovered( - "Save Landmarks to CSV (no names)", - "Saves all pair-able landmarks to a CSV file, for external processing\n\n(legacy behavior: does not export names: use 'File' menu if you want the names)" - ); - } - - void drawCameraLockCheckbox() - { - ui::draw_checkbox("link cameras", &m_State->linkCameras); - ui::same_line(); - if (!m_State->linkCameras) - { - ui::begin_disabled(); - } - ui::draw_checkbox("only link rotation", &m_State->onlyLinkRotation); - if (!m_State->linkCameras) - { - ui::end_disabled(); - } - } - - std::string m_Label; - std::shared_ptr m_State; - UndoButton m_UndoButton{m_State->editedDocument}; - RedoButton m_RedoButton{m_State->editedDocument}; + class Impl; + std::unique_ptr m_Impl; }; }