summaryrefslogtreecommitdiff
path: root/src/gui/gui.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-07-12 14:27:09 +0300
committerAndrei Karas <akaras@inbox.ru>2013-07-12 14:27:09 +0300
commit36027fc87b99b8f048265f6ac470227a1c32d481 (patch)
tree617b39aaf314fa9660b02fd849d994fde19f7959 /src/gui/gui.cpp
parentd0c97c8a12b0904c00a492acd129aebffd7816c8 (diff)
downloadmanaplus-36027fc87b99b8f048265f6ac470227a1c32d481.tar.gz
manaplus-36027fc87b99b8f048265f6ac470227a1c32d481.tar.bz2
manaplus-36027fc87b99b8f048265f6ac470227a1c32d481.tar.xz
manaplus-36027fc87b99b8f048265f6ac470227a1c32d481.zip
add option for enable/disable double click support.
New option: setup / misc / other / Enable double clicks
Diffstat (limited to 'src/gui/gui.cpp')
-rw-r--r--src/gui/gui.cpp58
1 files changed, 51 insertions, 7 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 1032e7e4e..2a838069b 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -68,11 +68,12 @@ class GuiConfigListener final : public ConfigListener
void optionChanged(const std::string &name)
{
- if (name == "customcursor" && mGui)
- {
- const bool bCustomCursor = config.getBoolValue("customcursor");
- mGui->setUseCustomCursor(bCustomCursor);
- }
+ if (!mGui)
+ return;
+ if (name == "customcursor")
+ mGui->setUseCustomCursor(config.getBoolValue("customcursor"));
+ else if (name == "doubleClick")
+ mGui->setDoubleClick(config.getBoolValue("doubleClick"));
}
private:
Gui *mGui;
@@ -97,7 +98,8 @@ Gui::Gui(Graphics *const graphics) :
mFocusListeners(),
mForegroundColor(Theme::getThemeColor(Theme::TEXT)),
mForegroundColor2(Theme::getThemeColor(Theme::TEXT_OUTLINE)),
- mCustomCursor(false)
+ mCustomCursor(false),
+ mDoubleClick(true)
{
logger->log1("Initializing GUI...");
// Set graphics
@@ -236,12 +238,14 @@ Gui::Gui(Graphics *const graphics) :
// Initialize mouse cursor and listen for changes to the option
setUseCustomCursor(config.getBoolValue("customcursor"));
+ setDoubleClick(config.getBoolValue("doubleClick"));
config.addListener("customcursor", mConfigListener);
+ config.addListener("doubleClick", mConfigListener);
}
Gui::~Gui()
{
- config.removeListener("customcursor", mConfigListener);
+ config.removeListeners(mConfigListener);
delete mConfigListener;
mConfigListener = nullptr;
@@ -522,6 +526,46 @@ void Gui::handleMouseMoved(const gcn::MouseInput &mouseInput)
mMouseInactivityTimer = 0;
}
+void Gui::handleMousePressed(const gcn::MouseInput &mouseInput)
+{
+ const int x = mouseInput.getX();
+ const int y = mouseInput.getY();
+ const unsigned int button = mouseInput.getButton();
+ const int timeStamp = mouseInput.getTimeStamp();
+
+ gcn::Widget *sourceWidget = getMouseEventSource(x, y);
+
+ if (mFocusHandler->getDraggedWidget())
+ sourceWidget = mFocusHandler->getDraggedWidget();
+
+ int sourceWidgetX, sourceWidgetY;
+ sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
+
+ if ((mFocusHandler->getModalFocused()
+ && sourceWidget->isModalFocused())
+ || !mFocusHandler->getModalFocused())
+ {
+ sourceWidget->requestFocus();
+ }
+
+ if (mDoubleClick && timeStamp - mLastMousePressTimeStamp < 250
+ && mLastMousePressButton == button)
+ {
+ mClickCount ++;
+ }
+ else
+ {
+ mClickCount = 1;
+ }
+
+ distributeMouseEvent(sourceWidget, MouseEvent::PRESSED, button, x, y);
+ mFocusHandler->setLastWidgetPressed(sourceWidget);
+ mFocusHandler->setDraggedWidget(sourceWidget);
+ mLastMouseDragButton = button;
+ mLastMousePressButton = button;
+ mLastMousePressTimeStamp = timeStamp;
+}
+
void Gui::updateFonts()
{
const int fontSize = config.getIntValue("fontSize");