diff options
author | MaZderMind <git@mazdermind.de> | 2015-12-03 00:44:22 +0100 |
---|---|---|
committer | MaZderMind <git@mazdermind.de> | 2015-12-03 00:44:22 +0100 |
commit | 331f1dc3fc5ee57c4714a0f5d78160e8aec9cbff (patch) | |
tree | 924ca1f2e67a7c9971f355631f75590506afe76d /voctogui/lib/warningoverlay.py | |
parent | cfae754c4a5d20431a42ed8d3864eec51de3c490 (diff) |
[voctogui] implement warning-overlay in gtk instead of rendering it into the video
Diffstat (limited to 'voctogui/lib/warningoverlay.py')
-rw-r--r-- | voctogui/lib/warningoverlay.py | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/voctogui/lib/warningoverlay.py b/voctogui/lib/warningoverlay.py index 3cbe13c..bf2c2cd 100644 --- a/voctogui/lib/warningoverlay.py +++ b/voctogui/lib/warningoverlay.py @@ -6,51 +6,40 @@ from lib.config import Config class VideoWarningOverlay(object): """ Displays a Warning-Overlay above the Video-Feed of another VideoDisplay """ - def __init__(self): + def __init__(self, drawing_area): self.log = logging.getLogger('VideoWarningOverlay') + self.drawing_area = drawing_area + self.drawing_area.connect("draw", self.draw_callback) + self.text = None - self.enabled = False self.blink_state = False GLib.timeout_add_seconds(1, self.on_blink_callback) - caps_string = Config.get('mix', 'videocaps') - self.log.debug('parsing video-caps: %s', caps_string) - caps = Gst.Caps.from_string(caps_string) - struct = caps.get_structure(0) - _, self.width = struct.get_int('width') - _, self.height = struct.get_int('height') - - self.log.debug('configuring size to %ux%u', self.width, self.height) - - def on_blink_callback(self): self.blink_state = not self.blink_state + self.drawing_area.queue_draw() return True def enable(self, text=None): self.text = text - self.enabled = True + self.drawing_area.show() + self.drawing_area.queue_draw() def set_text(self, text=None): self.text = text + self.drawing_area.queue_draw() def disable(self): - self.enabled = False - - def draw_callback(self, cr, timestamp, duration): - if not self.enabled: - return + self.drawing_area.hide() + self.drawing_area.queue_draw() - w = self.width - h = self.height / 20 + def draw_callback(self, area, cr): + w = self.drawing_area.get_allocated_width(); + h = self.drawing_area.get_allocated_height(); - # during startup, cr is sometimes another kind of context, - # which does not expose set_source_rgba and other methods. - # this check avoids the exceptions that would be thrown then. - if isinstance(cr, cairo.Context): - return + self.log.debug('draw_callback: w/h=%u/%u, blink_state=%u', w, h, self.blink_state) if self.blink_state: cr.set_source_rgba(1.0, 0.0, 0.0, 0.8) |