-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomposable.go
More file actions
85 lines (68 loc) · 2.26 KB
/
composable.go
File metadata and controls
85 lines (68 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// SPDX-License-Identifier: Apache-2.0
// Copyright Contributors to the OpenTimelineIO project
package gotio
import (
"github.com/Avalanche-io/gotio/opentime"
)
// Composable is the interface for items that can be composed in a composition.
type Composable interface {
SerializableObjectWithMetadata
// Parent returns the parent composition.
Parent() Composition
// SetParent sets the parent composition.
SetParent(parent Composition)
// Duration returns the duration.
Duration() (opentime.RationalTime, error)
// Visible returns whether this item is visible (takes up time in parent).
Visible() bool
// Overlapping returns whether this item overlaps with neighbors.
Overlapping() bool
}
// ComposableBase is the base implementation of Composable.
type ComposableBase struct {
SerializableObjectWithMetadataBase
parent any // stores Composition, but uses any to avoid type constraints on embedded methods
self Composable // reference to the containing struct (set by concrete types)
}
// NewComposableBase creates a new ComposableBase.
func NewComposableBase(name string, metadata AnyDictionary) ComposableBase {
return ComposableBase{
SerializableObjectWithMetadataBase: NewSerializableObjectWithMetadataBase(name, metadata),
}
}
// Parent returns the parent.
func (c *ComposableBase) Parent() Composition {
if c.parent == nil {
return nil
}
if comp, ok := c.parent.(Composition); ok {
return comp
}
return nil
}
// SetParent sets the parent.
func (c *ComposableBase) SetParent(parent Composition) {
c.parent = parent
}
// setParentRaw sets the parent without type checking (used internally by CompositionBase).
func (c *ComposableBase) setParentRaw(parent any) {
c.parent = parent
}
// Visible returns true by default.
func (c *ComposableBase) Visible() bool {
return true
}
// Overlapping returns false by default.
func (c *ComposableBase) Overlapping() bool {
return false
}
// Self returns the Composable interface value for this object.
// This is set by concrete types to enable hierarchy traversal.
func (c *ComposableBase) Self() Composable {
return c.self
}
// SetSelf sets the Composable interface value for this object.
// Concrete types must call this after construction.
func (c *ComposableBase) SetSelf(self Composable) {
c.self = self
}