still implemeting uitextedit
This commit is contained in:
parent
43c9c5de7c
commit
5bfeee91b2
|
@ -81,6 +81,7 @@ public:
|
|||
const Size *getGlyphsSize() const { return m_glyphsSize; }
|
||||
const TexturePtr& getTexture() const { return m_texture; }
|
||||
int getTopMargin() const { return m_topMargin; }
|
||||
const Size& getGlyphSpacing() const { return m_glyphSpacing; }
|
||||
|
||||
private:
|
||||
void calculateGlyphsWidthsAutomatically(const Size& glyphSize);
|
||||
|
|
|
@ -281,4 +281,17 @@ void TextArea::moveCursor(bool right)
|
|||
recalculate();
|
||||
}
|
||||
|
||||
|
||||
int TextArea::getTextPos(Point pos)
|
||||
{
|
||||
int textLength = m_text.length();
|
||||
dump << " get pos: " << pos << m_drawArea;
|
||||
for(int i=0;i<textLength;++i) {
|
||||
Rect clickGlyphRect = m_glyphsCoords[i];
|
||||
clickGlyphRect.addTop(m_font->getTopMargin() + m_font->getGlyphSpacing().height());
|
||||
clickGlyphRect.addLeft(m_font->getGlyphSpacing().width()+1);
|
||||
dump << clickGlyphRect;
|
||||
if(m_glyphsCoords[i].contains(pos))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ public:
|
|||
|
||||
const std::string& getText() const { return m_text; }
|
||||
|
||||
int getTextPos(Point pos);
|
||||
|
||||
private:
|
||||
void recalculate();
|
||||
|
||||
|
|
|
@ -47,6 +47,10 @@ void UITextEdit::onInputEvent(const InputEvent& event)
|
|||
m_textArea.moveCursor(true);
|
||||
else if(event.keycode == KC_LEFT)
|
||||
m_textArea.moveCursor(false);
|
||||
} else if(event.type == EV_MOUSE_LDOWN) {
|
||||
|
||||
} else if(event.type == EV_MOUSE_LUP) {
|
||||
dump << m_textArea.getTextPos(event.mousePos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,11 @@ public:
|
|||
inline void setRect(T x, T y, T width, T height) { x1 = x; y1 = y; x2 = (x + width - 1); y2 = (y + height - 1); }
|
||||
inline void setCoords(int left, int top, int right, int bottom) { x1 = left; y1 = top; x2 = right; y2 = bottom; }
|
||||
|
||||
inline void addLeft(T add) { x1 -= add; }
|
||||
inline void addTop(T add) { y1 -= add; }
|
||||
inline void addRight(T add) { x2 += add; }
|
||||
inline void addBottom(T add) { y2 += add; }
|
||||
|
||||
inline void translate(T x, T y) { x1 += x; y1 += y; x2 += x; y2 += y; }
|
||||
inline void translate(const TPoint<T> &p) { x1 += p.x; y1 += p.y; x2 += p.x; y2 += p.y; }
|
||||
inline void moveTo(T x, T y) { x2 += x - x1; y2 += y - y1; x1 = x; y1 = y; }
|
||||
|
@ -135,7 +140,7 @@ public:
|
|||
if(p.x < l || p.x > r)
|
||||
return false;
|
||||
}
|
||||
int t, b;
|
||||
T t, b;
|
||||
if(y2 < y1 - 1) {
|
||||
t = y2;
|
||||
b = y1;
|
||||
|
|
Loading…
Reference in New Issue