Skip to content
Snippets Groups Projects
Commit ee6245a6 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Add popup tools

parent 44f9b1f5
No related branches found
No related tags found
1 merge request!329Add pose adjustment and toolbar
Pipeline #28938 passed
......@@ -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,
......
......@@ -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)) {
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment