summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.cpp42
-rw-r--r--src/gui/gui.h3
-rw-r--r--src/gui/theme.cpp6
-rw-r--r--src/gui/theme.h9
4 files changed, 60 insertions, 0 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 956b9e8b3..f0171ede4 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -36,6 +36,7 @@
#include "keydata.h"
#include "keyevent.h"
#include "keyinput.h"
+#include "touchmanager.h"
#include "resources/image.h"
#include "resources/imageset.h"
@@ -395,6 +396,7 @@ void Gui::draw()
BLOCK_START("Gui::draw 1")
mGraphics->pushClipArea(getTop()->getDimension());
getTop()->draw(mGraphics);
+ touchManager.draw();
int mouseX, mouseY;
const uint8_t button = SDL_GetMouseState(&mouseX, &mouseY);
@@ -650,3 +652,43 @@ void Gui::getAbsolutePosition(gcn::Widget *widget, int &x, int &y)
widget = widget->getParent();
}
}
+
+void Gui::handleMouseInput()
+{
+ BLOCK_START("Gui::handleMouseInput")
+ while (!mInput->isMouseQueueEmpty())
+ {
+ const gcn::MouseInput mouseInput = mInput->dequeueMouseInput();
+
+ if (touchManager.processEvent(mouseInput))
+ continue;
+
+ // Save the current mouse state. It will be needed if modal focus
+ // changes or modal mouse input focus changes.
+ mLastMouseX = mouseInput.getX();
+ mLastMouseY = mouseInput.getY();
+
+ switch (mouseInput.getType())
+ {
+ case gcn::MouseInput::PRESSED:
+ handleMousePressed(mouseInput);
+ break;
+ case gcn::MouseInput::RELEASED:
+ handleMouseReleased(mouseInput);
+ break;
+ case gcn::MouseInput::MOVED:
+ handleMouseMoved(mouseInput);
+ break;
+ case gcn::MouseInput::WHEEL_MOVED_DOWN:
+ handleMouseWheelMovedDown(mouseInput);
+ break;
+ case gcn::MouseInput::WHEEL_MOVED_UP:
+ handleMouseWheelMovedUp(mouseInput);
+ break;
+ default:
+ throw GCN_EXCEPTION("Unknown mouse input type.");
+ break;
+ }
+ }
+ BLOCK_END("Gui::handleMouseInput")
+}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 74c5404aa..db373193a 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -24,6 +24,7 @@
#define GUI_H
#include "resources/cursor.h"
+#include "resources/image.h"
#include <guichan/gui.hpp>
@@ -144,6 +145,8 @@ class Gui final : public gcn::Gui
protected:
void handleMouseMoved(const gcn::MouseInput &mouseInput);
+ void handleMouseInput();
+
void distributeMouseEvent(gcn::Widget* source, int type, int button,
int x, int y, bool force = false,
bool toSourceOnly = false);
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 7331724d1..46506ecb4 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -46,6 +46,9 @@ static std::string defaultThemePath;
std::string Theme::mThemePath;
std::string Theme::mThemeName;
Theme *Theme::mInstance = nullptr;
+#ifdef ANDROID
+SDL_Rect *Theme::mKeybRect = nullptr;
+#endif
// Set the theme path...
static void initDefaultThemePath()
@@ -634,6 +637,9 @@ void Theme::fillSoundsList(StringVect &list)
void Theme::selectSkin()
{
prepareThemePath();
+#ifdef ANDROID
+ mKeybRect = SDL_GetScreenKeyboardBlock();
+#endif
}
void Theme::prepareThemePath()
diff --git a/src/gui/theme.h b/src/gui/theme.h
index a19e93812..bd5e27708 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -361,6 +361,12 @@ class Theme final : public Palette, public ConfigListener
static ThemeInfo *loadInfo(const std::string &themeName) A_WARN_UNUSED;
+ static SDL_Rect *getKeybRect()
+#ifdef ANDROID
+ { return mKeybRect; }
+#else
+ { return nullptr; }
+#endif
private:
Theme();
@@ -391,6 +397,9 @@ class Theme final : public Palette, public ConfigListener
typedef std::vector<DyePalette*> ProgressColors;
ProgressColors mProgressColors;
+#ifdef ANDROID
+ static SDL_Rect *mKeybRect;
+#endif
};
#endif