Re: Gtk::Table really slow



Thank you for replying :)

I modified the loop:

for(int y = 0; y < gData->height; y++)
{
	for(int x = 0; x < gData->width; x++)
	{
		//Initialise the array of cells to ROAD_CELL
		*(gData->pmap + y*gData->width + x) = Pfv::ROAD_CELL;

		//Initialise the array of firstCall to true
		*(gData->pcalls + y*gData->width + x) = true;

		//Create the event box and the label
		Gtk::EventBox* eb = manage(new Gtk::EventBox());
		*(gData->pcells + y*gData->width + x) = eb;
		eb->set_size_request(cellSize, cellSize);
			
		//Add the event box to the grid
		gData->grid->attach(*eb, x, x + 1, y, y + 1);

		//Set the image of the event box to ROAD_IMAGE
		eb->modify_bg_pixmap(Gtk::STATE_NORMAL, gData->ROAD_IMAGE);

		eb->signal_button_press_event().connect(sigc::bind<int,
int>(sigc::mem_fun(*this,
              			&newGridAction::on_cell_clicked), x, y));
		eb->signal_size_allocate().connect(sigc::bind<Gtk::EventBox*, int, int>
(sigc::mem_fun
                                (*this,
&newGridAction::on_grid_image_resized), eb, x, y));
		eb->signal_enter_notify_event().connect(sigc::bind<int,
int>(sigc::mem_fun(*this,
				&newGridAction::on_mouse_over_cell), x, y));

	}
}

Like Juan said, I don't need to call to eb->show_all_children in every
iteration. Furthermore, I avoided the creation of a pixbuf and an image in
every iteration by setting the background of the event box. Each iteration
is now 0,2-0,3 ms less than before, but it is still too slow, and when the
loop finishes, it takes a lot of time to show the table.

I am going to have a look at goocanvas like Murray suggested, but after
browsing a little bit its website, I really don't know what it can provide
me in this situation.


Jordi
-- 
View this message in context: http://www.nabble.com/Gtk%3A%3ATable-really-slow-tp24546767p24568835.html
Sent from the Gtkmm mailing list archive at Nabble.com.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]