diff --git a/applications/gui2/src/modules/camera_tools.hpp b/applications/gui2/src/modules/camera_tools.hpp index 78182b7704432d29bdb225746ba503a48084c20c..5616a89aa63dfe5205ac14c518a167d92393df05 100644 --- a/applications/gui2/src/modules/camera_tools.hpp +++ b/applications/gui2/src/modules/camera_tools.hpp @@ -19,6 +19,8 @@ enum class CameraTools { MOVE_CURSOR, // Move 3D Cursor ROTATE_CURSOR, ORIGIN_TO_CURSOR, + RESET_ORIGIN, + SAVE_CURSOR, ROTATE_X, ROTATE_Y, ROTATE_Z, diff --git a/applications/gui2/src/views/camera.cpp b/applications/gui2/src/views/camera.cpp index c7416b7de9357314bd2c6f50038fb602a363bad9..a1a3592c96d98fd60f06c64c13c8f8c7bb8df1d9 100644 --- a/applications/gui2/src/views/camera.cpp +++ b/applications/gui2/src/views/camera.cpp @@ -397,7 +397,15 @@ ToolPanel::ToolPanel(nanogui::Widget *parent, ftl::gui2::Camera* ctrl, CameraVie _addButton(CameraTools::ZOOM_IN, ENTYPO_ICON_CIRCLE_WITH_PLUS, "Zoom In (+)"); _addButton(CameraTools::ZOOM_OUT, ENTYPO_ICON_CIRCLE_WITH_MINUS, "Zoom Out (-)"); _addButton(CameraTools::INSPECT_POINT, ENTYPO_ICON_MAGNIFYING_GLASS, "Inspect Point"); - _addButton(CameraTools::ORIGIN_TO_CURSOR, ENTYPO_ICON_LOCATION, "Origin to 3D Cursor"); + //_addButton(CameraTools::ORIGIN_TO_CURSOR, ENTYPO_ICON_LOCATION, "Origin to 3D Cursor"); + auto *cur_but = _addButton({ + CameraTools::ORIGIN_TO_CURSOR, + CameraTools::RESET_ORIGIN, + CameraTools::SAVE_CURSOR + }, ENTYPO_ICON_LOCATION, "Use Cursor"); + _addButton(cur_but, CameraTools::ORIGIN_TO_CURSOR, "Origin to Cursor"); + _addButton(cur_but, CameraTools::RESET_ORIGIN, "Reset Origin"); + _addButton(cur_but, CameraTools::SAVE_CURSOR, "Save Cursor as Pose"); _addButton(CameraTools::OVERLAY, ENTYPO_ICON_LINE_GRAPH, "Show/Hide Overlay"); _addButton(CameraTools::CLIPPING, ENTYPO_ICON_SCISSORS, "Enable/Disable Clipping"); @@ -424,7 +432,7 @@ ToolPanel::~ToolPanel() { void ToolPanel::_addButton(ftl::gui2::CameraTools tool, int icon, const std::string &tooltip) { auto *b = new nanogui::Button(container_, "", icon); b->setTooltip(tooltip); - b->setFlags(nanogui::Button::Flags::RadioButton); + //b->setFlags(nanogui::Button::Flags::RadioButton); b->setCallback([this, tool]() { active_ = tool; for (auto &f : callbacks_) { @@ -434,6 +442,38 @@ void ToolPanel::_addButton(ftl::gui2::CameraTools tool, int icon, const std::str buttons_[tool] = b; } +void ToolPanel::_addButton(ftl::gui2::PopupButton *parent, ftl::gui2::CameraTools tool, const std::string &label) { + auto *b = new nanogui::Button(parent->popup(), label); + b->setCallback([this, parent, tool]() { + parent->setPushed(false); + active_ = tool; + for (auto &f : callbacks_) { + if (f(tool)) break; + } + }); + //buttons_[tool] = b; +} + +ftl::gui2::PopupButton *ToolPanel::_addButton(std::unordered_set<ftl::gui2::CameraTools> tools, int icon, const std::string &tooltip) { + auto *b = new ftl::gui2::PopupButton(container_, "", icon); + b->setTooltip(tooltip); + b->setSide(nanogui::Popup::Side::Left); + b->setChevronIcon(0); + + for (auto t : tools) { + buttons_[t] = b; + } + + auto *popup = b->popup(); + popup->setLayout(new nanogui::BoxLayout + (nanogui::Orientation::Vertical, nanogui::Alignment::Fill, 10, 6)); + + auto theme = dynamic_cast<ftl::gui2::Screen*>(screen())->getTheme("media_small"); + popup->setTheme(theme); + + return b; +} + void ToolPanel::setTool(ftl::gui2::CameraTools tool) { active_ = tool; if (buttons_.count(tool)) { diff --git a/applications/gui2/src/views/camera.hpp b/applications/gui2/src/views/camera.hpp index 6f12c96bfec4a63d41cd882829feb77b97546280..da1dc3db7a2460868b27918c6b35da8636a4519c 100644 --- a/applications/gui2/src/views/camera.hpp +++ b/applications/gui2/src/views/camera.hpp @@ -7,6 +7,7 @@ #include "../widgets/window.hpp" #include "../widgets/soundctrl.hpp" #include "../widgets/imageview.hpp" +#include "../widgets/popupbutton.hpp" #include "../modules/camera_tools.hpp" namespace ftl { @@ -47,6 +48,8 @@ private: std::list<std::function<bool(ftl::gui2::CameraTools)>> callbacks_; void _addButton(ftl::gui2::CameraTools, int icon, const std::string &tooltip); + void _addButton(ftl::gui2::PopupButton *parent, ftl::gui2::CameraTools, const std::string &label); + ftl::gui2::PopupButton *_addButton(std::unordered_set<ftl::gui2::CameraTools> tools, int icon, const std::string &tooltip); public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW