int tvertical_scrollbar::on_bar(const tpoint& coordinate) const
{
	// Not on the widget, leave.
	if(static_cast<size_t>(coordinate.x) > get_width()
			|| static_cast<size_t>(coordinate.y) > get_height()) {
		return 0;
	}

	// we also assume the bar is over the entire width of the widget.
	if(static_cast<size_t>(coordinate.y) < get_positioner_offset()) {
		return -1;
	} else if(static_cast<size_t>(coordinate.y) >get_positioner_offset() + get_positioner_length()) {
		return 1;
	} else {
		return 0;
	}
}
bool horizontal_scrollbar::on_positioner(const point& coordinate) const
{
	SDL_Rect positioner_rect =
		sdl::create_rect(get_positioner_offset(), 0, get_positioner_length(), get_height());

	// Note we assume the positioner is over the entire height of the widget.
	return sdl::point_in_rect(coordinate, positioner_rect);
}
Example #3
0
int slider::on_bar(const point& coordinate) const
{
    const unsigned x = static_cast<size_t>(coordinate.x);
    const unsigned y = static_cast<size_t>(coordinate.y);

    // Not on the widget, leave.
    if(x > get_width() || y > get_height()) {
        return 0;
    }

    // we also assume the bar is over the entire height of the widget.
    if(x < get_positioner_offset()) {
        return -1;
    } else if(x > get_positioner_offset() + get_positioner_length()) {
        return 1;
    }

    return 0;
}