Ticket #43423: surface-geometry.patch

File surface-geometry.patch, 2.0 KB (added by count0 (Tiago de Paula Peixoto), 11 years ago)

Tentative patch for issue with cairo surface geometry

  • src/graph_tool/draw/gtk_draw.py

    diff --git a/src/graph_tool/draw/gtk_draw.py b/src/graph_tool/draw/gtk_draw.py
    index 6139a3b..95392cc 100644
    a b class GraphWidget(Gtk.DrawingArea): 
    240240
    241241        self.geometry = None
    242242        self.base = None
     243        self.base_geometry = None
    243244        self.background = None
    244245        self.bg_color = bg_color if bg_color is not None else [1, 1, 1, 1]
    245246        self.surface_callback = None
    class GraphWidget(Gtk.DrawingArea): 
    384385                        self.get_allocated_height())
    385386            self.smatrix = self.smatrix * m
    386387            self.tmatrix = self.tmatrix * self.smatrix
    387             if (self.base is None or self.base.get_width() != geometry[0] or
    388                 self.base.get_height() != geometry[1]):
     388            if (self.base is None or self.base_geometry[0] != geometry[0] or
     389                self.base_geometry[1] != geometry[1]):
    389390                # self.base = cairo.ImageSurface(cairo.FORMAT_ARGB32,
    390391                #                                *geometry)
    391392                w = self.get_window()
    class GraphWidget(Gtk.DrawingArea): 
    393394                    return False
    394395                self.base = w.create_similar_surface(cairo.CONTENT_COLOR_ALPHA,
    395396                                                     *geometry)
     397                self.base_geometry = geometry
     398
    396399            cr = cairo.Context(self.base)
    397400            cr.set_source_rgba(*self.bg_color)
    398401            cr.paint()
    class GraphWidget(Gtk.DrawingArea): 
    421424            self.geometry = geometry
    422425
    423426        ul = self.pos_to_device((0, 0), surface=True)
    424         lr = self.pos_to_device((self.base.get_width(),
    425                                  self.base.get_height()),
    426                                 surface=True)
     427        lr = self.pos_to_device(self.base_geometry, surface=True)
     428
    427429        if (ul[0] > 0 or lr[0] < geometry[0] or
    428430            ul[1] > 0 or lr[1] < geometry[1]):
    429431            self.regenerate_surface()