smani
March 28th, 2010, 04:14 PM
Hello,
I have a small problem: I have some scrolled window + viewport + image surface. I have a function that zooms in, keeping the target area under the mouse pointer, hence I do resize, then adjust scrollbars, basic code:
# a set_size_request triggers expose
def expose(self,widget,event):
self.draw()
def draw(self):
[Create buffer ...]
if self.zoomTarget!=None:
[...]
self.scrolled_window.get_hscrollbar().set_value(se lf.scrollX)
self.scrolled_window.get_vscrollbar().set_value(se lf.scrollY)
[Draw buffer to the image]
This generally redraws once at the expose, and then at least once again after setting the scrollbars. I'd like to prevent the first redraw from happening, but I cannot write return after setting the scrollbar values since in some special cases the scrollbar aren't moved and hence no expose event would be fired afterwards (and I'm left with an undrawn surface).
So question: is there any way to determine if a redraw is queued in the gtk loop, so that I could write
# a set_size_request triggers expose
def expose(self,widget,event):
self.draw()
def draw(self):
[Create buffer ...]
if self.zoomTarget!=None:
[...]
self.scrolled_window.get_hscrollbar().set_value(se lf.scrollX)
self.scrolled_window.get_vscrollbar().set_value(se lf.scrollY)
if <redraw queued>:
return
[Draw buffer to the image]
or is there any other common design pattern to handle this kind of problems?
Thanks!
Cheers
smani
I have a small problem: I have some scrolled window + viewport + image surface. I have a function that zooms in, keeping the target area under the mouse pointer, hence I do resize, then adjust scrollbars, basic code:
# a set_size_request triggers expose
def expose(self,widget,event):
self.draw()
def draw(self):
[Create buffer ...]
if self.zoomTarget!=None:
[...]
self.scrolled_window.get_hscrollbar().set_value(se lf.scrollX)
self.scrolled_window.get_vscrollbar().set_value(se lf.scrollY)
[Draw buffer to the image]
This generally redraws once at the expose, and then at least once again after setting the scrollbars. I'd like to prevent the first redraw from happening, but I cannot write return after setting the scrollbar values since in some special cases the scrollbar aren't moved and hence no expose event would be fired afterwards (and I'm left with an undrawn surface).
So question: is there any way to determine if a redraw is queued in the gtk loop, so that I could write
# a set_size_request triggers expose
def expose(self,widget,event):
self.draw()
def draw(self):
[Create buffer ...]
if self.zoomTarget!=None:
[...]
self.scrolled_window.get_hscrollbar().set_value(se lf.scrollX)
self.scrolled_window.get_vscrollbar().set_value(se lf.scrollY)
if <redraw queued>:
return
[Draw buffer to the image]
or is there any other common design pattern to handle this kind of problems?
Thanks!
Cheers
smani