コード例 #1
0
ファイル: slider.cpp プロジェクト: Martin9295/wesnoth
bool tslider::on_positioner(const tpoint& coordinate) const
{
	// Note we assume the positioner is over the entire height of the widget.
	return coordinate.x >= static_cast<int>(get_positioner_offset())
		   && coordinate.x < static_cast<int>(get_positioner_offset()
											  + get_positioner_length())
		   && coordinate.y > 0 && coordinate.y < static_cast<int>(get_height());
}
コード例 #2
0
bool tvertical_scrollbar::on_positioner(const tpoint& coordinate) const
{
	// Note we assume the positioner is over the entire width of the widget.
	return coordinate.y >= static_cast<int>(get_positioner_offset())
		&& coordinate.y < static_cast<int>(get_positioner_offset() + get_positioner_length())
		&& coordinate.x > 0
		&& coordinate.x < static_cast<int>(get_width());
}
コード例 #3
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);
}
コード例 #4
0
ファイル: slider.cpp プロジェクト: suxinde2009/Rose
int tslider::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 height of the widget.
	if(static_cast<size_t>(coordinate.x) < get_positioner_offset()) {
		return -1;
	} else if(static_cast<size_t>(coordinate.x) >get_positioner_offset() + get_positioner_length()) {
		return 1;
	} else {
		return 0;
	}
}
コード例 #5
0
ファイル: slider.cpp プロジェクト: GregoryLundberg/wesnoth
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;
}