Browse Source

gcc 5.4 linux fixes, mostly deshadows/casts

master
Odilitime 5 years ago
parent
commit
b317b4db72
  1. 10
      src/TextBlock.cpp
  2. 32
      src/graphics/components/InputComponent.cpp
  3. 6
      src/scheduler.cpp

10
src/TextBlock.cpp

@ -56,7 +56,7 @@ void TextBlock::deleteAt(size_t x, size_t y, size_t count) { @@ -56,7 +56,7 @@ void TextBlock::deleteAt(size_t x, size_t y, size_t count) {
if (this->lineLength(y)) {
this->trailingNewline = true;
}
this->lines.erase(this->lines.begin() + y);
this->lines.erase(this->lines.begin() + static_cast<int>(y));
return;
} else {
if (y == this->lines.size()) {
@ -105,7 +105,7 @@ size_t TextBlock::setValue(std::string value) { @@ -105,7 +105,7 @@ size_t TextBlock::setValue(std::string value) {
size_t pos = 0;
size_t lPos = 0;
size_t lines = 0; // start at 0 (should this start at 1?)
size_t tLines = 0; // start at 0 (should this start at 1?)
this->trailingNewline = false;
while ((pos = value.find(delimiter, lPos)) != std::string::npos) {
//std::cout << "TextBlock::setValue pushing [" << value.substr(lPos, pos) << "]" << std::endl;
@ -122,7 +122,7 @@ size_t TextBlock::setValue(std::string value) { @@ -122,7 +122,7 @@ size_t TextBlock::setValue(std::string value) {
this->lines.push_back(token);
//value.erase(0, pos + delimiter.length());
lPos = pos + delimiter.length();
lines++;
tLines++;
}
//std::cout << "lPos: " << lPos << " pos: " << pos << " size: " << value.size() << " last: [" << value.substr(lPos) << "]" << std::endl;
// if we're not at the end of the string, we don't end on a trailing slash
@ -136,7 +136,7 @@ size_t TextBlock::setValue(std::string value) { @@ -136,7 +136,7 @@ size_t TextBlock::setValue(std::string value) {
this->trailingNewline = true;
}
}
return lines;
return tLines;
}
std::string TextBlock::getValue() {
@ -154,7 +154,7 @@ std::string TextBlock::getValue() { @@ -154,7 +154,7 @@ std::string TextBlock::getValue() {
std::string TextBlock::getValueUpTo(size_t x, size_t y) {
std::string value;
if (y && this->lines.size()) {
for(int cy = 0; cy < y; cy++) {
for(size_t cy = 0; cy < y; cy++) {
value += this->lines[cy] + "\r";
}
// we don't want this because 1st char on the 2nd line breaks

32
src/graphics/components/InputComponent.cpp

@ -295,7 +295,7 @@ void InputComponent::setValue(std::string newValue) { @@ -295,7 +295,7 @@ void InputComponent::setValue(std::string newValue) {
}
void InputComponent::addChar(char c) {
this->text.insertAt(std::string(1, c), this->cursorCharX, this->cursorCharY);
this->text.insertAt(std::string(1, c), static_cast<size_t>(this->cursorCharX), static_cast<size_t>(this->cursorCharY));
//this->value += c;
//std::cout << "InputComponent::addChar - was cursor at " << this->cursorCharX << "," << this->cursorCharY << std::endl;
if (c == '\r') {
@ -323,10 +323,10 @@ void InputComponent::backSpace() { @@ -323,10 +323,10 @@ void InputComponent::backSpace() {
// 0,A,1,S,2,D,3,F,4
// ^ means remove char 2 (starting at 0)
//
this->text.deleteAt(this->cursorCharX - 1, this->cursorCharY, 1);
this->text.deleteAt(static_cast<size_t>(this->cursorCharX - 1), static_cast<size_t>(this->cursorCharY), 1);
} else {
// maybe delete line
this->text.deleteAt(this->cursorCharX, this->cursorCharY, 1);
this->text.deleteAt(static_cast<size_t>(this->cursorCharX), static_cast<size_t>(this->cursorCharY), 1);
}
//std::cout << "InputComponent::backSpace - removed [" << last << "]" << std::endl;
if (last == '\r') {
@ -336,7 +336,7 @@ void InputComponent::backSpace() { @@ -336,7 +336,7 @@ void InputComponent::backSpace() {
this->cursorCharY = 0;
this->cursorCharX = 0;
} else {
this->cursorCharX = this->text.lineLength(this->cursorCharY);
this->cursorCharX = this->text.lineLength(static_cast<size_t>(this->cursorCharY));
}
//std::pair<int, int> lineData = getLine(this->text.getValue(), this->cursorCharY);
//this->cursorCharX = lineData.second - lineData.first + 1;
@ -365,9 +365,9 @@ void InputComponent::updateCursor(int mX, int mY) { @@ -365,9 +365,9 @@ void InputComponent::updateCursor(int mX, int mY) {
} else if (mY > 0) {
// down
this->cursorCharY++;
if (this->cursorCharY >= this->text.lines.size()) {
if (static_cast<size_t>(this->cursorCharY) >= this->text.lines.size()) {
this->cursorCharY = this->text.lines.size() - 1;
this->cursorCharX = this->text.lineLength(this->cursorCharY);
this->cursorCharX = this->text.lineLength(static_cast<size_t>(this->cursorCharY));
}
}
} else {
@ -388,17 +388,17 @@ void InputComponent::updateCursor(int mX, int mY) { @@ -388,17 +388,17 @@ void InputComponent::updateCursor(int mX, int mY) {
if (this->cursorCharY < 0) {
this->cursorCharY = 0;
} else {
this->cursorCharX = this->text.lineLength(this->cursorCharY);
this->cursorCharX = this->text.lineLength(static_cast<size_t>(this->cursorCharY));
}
}
} else if (mX > 0) {
// right
this->cursorCharX++;
if (this->cursorCharX > this->text.lineLength(this->cursorCharY)) {
if (static_cast<size_t>(this->cursorCharX) > this->text.lineLength(static_cast<size_t>(this->cursorCharY))) {
this->cursorCharY++;
if (this->cursorCharY >= this->text.lines.size()) {
if (static_cast<size_t>(this->cursorCharY) >= this->text.lines.size()) {
this->cursorCharY = this->text.lines.size() - 1;
this->cursorCharX = this->text.lineLength(this->cursorCharY);
this->cursorCharX = this->text.lineLength(static_cast<size_t>(this->cursorCharY));
} else {
this->cursorCharX = 0;
}
@ -422,7 +422,7 @@ void InputComponent::updateCursor(int mX, int mY) { @@ -422,7 +422,7 @@ void InputComponent::updateCursor(int mX, int mY) {
const std::shared_ptr<TextRasterizer> textRasterizer = rasterizerCache->loadFont(12, false); // fontSize, bold
rasterizationRequest request;
//request.text = text.getValue().substr(0, pos);
request.text = this->text.getValueUpTo(this->cursorCharX, this->cursorCharY);
request.text = this->text.getValueUpTo(static_cast<size_t>(this->cursorCharX), static_cast<size_t>(this->cursorCharY));
//std::cout << "InputComponent::updateCursor - sizeText[" << request.text << "]" << std::endl;
request.startX = x;
request.availableWidth = windowWidth;
@ -435,8 +435,8 @@ void InputComponent::updateCursor(int mX, int mY) { @@ -435,8 +435,8 @@ void InputComponent::updateCursor(int mX, int mY) {
}
std::unique_ptr<sizeResponse> textInfo = textRasterizer->size(request);
//std::cout << "InputComponent::updateCursor - response at [" << textInfo->endingX << "," << textInfo->endingY << "]" << std::endl;
int endingX = textInfo->endingX;
int endingY = textInfo->endingY;
int textEndingX = textInfo->endingX;
int textEndingY = textInfo->endingY;
// adjust text crop
//std::cout << "c.endingY: " << textInfo->endingY << " c.y:" << endingY << "" << std::endl;
@ -449,14 +449,14 @@ void InputComponent::updateCursor(int mX, int mY) { @@ -449,14 +449,14 @@ void InputComponent::updateCursor(int mX, int mY) {
// adjust our scroll
//std::cout << "cursor height" << (int)textInfo->height << " > " << (int)this->height << " (" << this->textScrollY << ")" << std::endl;
if (textInfo->height > this->height) {
endingY += textInfo->height - this->height;
textEndingY += textInfo->height - this->height;
this->textScrollY = textInfo->height - this->height;
}
// this is texture shader coordinates now (not text shader coords)
cursorBox->x = x + endingX;
cursorBox->x = x + textEndingX;
if (boundToPage) {
cursorBox->y = this->windowHeight + this->y + endingY;
cursorBox->y = this->windowHeight + this->y + textEndingY;
} else {
// + this->cursorStartAtY
cursorBox->y = this->y + 5;

6
src/scheduler.cpp

@ -58,10 +58,10 @@ bool Scheduler::fireTimer(std::shared_ptr<timer_handle> timer, double now) { @@ -58,10 +58,10 @@ bool Scheduler::fireTimer(std::shared_ptr<timer_handle> timer, double now) {
void Scheduler::fireTimers() {
double now = glfwGetTime() * 1000;
size_t unfired = 0;
size_t next = INT_MAX;
int next = INT_MAX;
for(std::vector<std::shared_ptr<timer_handle>>::iterator it=this->timers.begin(); it!=this->timers.end(); ++it) {
// if it's the timer time to fire
size_t left = abs(static_cast<int>(it->get()->nextAt - now)); // maybe remove the ABS
int left = abs(static_cast<int>(it->get()->nextAt - now)); // maybe remove the ABS
if (left <= 10 || it->get()->nextAt < now) {
// fire it, do we need to clean it up
if (this->fireTimer(*it, now)) {
@ -77,7 +77,7 @@ void Scheduler::fireTimers() { @@ -77,7 +77,7 @@ void Scheduler::fireTimers() {
}
if (unfired) {
if (next < 10) {
std::cout << "There are " << unfired << "/" << this->timers.size() << " unfired timers left, next at " << (int)next << std::endl;
std::cout << "There are " << unfired << "/" << this->timers.size() << " unfired timers left, next at " << next << std::endl;
std::cout << "Scheduler::fireTimers - failed" << std::endl;
}
}

Loading…
Cancel
Save