Example #1
0
bool GrBx::Area::on_scroll_event (GdkEventScroll *_scroll)
{
    bool ret = Gtk::Widget::on_scroll_event (_scroll);
    if (_scroll)
    {
	double prev_sx = sx, prev_sy = sy;
	double x1, y1, x2, y2;
	calculate_bounds (x1, y1, x2, y2);
	switch (_scroll->direction)
	{
	    case GDK_SCROLL_UP:
		sx += ZOOM_STEP;
		sy += ZOOM_STEP;
		break;
		
	    case GDK_SCROLL_DOWN:
		if (sx > ZOOM_STEP && sy > ZOOM_STEP)
		{
		    sx -= ZOOM_STEP;
		    sy -= ZOOM_STEP;
		}
		break;
		
	    default:
		break;
	}
	if (prev_sx != sx) hadjustment.configure (hadjustment.get_value () / prev_sx * sx, x1 * sx, x2 * sx, sx, 10 * sx, hadjustment.get_page_size ());
	if (prev_sy != sy) vadjustment.configure (vadjustment.get_value () / prev_sy * sy, y1 * sy, y2 * sy, sy, 10 * sy, vadjustment.get_page_size ());
	if (prev_sx != sx || prev_sy != sy) draw_graphs ();
    }
    return ret;
}
Example #2
0
void GrBx::Area::alignment_all ()
{
    double x1, y1, x2, y2;
    calculate_bounds (x1, y1, x2, y2);
    
    sx = get_width () / (x2 - x1);
    sy = get_height () / (y2 - y1);

    hadjustment.configure (x1 * sx, x1 * sx, x2 * sx, sx, 10 * sx, (x2 - x1) * sx);
    vadjustment.configure (y1 * sy, y1 * sy, y2 * sy, sy, 10 * sy, (y2 - y1) * sy);
}
Example #3
0
void Frame::run()
{
	while(isOpen())
	{
		calculate_bounds();
		calculate_mouse_pos();
		while(pollEvent(_event))
		{
			eventHandling();
		}
		drawAll();
	}
}
ScreenShooter::ScreenShooter() {
  init_displays();
  calculate_bounds();
}
Example #5
0
void map_view::draw(int width, int height, int grid_pitch) const
{
	int corner_x, corner_y;
	int x, y;
	int w, h;
	float xmin, xmax;
	float ymin, ymax;
	float cw, ch;
	const tileset *ts;
	SDL_Rect dst;

	int pw, ph;

	w = cur_map->get_width();
	h = cur_map->get_height();
	ts = cur_map->get_tileset();

	pw = w * grid_pitch;
	ph = h * grid_pitch;

	cw = (float)width / (float)grid_pitch;
	ch = (float)width / (float)grid_pitch;

	calculate_bounds(w, grid_pitch, width, hero->get_x(), &corner_x);
	calculate_bounds(h, grid_pitch, height, hero->get_y(), &corner_y);

	dst.x = corner_x;
	dst.y = corner_y;
	dst.w = pw;
	dst.h = ph;

	for (y = 0; y < h; y++) {
		for (x = 0; x < w; x++) {
			const tile *t;
			unsigned short tileid;

			tileid = cur_map->get_tile(x, y);

			if (tileid) {
				ts->get_tile(tileid - 1)->draw(rend,
					corner_x + x * 32,
					corner_y + y * 32,
					32
				);
			}
		}
	}

	std::vector<sprite *> slist;

	std::set<sprite *>::iterator sb, se;

	sb = sprites.begin();
	se = sprites.end();

	while (sb != se) {
		slist.push_back(*sb++);
	}

	std::sort(slist.begin(), slist.end(), less);

	std::vector<sprite *>::iterator slb, sle;

	slb = slist.begin();
	sle = slist.end();

	while (slb != sle) {
		(*slb++)->draw(rend, corner_x, corner_y, grid_pitch);
	}
}