mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-18 04:36:30 +01:00
Prepare for std::optional
This commit is contained in:
parent
7037d86a00
commit
168b917730
8 changed files with 61 additions and 67 deletions
|
|
@ -1397,7 +1397,7 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move)
|
||||||
ArdourCanvas::Rect bbox;
|
ArdourCanvas::Rect bbox;
|
||||||
|
|
||||||
if (obbox) {
|
if (obbox) {
|
||||||
bbox = obbox.get ();
|
bbox = obbox.value ();
|
||||||
}
|
}
|
||||||
|
|
||||||
last_track_bottom_edge += bbox.height ();
|
last_track_bottom_edge += bbox.height ();
|
||||||
|
|
@ -5124,7 +5124,7 @@ FeatureLineDrag::motion (GdkEvent*, bool)
|
||||||
|
|
||||||
boost::optional<ArdourCanvas::Rect> bbox = _line->bounding_box ();
|
boost::optional<ArdourCanvas::Rect> bbox = _line->bounding_box ();
|
||||||
assert (bbox);
|
assert (bbox);
|
||||||
_line->set (ArdourCanvas::Duple (cx, 2.0), ArdourCanvas::Duple (cx, bbox.get ().height ()));
|
_line->set (ArdourCanvas::Duple (cx, 2.0), ArdourCanvas::Duple (cx, bbox.value ().height ()));
|
||||||
|
|
||||||
float* pos = new float;
|
float* pos = new float;
|
||||||
*pos = cx;
|
*pos = cx;
|
||||||
|
|
|
||||||
|
|
@ -260,16 +260,16 @@ NoteBase::set_mouse_fractions (GdkEvent* ev)
|
||||||
/* hmm, something wrong here. w2i should give item-local coordinates
|
/* hmm, something wrong here. w2i should give item-local coordinates
|
||||||
but it doesn't. for now, finesse this.
|
but it doesn't. for now, finesse this.
|
||||||
*/
|
*/
|
||||||
ix = ix - bbox.get().x0;
|
ix = ix - bbox.value().x0;
|
||||||
iy = iy - bbox.get().y0;
|
iy = iy - bbox.value().y0;
|
||||||
|
|
||||||
/* fraction of width/height */
|
/* fraction of width/height */
|
||||||
double xf;
|
double xf;
|
||||||
double yf;
|
double yf;
|
||||||
bool notify = false;
|
bool notify = false;
|
||||||
|
|
||||||
xf = ix / bbox.get().width ();
|
xf = ix / bbox.value().width ();
|
||||||
yf = iy / bbox.get().height ();
|
yf = iy / bbox.value().height ();
|
||||||
|
|
||||||
if (xf != _mouse_x_fraction || yf != _mouse_y_fraction) {
|
if (xf != _mouse_x_fraction || yf != _mouse_y_fraction) {
|
||||||
notify = true;
|
notify = true;
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ VisibilityGroup::should_actually_be_visible (Member const & m) const
|
||||||
if (m.override) {
|
if (m.override) {
|
||||||
boost::optional<bool> o = m.override ();
|
boost::optional<bool> o = m.override ();
|
||||||
if (o) {
|
if (o) {
|
||||||
return o.get ();
|
return o.value ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -533,7 +533,7 @@ DiskWriter::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||||
if (_midi_write_source) {
|
if (_midi_write_source) {
|
||||||
assert (_capture_start_sample);
|
assert (_capture_start_sample);
|
||||||
|
|
||||||
timepos_t start (_capture_start_sample.get());
|
timepos_t start (_capture_start_sample.value());
|
||||||
|
|
||||||
if (time_domain() != Temporal::AudioTime) {
|
if (time_domain() != Temporal::AudioTime) {
|
||||||
start = timepos_t (start.beats());
|
start = timepos_t (start.beats());
|
||||||
|
|
|
||||||
|
|
@ -609,7 +609,7 @@ void
|
||||||
TransportFSM::start_locate_after_declick ()
|
TransportFSM::start_locate_after_declick ()
|
||||||
{
|
{
|
||||||
DEBUG_TRACE (DEBUG::TFSMEvents, string_compose ("start_locate_after_declick, have crals ? %1 roll will be %2\n", (bool) current_roll_after_locate_status,
|
DEBUG_TRACE (DEBUG::TFSMEvents, string_compose ("start_locate_after_declick, have crals ? %1 roll will be %2\n", (bool) current_roll_after_locate_status,
|
||||||
current_roll_after_locate_status ? current_roll_after_locate_status.get() : compute_should_roll (_last_locate.ltd)));
|
current_roll_after_locate_status.value_or (compute_should_roll (_last_locate.ltd))));
|
||||||
|
|
||||||
/* we only get here because a locate request arrived while we were rolling. We declicked and that is now finished */
|
/* we only get here because a locate request arrived while we were rolling. We declicked and that is now finished */
|
||||||
|
|
||||||
|
|
@ -683,14 +683,8 @@ TransportFSM::schedule_butler_for_transport_work () const
|
||||||
bool
|
bool
|
||||||
TransportFSM::should_roll_after_locate () const
|
TransportFSM::should_roll_after_locate () const
|
||||||
{
|
{
|
||||||
bool roll;
|
bool roll = current_roll_after_locate_status.value_or (api->should_roll_after_locate ());
|
||||||
|
current_roll_after_locate_status = boost::none; // used it
|
||||||
if (current_roll_after_locate_status) {
|
|
||||||
roll = current_roll_after_locate_status.get();
|
|
||||||
current_roll_after_locate_status = boost::none; // used it
|
|
||||||
} else {
|
|
||||||
roll = api->should_roll_after_locate ();
|
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG_TRACE (DEBUG::TFSMEvents, string_compose ("should_roll_after_locate() ? %1\n", roll));
|
DEBUG_TRACE (DEBUG::TFSMEvents, string_compose ("should_roll_after_locate() ? %1\n", roll));
|
||||||
return roll;
|
return roll;
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ ArrowTest::bounding_box ()
|
||||||
boost::optional<Rect> bbox = arrow.bounding_box ();
|
boost::optional<Rect> bbox = arrow.bounding_box ();
|
||||||
|
|
||||||
CPPUNIT_ASSERT (bbox.is_initialized ());
|
CPPUNIT_ASSERT (bbox.is_initialized ());
|
||||||
CPPUNIT_ASSERT (bbox.get().x0 == -6);
|
CPPUNIT_ASSERT (bbox.value().x0 == -6);
|
||||||
CPPUNIT_ASSERT (bbox.get().y0 == 0);
|
CPPUNIT_ASSERT (bbox.value().y0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().x1 == 6);
|
CPPUNIT_ASSERT (bbox.value().x1 == 6);
|
||||||
CPPUNIT_ASSERT (bbox.get().y1 == 128);
|
CPPUNIT_ASSERT (bbox.value().y1 == 128);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,20 +27,20 @@ GroupTest::bounding_box ()
|
||||||
|
|
||||||
/* check the bounding box */
|
/* check the bounding box */
|
||||||
CPPUNIT_ASSERT (bbox.is_initialized ());
|
CPPUNIT_ASSERT (bbox.is_initialized ());
|
||||||
CPPUNIT_ASSERT (bbox.get().x0 == 0);
|
CPPUNIT_ASSERT (bbox.value().x0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().y0 == 0);
|
CPPUNIT_ASSERT (bbox.value().y0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().x1 == 64);
|
CPPUNIT_ASSERT (bbox.value().x1 == 64);
|
||||||
CPPUNIT_ASSERT (bbox.get().y1 == 64);
|
CPPUNIT_ASSERT (bbox.value().y1 == 64);
|
||||||
|
|
||||||
/* check that adding an item resets the bbox */
|
/* check that adding an item resets the bbox */
|
||||||
Rectangle e (canvas.root(), Rect (64, 64, 128, 128));
|
Rectangle e (canvas.root(), Rect (64, 64, 128, 128));
|
||||||
bbox = canvas.root()->bounding_box ();
|
bbox = canvas.root()->bounding_box ();
|
||||||
|
|
||||||
CPPUNIT_ASSERT (bbox.is_initialized ());
|
CPPUNIT_ASSERT (bbox.is_initialized ());
|
||||||
CPPUNIT_ASSERT (bbox.get().x0 == 0);
|
CPPUNIT_ASSERT (bbox.value().x0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().y0 == 0);
|
CPPUNIT_ASSERT (bbox.value().y0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().x1 == 128.25);
|
CPPUNIT_ASSERT (bbox.value().x1 == 128.25);
|
||||||
CPPUNIT_ASSERT (bbox.get().y1 == 128.25);
|
CPPUNIT_ASSERT (bbox.value().y1 == 128.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that a group containing only items with no bounding box itself has no bounding box */
|
/* Check that a group containing only items with no bounding box itself has no bounding box */
|
||||||
|
|
@ -118,28 +118,28 @@ GroupTest::children_changing ()
|
||||||
/* Check that initial bbox */
|
/* Check that initial bbox */
|
||||||
boost::optional<Rect> bbox = canvas.root()->bounding_box ();
|
boost::optional<Rect> bbox = canvas.root()->bounding_box ();
|
||||||
CPPUNIT_ASSERT (bbox.is_initialized ());
|
CPPUNIT_ASSERT (bbox.is_initialized ());
|
||||||
CPPUNIT_ASSERT (bbox.get().x0 == 0);
|
CPPUNIT_ASSERT (bbox.value().x0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().y0 == 0);
|
CPPUNIT_ASSERT (bbox.value().y0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().x1 == 32);
|
CPPUNIT_ASSERT (bbox.value().x1 == 32);
|
||||||
CPPUNIT_ASSERT (bbox.get().y1 == 32);
|
CPPUNIT_ASSERT (bbox.value().y1 == 32);
|
||||||
|
|
||||||
/* Change the rectangle's size and check the parent */
|
/* Change the rectangle's size and check the parent */
|
||||||
a.set (Rect (0, 0, 48, 48));
|
a.set (Rect (0, 0, 48, 48));
|
||||||
bbox = canvas.root()->bounding_box ();
|
bbox = canvas.root()->bounding_box ();
|
||||||
CPPUNIT_ASSERT (bbox.is_initialized ());
|
CPPUNIT_ASSERT (bbox.is_initialized ());
|
||||||
CPPUNIT_ASSERT (bbox.get().x0 == 0);
|
CPPUNIT_ASSERT (bbox.value().x0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().y0 == 0);
|
CPPUNIT_ASSERT (bbox.value().y0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().x1 == 48);
|
CPPUNIT_ASSERT (bbox.value().x1 == 48);
|
||||||
CPPUNIT_ASSERT (bbox.get().y1 == 48);
|
CPPUNIT_ASSERT (bbox.value().y1 == 48);
|
||||||
|
|
||||||
/* Change the rectangle's line width and check the parent */
|
/* Change the rectangle's line width and check the parent */
|
||||||
a.set_outline_width (1);
|
a.set_outline_width (1);
|
||||||
bbox = canvas.root()->bounding_box ();
|
bbox = canvas.root()->bounding_box ();
|
||||||
CPPUNIT_ASSERT (bbox.is_initialized ());
|
CPPUNIT_ASSERT (bbox.is_initialized ());
|
||||||
CPPUNIT_ASSERT (bbox.get().x0 == -0.5);
|
CPPUNIT_ASSERT (bbox.value().x0 == -0.5);
|
||||||
CPPUNIT_ASSERT (bbox.get().y0 == -0.5);
|
CPPUNIT_ASSERT (bbox.value().y0 == -0.5);
|
||||||
CPPUNIT_ASSERT (bbox.get().x1 == 48.5);
|
CPPUNIT_ASSERT (bbox.value().x1 == 48.5);
|
||||||
CPPUNIT_ASSERT (bbox.get().y1 == 48.5);
|
CPPUNIT_ASSERT (bbox.value().y1 == 48.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that a group notices when its grandchildren change */
|
/* Check that a group notices when its grandchildren change */
|
||||||
|
|
@ -158,34 +158,34 @@ GroupTest::grandchildren_changing ()
|
||||||
/* Check the initial bboxes */
|
/* Check the initial bboxes */
|
||||||
boost::optional<Rect> bbox = canvas.root()->bounding_box ();
|
boost::optional<Rect> bbox = canvas.root()->bounding_box ();
|
||||||
CPPUNIT_ASSERT (bbox.is_initialized ());
|
CPPUNIT_ASSERT (bbox.is_initialized ());
|
||||||
CPPUNIT_ASSERT (bbox.get().x0 == 0);
|
CPPUNIT_ASSERT (bbox.value().x0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().y0 == 0);
|
CPPUNIT_ASSERT (bbox.value().y0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().x1 == 32);
|
CPPUNIT_ASSERT (bbox.value().x1 == 32);
|
||||||
CPPUNIT_ASSERT (bbox.get().y1 == 32);
|
CPPUNIT_ASSERT (bbox.value().y1 == 32);
|
||||||
|
|
||||||
bbox = B.bounding_box ();
|
bbox = B.bounding_box ();
|
||||||
CPPUNIT_ASSERT (bbox.is_initialized ());
|
CPPUNIT_ASSERT (bbox.is_initialized ());
|
||||||
CPPUNIT_ASSERT (bbox.get().x0 == 0);
|
CPPUNIT_ASSERT (bbox.value().x0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().y0 == 0);
|
CPPUNIT_ASSERT (bbox.value().y0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().x1 == 32);
|
CPPUNIT_ASSERT (bbox.value().x1 == 32);
|
||||||
CPPUNIT_ASSERT (bbox.get().y1 == 32);
|
CPPUNIT_ASSERT (bbox.value().y1 == 32);
|
||||||
|
|
||||||
/* Change the grandchild and check its parent and grandparent */
|
/* Change the grandchild and check its parent and grandparent */
|
||||||
a.set (Rect (0, 0, 48, 48));
|
a.set (Rect (0, 0, 48, 48));
|
||||||
|
|
||||||
bbox = canvas.root()->bounding_box ();
|
bbox = canvas.root()->bounding_box ();
|
||||||
CPPUNIT_ASSERT (bbox.is_initialized ());
|
CPPUNIT_ASSERT (bbox.is_initialized ());
|
||||||
CPPUNIT_ASSERT (bbox.get().x0 == 0);
|
CPPUNIT_ASSERT (bbox.value().x0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().y0 == 0);
|
CPPUNIT_ASSERT (bbox.value().y0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().x1 == 48);
|
CPPUNIT_ASSERT (bbox.value().x1 == 48);
|
||||||
CPPUNIT_ASSERT (bbox.get().y1 == 48);
|
CPPUNIT_ASSERT (bbox.value().y1 == 48);
|
||||||
|
|
||||||
bbox = B.bounding_box ();
|
bbox = B.bounding_box ();
|
||||||
CPPUNIT_ASSERT (bbox.is_initialized ());
|
CPPUNIT_ASSERT (bbox.is_initialized ());
|
||||||
CPPUNIT_ASSERT (bbox.get().x0 == 0);
|
CPPUNIT_ASSERT (bbox.value().x0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().y0 == 0);
|
CPPUNIT_ASSERT (bbox.value().y0 == 0);
|
||||||
CPPUNIT_ASSERT (bbox.get().x1 == 48);
|
CPPUNIT_ASSERT (bbox.value().x1 == 48);
|
||||||
CPPUNIT_ASSERT (bbox.get().y1 == 48);
|
CPPUNIT_ASSERT (bbox.value().y1 == 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Basic tests on the code to find items at a particular point */
|
/* Basic tests on the code to find items at a particular point */
|
||||||
|
|
@ -271,14 +271,14 @@ GroupTest::torture_add_items_at_point ()
|
||||||
|
|
||||||
/* work it out ourselves */
|
/* work it out ourselves */
|
||||||
vector<Item*> items_B;
|
vector<Item*> items_B;
|
||||||
if (canvas.root()->bounding_box() && canvas.root()->bounding_box().get().contains (test)) {
|
if (canvas.root()->bounding_box() && canvas.root()->bounding_box().value().contains (test)) {
|
||||||
items_B.push_back (canvas.root());
|
items_B.push_back (canvas.root());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (list<Item*>::iterator j = rectangles.begin(); j != rectangles.end(); ++j) {
|
for (list<Item*>::iterator j = rectangles.begin(); j != rectangles.end(); ++j) {
|
||||||
boost::optional<Rect> bbox = (*j)->bounding_box ();
|
boost::optional<Rect> bbox = (*j)->bounding_box ();
|
||||||
assert (bbox);
|
assert (bbox);
|
||||||
if (bbox.get().contains (test)) {
|
if (bbox.value().contains (test)) {
|
||||||
items_B.push_back (*j);
|
items_B.push_back (*j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@ PolygonTest::bounding_box ()
|
||||||
*/
|
*/
|
||||||
boost::optional<Rect> bbox = polygon.bounding_box ();
|
boost::optional<Rect> bbox = polygon.bounding_box ();
|
||||||
CPPUNIT_ASSERT (bbox.is_initialized ());
|
CPPUNIT_ASSERT (bbox.is_initialized ());
|
||||||
CPPUNIT_ASSERT (bbox.get().x0 == -6.25);
|
CPPUNIT_ASSERT (bbox.value().x0 == -6.25);
|
||||||
CPPUNIT_ASSERT (bbox.get().x1 == 6.25);
|
CPPUNIT_ASSERT (bbox.value().x1 == 6.25);
|
||||||
CPPUNIT_ASSERT (bbox.get().y0 == -6.25);
|
CPPUNIT_ASSERT (bbox.value().y0 == -6.25);
|
||||||
CPPUNIT_ASSERT (bbox.get().y1 == 6.25);
|
CPPUNIT_ASSERT (bbox.value().y1 == 6.25);
|
||||||
|
|
||||||
/* and its parent group should have noticed and adjusted
|
/* and its parent group should have noticed and adjusted
|
||||||
its bounding box
|
its bounding box
|
||||||
|
|
@ -42,8 +42,8 @@ PolygonTest::bounding_box ()
|
||||||
|
|
||||||
bbox = group.bounding_box ();
|
bbox = group.bounding_box ();
|
||||||
CPPUNIT_ASSERT (bbox.is_initialized ());
|
CPPUNIT_ASSERT (bbox.is_initialized ());
|
||||||
CPPUNIT_ASSERT (bbox.get().x0 == -6.25);
|
CPPUNIT_ASSERT (bbox.value().x0 == -6.25);
|
||||||
CPPUNIT_ASSERT (bbox.get().x1 == 6.25);
|
CPPUNIT_ASSERT (bbox.value().x1 == 6.25);
|
||||||
CPPUNIT_ASSERT (bbox.get().y0 == -6.25);
|
CPPUNIT_ASSERT (bbox.value().y0 == -6.25);
|
||||||
CPPUNIT_ASSERT (bbox.get().y1 == 6.25);
|
CPPUNIT_ASSERT (bbox.value().y1 == 6.25);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue