summaryrefslogtreecommitdiff
path: root/libs/canvas/test/gtk_many.cc
blob: e75ce05ac0dcc0f388cdf162d5f496e45f9302d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <gtkmm.h>
#include "canvas/canvas.h"
#include "canvas/rectangle.h"

using namespace std;
using namespace ArdourCanvas;

int main (int argc, char* argv[])
{
	Gtk::Main kit (argc, argv);

	Gtk::Window window;
	window.set_title ("Hello world");
	window.set_size_request (512, 512);
	GtkCanvas canvas;
	canvas.set_size_request (2048, 2048);

	int const N = 10000;
	double Ns = sqrt (N);
	int max_x = 1024;
	int max_y = 1024;
	
	for (int x = 0; x < Ns; ++x) {
		for (int y = 0; y < Ns; ++y) {
			Rectangle* r = new Rectangle (canvas.root ());
			r->set (Rect (x * max_x / Ns, y * max_y / Ns, (x + 1) * max_x / Ns, (y + 1) * max_y / Ns));
		}
	}
	
	Gtk::ScrolledWindow scroller;
	scroller.add (canvas);
	window.add (scroller);
	canvas.show ();
	window.show_all ();
	
	Gtk::Main::run (window);
	return 0;
}