From 2f9ba9e9550beeb358f0e1c86ef347750e361207 Mon Sep 17 00:00:00 2001 From: fengalin Date: Mon, 4 Sep 2017 19:11:49 +0200 Subject: [PATCH] Use a black background for waveform rendering (#16) --- src/ui/audio_controller.rs | 11 +++++++ src/ui/media-toc.ui | 61 +++++++++++++++++++------------------- 2 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/ui/audio_controller.rs b/src/ui/audio_controller.rs index 51586d7..746d6cb 100644 --- a/src/ui/audio_controller.rs +++ b/src/ui/audio_controller.rs @@ -16,6 +16,7 @@ pub struct AudioController { container: gtk::Container, drawingarea: gtk::DrawingArea, + is_active: bool, position: u64, waveform_buffer_mtx: Arc>>, } @@ -26,6 +27,7 @@ impl AudioController { container: builder.get_object("audio-container").unwrap(), drawingarea: builder.get_object("audio-drawingarea").unwrap(), + is_active: false, position: 0, waveform_buffer_mtx: Arc::new(Mutex::new(None)), })); @@ -43,6 +45,7 @@ impl AudioController { } pub fn cleanup(&mut self) { + self.is_active = false; // force redraw to purge the double buffer self.drawingarea.queue_draw(); } @@ -54,6 +57,7 @@ impl AudioController { .is_some(); if has_audio { + self.is_active = true; self.position = 0; self.waveform_buffer_mtx = context.waveform_buffer_mtx.clone(); @@ -70,6 +74,13 @@ impl AudioController { } fn draw(&self, drawing_area: >k::DrawingArea, cr: &cairo::Context) -> Inhibit { + if !self.is_active { + return Inhibit(false); + } + + cr.set_source_rgb(0.0f64, 0.0f64, 0.0f64); + cr.paint(); + if self.position == 0 { return Inhibit(false); } diff --git a/src/ui/media-toc.ui b/src/ui/media-toc.ui index 7e54175..f025466 100644 --- a/src/ui/media-toc.ui +++ b/src/ui/media-toc.ui @@ -15,7 +15,6 @@ False True 5 - 6 220 @@ -78,46 +77,19 @@ - + True False end - end + vertical icons False - - - True - False - Back - True - gtk-media-rewind - - - False - True - - True False - Play True - media-playback-start - - - False - True - - - - - True - False - Forward - True - gtk-media-forward + gtk-media-play False @@ -168,6 +140,33 @@ 0 + + + True + False + end + vertical + icons + False + + + True + False + True + False + True + + + False + True + + + + + 1 + 0 + + True