summaryrefslogtreecommitdiff
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
parentd0c97c8a12b0904c00a492acd129aebffd7816c8 (diff)
downloadManaVerse-36027fc87b99b8f048265f6ac470227a1c32d481.tar.gz
ManaVerse-36027fc87b99b8f048265f6ac470227a1c32d481.tar.bz2
ManaVerse-36027fc87b99b8f048265f6ac470227a1c32d481.tar.xz
ManaVerse-36027fc87b99b8f048265f6ac470227a1c32d481.zip
add option for enable/disable double click support.
New option: setup / misc / other / Enable double clicks
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/gui/gui.cpp58
-rw-r--r--src/gui/gui.h6
-rw-r--r--src/gui/setup_other.cpp4
-rw-r--r--src/guichan/gui.cpp43
-rw-r--r--src/guichan/include/guichan/gui.hpp8
6 files changed, 62 insertions, 58 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index b5a3a410b..b9a522bff 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -317,6 +317,7 @@ DefaultsData* getConfigDefaults()
AddDEF("screenDensity", 0);
AddDEF("cfgver", 0);
AddDEF("enableDebugLog", false);
+ AddDEF("doubleClick", true);
return configData;
}
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");
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 129dedfce..0b4b4a292 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -134,6 +134,9 @@ class Gui final : public gcn::Gui
void setCursorType(const int index)
{ mCursorType = index; }
+ void setDoubleClick(const bool b)
+ { mDoubleClick = b; }
+
void updateFonts();
bool handleInput();
@@ -159,6 +162,8 @@ class Gui final : public gcn::Gui
void handleMouseReleased(const gcn::MouseInput &mouseInput);
+ void handleMousePressed(const gcn::MouseInput &mouseInput);
+
void handleMouseInput();
void distributeMouseEvent(gcn::Widget* source, int type, int button,
@@ -186,6 +191,7 @@ class Gui final : public gcn::Gui
gcn::Color mForegroundColor;
gcn::Color mForegroundColor2;
bool mCustomCursor; /**< Show custom cursor */
+ bool mDoubleClick;
};
extern Gui *gui; /**< The GUI system */
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index f26378630..ae6f6f6bb 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -323,6 +323,10 @@ Setup_Other::Setup_Other(const Widget2 *const widget) :
"serverAttack", this, "serverAttackEvent");
// TRANSLATORS: settings option
+ new SetupItemCheckBox(_("Enable double clicks"), "",
+ "doubleClick", this, "doubleClickEvent");
+
+ // TRANSLATORS: settings option
new SetupItemCheckBox(_("Enable bot checker"), "",
"enableBotCheker", this, "enableBotChekerEvent");
diff --git a/src/guichan/gui.cpp b/src/guichan/gui.cpp
index fcfe58bef..4ba60089a 100644
--- a/src/guichan/gui.cpp
+++ b/src/guichan/gui.cpp
@@ -337,49 +337,6 @@ namespace gcn
}
}
- void Gui::handleMousePressed(const MouseInput& mouseInput)
- {
- Widget* sourceWidget = getMouseEventSource(
- mouseInput.getX(), mouseInput.getY());
-
- if (mFocusHandler->getDraggedWidget())
- sourceWidget = mFocusHandler->getDraggedWidget();
-
- int sourceWidgetX, sourceWidgetY;
- sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
-
- if ((mFocusHandler->getModalFocused()
- && sourceWidget->isModalFocused())
- || !mFocusHandler->getModalFocused())
- {
- sourceWidget->requestFocus();
- }
-
- if (mouseInput.getTimeStamp() - mLastMousePressTimeStamp < 250
- && mLastMousePressButton == mouseInput.getButton())
- {
- mClickCount++;
- }
- else
- {
- mClickCount = 1;
- }
-
- distributeMouseEvent(sourceWidget,
- MouseEvent::PRESSED,
- mouseInput.getButton(),
- mouseInput.getX(),
- mouseInput.getY());
-
- mFocusHandler->setLastWidgetPressed(sourceWidget);
-
- mFocusHandler->setDraggedWidget(sourceWidget);
- mLastMouseDragButton = mouseInput.getButton();
-
- mLastMousePressButton = mouseInput.getButton();
- mLastMousePressTimeStamp = mouseInput.getTimeStamp();
- }
-
void Gui::handleMouseWheelMovedDown(const MouseInput& mouseInput)
{
Widget* sourceWidget = getMouseEventSource(
diff --git a/src/guichan/include/guichan/gui.hpp b/src/guichan/include/guichan/gui.hpp
index 3a30dedd0..d42a11255 100644
--- a/src/guichan/include/guichan/gui.hpp
+++ b/src/guichan/include/guichan/gui.hpp
@@ -265,14 +265,6 @@ namespace gcn
virtual void handleMouseMoved(const MouseInput& mouseInput);
/**
- * Handles mouse pressed input.
- *
- * @param mouseInput The mouse input to handle.
- * @since 0.6.0
- */
- virtual void handleMousePressed(const MouseInput& mouseInput);
-
- /**
*
* Handles mouse wheel moved down input.
*