void Slider::GetButtonState() { Input* input = gEngine->GetInput(); POINT cursorPos = input->GetCursorPos(); if(state == Active && input->GetLeftButton()) return; float offset = ((value - minValue)/(maxValue - minValue)) * (screenRect.right - style->sliderBarSize*(screenRect.bottom - screenRect.top) - screenRect.left); float width = style->sliderBarSize * (screenRect.bottom - screenRect.top); if(cursorPos.x > screenRect.left && cursorPos.x < screenRect.right && cursorPos.y > screenRect.top && cursorPos.y < screenRect.bottom && input->GetLeftButton()) { state = Active; return; } if(cursorPos.x > screenRect.left + offset && cursorPos.x < screenRect.left + offset + width && cursorPos.y > screenRect.top && cursorPos.y < screenRect.bottom) { state = Hover; } else state = Normal; }
void Toggle::GetButtonState() { Input* input = gEngine->GetInput(); POINT cursorPos = input->GetCursorPos(); if(cursorPos.x > screenRect.left && cursorPos.x < screenRect.right && cursorPos.y > screenRect.top && cursorPos.y < screenRect.bottom) { if(input->GetLeftButton()) state = Active; else state = Hover; } else state = Normal; }