Element scroll bar Improvement
Signed-off-by: xphere07 <xphere07@outlook.com>
This commit is contained in:
parent
48e15af738
commit
18c604fd42
@ -921,32 +921,49 @@ void GameView::updateToolButtonScroll()
|
||||
{
|
||||
if (toolButtons.size())
|
||||
{
|
||||
int x = currentMouse.X, y = currentMouse.Y;
|
||||
int x = currentMouse.X;
|
||||
int y = currentMouse.Y;
|
||||
|
||||
int offsetDelta = 0;
|
||||
|
||||
int newInitialX = WINDOWW - 56;
|
||||
int totalWidth = (toolButtons[0]->Size.X + 1) * toolButtons.size();
|
||||
int scrollSize = (int)(((float)(XRES - BARSIZE))/((float)totalWidth) * ((float)XRES - BARSIZE));
|
||||
|
||||
if (scrollSize > XRES - 1)
|
||||
scrollSize = XRES - 1;
|
||||
|
||||
if (totalWidth > XRES - 15)
|
||||
{
|
||||
int mouseX = x;
|
||||
|
||||
float overflow = 0;
|
||||
float mouseLocation = 0;
|
||||
|
||||
if (mouseX > XRES)
|
||||
mouseX = XRES;
|
||||
|
||||
// if (mouseX < 15) // makes scrolling a little nicer at edges but apparently if you put hundreds of elements in a menu it makes the end not show ...
|
||||
// mouseX = 15;
|
||||
|
||||
scrollBar->Position.X = (int)(((float)mouseX/((float)XRES))*(float)(XRES-scrollSize));
|
||||
scrollBar->Visible = true;
|
||||
|
||||
float overflow = float(totalWidth-(XRES-BARSIZE)), mouseLocation = float(XRES-3)/float((XRES-2)-mouseX); //mouseLocation adjusted slightly in case you have 200 elements in one menu
|
||||
scrollBar->Position.X = (int)(((float)mouseX / (float)XRES) * (float)(XRES - scrollSize)) + 1;
|
||||
|
||||
newInitialX += int(overflow/mouseLocation);
|
||||
overflow = (float)(totalWidth - (XRES - BARSIZE));
|
||||
mouseLocation = (float)(XRES - 3)/(float)((XRES - 2) - mouseX); // mouseLocation adjusted slightly in case you have 200 elements in one menu
|
||||
|
||||
newInitialX += (int)(overflow/mouseLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollBar->Position.X = 1;
|
||||
scrollBar->Visible = false;
|
||||
}
|
||||
scrollBar->Size.X=scrollSize;
|
||||
int offsetDelta = toolButtons[0]->Position.X - newInitialX;
|
||||
|
||||
scrollBar->Size.X = scrollSize - 1;
|
||||
|
||||
offsetDelta = toolButtons[0]->Position.X - newInitialX;
|
||||
|
||||
for (auto *button : toolButtons)
|
||||
{
|
||||
button->Position.X -= offsetDelta;
|
||||
|
Loading…
Reference in New Issue
Block a user