Example #1
0
    def _layer_preview_pixbuf_datafunc(self, column, cell, model, it, data):
        """Render layer preview icons and type info."""

        # Get the layer's thumbnail
        layer = model.get_layer(it=it)
        thumb = layer.thumbnail

        # Scale it to a reasonable size for use as the preview.
        s = self._datafunc_get_pixbuf_height(32, column)
        preview = make_preview(thumb, s)
        cell.set_property("pixbuf", preview)

        # Add a watermark icon for non-painting layers.
        # Not completely sure this is a good idea...
        try:
            cache = self.__icon_cache
        except AttributeError:
            cache = {}
            self.__icon_cache = cache
        icon_name = layer.get_icon_name()
        icon_size = 16
        icon_size += 2  # allow fopr the outline
        icon = cache.get(icon_name, None)
        if not icon:
            icon = gui.drawutils.load_symbolic_icon(
                icon_name,
                icon_size,
                fg=(1, 1, 1, 1),
                outline=(0, 0, 0, 1),
            )
            cache[icon_name] = icon

        # Composite the watermark over the preview
        x = (preview.get_width() - icon_size) // 2
        y = (preview.get_height() - icon_size) // 2
        icon.composite(
            dest=preview,
            dest_x=x,
            dest_y=y,
            dest_width=icon_size,
            dest_height=icon_size,
            offset_x=x,
            offset_y=y,
            scale_x=1,
            scale_y=1,
            interp_type=GdkPixbuf.InterpType.NEAREST,
            overall_alpha=255 / 6,
        )
Example #2
0
    def _layer_preview_pixbuf_datafunc(self, column, cell, model, it, data):
        """Render layer preview icons and type info."""

        # Get the layer's thumbnail
        layer = model.get_layer(it=it)
        thumb = layer.thumbnail

        # Scale it to a reasonable size for use as the preview.
        s = self._datafunc_get_pixbuf_height(32, column)
        preview = make_preview(thumb, s)
        cell.set_property("pixbuf", preview)

        # Add a watermark icon for non-painting layers.
        # Not completely sure this is a good idea...
        try:
            cache = self.__icon_cache
        except AttributeError:
            cache = {}
            self.__icon_cache = cache
        icon_name = layer.get_icon_name()
        icon_size = 16
        icon_size += 2   # allow fopr the outline
        icon = cache.get(icon_name, None)
        if not icon:
            icon = gui.drawutils.load_symbolic_icon(
                icon_name, icon_size,
                fg=(1, 1, 1, 1),
                outline=(0, 0, 0, 1),
            )
            cache[icon_name] = icon

        # Composite the watermark over the preview
        x = (preview.get_width() - icon_size) // 2
        y = (preview.get_height() - icon_size) // 2
        icon.composite(
            dest=preview,
            dest_x=x,
            dest_y=y,
            dest_width=icon_size,
            dest_height=icon_size,
            offset_x=x,
            offset_y=y,
            scale_x=1,
            scale_y=1,
            interp_type=GdkPixbuf.InterpType.NEAREST,
            overall_alpha=255/6,
        )