Fix compilation under MSVC

Use template for std::min and std::max
This commit is contained in:
conde2
2013-11-30 23:08:43 -02:00
parent b61f509755
commit ca2fe9cf45
10 changed files with 28 additions and 28 deletions

View File

@@ -66,10 +66,10 @@ bool UIHorizontalLayout::internalUpdate()
pos.y = paddingRect.top() + widget->getMarginTop();
} else if(widget->getTextAlign() & Fw::AlignBottom) {
pos.y = paddingRect.bottom() - widget->getHeight() - widget->getMarginBottom();
pos.y = std::max(pos.y, paddingRect.top());
pos.y = std::max<int>(pos.y, paddingRect.top());
} else { // center it
pos.y = paddingRect.top() + (paddingRect.height() - (widget->getMarginTop() + widget->getHeight() + widget->getMarginBottom()))/2;
pos.y = std::max(pos.y, paddingRect.top());
pos.y = std::max<int>(pos.y, paddingRect.top());
}
} else {
// expand height

View File

@@ -40,7 +40,7 @@ public:
virtual void addWidget(const UIWidgetPtr& widget) { }
virtual void removeWidget(const UIWidgetPtr& widget) { }
void disableUpdates() { m_updateDisabled++; }
void enableUpdates() { m_updateDisabled = std::max(m_updateDisabled-1,0); }
void enableUpdates() { m_updateDisabled = std::max<int>(m_updateDisabled-1,0); }
void setParent(UIWidgetPtr parentWidget) { m_parentWidget = parentWidget; }
UIWidgetPtr getParentWidget() { return m_parentWidget; }

View File

@@ -181,15 +181,15 @@ void UITextEdit::update(bool focusCursor)
if(!virtualRect.contains(glyphRect.topLeft()) || !virtualRect.contains(glyphRect.bottomRight())) {
// calculate where is the first glyph visible
Point startGlyphPos;
startGlyphPos.y = std::max(glyphRect.bottom() - virtualRect.height(), 0);
startGlyphPos.x = std::max(glyphRect.right() - virtualRect.width(), 0);
startGlyphPos.y = std::max<int>(glyphRect.bottom() - virtualRect.height(), 0);
startGlyphPos.x = std::max<int>(glyphRect.right() - virtualRect.width(), 0);
// find that glyph
for(pos = 0; pos < textLength; ++pos) {
glyph = (uchar)text[pos];
glyphRect = Rect(glyphsPositions[pos], glyphsSize[glyph]);
glyphRect.setTop(std::max(glyphRect.top() - m_font->getYOffset() - m_font->getGlyphSpacing().height(), 0));
glyphRect.setLeft(std::max(glyphRect.left() - m_font->getGlyphSpacing().width(), 0));
glyphRect.setTop(std::max<int>(glyphRect.top() - m_font->getYOffset() - m_font->getGlyphSpacing().height(), 0));
glyphRect.setLeft(std::max<int>(glyphRect.left() - m_font->getGlyphSpacing().width(), 0));
// first glyph entirely visible found
if(glyphRect.topLeft() >= startGlyphPos) {
@@ -358,8 +358,8 @@ void UITextEdit::setSelection(int start, int end)
if(end == -1)
end = m_text.length();
m_selectionStart = std::min(std::max(start, 0), (int)m_text.length());
m_selectionEnd = std::min(std::max(end, 0), (int)m_text.length());
m_selectionStart = std::min<int>(std::max<int>(start, 0), (int)m_text.length());
m_selectionEnd = std::min<int>(std::max<int>(end, 0), (int)m_text.length());
}
void UITextEdit::setTextHidden(bool hidden)

View File

@@ -68,10 +68,10 @@ bool UIVerticalLayout::internalUpdate()
pos.x = paddingRect.left() + widget->getMarginLeft();
} else if(widget->getTextAlign() & Fw::AlignLeft) {
pos.x = paddingRect.bottom() - widget->getHeight() - widget->getMarginBottom();
pos.x = std::max(pos.x, paddingRect.left());
pos.x = std::max<int>(pos.x, paddingRect.left());
} else {
pos.x = paddingRect.left() + (paddingRect.width() - (widget->getMarginLeft() + widget->getWidth() + widget->getMarginRight()))/2;
pos.x = std::max(pos.x, paddingRect.left());
pos.x = std::max<int>(pos.x, paddingRect.left());
}
} else {
// expand width

View File

@@ -192,7 +192,7 @@ void UIWidget::insertChild(int index, const UIWidgetPtr& child)
if(!(index >= 0 && (uint)index <= m_children.size())) {
//g_logger.traceWarning("attempt to insert a child UIWidget into an invalid index, using nearest index...");
index = std::min(std::max(index, 0), (int)m_children.size());
index = std::min<int>(std::max<int>(index, 0), (int)m_children.size());
}
// retrieve child by index

View File

@@ -346,7 +346,7 @@ public:
void setPaddingRight(int padding) { m_padding.right = padding; updateLayout(); }
void setPaddingBottom(int padding) { m_padding.bottom = padding; updateLayout(); }
void setPaddingLeft(int padding) { m_padding.left = padding; updateLayout(); }
void setOpacity(float opacity) { m_opacity = std::min(std::max(opacity, 0.0f), 1.0f); }
void setOpacity(float opacity) { m_opacity = std::min<float>(std::max<float>(opacity, 0.0f), 1.0f); }
void setRotation(float degrees) { m_rotation = degrees; }
int getX() { return m_rect.x(); }