PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
smooth scrolling for a gtkimage drawing (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: smooth scrolling for a gtkimage drawing
#93
paamayim (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
smooth scrolling for a gtkimage drawing 8 Months, 3 Weeks ago Karma: 0  
I'm familiarizing with PHP-GTK2 and I must admints it's not so hard, also thanks to samples and tutorials around, such as one I found in this site about displaying a graph.

Using that useful code as a start I enanched it to display a graph, bounding a scrollbar to modify the scale of x axis and y axis.

What I've done is creating a timeout_add to call every 100 ms to render the graph in the following function ($graph is a GtkImage() globally declared):

Code:
function onRenderGraph()
{
	global $graph, $hscroll;

	$im = imagecreate(GRAPH_W, GRAPH_H);

	// painting stuff ... on $im
	
	$pixbuf = GdkPixbuf::new_from_gd( $im );
	$graph->set_from_pixbuf($pixbuf);

	return true;
}
When I drag the scrollbar, the changes are not instant, but they happen at least every 100 ms, the timeout delay. I would need a function to connect with a sort of "onScrollChange" event, but I didnt find any :( Moreover, I was thinking if the onRenderGraph() function could be optimized, without creating every time the $im buffer, maybe create it once when the program starts, and in the function above writing directly to the gd buffer? I realize I've wrote too much maybe, thanks for reading if you've come up so far.
 
  The administrator has disabled public write access.
#94
kksou (Admin)
Admin
Posts: 391
graph
User Online Now Click here to see the profile of this user
Re:smooth scrolling for a gtkimage drawing 8 Months, 3 Weeks ago Karma: 8  
 
  The administrator has disabled public write access.
#95
paamayim (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:smooth scrolling for a gtkimage drawing 8 Months, 3 Weeks ago Karma: 0  
It sure helped me a lot.

Man, you're amazing.
 
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2008. kksou.com. All Rights Reserved