[Scummvm-cvs-logs] scummvm master -> fe7f28bf6c955715f1180a0da315ec4ade38fdd0

lordhoto lordhoto at gmail.com
Sun Nov 24 01:17:00 CET 2013


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
95f07fd405 GUI: Document EditableWidget::getEditRect.
b487c1fc38 GUI: Fix undrawing caret glitch when the edit text is inversed.
fe7f28bf6c GUI: Do not draw text outside edit rect in EditableWidget.


Commit: 95f07fd405cd72822faef1a0e0bffe953a8856df
    https://github.com/scummvm/scummvm/commit/95f07fd405cd72822faef1a0e0bffe953a8856df
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-11-23T15:20:29-08:00

Commit Message:
GUI: Document EditableWidget::getEditRect.

Changed paths:
    gui/widgets/editable.h



diff --git a/gui/widgets/editable.h b/gui/widgets/editable.h
index 4a18d5e..63a1942 100644
--- a/gui/widgets/editable.h
+++ b/gui/widgets/editable.h
@@ -78,6 +78,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);


Commit: b487c1fc38405ca80683b0d30318d0c4bd408b67
    https://github.com/scummvm/scummvm/commit/b487c1fc38405ca80683b0d30318d0c4bd408b67
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-11-23T15:38:47-08:00

Commit Message:
GUI: Fix undrawing caret glitch when the edit text is inversed.

This is prominently visible in the list based save/load chooser since the
edit string is drawn on a special green background there. When the caret is
at the end of the edit string this would result in the green color missing
at the place of the (undrawn) caret. To avoid this we simply draw a fake
space now.

Changed paths:
    gui/widgets/editable.cpp



diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp
index fca9702..9ce4def 100644
--- a/gui/widgets/editable.cpp
+++ b/gui/widgets/editable.cpp
@@ -272,13 +272,25 @@ void EditableWidget::drawCaret(bool 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()), 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 = " ";
 		}
+
+		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);
 	}
 
 	_caretVisible = !erase;


Commit: fe7f28bf6c955715f1180a0da315ec4ade38fdd0
    https://github.com/scummvm/scummvm/commit/fe7f28bf6c955715f1180a0da315ec4ade38fdd0
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-11-23T16:15:27-08:00

Commit Message:
GUI: Do not draw text outside edit rect in EditableWidget.

Changed paths:
    gui/widgets/editable.cpp



diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp
index 9ce4def..6f550b5 100644
--- a/gui/widgets/editable.cpp
+++ b/gui/widgets/editable.cpp
@@ -261,7 +261,8 @@ 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() > _h)
 		return;
@@ -290,7 +291,16 @@ void EditableWidget::drawCaret(bool erase) {
 			character = " ";
 		}
 
-		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);
+		// 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);
+		}
 	}
 
 	_caretVisible = !erase;






More information about the Scummvm-git-logs mailing list