aboutsummaryrefslogtreecommitdiff
path: root/src/GlobalContextMenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/GlobalContextMenu.cpp')
-rw-r--r--src/GlobalContextMenu.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/GlobalContextMenu.cpp b/src/GlobalContextMenu.cpp
new file mode 100644
index 0000000..9eddb7f
--- /dev/null
+++ b/src/GlobalContextMenu.cpp
@@ -0,0 +1,42 @@
+#include "../include/GlobalContextMenu.hpp"
+
+namespace dchat
+{
+ static ContextMenu *editMessageContextMenu = nullptr;
+
+ ContextMenu* GlobalContextMenu::getEditMessageContextMenu()
+ {
+ if(!editMessageContextMenu)
+ {
+ editMessageContextMenu = new ContextMenu();
+ editMessageContextMenu->setVisible(false);
+
+ ContextMenuItem editMessageItem("Edit message", nullptr);
+ ContextMenuItem deleteMessageItem("Delete message", nullptr);
+ deleteMessageItem.text.setFillColor(sf::Color::Red);
+ editMessageContextMenu->addItem(editMessageItem);
+ editMessageContextMenu->addItem(deleteMessageItem);
+ }
+ return editMessageContextMenu;
+ }
+
+ void GlobalContextMenu::setClickEditMessageCallbackFunc(MenuItemClickCallbackFunc callbackFunc)
+ {
+ getEditMessageContextMenu()->getItemByIndex(0).clickCallbackFunc = callbackFunc;
+ }
+
+ void GlobalContextMenu::setClickDeleteMessageCallbackFunc(MenuItemClickCallbackFunc callbackFunc)
+ {
+ getEditMessageContextMenu()->getItemByIndex(1).clickCallbackFunc = callbackFunc;
+ }
+
+ void GlobalContextMenu::processEvent(const sf::Event &event)
+ {
+ getEditMessageContextMenu()->processEvent(event);
+ }
+
+ void GlobalContextMenu::draw(sf::RenderWindow &window)
+ {
+ getEditMessageContextMenu()->draw(window);
+ }
+}