Mercurial > projects > mde
comparison 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 |
comparison
equal
deleted
inserted
replaced
118:9ac208b53582 | 119:d28aea50c6da |
---|---|
101 | 101 |
102 /** If not size_t.max, an edit marker is drawn before character index. */ | 102 /** If not size_t.max, an edit marker is drawn before character index. */ |
103 void index (size_t index = size_t.max) { | 103 void index (size_t index = size_t.max) { |
104 index_ = index; | 104 index_ = index; |
105 } | 105 } |
106 /** Set the edit index for a click at x. | |
107 * | |
108 * TODO: this uses the left edge of the cached bitmap to compare against; it should | |
109 * probably use the glyph position. The font system needs some redesigning anyway. */ | |
110 size_t setIndex (wdrel x) { | |
111 foreach (i,ch; textCache.chars) | |
112 if (x < ch.xPos) { | |
113 index_ = i; | |
114 goto gotIndex; | |
115 } | |
116 index_ = textCache.chars.length; | |
117 gotIndex: | |
118 return index_; | |
119 } | |
106 | 120 |
107 void getDimensions (out wdsize w, out wdsize h) { | 121 void getDimensions (out wdsize w, out wdsize h) { |
108 font.updateBlock (content, textCache); | 122 font.updateBlock (content, textCache); |
109 w = cast(wdim) textCache.w; | 123 w = cast(wdim) textCache.w; |
110 h = cast(wdim) textCache.h; | 124 h = cast(wdim) textCache.h; |