diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-12-31 02:00:06 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-12-31 02:00:06 +0300 |
commit | f4f8701763eed4c1ab9badf004e4755126b98e9e (patch) | |
tree | f904efec07054d9be7bac7dba4d34b5de8bc49ce /src | |
parent | 021e567ba44650b0ab63e7f571dc0d622edbcc6d (diff) | |
download | plus-f4f8701763eed4c1ab9badf004e4755126b98e9e.tar.gz plus-f4f8701763eed4c1ab9badf004e4755126b98e9e.tar.bz2 plus-f4f8701763eed4c1ab9badf004e4755126b98e9e.tar.xz plus-f4f8701763eed4c1ab9badf004e4755126b98e9e.zip |
Add option to show/hide onscreen keyboard icon.
Diffstat (limited to 'src')
-rw-r--r-- | src/defaults.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup_touch.cpp | 3 | ||||
-rw-r--r-- | src/touchmanager.cpp | 35 | ||||
-rw-r--r-- | src/touchmanager.h | 3 |
4 files changed, 35 insertions, 8 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp index 9ff313ae3..2c59ee887 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -111,6 +111,7 @@ DefaultsData* getConfigDefaults() AddDEF("showScreenButtons", true); AddDEF("showBeingPopup", false); AddDEF("mouseDirectionMove", true); + AddDEF("showScreenKeyboard", true); #else AddDEF("screenwidth", defaultScreenWidth); AddDEF("screenheight", defaultScreenHeight); @@ -118,6 +119,7 @@ DefaultsData* getConfigDefaults() AddDEF("showScreenButtons", false); AddDEF("showBeingPopup", true); AddDEF("mouseDirectionMove", false); + AddDEF("showScreenKeyboard", false); #endif AddDEF("screen", false); AddDEF("hwaccel", false); diff --git a/src/gui/setup_touch.cpp b/src/gui/setup_touch.cpp index 1f1d53e0e..fb91633b8 100644 --- a/src/gui/setup_touch.cpp +++ b/src/gui/setup_touch.cpp @@ -50,6 +50,9 @@ Setup_Touch::Setup_Touch(const Widget2 *const widget) : ContainerPlacer place = h.getPlacer(0, 0); place(0, 0, mScroll, 10, 10); + new SetupItemCheckBox(_("Show on screen keyboard icon"), "", + "showScreenKeyboard", this, "showScreenKeyboardEvent"); + new SetupItemCheckBox(_("Show on screen buttons"), "", "showScreenButtons", this, "showScreenButtonsEvent"); diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index 3dd9e64a9..b78f0264d 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -42,6 +42,7 @@ TouchManager::TouchManager() : mRedraw(true), mShowJoystick(false), mShowButtons(false), + mShowKeyboard(false), mButtonsSize(1), mJoystickSize(1), mShow(false), @@ -68,21 +69,20 @@ void TouchManager::init() { config.addListener("showScreenJoystick", this); config.addListener("showScreenButtons", this); + config.addListener("showScreenKeyboard", this); config.addListener("screenButtonsSize", this); config.addListener("screenJoystickSize", this); mShowJoystick = config.getBoolValue("showScreenJoystick"); mShowButtons = config.getBoolValue("showScreenButtons"); + mShowKeyboard = config.getBoolValue("showScreenKeyboard"); mButtonsSize = config.getIntValue("screenButtonsSize"); mJoystickSize = config.getIntValue("screenJoystickSize"); setHalfJoyPad(getPadSize() / 2); -#ifdef ANDROID - loadTouchItem(&mKeyboard, "keyboard_icon.xml", "", -1, -1, 28, 28, NORMAL, - nullptr, nullptr, &showKeyboard, nullptr); -#endif - + if (mShowKeyboard) + loadKeyboard(); if (mShowJoystick) loadPad(); if (mShowButtons) @@ -172,7 +172,8 @@ void TouchManager::draw() it != it_end; ++ it) { const TouchItem *const item = *it; - if (item && item->images && (mShow || item == mKeyboard)) + if (item && item->images && (mShow || + (item == mKeyboard && mShowKeyboard))) { mainGraphics->calcWindow(mVertexes, item->x, item->y, item->width, item->height, *item->images); @@ -195,7 +196,8 @@ void TouchManager::draw() it != it_end; ++ it) { const TouchItem *const item = *it; - if (item && item->images && (mShow || item == mKeyboard)) + if (item && item->images && (mShow || + (item == mKeyboard && mShowKeyboard))) { mainGraphics->drawImageRect(item->x, item->y, item->width, item->height, *item->images); @@ -220,7 +222,7 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) it != it_end; ++ it) { const TouchItem *const item = *it; - if (!item || (!mShow && item != mKeyboard)) + if (!item || (!mShow && (item != mKeyboard || !mShowKeyboard))) continue; const gcn::Rectangle &rect = item->rect; if (rect.isPointInRect(x, y)) @@ -372,6 +374,12 @@ void TouchManager::loadButtons() } +void TouchManager::loadKeyboard() +{ + loadTouchItem(&mKeyboard, "keyboard_icon.xml", "", -1, -1, 28, 28, NORMAL, + nullptr, nullptr, &showKeyboard, nullptr); +} + void TouchManager::optionChanged(const std::string &value) { if (value == "showScreenJoystick") @@ -401,6 +409,17 @@ void TouchManager::optionChanged(const std::string &value) } mRedraw = true; } + else if (value == "showScreenKeyboard") + { + if (mShowKeyboard == config.getBoolValue("showScreenKeyboard")) + return; + mShowKeyboard = config.getBoolValue("showScreenKeyboard"); + if (mShowKeyboard) + loadKeyboard(); + else + unloadTouchItem(&mKeyboard); + mRedraw = true; + } else if (value == "screenButtonsSize") { if (mButtonsSize == config.getIntValue("screenButtonsSize")) diff --git a/src/touchmanager.h b/src/touchmanager.h index 05b062074..512c82909 100644 --- a/src/touchmanager.h +++ b/src/touchmanager.h @@ -135,6 +135,8 @@ class TouchManager final : public ConfigListener void loadButtons(); + void loadKeyboard(); + int getPadSize() { return (mJoystickSize + 2) * 50; } @@ -155,6 +157,7 @@ class TouchManager final : public ConfigListener bool mRedraw; bool mShowJoystick; bool mShowButtons; + bool mShowKeyboard; int mButtonsSize; int mJoystickSize; bool mShow; |