public static MinMaxScroller ( |
||
position | ||
id | int | |
value | float | |
size | float | |
visualStart | float | |
visualEnd | float | |
startLimit | float | |
endLimit | float | |
slider | ||
thumb | ||
leftButton | ||
rightButton | ||
horiz | bool | |
return | void |
public static void MinMaxScroller(Rect position, int id, ref float value, ref float size, float visualStart, float visualEnd, float startLimit, float endLimit, GUIStyle slider, GUIStyle thumb, GUIStyle leftButton, GUIStyle rightButton, bool horiz)
{
float num;
Rect rect;
Rect rect2;
Rect rect3;
if (horiz)
{
num = (size * 10f) / position.width;
}
else
{
num = (size * 10f) / position.height;
}
if (horiz)
{
rect = new Rect(position.x + leftButton.fixedWidth, position.y, (position.width - leftButton.fixedWidth) - rightButton.fixedWidth, position.height);
rect2 = new Rect(position.x, position.y, leftButton.fixedWidth, position.height);
rect3 = new Rect(position.xMax - rightButton.fixedWidth, position.y, rightButton.fixedWidth, position.height);
}
else
{
rect = new Rect(position.x, position.y + leftButton.fixedHeight, position.width, (position.height - leftButton.fixedHeight) - rightButton.fixedHeight);
rect2 = new Rect(position.x, position.y, position.width, leftButton.fixedHeight);
rect3 = new Rect(position.x, position.yMax - rightButton.fixedHeight, position.width, rightButton.fixedHeight);
}
float num2 = Mathf.Min(visualStart, value);
float num3 = Mathf.Max(visualEnd, value + size);
MinMaxSlider(rect, ref value, ref size, num2, num3, num2, num3, slider, thumb, horiz);
bool flag = false;
if (Event.current.type == EventType.MouseUp)
{
flag = true;
}
if (ScrollerRepeatButton(id, rect2, leftButton))
{
value -= num * ((visualStart >= visualEnd) ? -1f : 1f);
}
if (ScrollerRepeatButton(id, rect3, rightButton))
{
value += num * ((visualStart >= visualEnd) ? -1f : 1f);
}
if (flag && (Event.current.type == EventType.Used))
{
scrollControlID = 0;
}
if (startLimit < endLimit)
{
value = Mathf.Clamp(value, startLimit, endLimit - size);
}
else
{
value = Mathf.Clamp(value, endLimit, startLimit - size);
}
}
private void SliderGUI() { if (!this.m_HSlider && !this.m_VSlider) { return; } Bounds drawingBounds = this.drawingBounds; Rect areaInsideMargins = this.shownAreaInsideMargins; float num1 = this.styles.sliderWidth - this.styles.visualSliderWidth; float num2 = !this.vSlider || !this.hSlider ? 0.0f : num1; Vector2 scale = this.m_Scale; if (this.m_HSlider) { Rect position = new Rect(this.drawRect.x + 1f, this.drawRect.yMax - num1, this.drawRect.width - num2, this.styles.sliderWidth); float width = areaInsideMargins.width; float xMin = areaInsideMargins.xMin; EditorGUIExt.MinMaxScroller(position, this.horizontalScrollbarID, ref xMin, ref width, drawingBounds.min.x, drawingBounds.max.x, float.NegativeInfinity, float.PositiveInfinity, this.styles.horizontalScrollbar, this.styles.horizontalMinMaxScrollbarThumb, this.styles.horizontalScrollbarLeftButton, this.styles.horizontalScrollbarRightButton, true); float num3 = xMin; float num4 = xMin + width; if ((double)num3 > (double)areaInsideMargins.xMin) { num3 = Mathf.Min(num3, num4 - this.m_HScaleMin); } if ((double)num4 < (double)areaInsideMargins.xMax) { num4 = Mathf.Max(num4, num3 + this.m_HScaleMin); } this.SetShownHRangeInsideMargins(num3, num4); } if (this.m_VSlider) { Rect position = new Rect(this.drawRect.xMax - num1, this.drawRect.y, this.styles.sliderWidth, this.drawRect.height - num2); float height = areaInsideMargins.height; float num3 = -areaInsideMargins.yMax; EditorGUIExt.MinMaxScroller(position, this.verticalScrollbarID, ref num3, ref height, -drawingBounds.max.y, -drawingBounds.min.y, float.NegativeInfinity, float.PositiveInfinity, this.styles.verticalScrollbar, this.styles.verticalMinMaxScrollbarThumb, this.styles.verticalScrollbarUpButton, this.styles.verticalScrollbarDownButton, false); float num4 = (float)-((double)num3 + (double)height); float num5 = -num3; if ((double)num4 > (double)areaInsideMargins.yMin) { num4 = Mathf.Min(num4, num5 - this.m_VScaleMin); } if ((double)num5 < (double)areaInsideMargins.yMax) { num5 = Mathf.Max(num5, num4 + this.m_VScaleMin); } this.SetShownVRangeInsideMargins(num4, num5); } if (!this.uniformScale) { return; } float num6 = this.drawRect.width / this.drawRect.height; Vector2 vector2 = scale - this.m_Scale; this.m_Scale -= new Vector2(-vector2.y * num6, -vector2.x / num6); this.m_Translation.x -= vector2.y / 2f; this.m_Translation.y -= vector2.x / 2f; this.EnforceScaleAndRange(); }