mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-12-26 20:06:46 +02:00
utilities: Replace min/max functions by the versions from STL.
This commit is contained in:
parent
40c510a28a
commit
aea1c44020
@ -3,6 +3,7 @@
|
||||
#include "surface.h"
|
||||
#include "utilities.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
@ -115,7 +116,7 @@ int ASFont::getTextWidth(const char *text) {
|
||||
while (char ch = *text++) {
|
||||
if (ch == '\n') {
|
||||
// New line.
|
||||
maxWidth = max(width, maxWidth);
|
||||
maxWidth = std::max(width, maxWidth);
|
||||
width = 0;
|
||||
} else {
|
||||
std::string::size_type pos;
|
||||
@ -133,7 +134,7 @@ int ASFont::getTextWidth(const char *text) {
|
||||
width += charpos[pos * 2 + 2] - charpos[pos * 2 + 1];
|
||||
}
|
||||
}
|
||||
return max(width, maxWidth);
|
||||
return std::max(width, maxWidth);
|
||||
}
|
||||
|
||||
int ASFont::getTextWidth(const std::string& text) {
|
||||
|
@ -1541,7 +1541,8 @@ void GMenu2X::contextMenu() {
|
||||
}
|
||||
|
||||
bool close = false;
|
||||
uint i, sel=0, fadeAlpha=0;
|
||||
uint i, fadeAlpha=0;
|
||||
int sel = 0;
|
||||
|
||||
int h = font->getHeight();
|
||||
SDL_Rect box;
|
||||
@ -1624,10 +1625,10 @@ void GMenu2X::contextMenu() {
|
||||
close = true;
|
||||
break;
|
||||
case InputManager::UP:
|
||||
sel = max(0, sel-1);
|
||||
sel = std::max(0, sel-1);
|
||||
break;
|
||||
case InputManager::DOWN:
|
||||
sel = min((int)voices.size()-1, sel+1);
|
||||
sel = std::min((int)voices.size()-1, sel+1);
|
||||
break;
|
||||
case InputManager::ACCEPT:
|
||||
voices[sel].action();
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_gfxPrimitives.h>
|
||||
#include <algorithm>
|
||||
|
||||
//for browsing the filesystem
|
||||
#include <sys/stat.h>
|
||||
@ -102,8 +103,11 @@ int Selector::exec(int startSelection) {
|
||||
//Screenshot
|
||||
if (selected-fl.dirCount()<screens.size() && screens[selected-fl.dirCount()]!="") {
|
||||
curTick = SDL_GetTicks();
|
||||
if (curTick-selTick>200)
|
||||
gmenu2x->sc[screens[selected-fl.dirCount()]]->blitRight(gmenu2x->s, 311, 42, 160, 160, min((curTick-selTick-200)/3,255));
|
||||
if (curTick - selTick > 200) {
|
||||
gmenu2x->sc[screens[selected-fl.dirCount()]]->blitRight(
|
||||
gmenu2x->s, 311, 42, 160, 160,
|
||||
min((curTick - selTick - 200) / 3, 255u));
|
||||
}
|
||||
}
|
||||
|
||||
//Files & Dirs
|
||||
|
@ -1,6 +1,6 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Massimiliano Torromeo *
|
||||
* massimiliano.torromeo@gmail.com *
|
||||
* Copyright (C) 2006 by Massimiliano Torromeo *
|
||||
* massimiliano.torromeo@gmail.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
@ -138,7 +138,7 @@ void TextDialog::exec() {
|
||||
if (firstRow + rowsPerPage*2 -1 < text->size()) {
|
||||
firstRow += rowsPerPage-1;
|
||||
} else {
|
||||
firstRow = max(0, text->size() - rowsPerPage);
|
||||
firstRow = max(0u, text->size() - rowsPerPage);
|
||||
}
|
||||
break;
|
||||
case InputManager::SETTINGS:
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "gmenu2x.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
@ -131,7 +132,7 @@ void TextManualDialog::exec() {
|
||||
break;
|
||||
case InputManager::ALTRIGHT:
|
||||
if (firstRow + rowsPerPage*2 -1 < pages[page].text.size()) firstRow += rowsPerPage-1;
|
||||
else firstRow = max(0, pages[page].text.size() - rowsPerPage);
|
||||
else firstRow = max(0u, pages[page].text.size() - rowsPerPage);
|
||||
break;
|
||||
case InputManager::CANCEL:
|
||||
case InputManager::SETTINGS:
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "debug.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <algorithm>
|
||||
|
||||
//for browsing the filesystem
|
||||
#include <sys/stat.h>
|
||||
@ -86,14 +87,8 @@ bool rmtree(string path) {
|
||||
return rmdir(path.c_str())==0;
|
||||
}
|
||||
|
||||
int max (int a, int b) {
|
||||
return a>b ? a : b;
|
||||
}
|
||||
int min (int a, int b) {
|
||||
return a<b ? a : b;
|
||||
}
|
||||
int constrain (int x, int imin, int imax) {
|
||||
return min( imax, max(imin,x) );
|
||||
int constrain(int x, int imin, int imax) {
|
||||
return min(imax, max(imin, x));
|
||||
}
|
||||
|
||||
//Configuration parsing utilities
|
||||
|
@ -36,8 +36,6 @@ std::string cmdclean(std::string cmdline);
|
||||
bool fileExists(const std::string &file);
|
||||
bool rmtree(std::string path);
|
||||
|
||||
int max(int a, int b);
|
||||
int min(int a, int b);
|
||||
int constrain(int x, int imin, int imax);
|
||||
|
||||
int evalIntConf(int val, int def, int imin, int imax);
|
||||
|
Loading…
Reference in New Issue
Block a user