Browse Source

Fix std::clamp whining

kiwec 2 months ago
parent
commit
695cd5867d
2 changed files with 7 additions and 1 deletions
  1. 1 1
      src/GUI/CBaseUIScrollView.cpp
  2. 6 0
      src/Util/cbase.h

+ 1 - 1
src/GUI/CBaseUIScrollView.cpp

@@ -519,7 +519,7 @@ void CBaseUIScrollView::updateScrollbars() {
         const float verticalPercent = clamp<float>(rawVerticalPercent, 0.0f, 1.0f);
 
         const float verticalHeightPercent = (m_vSize.y - (verticalBlockWidth * 2)) / m_vScrollSize.y;
-        const float verticalBlockHeight = clamp<float>(
+        const float verticalBlockHeight = bad_clamp<float>(
             max(verticalHeightPercent * m_vSize.y, verticalBlockWidth) * overscroll, verticalBlockWidth, m_vSize.y);
 
         m_verticalScrollbar =

+ 6 - 0
src/Util/cbase.h

@@ -135,6 +135,12 @@ typedef unsigned char COLORPART;
 
 // UTIL
 
+// "bad" because a can be lower than b
+template <class T>
+inline T bad_clamp(T x, T a, T b) {
+    return x < a ? a : (x > b ? b : x);
+}
+
 template <class T>
 inline T lerp(T x1, T x2, T percent) {
     return x1 * (1 - percent) + x2 * percent;