diff mde/gui/renderer/IRenderer.d @ 119:d28aea50c6da

Basic edit cursor placement using the mouse. Moved textContent.d's contents into TextWidget.d.
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 01 Jan 2009 14:52:09 +0000
parents 1655693702fc
children d3b2cefd46c9
line wrap: on
line diff
--- a/mde/gui/renderer/IRenderer.d	Sun Dec 28 10:55:15 2008 +0000
+++ b/mde/gui/renderer/IRenderer.d	Thu Jan 01 14:52:09 2009 +0000
@@ -103,6 +103,20 @@
 	void index (size_t index = size_t.max) {
 	    index_ = index;
 	}
+        /** Set the edit index for a click at x.
+         *
+         * TODO: this uses the left edge of the cached bitmap to compare against; it should
+         * probably use the glyph position. The font system needs some redesigning anyway. */
+        size_t setIndex (wdrel x) {
+            foreach (i,ch; textCache.chars)
+                if (x < ch.xPos) {
+                    index_ = i;
+                    goto gotIndex;
+                }
+            index_ = textCache.chars.length;
+            gotIndex:
+            return index_;
+        }
         
         void getDimensions (out wdsize w, out wdsize h) {
             font.updateBlock (content, textCache);