Example #1
0
    def do_draw(self, cr):
        context = self.get_style_context()

        # Get colors
        context.save()
        context.set_state(Gtk.StateFlags.NORMAL)
        bg_color = context.get_background_color(context.get_state())
        remaining_color = context.get_color(context.get_state())
        context.restore()

        elapsed_color = get_fg_highlight_color(self)

        # Check if the user set a different elapsed color in the config
        elapsed_color_config = CONFIG.elapsed_color
        if elapsed_color_config and Gdk.RGBA().parse(elapsed_color_config):
            elapsed_color = Gdk.RGBA()
            elapsed_color.parse(elapsed_color_config)

        # Check if the user set a different remaining color in the config
        remaining_color_config = CONFIG.remaining_color
        if remaining_color_config and Gdk.RGBA().parse(remaining_color_config):
            remaining_color = Gdk.RGBA()
            remaining_color.parse(remaining_color_config)

        # Check if the user set a hover color in the config
        hover_color_config = CONFIG.hover_color
        if hover_color_config and Gdk.RGBA().parse(hover_color_config):
            hover_color = Gdk.RGBA()
            hover_color.parse(hover_color_config)
        else:
            # Generate default hover_color by blending elapsed_color and
            # remaining_color
            opacity = 0.4
            r = (opacity * elapsed_color.alpha * elapsed_color.red +
                 (1 - opacity) * remaining_color.alpha * remaining_color.red)
            g = (opacity * elapsed_color.alpha * elapsed_color.green +
                 (1 - opacity) * remaining_color.alpha * remaining_color.green)
            b = (opacity * elapsed_color.alpha * elapsed_color.blue +
                 (1 - opacity) * remaining_color.alpha * remaining_color.blue)
            a = (opacity * elapsed_color.alpha +
                 (1 - opacity) * remaining_color.alpha)
            hover_color = Gdk.RGBA(r, g, b, a)

        # Check if the user turned on showing current position
        show_current_pos_config = CONFIG.show_current_pos

        # Paint the background
        cr.set_source_rgba(*list(bg_color))
        cr.paint()

        allocation = self.get_allocation()
        width = allocation.width
        height = allocation.height

        if not self._placeholder and self._rms_vals:
            self.draw_waveform(cr, width, height, elapsed_color,
                               hover_color, remaining_color,
                               show_current_pos_config)
        else:
            self.draw_placeholder(cr, width, height, remaining_color)
Example #2
0
    def do_draw(self, cr):
        context = self.get_style_context()

        # Get colors
        context.save()
        context.set_state(Gtk.StateFlags.NORMAL)
        bg_color = context.get_background_color(context.get_state())
        fg_color = context.get_color(context.get_state())
        context.restore()

        elapsed_color = get_fg_highlight_color(self)

        # Check if the user set a different color in the config
        elapsed_color_config = CONFIG.elapsed_color
        if elapsed_color_config and Gdk.RGBA().parse(elapsed_color_config):
            elapsed_color = Gdk.RGBA()
            elapsed_color.parse(elapsed_color_config)

        # Paint the background
        cr.set_source_rgba(*list(bg_color))
        cr.paint()

        allocation = self.get_allocation()
        width = allocation.width
        height = allocation.height

        if not self._placeholder and len(self._rms_vals) > 0:
            self.draw_waveform(cr, width, height, elapsed_color, fg_color)
        else:
            self.draw_placeholder(cr, width, height, fg_color)
Example #3
0
    def do_draw(self, cr):
        context = self.get_style_context()

        # Get colors
        context.save()
        context.set_state(Gtk.StateFlags.NORMAL)
        bg_color = context.get_background_color(context.get_state())
        fg_color = context.get_color(context.get_state())
        context.restore()

        elapsed_color = get_fg_highlight_color(self)

        # Check if the user set a different color in the config
        elapsed_color_config = CONFIG.elapsed_color
        if elapsed_color_config and Gdk.RGBA().parse(elapsed_color_config):
            elapsed_color = Gdk.RGBA()
            elapsed_color.parse(elapsed_color_config)

        # Paint the background
        cr.set_source_rgba(*list(bg_color))
        cr.paint()

        allocation = self.get_allocation()
        width = allocation.width
        height = allocation.height

        if not self._placeholder and len(self._rms_vals) > 0:
            self.draw_waveform(cr, width, height, elapsed_color, fg_color)
        else:
            self.draw_placeholder(cr, width, height, fg_color)
Example #4
0
    def do_draw(self, cr):
        context = self.get_style_context()

        # Get colors
        context.save()
        context.set_state(Gtk.StateFlags.NORMAL)
        bg_color = context.get_background_color(context.get_state())
        remaining_color = context.get_color(context.get_state())
        context.restore()

        elapsed_color = get_fg_highlight_color(self)

        # Check if the user set a different elapsed color in the config
        elapsed_color_config = CONFIG.elapsed_color
        if elapsed_color_config and Gdk.RGBA().parse(elapsed_color_config):
            elapsed_color = Gdk.RGBA()
            elapsed_color.parse(elapsed_color_config)

        # Check if the user set a different remaining color in the config
        remaining_color_config = CONFIG.remaining_color
        if remaining_color_config and Gdk.RGBA().parse(remaining_color_config):
            remaining_color = Gdk.RGBA()
            remaining_color.parse(remaining_color_config)

        # Check if the user set a hover color in the config
        hover_color_config = CONFIG.hover_color
        if hover_color_config and Gdk.RGBA().parse(hover_color_config):
            hover_color = Gdk.RGBA()
            hover_color.parse(hover_color_config)
        else:
            # Generate default hover_color by blending elapsed_color and
            # remaining_color
            opacity = 0.4
            r = (opacity * elapsed_color.alpha * elapsed_color.red +
                 (1 - opacity) * remaining_color.alpha * remaining_color.red)
            g = (opacity * elapsed_color.alpha * elapsed_color.green +
                 (1 - opacity) * remaining_color.alpha * remaining_color.green)
            b = (opacity * elapsed_color.alpha * elapsed_color.blue +
                 (1 - opacity) * remaining_color.alpha * remaining_color.blue)
            a = (opacity * elapsed_color.alpha +
                 (1 - opacity) * remaining_color.alpha)
            hover_color = Gdk.RGBA(r, g, b, a)

        # Check if the user turned on showing current position
        show_current_pos_config = CONFIG.show_current_pos

        # Paint the background
        cr.set_source_rgba(*list(bg_color))
        cr.paint()

        allocation = self.get_allocation()
        width = allocation.width
        height = allocation.height

        if not self._placeholder and self._rms_vals:
            self.draw_waveform(cr, width, height, elapsed_color,
                               hover_color, remaining_color,
                               show_current_pos_config)
        else:
            self.draw_placeholder(cr, width, height, remaining_color)
Example #5
0
 def elapsed_color(self):
     # Check if the user set a different elapsed color in the config
     elapsed_color_config = CONFIG.elapsed_color
     if elapsed_color_config and Gdk.RGBA().parse(elapsed_color_config):
         col = Gdk.RGBA()
         col.parse(elapsed_color_config)
         return col
     return get_fg_highlight_color(self)
Example #6
0
    def update_colors(self):
        context = self.get_style_context()

        # Get colors
        context.save()
        context.set_state(Gtk.StateFlags.NORMAL)
        self.bg_color = context.get_background_color(context.get_state())
        self.remaining_color = context.get_color(context.get_state())
        context.restore()

        self.elapsed_color = get_fg_highlight_color(self)

        # Check if the user set a different elapsed color in the config
        elapsed_color_config = CONFIG.elapsed_color
        if elapsed_color_config and Gdk.RGBA().parse(elapsed_color_config):
            self.elapsed_color = Gdk.RGBA()
            self.elapsed_color.parse(elapsed_color_config)

        # Check if the user set a different remaining color in the config
        remaining_color_config = CONFIG.remaining_color
        if remaining_color_config and Gdk.RGBA().parse(remaining_color_config):
            self.remaining_color = Gdk.RGBA()
            self.remaining_color.parse(remaining_color_config)

        # Check if the user set a hover color in the config
        preview_color_config = CONFIG.preview_color
        if preview_color_config and Gdk.RGBA().parse(preview_color_config):
            self.preview_base_color = Gdk.RGBA()
            self.preview_base_color.parse(preview_color_config)
            eh = HSLA.rgba_to_hsla(self.elapsed_color)
            ph = HSLA.rgba_to_hsla(self.preview_base_color)
            ph.mix(eh, 0.65)
            self.preview_shade_color = HSLA.hsla_to_rgba(ph)
        else:
            self.preview_base_color, self.preview_shade_color = \
                self._calulate_colors(self.elapsed_color, self.remaining_color)
Example #7
0
 def test_get_fg_highlight_color(self):
     widget = Gtk.Button()
     color = qltk.get_fg_highlight_color(widget)
     assert color is not None
     assert isinstance(color, Gdk.RGBA)
 def test_get_fg_highlight_color(self):
     widget = Gtk.Button()
     color = qltk.get_fg_highlight_color(widget)
     assert color is not None
     assert isinstance(color, Gdk.RGBA)