audio clip editor: add scroll bar handle

This commit is contained in:
Paul Davis 2021-12-10 16:04:47 -07:00
parent 02026c98ff
commit cb2b78bb41
2 changed files with 28 additions and 5 deletions

View file

@ -97,6 +97,11 @@ AudioClipEditor::AudioClipEditor ()
frame->set_fill (false); frame->set_fill (false);
frame->Event.connect (sigc::mem_fun (*this, &AudioClipEditor::event_handler)); frame->Event.connect (sigc::mem_fun (*this, &AudioClipEditor::event_handler));
scroll_bar_trough = new Rectangle (root());
scroll_bar_handle = new Rectangle (scroll_bar_trough);
scroll_bar_handle->set_outline (false);
scroll_bar_handle->set_corner_radius (5.);
waves_container = new ArdourCanvas::ScrollGroup (frame, ScrollGroup::ScrollsHorizontally); waves_container = new ArdourCanvas::ScrollGroup (frame, ScrollGroup::ScrollsHorizontally);
line_container = new ArdourCanvas::Container (frame); line_container = new ArdourCanvas::Container (frame);
@ -233,6 +238,10 @@ AudioClipEditor::set_colors ()
end_line->set_outline_color (UIConfiguration::instance().color (X_("theme:contrasting alt"))); end_line->set_outline_color (UIConfiguration::instance().color (X_("theme:contrasting alt")));
loop_line->set_outline_color (UIConfiguration::instance().color (X_("theme:contrasting selection"))); loop_line->set_outline_color (UIConfiguration::instance().color (X_("theme:contrasting selection")));
scroll_bar_trough->set_fill_color (UIConfiguration::instance().color (X_("theme:bg")));
scroll_bar_trough->set_outline_color (UIConfiguration::instance().color (X_("theme:contrasting less")));
scroll_bar_handle->set_fill_color (UIConfiguration::instance().color (X_("theme:contrasting clock")));
set_waveform_colors (); set_waveform_colors ();
} }
@ -279,7 +288,7 @@ AudioClipEditor::set_region (boost::shared_ptr<AudioRegion> r)
} }
set_spp_from_length (len); set_spp_from_length (len);
set_wave_heights (frame->get().height() - 2.0); set_wave_heights ();
set_waveform_colors (); set_waveform_colors ();
line_container->show (); line_container->show ();
@ -293,13 +302,18 @@ AudioClipEditor::on_size_allocate (Gtk::Allocation& alloc)
ArdourCanvas::Rect r (1, 1, alloc.get_width() - 2, alloc.get_height() - 2); ArdourCanvas::Rect r (1, 1, alloc.get_width() - 2, alloc.get_height() - 2);
frame->set (r); frame->set (r);
const double scroll_bar_height = 10.;
scroll_bar_trough->set (Rect (1, alloc.get_height() - scroll_bar_height, alloc.get_width() - 2, alloc.get_height()));
scroll_bar_handle->set (Rect (30, scroll_bar_trough->get().y0 + 1, 50, scroll_bar_trough->get().y1 - 1));
position_lines (); position_lines ();
start_line->set_y1 (frame->get().height() - 2.); start_line->set_y1 (frame->get().height() - 2.);
end_line->set_y1 (frame->get().height() - 2.); end_line->set_y1 (frame->get().height() - 2.);
loop_line->set_y1 (frame->get().height() - 2.); loop_line->set_y1 (frame->get().height() - 2.);
set_wave_heights (r.height() - 2.0); set_wave_heights ();
} }
void void
@ -324,14 +338,15 @@ AudioClipEditor::set_spp_from_length (samplecnt_t len)
} }
void void
AudioClipEditor::set_wave_heights (int h) AudioClipEditor::set_wave_heights ()
{ {
if (waves.empty()) { if (waves.empty()) {
return; return;
} }
uint32_t n = 0; uint32_t n = 0;
Distance ht = h / waves.size(); const Distance w = frame->get().height() - scroll_bar_trough->get().height() - 2.;
Distance ht = w / waves.size();
std::cerr << "wave heights: " << ht << std::endl; std::cerr << "wave heights: " << ht << std::endl;

View file

@ -104,10 +104,18 @@ class AudioClipEditor : public ArdourCanvas::GtkCanvas
ArdourCanvas::Line* start_line; ArdourCanvas::Line* start_line;
ArdourCanvas::Line* end_line; ArdourCanvas::Line* end_line;
ArdourCanvas::Line* loop_line; ArdourCanvas::Line* loop_line;
ArdourCanvas::Rectangle* scroll_bar_trough;
ArdourCanvas::Rectangle* scroll_bar_handle;
std::vector<ArdourWaveView::WaveView *> waves; std::vector<ArdourWaveView::WaveView *> waves;
double non_wave_height;
samplepos_t left_origin;
double scroll_fraction;
double _spp; double _spp;
boost::shared_ptr<ARDOUR::AudioRegion> audio_region; boost::shared_ptr<ARDOUR::AudioRegion> audio_region;
void scroll_left ();
void scrol_right ();
enum LineType { enum LineType {
StartLine, StartLine,
EndLine, EndLine,
@ -117,7 +125,7 @@ class AudioClipEditor : public ArdourCanvas::GtkCanvas
bool event_handler (GdkEvent* ev); bool event_handler (GdkEvent* ev);
bool line_event_handler (GdkEvent* ev, ArdourCanvas::Line*); bool line_event_handler (GdkEvent* ev, ArdourCanvas::Line*);
void drop_waves (); void drop_waves ();
void set_wave_heights (int); void set_wave_heights ();
void set_spp_from_length (ARDOUR::samplecnt_t); void set_spp_from_length (ARDOUR::samplecnt_t);
void set_waveform_colors (); void set_waveform_colors ();
void set_colors (); void set_colors ();