summaryrefslogtreecommitdiff
path: root/src/interface/Label.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-14 17:05:07 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-14 17:05:07 (GMT)
commitbd7dd2074228baf32e217ffe619aa53fe7f78f55 (patch)
tree18cd1360105ed01e070e1de663efc90095e518d5 /src/interface/Label.cpp
parent3fcfede08f35514cc5af56829a141fba4427f80f (diff)
downloadpowder-bd7dd2074228baf32e217ffe619aa53fe7f78f55.zip
powder-bd7dd2074228baf32e217ffe619aa53fe7f78f55.tar.gz
Better text selection colour invert, fixes #107
Diffstat (limited to 'src/interface/Label.cpp')
-rw-r--r--src/interface/Label.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/interface/Label.cpp b/src/interface/Label.cpp
index 976c788..d4bd82e 100644
--- a/src/interface/Label.cpp
+++ b/src/interface/Label.cpp
@@ -250,26 +250,49 @@ void Label::updateSelection()
selectionLineL = Graphics::PositionAtCharIndex((char*)currentText.c_str(), selectionIndex0, selectionXL, selectionYL);
textFragments = std::string(currentText);
- textFragments.insert(selectionIndex1, "\x0E");
- textFragments.insert(selectionIndex0, "\x0F\x01\x01\x01");
+ //textFragments.insert(selectionIndex1, "\x0E");
+ //textFragments.insert(selectionIndex0, "\x0F\x01\x01\x01");
+ textFragments.insert(selectionIndex1, "\x01");
+ textFragments.insert(selectionIndex0, "\x01");
} else if(selectionIndex0 > selectionIndex1) {
selectionLineH = Graphics::PositionAtCharIndex((char*)currentText.c_str(), selectionIndex0, selectionXH, selectionYH);
selectionLineL = Graphics::PositionAtCharIndex((char*)currentText.c_str(), selectionIndex1, selectionXL, selectionYL);
textFragments = std::string(currentText);
- textFragments.insert(selectionIndex0, "\x0E");
- textFragments.insert(selectionIndex1, "\x0F\x01\x01\x01");
+ //textFragments.insert(selectionIndex0, "\x0E");
+ //textFragments.insert(selectionIndex1, "\x0F\x01\x01\x01");
+ textFragments.insert(selectionIndex0, "\x01");
+ textFragments.insert(selectionIndex1, "\x01");
} else {
selectionXH = -1;
selectionXL = -1;
textFragments = std::string(currentText);
}
+
+ if(displayText.length())
+ {
+ displayText = tDisplayText;
+ if(selectionIndex1 > selectionIndex0) {
+ int tSelectionIndex1 = Graphics::CharIndexAtPosition((char*)displayText.c_str(), selectionXH, selectionYH);
+ int tSelectionIndex0 = Graphics::CharIndexAtPosition((char*)displayText.c_str(), selectionXL, selectionYL);
+
+ displayText.insert(tSelectionIndex1, "\x01");
+ displayText.insert(tSelectionIndex0, "\x01");
+ } else if(selectionIndex0 > selectionIndex1) {
+ int tSelectionIndex0 = Graphics::CharIndexAtPosition((char*)displayText.c_str(), selectionXH, selectionYH);
+ int tSelectionIndex1 = Graphics::CharIndexAtPosition((char*)displayText.c_str(), selectionXL, selectionYL);
+
+ displayText.insert(tSelectionIndex0, "\x01");
+ displayText.insert(tSelectionIndex1, "\x01");
+ }
+ }
}
void Label::SetDisplayText(std::string newText)
{
displayText = newText;
+ tDisplayText = displayText;
}
void Label::Draw(const Point& screenPos)