mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
Added space only wrapping to the simple text area (#851)
This commit is contained in:
parent
712caa4c1e
commit
e0d9056a88
2 changed files with 9 additions and 5 deletions
|
@ -7,6 +7,7 @@ namespace geode {
|
|||
enum WrappingMode {
|
||||
NO_WRAP,
|
||||
WORD_WRAP,
|
||||
SPACE_WRAP,
|
||||
CUTOFF_WRAP
|
||||
};
|
||||
|
||||
|
@ -70,7 +71,7 @@ namespace geode {
|
|||
float calculateOffset(cocos2d::CCLabelBMFont* label);
|
||||
void charIteration(const std::function<cocos2d::CCLabelBMFont*(cocos2d::CCLabelBMFont* line, const char c, const float top)>& overflowHandling);
|
||||
void updateLinesNoWrap();
|
||||
void updateLinesWordWrap();
|
||||
void updateLinesWordWrap(bool spaceWrap);
|
||||
void updateLinesCutoffWrap();
|
||||
void updateContainer();
|
||||
};
|
||||
|
|
|
@ -209,9 +209,9 @@ void SimpleTextArea::updateLinesNoWrap() {
|
|||
}
|
||||
}
|
||||
|
||||
void SimpleTextArea::updateLinesWordWrap() {
|
||||
this->charIteration([this](CCLabelBMFont* line, const char c, const float top) {
|
||||
static const std::string delimiters(" `~!@#$%^&*()-_=+[{}];:'\",<.>/?\\|");
|
||||
void SimpleTextArea::updateLinesWordWrap(bool spaceWrap) {
|
||||
this->charIteration([this, spaceWrap](CCLabelBMFont* line, const char c, const float top) {
|
||||
static const std::string delimiters(spaceWrap ? " " : " `~!@#$%^&*()-_=+[{}];:'\",<.>/?\\|");
|
||||
|
||||
if (delimiters.find(c) == std::string_view::npos) {
|
||||
const std::string& text = line->getString();
|
||||
|
@ -254,7 +254,10 @@ void SimpleTextArea::updateContainer() {
|
|||
this->updateLinesNoWrap();
|
||||
} break;
|
||||
case WORD_WRAP: {
|
||||
this->updateLinesWordWrap();
|
||||
this->updateLinesWordWrap(false);
|
||||
} break;
|
||||
case SPACE_WRAP: {
|
||||
this->updateLinesWordWrap(true);
|
||||
} break;
|
||||
case CUTOFF_WRAP: {
|
||||
this->updateLinesCutoffWrap();
|
||||
|
|
Loading…
Reference in a new issue