def do_snapshot(self, snapshot: Gtk.Snapshot): if not self._colors: return # Scroll tx = -int(self.props.hadjustment.props.value) ty = -int(self.props.vadjustment.props.value) area = Graphene.Rect().init(0, 0, self.get_width(), self.get_height()) snapshot.append_color(self._colors[icon.CommandColor.INDENTATION][0], area) if not self._codebuffer: return # Content snapshot.push_clip(area) end_x = math.ceil( (self.props.hadjustment.props.value + self.get_width()) / icon.WIDTH) start_y = int(self.props.vadjustment.props.value / icon.HEIGHT) end_y = math.ceil( (self.props.vadjustment.props.value + self.get_height()) / icon.HEIGHT) icon.append_block_to_snapshot(self._codebuffer.lines, snapshot, tx, ty, self, self._colors, self._codebuffer, end_x, start_y, end_y) # Selection if self.props.selection: start_y = self.props.selection.start_y end_y = self.props.selection.end_y for y in range(start_y, end_y + 1): start_x = (0 if y > start_y else self._line_x_to_render_x( self.props.selection.start_x, y)) end_x = self._line_x_to_render_x( len(self._codebuffer.lines[y]) - 1 if y < end_y else self.props.selection.end_x, y, True) selection_rect = Graphene.Rect().init( tx + start_x * icon.WIDTH, ty + y * icon.HEIGHT, (end_x - start_x + 1) * icon.WIDTH, icon.HEIGHT) snapshot.append_color( self._colors[icon.CommandColor.OVERLAY_SELECTION][0], selection_rect) snapshot.pop() snapshot.render_focus(self.get_style_context(), 0, 0, self.get_width(), self.get_height())
def do_snapshot(self, snapshot: Gtk.Snapshot): # Scroll tx = -int(self.props.hadjustment.props.value) ty = -int(self.props.vadjustment.props.value) if self.scenebuffer is None or self.scenebuffer.scene_name is None: snapshot.render_background(self.get_style_context(), 0, 0, self.get_width(), self.get_height()) return area = Graphene.Rect().init(0, 0, self.get_width(), self.get_height()) snapshot.append_color(self.BACKGROUND_COLOR, area) snapshot.push_clip(area) # Background scene_area = Graphene.Rect().init(tx, ty, self.scenebuffer.props.scene_width, self.scenebuffer.props.scene_height) snapshot.append_color(self.SCENE_COLOR, scene_area) # Sprites for s in self.scenebuffer.scene_sprites: sprite_area, texture = self.get_sprite_info(s) if texture is not None: snapshot.append_texture(texture, sprite_area) else: snapshot.append_color(self.MISSING_TEXTURE_COLOR, sprite_area) # Selection if self.props.selection is not None: selection_area = self.get_sprite_info(self.props.selection)[0] snapshot.append_color(self.SELECTION_COLOR, selection_area) snapshot.pop() snapshot.render_focus(self.get_style_context(), 0, 0, self.get_width(), self.get_height())