mirror of
https://github.com/edubart/otclient.git
synced 2025-12-26 09:47:11 +01:00
Use of clamp
This commit is contained in:
@@ -358,8 +358,8 @@ void UITextEdit::setSelection(int start, int end)
|
||||
if(end == -1)
|
||||
end = 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());
|
||||
m_selectionStart = stdext::clamp<int>(start, 0, (int)m_text.length());
|
||||
m_selectionEnd = stdext::clamp<int>(end, 0, (int)m_text.length());
|
||||
}
|
||||
|
||||
void UITextEdit::setTextHidden(bool hidden)
|
||||
|
||||
@@ -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<int>(std::max<int>(index, 0), (int)m_children.size());
|
||||
index = stdext::clamp<int>(index, 0, (int)m_children.size());
|
||||
}
|
||||
|
||||
// retrieve child by index
|
||||
|
||||
@@ -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<float>(std::max<float>(opacity, 0.0f), 1.0f); }
|
||||
void setOpacity(float opacity) { m_opacity = stdext::clamp<float>(opacity, 0.0f, 1.0f); }
|
||||
void setRotation(float degrees) { m_rotation = degrees; }
|
||||
|
||||
int getX() { return m_rect.x(); }
|
||||
|
||||
Reference in New Issue
Block a user