scroll normalization corrected and now has boundary restrictions.
This commit is contained in:
parent
72188194e5
commit
c52283295a
@ -31,12 +31,17 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return -shiftX;
|
return (Width - horizontalScrollBarBounds.Width) * (-shiftX / (group.Width - viewport.Width));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
shiftX = -value;
|
if (value > Width - verticalScrollBarBounds.Height)
|
||||||
|
{
|
||||||
|
value = Width - verticalScrollBarBounds.Height;
|
||||||
|
}
|
||||||
|
if (value < 0) value = 0;
|
||||||
|
shiftX = -(group.Width - viewport.Width) * (value / (Width - horizontalScrollBarBounds.Width));
|
||||||
WidthOrXChange(true);
|
WidthOrXChange(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,12 +49,17 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return shiftY;
|
return (Height - verticalScrollBarBounds.Height) * (-shiftY / (group.Height - viewport.Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
shiftY = value;
|
if (value > Height - verticalScrollBarBounds.Height)
|
||||||
|
{
|
||||||
|
value = Height - verticalScrollBarBounds.Height;
|
||||||
|
}
|
||||||
|
if (value < 0) value = 0;
|
||||||
|
shiftY = -(group.Height - viewport.Height) * (value/(Height - verticalScrollBarBounds.Height));
|
||||||
HeightOrYChange(true);
|
HeightOrYChange(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,12 +213,12 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
|
|||||||
|
|
||||||
if (horScrollAvailable)
|
if (horScrollAvailable)
|
||||||
{
|
{
|
||||||
horizontalScrollBarBounds.X = (int)(((float)-shiftX / group.Width) * (viewport.Width - horizontalScrollBarBounds.Width));
|
horizontalScrollBarBounds.X = (int)XScrollPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vertScrollAvailable)
|
if (vertScrollAvailable)
|
||||||
{
|
{
|
||||||
verticalScrollBarBounds.Y = (int)(((float)-shiftY / group.Height) * (viewport.Height - verticalScrollBarBounds.Height));
|
verticalScrollBarBounds.Y = (int)YScrollPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -373,7 +383,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
|
|||||||
{
|
{
|
||||||
if (state.IsKeyDown(Keys.Right))
|
if (state.IsKeyDown(Keys.Right))
|
||||||
{
|
{
|
||||||
XScrollPosition += 20;
|
XScrollPosition += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.KeyboardStateChanged(state);
|
return base.KeyboardStateChanged(state);
|
||||||
@ -420,13 +430,13 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
|
|||||||
{
|
{
|
||||||
if (horizontalSelected)
|
if (horizontalSelected)
|
||||||
{
|
{
|
||||||
float latestPosition = state.X - mouseRelativePosition.X;
|
float latestPosition = state.X - mouseRelativePosition.X - X;
|
||||||
XScrollPosition = (latestPosition / (Width - horizontalScrollBarBounds.Width)) * group.Width;
|
XScrollPosition = latestPosition;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float latestPosition = state.Y - mouseRelativePosition.Y;
|
float latestPosition = state.Y - mouseRelativePosition.Y - Y;
|
||||||
YScrollPosition = -(latestPosition / (Height - verticalScrollBarBounds.Height)) * group.Height;
|
YScrollPosition = latestPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.LeftButton == ButtonState.Released)
|
if (state.LeftButton == ButtonState.Released)
|
||||||
|
Loading…
Reference in New Issue
Block a user