mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-15 19:16:40 +01:00
refactor code for region trimming from Pianoroll/MidiView
This splits out boundary-dragging things into boundary.{cc,h} and the rest
into CueEditor
This commit is contained in:
parent
cd9fe29347
commit
6187dd35c8
11 changed files with 250 additions and 190 deletions
|
|
@ -5364,98 +5364,3 @@ MidiView::set_visible_channel (int chn, bool clear_selection)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
StartBoundaryRect::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
|
||||
{
|
||||
Rectangle::render (area, context);
|
||||
|
||||
ArdourCanvas::Rect self (item_to_window (_rect));
|
||||
const double scale = UIConfiguration::instance().get_ui_scale();
|
||||
const double radius = 10. * scale;
|
||||
|
||||
context->arc (self.x1, (self.y0 + (self.height() / 2.)) - radius, radius, -(M_PI/2.), (M_PI/2.));
|
||||
Gtkmm2ext::set_source_rgba (context, _outline_color);
|
||||
context->fill ();
|
||||
|
||||
}
|
||||
|
||||
bool
|
||||
StartBoundaryRect::covers (ArdourCanvas::Duple const & point) const
|
||||
{
|
||||
ArdourCanvas::Rect self (item_to_window (_rect));
|
||||
const double scale = UIConfiguration::instance().get_ui_scale();
|
||||
|
||||
if ((point.x >= self.x1 - (20. * scale)) && (point.x < self.x1)) {
|
||||
/* within 20 (scaled) pixels of the boundary, on the right */
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Approximate the semicircle handle with a square */
|
||||
|
||||
const double radius = 10. * scale;
|
||||
double cy = self.y0 + (self.height() / 2.);
|
||||
|
||||
if (point.x >= self.x1 && point.x < self.x1 + radius &&
|
||||
point.y >= cy - radius && point.y < cy + radius) {
|
||||
/*inside rectangle that approximates the handle */
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
StartBoundaryRect::compute_bounding_box() const
|
||||
{
|
||||
Rectangle::compute_bounding_box ();
|
||||
const double scale = UIConfiguration::instance().get_ui_scale();
|
||||
const double radius = 10. * scale;
|
||||
_bounding_box = _bounding_box.expand (0., radius + _outline_width + 1.0, 0., 0.);
|
||||
}
|
||||
|
||||
void
|
||||
EndBoundaryRect::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
|
||||
{
|
||||
Rectangle::render (area, context);
|
||||
|
||||
ArdourCanvas::Rect self (item_to_window (_rect));
|
||||
const double scale = UIConfiguration::instance().get_ui_scale();
|
||||
const double radius = 10. * scale;
|
||||
|
||||
context->arc (self.x0, (self.y0 + (self.height() / 2.)) - radius, radius, (M_PI/2.), -(M_PI/2.));
|
||||
Gtkmm2ext::set_source_rgba (context, _outline_color);
|
||||
context->fill ();
|
||||
}
|
||||
|
||||
bool
|
||||
EndBoundaryRect::covers (ArdourCanvas::Duple const & point) const
|
||||
{
|
||||
ArdourCanvas::Rect self (item_to_window (_rect));
|
||||
const double scale = UIConfiguration::instance().get_ui_scale();
|
||||
|
||||
if ((point.x >= self.x0) && (point.x < self.x0 + (20. * scale))) {
|
||||
/* within 20 (scaled) pixels of the left edge */
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Approximate the semicircle handle with a square */
|
||||
|
||||
const double radius = 10. * scale;
|
||||
double cy = self.y0 + (self.height() / 2.);
|
||||
|
||||
if (point.x <= self.x0 && point.x >= self.x0 - radius && point.y >= cy - radius && point.y < cy + radius) {
|
||||
/* within a rectangle approximating the handle */
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
EndBoundaryRect::compute_bounding_box() const
|
||||
{
|
||||
Rectangle::compute_bounding_box ();
|
||||
const double scale = UIConfiguration::instance().get_ui_scale();
|
||||
const double radius = 10. * scale;
|
||||
_bounding_box = _bounding_box.expand (0., 0., 0., radius + _outline_width);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue