Skip to content

Commit 66e3d65

Browse files
committed
Update to leverage CGRect being cross platform - delete CxxBox and simply use CGRect structs as appropriate.
Signed-off-by: vade <vade@vade.info>
1 parent 1b06e13 commit 66e3d65

File tree

4 files changed

+19
-32
lines changed

4 files changed

+19
-32
lines changed

Sources/objc/include/CxxBox.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

Sources/objc/include/opentimelineio.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#import "CxxAnyDictionaryIterator.h"
1111
#import "CxxAnyVectorMutationStamp.h"
1212
#import "CxxVectorProperty.h"
13-
#import "CxxBox.h"
1413
#import "errorStruct.h"
1514

1615
#if defined(__cplusplus)
@@ -185,8 +184,8 @@ bool media_reference_available_range(CxxRetainer* self, CxxTimeRange*);
185184
void media_reference_set_available_range(CxxRetainer* self, CxxTimeRange);
186185
void media_reference_clear_available_range(CxxRetainer* self);
187186

188-
bool media_reference_available_image_bounds(CxxRetainer* self, CxxBox2D* );
189-
void media_reference_set_available_image_bounds(CxxRetainer* self, CxxBox2D image_bounds);
187+
bool media_reference_available_image_bounds(CxxRetainer* self, CGRect* );
188+
void media_reference_set_available_image_bounds(CxxRetainer* self, CGRect image_bounds);
190189
void media_reference_clear_available_image_bounds(CxxRetainer* self);
191190

192191
// MARK: - Timeline

Sources/objc/opentimelineio.mm

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#import "opentimelineio.h"
3838
#import "opentime.h"
3939
#import "errorStruct.h"
40-
#import "CxxBox.h"
4140
#import "CxxVectorProperty.h"
4241

4342
namespace otio = opentimelineio::OPENTIMELINEIO_VERSION;
@@ -632,30 +631,30 @@ void media_reference_clear_available_range(CxxRetainer* self) {
632631
SO_cast<otio::MediaReference>(self)->set_available_range(std::nullopt);
633632
}
634633

635-
bool media_reference_available_image_bounds(CxxRetainer* self, CxxBox2D* ib) {
634+
bool media_reference_available_image_bounds(CxxRetainer* self, CGRect* rect) {
636635
std::optional<IMATH_NAMESPACE::Box2d> iBox2D = SO_cast<otio::MediaReference>(self)->available_image_bounds();
637636

638-
if (iBox2D && ib) {
639-
ib->minX = iBox2D->min.x;
640-
ib->minY = iBox2D->min.y;
641-
ib->maxX = iBox2D->max.x;
642-
ib->maxX = iBox2D->max.y;
637+
if (iBox2D && rect) {
638+
rect->origin.x = iBox2D->min.x;
639+
rect->origin.y = iBox2D->min.y;
640+
rect->size.width = iBox2D->max.x - iBox2D->min.x;
641+
rect->size.height = iBox2D->max.y - iBox2D->max.y;
643642

644643
return true;
645644
}
646645

647-
ib = NULL;
646+
rect = NULL;
648647

649648
return false;
650649
}
651650

652-
void media_reference_set_available_image_bounds(CxxRetainer* self, CxxBox2D image_bounds) {
651+
void media_reference_set_available_image_bounds(CxxRetainer* self, CGRect image_bounds) {
653652
std::optional<IMATH_NAMESPACE::Box2d> iBox2D = std::optional<IMATH_NAMESPACE::Box2d>();
654653

655-
iBox2D->min.x = image_bounds.minX;
656-
iBox2D->min.y = image_bounds.minY;
657-
iBox2D->max.x = image_bounds.maxX;
658-
iBox2D->max.y = image_bounds.maxX;
654+
iBox2D->min.x = image_bounds.origin.x;
655+
iBox2D->min.y = image_bounds.origin.y;
656+
iBox2D->max.x = image_bounds.size.width + image_bounds.origin.x;
657+
iBox2D->max.y = image_bounds.size.height + image_bounds.origin.y;
659658

660659
SO_cast<otio::MediaReference>(self)->set_available_image_bounds(iBox2D);
661660
}

Sources/swift/MediaReference.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,16 @@ public class MediaReference : SerializableObjectWithMetadata {
5050
get { return media_reference_is_missing_reference(self) }
5151
}
5252

53-
public var availableImageBounds: SIMD4<Double>?
53+
public var availableImageBounds: CGRect?
5454
{
55-
get { var box2D = CxxBox2D()
56-
return media_reference_available_image_bounds(self, &box2D) ? SIMD4(box2D.minX, box2D.minY, box2D.maxX, box2D.maxY) : nil
55+
get {
56+
var rect = CGRect(origin: CGPoint.init(x: 0, y: 0), size: CGSize(width: 0, height: 0))
57+
return media_reference_available_image_bounds(self, &rect) ? rect : nil
5758
}
5859
set {
5960
if let newValue = newValue {
6061

61-
media_reference_set_available_image_bounds(self, CxxBox2D.init(minX: newValue.x, minY: newValue.y, maxX: newValue.z, maxY: newValue.w))
62+
media_reference_set_available_image_bounds(self, newValue)
6263
}
6364
else
6465
{

0 commit comments

Comments
 (0)