diff options
author | Marisa-Chan | 2014-06-13 21:43:04 +0700 |
---|---|---|
committer | Marisa-Chan | 2014-06-13 21:43:04 +0700 |
commit | 45589950c0fb1a449351e6a00ef10d42290d8bae (patch) | |
tree | 44e4eedcb7e69d5fc386155b000ed038af07251d /gui/widgets/editable.cpp | |
parent | 48360645dcd5f8fddb135b6e31ae5cae4be8d77f (diff) | |
parent | 5c005ad3a3f1df0bc968c85c1cf0fc48e36ab0b2 (diff) | |
download | scummvm-rg350-45589950c0fb1a449351e6a00ef10d42290d8bae.tar.gz scummvm-rg350-45589950c0fb1a449351e6a00ef10d42290d8bae.tar.bz2 scummvm-rg350-45589950c0fb1a449351e6a00ef10d42290d8bae.zip |
Merge remote-tracking branch 'upstream/master' into zvision
Conflicts:
engines/zvision/animation/rlf_animation.cpp
engines/zvision/animation_control.h
engines/zvision/core/console.cpp
engines/zvision/core/events.cpp
engines/zvision/cursors/cursor.cpp
engines/zvision/cursors/cursor_manager.cpp
engines/zvision/cursors/cursor_manager.h
engines/zvision/fonts/truetype_font.cpp
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
engines/zvision/inventory/inventory_manager.h
engines/zvision/inventory_manager.h
engines/zvision/meta_animation.h
engines/zvision/module.mk
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/control.h
engines/zvision/scripting/controls/animation_control.cpp
engines/zvision/scripting/controls/animation_control.h
engines/zvision/scripting/controls/input_control.cpp
engines/zvision/scripting/controls/lever_control.cpp
engines/zvision/scripting/controls/timer_node.cpp
engines/zvision/scripting/controls/timer_node.h
engines/zvision/scripting/puzzle.h
engines/zvision/scripting/scr_file_handling.cpp
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
engines/zvision/sidefx.cpp
engines/zvision/sound/zork_raw.cpp
engines/zvision/sound/zork_raw.h
engines/zvision/video/video.cpp
engines/zvision/video/zork_avi_decoder.h
engines/zvision/zvision.cpp
engines/zvision/zvision.h
Diffstat (limited to 'gui/widgets/editable.cpp')
-rw-r--r-- | gui/widgets/editable.cpp | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp index 667850d6cc..af3e5e9b9a 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" @@ -261,23 +262,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, ThemeEngine::kFontColorNormal, true, _textDrawableArea); + 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); } } |