Skip to content

Commit

Permalink
Use a black background for waveform rendering (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengalin committed Sep 4, 2017
1 parent a305ba2 commit 2f9ba9e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 31 deletions.
11 changes: 11 additions & 0 deletions src/ui/audio_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct AudioController {
container: gtk::Container,
drawingarea: gtk::DrawingArea,

is_active: bool,
position: u64,
waveform_buffer_mtx: Arc<Mutex<Option<WaveformBuffer>>>,
}
Expand All @@ -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)),
}));
Expand All @@ -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();
}
Expand All @@ -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();

Expand All @@ -70,6 +74,13 @@ impl AudioController {
}

fn draw(&self, drawing_area: &gtk::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);
}
Expand Down
61 changes: 30 additions & 31 deletions src/ui/media-toc.ui
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="row_spacing">5</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkTreeView" id="chapter-treeview">
<property name="width_request">220</property>
Expand Down Expand Up @@ -78,46 +77,19 @@
</packing>
</child>
<child>
<object class="GtkToolbar" id="play_control-toolbar">
<object class="GtkToolbar" id="play_pause-toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="valign">end</property>
<property name="orientation">vertical</property>
<property name="toolbar_style">icons</property>
<property name="show_arrow">False</property>
<child>
<object class="GtkToolButton" id="rewind-toolbutton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Back</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-media-rewind</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="play_pause-toolbutton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Play</property>
<property name="use_underline">True</property>
<property name="icon_name">media-playback-start</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="forward-toolbutton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Forward</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-media-forward</property>
<property name="stock_id">gtk-media-play</property>
</object>
<packing>
<property name="expand">False</property>
Expand Down Expand Up @@ -168,6 +140,33 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkToolbar" id="video-toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="orientation">vertical</property>
<property name="toolbar_style">icons</property>
<property name="show_arrow">False</property>
<child>
<object class="GtkToolButton" id="video-placeholder-toolbutton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="double_buffered">False</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="resize">True</property>
Expand Down

0 comments on commit 2f9ba9e

Please sign in to comment.