mirror of
https://github.com/raysan5/raygui.git
synced 2026-02-03 04:39:18 -05:00
Fix GuiScrollBar dragging taking slider behavior (#313)
This commit is contained in:
13
src/raygui.h
13
src/raygui.h
@ -4878,14 +4878,16 @@ static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
|
|||||||
|
|
||||||
if (guiSliderDragging) // Keep dragging outside of bounds
|
if (guiSliderDragging) // Keep dragging outside of bounds
|
||||||
{
|
{
|
||||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON) &&
|
||||||
|
!CheckCollisionPointRec(mousePoint, arrowUpLeft) &&
|
||||||
|
!CheckCollisionPointRec(mousePoint, arrowDownRight))
|
||||||
{
|
{
|
||||||
if (CHECK_BOUNDS_ID(bounds, guiSliderActive))
|
if (CHECK_BOUNDS_ID(bounds, guiSliderActive))
|
||||||
{
|
{
|
||||||
state = STATE_PRESSED;
|
state = STATE_PRESSED;
|
||||||
|
|
||||||
if (isVertical) value += (int)(GetMouseDelta().y/(scrollbar.height - slider.height)*valueRange);
|
if (isVertical) value = (int)(((float)(mousePoint.y - scrollbar.y - slider.height/2)*valueRange)/(scrollbar.height - slider.height) + minValue);
|
||||||
else value += (int)(GetMouseDelta().x/(scrollbar.width - slider.width)*valueRange);
|
else value = (int)(((float)(mousePoint.x - scrollbar.x - slider.width/2)*valueRange)/(scrollbar.width - slider.width) + minValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -4920,11 +4922,6 @@ static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
|
|||||||
|
|
||||||
state = STATE_PRESSED;
|
state = STATE_PRESSED;
|
||||||
}
|
}
|
||||||
else if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
|
|
||||||
{
|
|
||||||
if (isVertical) value += (int)(GetMouseDelta().y/(scrollbar.height - slider.height)*valueRange);
|
|
||||||
else value += (int)(GetMouseDelta().x/(scrollbar.width - slider.width)*valueRange);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Keyboard control on mouse hover scrollbar
|
// Keyboard control on mouse hover scrollbar
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user