aboutsummaryrefslogtreecommitdiff
path: root/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'gui/widgets')
-rw-r--r--gui/widgets/editable.cpp42
-rw-r--r--gui/widgets/editable.h6
-rw-r--r--gui/widgets/edittext.cpp20
-rw-r--r--gui/widgets/edittext.h1
-rw-r--r--gui/widgets/list.cpp6
-rw-r--r--gui/widgets/list.h1
-rw-r--r--gui/widgets/popup.cpp1
-rw-r--r--gui/widgets/popup.h1
-rw-r--r--gui/widgets/scrollbar.cpp1
-rw-r--r--gui/widgets/scrollbar.h1
-rw-r--r--gui/widgets/tab.cpp30
-rw-r--r--gui/widgets/tab.h8
12 files changed, 103 insertions, 15 deletions
diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp
index 6fae9346b2..2d929113b1 100644
--- a/gui/widgets/editable.cpp
+++ b/gui/widgets/editable.cpp
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#include "common/rect.h"
@@ -78,7 +79,7 @@ bool EditableWidget::tryInsertChar(byte c, int pos) {
void EditableWidget::handleTickle() {
uint32 time = g_system->getMillis();
- if (_caretTime < time) {
+ if (_caretTime < time && isEnabled()) {
_caretTime = time + kCaretBlinkTime;
drawCaret(_caretVisible);
}
@@ -89,6 +90,9 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
bool dirty = false;
bool forcecaret = false;
+ if (!isEnabled())
+ return false;
+
// First remove caret
if (_caretVisible)
drawCaret(true);
@@ -261,23 +265,45 @@ void EditableWidget::drawCaret(bool erase) {
int x = editRect.left;
int y = editRect.top;
- x += getCaretOffset();
+ const int caretOffset = getCaretOffset();
+ x += caretOffset;
- if (y < 0 || y + editRect.height() - 2 >= _h)
+ if (y < 0 || y + editRect.height() > _h)
return;
x += getAbsX();
y += getAbsY();
- g_gui.theme()->drawCaret(Common::Rect(x, y, x + 1, y + editRect.height() - 2), erase);
+ g_gui.theme()->drawCaret(Common::Rect(x, y, x + 1, y + editRect.height()), erase);
if (erase) {
+ GUI::EditableWidget::String character;
+ int width;
+
if ((uint)_caretPos < _editString.size()) {
- GUI::EditableWidget::String chr(_editString[_caretPos]);
- int chrWidth = g_gui.getCharWidth(_editString[_caretPos], _font);
+ const byte chr = _editString[_caretPos];
+ width = g_gui.getCharWidth(chr, _font);
+ character = chr;
+
const uint last = (_caretPos > 0) ? _editString[_caretPos - 1] : 0;
- x += g_gui.getKerningOffset(last, _editString[_caretPos], _font);
- g_gui.theme()->drawText(Common::Rect(x, y, x + chrWidth, y + editRect.height() - 2), chr, _state, Graphics::kTextAlignLeft, _inversion, 0, false, _font);
+ x += g_gui.getKerningOffset(last, chr, _font);
+ } else {
+ // We draw a fake space here to assure that removing the caret
+ // does not result in color glitches in case the edit rect is
+ // drawn with an inversion.
+ width = g_gui.getCharWidth(' ', _font);
+ character = " ";
+ }
+
+ // TODO: Right now we manually prevent text from being drawn outside
+ // the edit area here. We might want to consider to use
+ // setTextDrawableArea for this. However, it seems that only
+ // EditTextWidget uses that but not ListWidget. Thus, one should check
+ // whether we can unify the drawing in the text area first to avoid
+ // possible glitches due to different methods used.
+ width = MIN(editRect.width() - caretOffset, width);
+ if (width > 0) {
+ g_gui.theme()->drawText(Common::Rect(x, y, x + width, y + editRect.height()), character, _state, Graphics::kTextAlignLeft, _inversion, 0, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
}
}
diff --git a/gui/widgets/editable.h b/gui/widgets/editable.h
index 4a18d5e689..e3b3a2b014 100644
--- a/gui/widgets/editable.h
+++ b/gui/widgets/editable.h
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#ifndef GUI_WIDGETS_EDITABLE_H
@@ -78,6 +79,11 @@ protected:
virtual void startEditMode() = 0;
virtual void endEditMode() = 0;
virtual void abortEditMode() = 0;
+ /**
+ * The area where text input is being made. This should exactly match the
+ * rect with which the actual edit string is drawn otherwise nasty
+ * graphics glitches when redrawing the caret can occur.
+ */
virtual Common::Rect getEditRect() const = 0;
virtual int getCaretOffset() const;
void drawCaret(bool erase);
diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp
index 4b266e8194..1481bebae3 100644
--- a/gui/widgets/edittext.cpp
+++ b/gui/widgets/edittext.cpp
@@ -17,8 +17,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
+#include "common/system.h"
#include "gui/widgets/edittext.h"
#include "gui/gui-manager.h"
@@ -60,6 +62,9 @@ void EditTextWidget::reflowLayout() {
void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) {
+ if (!isEnabled())
+ return;
+
// First remove caret
if (_caretVisible)
drawCaret(true);
@@ -79,19 +84,28 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) {
}
if (setCaretPos(i))
draw();
-}
+#ifdef TIZEN
+ // Display the virtual keypad to allow text entry. Samsung app-store testers expected
+ // the keypad to be displayed when clicking the filter edit control in the laucher gui.
+ g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
+#endif
+}
void EditTextWidget::drawWidget() {
g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), 0, ThemeEngine::kWidgetBackgroundEditText);
// Draw the text
adjustOffset();
- g_gui.theme()->drawText(Common::Rect(_x+2+ _leftPadding,_y+2, _x+_leftPadding+getEditRect().width()+2, _y+_h-2), _editString, _state, Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone, -_editScrollOffset, false, _font);
+
+ const Common::Rect &r = Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 8, _y + _h);
+ setTextDrawableArea(r);
+
+ g_gui.theme()->drawText(Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 2, _y + _h), _editString, _state, Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone, -_editScrollOffset, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
}
Common::Rect EditTextWidget::getEditRect() const {
- Common::Rect r(2 + _leftPadding, 2, _w - 2 - _leftPadding - _rightPadding, _h-1);
+ Common::Rect r(2 + _leftPadding, 2, _w - 2 - _leftPadding - _rightPadding, _h);
return r;
}
diff --git a/gui/widgets/edittext.h b/gui/widgets/edittext.h
index a34dc4b5dd..7376ae70ff 100644
--- a/gui/widgets/edittext.h
+++ b/gui/widgets/edittext.h
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#ifndef GUI_WIDGETS_EDITTEXT_H
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index 473d5f04df..4b69202fdc 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#include "common/system.h"
@@ -91,6 +92,9 @@ ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h, const char *too
// FIXME: This flag should come from widget definition
_editable = true;
+
+ _quickSelect = true;
+ _editColor = ThemeEngine::kFontColorNormal;
}
ListWidget::~ListWidget() {
@@ -538,7 +542,7 @@ void ListWidget::drawWidget() {
}
Common::Rect ListWidget::getEditRect() const {
- Common::Rect r(_hlLeftPadding, 0, _w - _hlLeftPadding - _hlRightPadding, kLineHeight - 1);
+ Common::Rect r(_hlLeftPadding, 0, _w - _hlLeftPadding - _hlRightPadding, kLineHeight - 2);
const int offset = (_selectedItem - _currentPos) * kLineHeight + _topPadding;
r.top += offset;
r.bottom += offset;
diff --git a/gui/widgets/list.h b/gui/widgets/list.h
index d18a82dd3f..1abb2b810e 100644
--- a/gui/widgets/list.h
+++ b/gui/widgets/list.h
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#ifndef GUI_WIDGETS_LIST_H
diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp
index 829a49c53e..6186492339 100644
--- a/gui/widgets/popup.cpp
+++ b/gui/widgets/popup.cpp
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#include "common/system.h"
diff --git a/gui/widgets/popup.h b/gui/widgets/popup.h
index 34983adbeb..102c7fd258 100644
--- a/gui/widgets/popup.h
+++ b/gui/widgets/popup.h
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#ifndef GUI_WIDGETS_POPUP_H
diff --git a/gui/widgets/scrollbar.cpp b/gui/widgets/scrollbar.cpp
index c7c17bc908..f1306b9c4a 100644
--- a/gui/widgets/scrollbar.cpp
+++ b/gui/widgets/scrollbar.cpp
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#include "common/rect.h"
diff --git a/gui/widgets/scrollbar.h b/gui/widgets/scrollbar.h
index 1c9f371cbc..de7c13ce03 100644
--- a/gui/widgets/scrollbar.h
+++ b/gui/widgets/scrollbar.h
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#ifndef GUI_WIDGETS_SCROLLBAR_H
diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp
index 66f33907ca..756781a04b 100644
--- a/gui/widgets/tab.cpp
+++ b/gui/widgets/tab.cpp
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#include "common/util.h"
@@ -182,6 +183,7 @@ void TabWidget::setActiveTab(int tabID) {
}
_activeTab = tabID;
_firstWidget = _tabs[tabID].firstWidget;
+
_boss->draw();
}
}
@@ -225,12 +227,34 @@ void TabWidget::handleMouseDown(int x, int y, int button, int clickCount) {
}
bool TabWidget::handleKeyDown(Common::KeyState state) {
- // TODO: maybe there should be a way to switch between tabs
- // using the keyboard? E.g. Alt-Shift-Left/Right-Arrow or something
- // like that.
+ if (state.hasFlags(Common::KBD_SHIFT) && state.keycode == Common::KEYCODE_TAB)
+ adjustTabs(kTabBackwards);
+ else if (state.keycode == Common::KEYCODE_TAB)
+ adjustTabs(kTabForwards);
+
return Widget::handleKeyDown(state);
}
+void TabWidget::adjustTabs(int value) {
+ // Determine which tab is next
+ int tabID = _activeTab + value;
+ if (tabID >= (int)_tabs.size())
+ tabID = 0;
+ else if (tabID < 0)
+ tabID = ((int)_tabs.size() - 1);
+
+ // Slides _firstVisibleTab forward to the correct tab
+ int maxTabsOnScreen = (_w / _tabWidth);
+ if (tabID >= maxTabsOnScreen && (_firstVisibleTab + maxTabsOnScreen) < (int)_tabs.size())
+ _firstVisibleTab++;
+
+ // Slides _firstVisibleTab backwards to the correct tab
+ while (tabID < _firstVisibleTab)
+ _firstVisibleTab--;
+
+ setActiveTab(tabID);
+}
+
void TabWidget::reflowLayout() {
Widget::reflowLayout();
diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h
index b19036979e..148f164fbb 100644
--- a/gui/widgets/tab.h
+++ b/gui/widgets/tab.h
@@ -17,6 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
*/
#ifndef GUI_WIDGETS_TAB_H
@@ -28,6 +29,11 @@
namespace GUI {
+enum {
+ kTabForwards = 1,
+ kTabBackwards = -1
+};
+
class TabWidget : public Widget {
typedef Common::String String;
struct Tab {
@@ -108,6 +114,8 @@ protected:
virtual void drawWidget();
virtual Widget *findWidget(int x, int y);
+
+ virtual void adjustTabs(int value);
};
} // End of namespace GUI