diff --git a/include/ignition/gui/GuiEvents.hh b/include/ignition/gui/GuiEvents.hh index 08d776a54..8ef8ea819 100644 --- a/include/ignition/gui/GuiEvents.hh +++ b/include/ignition/gui/GuiEvents.hh @@ -201,6 +201,60 @@ namespace ignition /// \brief The 3D point that the user clicked within the scene. private: math::Vector3d point; }; + + /// \brief Event which is called to broadcast the 3D coordinates of a + /// user's right click within the scene. + class RightClickToScene : public QEvent + { + /// \brief Constructor + /// \param[in] _point The point which the user has right clicked + /// within the scene + public: explicit RightClickToScene(const math::Vector3d &_point) + : QEvent(kType), point(_point) + { + } + + /// \brief Unique type for this event. + static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 6); + + /// \brief Get the point within the scene that the user clicked. + /// \return The 3D point. + public: math::Vector3d Point() const + { + return this->point; + } + + /// \brief The 3D point that the user clicked within the scene. + private: math::Vector3d point; + }; + + /// \brief Event which is called to enable or disable the dropdown menu. + /// This is primarily used by plugins which also use the right click + /// mouse event to cancel any actions currently in progress. + class DropdownMenuEnabled : public QEvent + { + /// \brief Constructor + /// \param[in] _menuEnabled The boolean indicating whether the dropdown + /// menu should be enabled or disabled. + public: explicit DropdownMenuEnabled(bool _menuEnabled) + : QEvent(kType), menuEnabled(_menuEnabled) + { + } + + /// \brief Unique type for this event. + static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 7); + + /// \brief Gets whether the menu is enabled or not for this event. + /// \return True if enabling the menu, false if disabling the menu + public: bool MenuEnabled() const + { + return this->menuEnabled; + } + + /// \brief The boolean indicating whether the menu is disabled or not + /// for this event. + private: bool menuEnabled; + }; } } } diff --git a/src/GuiEvents_TEST.cc b/src/GuiEvents_TEST.cc index 0bdb24d74..72c4ee740 100644 --- a/src/GuiEvents_TEST.cc +++ b/src/GuiEvents_TEST.cc @@ -78,3 +78,26 @@ TEST(GuiEventsTest, LeftClickToScene) EXPECT_EQ(math::Vector3d(1, 2, 3), event.Point()); } +///////////////////////////////////////////////// +TEST(GuiEventsTest, RightClickToScene) +{ + events::RightClickToScene event({1, 2, 3}); + + EXPECT_LT(QEvent::User, event.type()); + EXPECT_EQ(math::Vector3d(1, 2, 3), event.Point()); +} + +///////////////////////////////////////////////// +TEST(GuiEventsTest, DropdownMenuEnabled) +{ + events::DropdownMenuEnabled event(true); + + EXPECT_LT(QEvent::User, event.type()); + EXPECT_EQ(true, event.MenuEnabled()); + + events::DropdownMenuEnabled event2(false); + + EXPECT_LT(QEvent::User, event2.type()); + EXPECT_EQ(false, event2.MenuEnabled()); +} +