コード例 #1
0
ファイル: KeyboardPopups.py プロジェクト: adityaphatak/Demo
    def _on_draw(self, widget, context):

        if not LabelPopup._pango_layout:
            LabelPopup._pango_layout = Pango.Layout(context=Gdk.pango_context_get())

        rect = Rect(0, 0, self.get_allocated_width(),
                          self.get_allocated_height())
        content_rect = Rect(rect.x, rect.y, rect.w,
                            rect.h - rect.h * self.ARROW_HEIGHT)
        arrow_rect   = Rect(rect.x, content_rect.bottom(), rect.w,
                            rect.h * self.ARROW_HEIGHT) \
                       .deflate((rect.w - rect.w * self.ARROW_WIDTH) / 2.0, 0)

        label_rect = content_rect.deflate(rect.w * self.LABEL_MARGIN)

        # background
        if config.scanner.color_type == "custom_color" and config.scanner.enabled == True:
            # scan label popup color
            color_rgba = []
            for val in config.scanner.scan_color:
                color_rgba.append(val)
            
            rgb = color_rgba[:3]
            opacity = color_rgba[3]
            fill = rgb + [opacity]
        else:
            fill = self._key.get_fill_color()

        context.save()
        context.set_operator(cairo.OPERATOR_CLEAR)
        context.paint()
        context.restore()

        context.set_source_rgba(*fill)
        roundrect_arc(context, content_rect, config.CORNER_RADIUS)
        context.fill()

        l, t, r, b = arrow_rect.to_extents()
        t -= 1
        context.move_to(l, t)
        context.line_to(r, t)
        context.line_to((l+r) / 2, b)
        context.fill()

        # draw label/image
        label_color = self._key.get_label_color()
        pixbuf = self._key.get_image(label_rect.w, label_rect.h)
        if pixbuf:
            self._draw_image(context, pixbuf, label_rect, label_color)
        else:
            label = self._key.get_label()
            if label:
                if label == " ":
                    label = "␣"
                self._draw_text(context, label, label_rect, label_color)
コード例 #2
0
    def on_draw(self, widget, context):
        if not LabelPopup._pango_layout:
            LabelPopup._pango_layout = Pango.Layout(
                context=Gdk.pango_context_get())

        rect = Rect(0, 0, self.get_allocated_width(),
                    self.get_allocated_height())
        content_rect = Rect(rect.x, rect.y, rect.w,
                            rect.h - rect.h * self.ARROW_HEIGHT)
        arrow_rect   = Rect(rect.x, content_rect.bottom(), rect.w,
                            rect.h * self.ARROW_HEIGHT) \
                       .deflate((rect.w - rect.w * self.ARROW_WIDTH) / 2.0, 0)

        label_rect = content_rect.deflate(rect.w * self.LABEL_MARGIN)

        # background
        fill = self._key.get_fill_color()
        context.save()
        context.set_operator(cairo.OPERATOR_CLEAR)
        context.paint()
        context.restore()

        context.push_group()

        context.set_source_rgba(*fill)
        roundrect_arc(context, content_rect, config.CORNER_RADIUS)
        context.fill()

        l, t, r, b = arrow_rect.to_extents()
        t -= 1
        context.move_to(l, t)
        context.line_to(r, t)
        context.line_to((l + r) / 2, b)
        context.fill()

        # draw label/image
        label_color = self._key.get_label_color()
        pixbuf = self._key.get_image(label_rect.w, label_rect.h)
        if pixbuf:
            pixbuf.draw(context, label_rect, label_color)
        else:
            label = self._key.get_label()
            if label:
                if label == " ":
                    label = "␣"
                self._draw_text(context, label, label_rect, label_color)

        context.pop_group_to_source()
        context.paint_with_alpha(self._opacity)
コード例 #3
0
    def _clear_xembed_background(self, context):
        """ fill with plain layer 0 color; no alpha support required """
        rect = Rect(0, 0, self.get_allocated_width(),
                    self.get_allocated_height())

        # draw background image
        if config.get_xembed_background_image_enabled():
            pixbuf = self._get_xembed_background_image()
            if pixbuf:
                src_size = (pixbuf.get_width(), pixbuf.get_height())
                x, y = 0, rect.bottom() - src_size[1]
                Gdk.cairo_set_source_pixbuf(context, pixbuf, x, y)
                context.paint()

        # draw solid colored bar on top (with transparency, usually)
        rgba = config.get_xembed_background_rgba()
        if rgba is None:
            rgba = self.get_background_rgba()
            rgba[3] = 0.5
        context.set_source_rgba(*rgba)
        context.rectangle(*rect)
        context.fill()
コード例 #4
0
ファイル: LayoutView.py プロジェクト: jegger/onboard
    def _clear_xembed_background(self, context):
        """ fill with plain layer 0 color; no alpha support required """
        rect = Rect(0, 0, self.get_allocated_width(),
                          self.get_allocated_height())

        # draw background image
        if config.get_xembed_background_image_enabled():
            pixbuf = self._get_xembed_background_image()
            if pixbuf:
                src_size = (pixbuf.get_width(), pixbuf.get_height())
                x, y = 0, rect.bottom() - src_size[1]
                Gdk.cairo_set_source_pixbuf(context, pixbuf, x, y)
                context.paint()

        # draw solid colored bar on top (with transparency, usually)
        rgba = config.get_xembed_background_rgba()
        if rgba is None:
            rgba = self.get_background_rgba()
            rgba[3] = 0.5
        context.set_source_rgba(*rgba)
        context.rectangle(*rect)
        context.fill()