Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enabled flag to Item #1175

Merged
merged 16 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/tutorials/otio-serialized-schema-only-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ parameters:

parameters:
- *effects*
- *enabled*
- *markers*
- *metadata*
- *name*
Expand All @@ -51,6 +52,7 @@ parameters:

parameters:
- *effects*
- *enabled*
- *markers*
- *metadata*
- *name*
Expand Down Expand Up @@ -132,6 +134,7 @@ parameters:

parameters:
- *effects*
- *enabled*
- *markers*
- *media_reference*
- *metadata*
Expand Down Expand Up @@ -165,6 +168,7 @@ parameters:

parameters:
- *effects*
- *enabled*
- *markers*
- *metadata*
- *name*
Expand Down Expand Up @@ -227,6 +231,7 @@ parameters:

parameters:
- *effects*
- *enabled*
- *markers*
- *metadata*
- *name*
Expand All @@ -251,6 +256,7 @@ parameters:

parameters:
- *effects*
- *enabled*
- *kind*
- *markers*
- *metadata*
Expand Down
6 changes: 6 additions & 0 deletions docs/tutorials/otio-serialized-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ None

parameters:
- *effects*:
- *enabled*: Enabled sets whether or not an Item contributes to compositions. Analogous to Mute in various NLEs.
ThomasWilshaw marked this conversation as resolved.
Show resolved Hide resolved
- *markers*:
- *metadata*:
- *name*:
Expand All @@ -97,6 +98,7 @@ None

parameters:
- *effects*:
- *enabled*: Enabled sets whether or not an Item contributes to compositions. Analogous to Mute in various NLEs.
ThomasWilshaw marked this conversation as resolved.
Show resolved Hide resolved
- *markers*:
- *metadata*:
- *name*:
Expand Down Expand Up @@ -269,6 +271,7 @@ None

parameters:
- *effects*:
- *enabled*: Enabled sets whether or not an Item contributes to compositions. Analogous to Mute in various NLEs.
ThomasWilshaw marked this conversation as resolved.
Show resolved Hide resolved
- *markers*:
- *media_reference*:
- *metadata*:
Expand Down Expand Up @@ -334,6 +337,7 @@ None

parameters:
- *effects*:
- *enabled*: Enabled sets whether or not an Item contributes to compositions. Analogous to Mute in various NLEs.
ThomasWilshaw marked this conversation as resolved.
Show resolved Hide resolved
- *markers*:
- *metadata*:
- *name*:
Expand Down Expand Up @@ -512,6 +516,7 @@ None

parameters:
- *effects*:
- *enabled*: Enabled sets whether or not an Item contributes to compositions. Analogous to Mute in various NLEs.
ThomasWilshaw marked this conversation as resolved.
Show resolved Hide resolved
- *markers*:
- *metadata*:
- *name*:
Expand Down Expand Up @@ -560,6 +565,7 @@ None

parameters:
- *effects*:
- *enabled*: Enabled sets whether or not an Item contributes to compositions. Analogous to Mute in various NLEs.
ThomasWilshaw marked this conversation as resolved.
Show resolved Hide resolved
- *kind*:
- *markers*:
- *metadata*:
Expand Down
8 changes: 6 additions & 2 deletions src/opentimelineio/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ Item::Item(
optional<TimeRange> const& source_range,
AnyDictionary const& metadata,
std::vector<Effect*> const& effects,
std::vector<Marker*> const& markers)
std::vector<Marker*> const& markers,
bool enabled)
: Parent(name, metadata)
, _source_range(source_range)
, _effects(effects.begin(), effects.end())
, _markers(markers.begin(), markers.end())
, _enabled(enabled)
{}

Item::~Item()
Expand All @@ -25,7 +27,7 @@ Item::~Item()
bool
Item::visible() const
{
return true;
return _enabled;
}

bool
Expand Down Expand Up @@ -165,6 +167,7 @@ Item::read_from(Reader& reader)
return reader.read_if_present("source_range", &_source_range) &&
reader.read_if_present("effects", &_effects) &&
reader.read_if_present("markers", &_markers) &&
reader.read_if_present("enabled", &_enabled) &&
Parent::read_from(reader);
}

Expand All @@ -175,6 +178,7 @@ Item::write_to(Writer& writer) const
writer.write("source_range", _source_range);
writer.write("effects", _effects);
writer.write("markers", _markers);
writer.write("enabled", _enabled);
}

}} // namespace opentimelineio::OPENTIMELINEIO_VERSION
11 changes: 10 additions & 1 deletion src/opentimelineio/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ class Item : public Composable
optional<TimeRange> const& source_range = nullopt,
AnyDictionary const& metadata = AnyDictionary(),
std::vector<Effect*> const& effects = std::vector<Effect*>(),
std::vector<Marker*> const& markers = std::vector<Marker*>());
std::vector<Marker*> const& markers = std::vector<Marker*>(),
bool enabled = true);

virtual bool visible() const;
virtual bool overlapping() const;

bool enabled() const { return _enabled; };

void set_enabled(bool enabled)
{
_enabled = enabled;
}

optional<TimeRange> source_range() const noexcept { return _source_range; }

Expand Down Expand Up @@ -90,6 +98,7 @@ class Item : public Composable
optional<TimeRange> _source_range;
std::vector<Retainer<Effect>> _effects;
std::vector<Retainer<Marker>> _markers;
bool _enabled;
};

}} // namespace opentimelineio::OPENTIMELINEIO_VERSION
5 changes: 4 additions & 1 deletion src/opentimelineio/stackAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ flatten_stack(Stack* in_stack, ErrorStatus* error_status)
{
if (auto track = dynamic_retainer_cast<Track>(c))
{
tracks.push_back(track);
if (track->enabled())
{
tracks.push_back(track);
}
}
else
{
Expand Down
11 changes: 10 additions & 1 deletion src/opentimelineview/track_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ def __init__(self, track, rect, *args, **kwargs):
font_metrics = QFontMetrics(self.font)
self.full_width = font_metrics.width(self.full_track_name) + 40

if not self.track.enabled:
self.setBrush(
QtGui.QBrush(QtGui.QColor(100, 100, 100, 255))
)

def mouseDoubleClickEvent(self, event):
super(TrackNameItem, self).mouseDoubleClickEvent(event)
if self.name_toggle:
Expand Down Expand Up @@ -412,7 +417,8 @@ class ClipItem(BaseItem):

def __init__(self, *args, **kwargs):
super(ClipItem, self).__init__(*args, **kwargs)
self.setBrush(QtGui.QBrush(QtGui.QColor(168, 197, 255, 255)))
self.setBrush(QtGui.QBrush(QtGui.QColor(168, 197, 255, 255) if self.item.enabled
else QtGui.QColor(100, 100, 100, 255)))
self.source_name_label.setText(self.item.name)


Expand Down Expand Up @@ -472,6 +478,9 @@ def _populate(self):
TRACK_HEIGHT
)

if not self.track.enabled:
item.enabled = False

if isinstance(item, otio.schema.Clip):
new_item = ClipItem(item, timeline_range, rect)
elif isinstance(item, otio.schema.Stack):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,19 @@ static void define_bases2(py::module m) {
static void define_items_and_compositions(py::module m) {
py::class_<Item, Composable, managing_ptr<Item>>(m, "Item", py::dynamic_attr())
.def(py::init([](std::string name, optional<TimeRange> source_range,
py::object effects, py::object markers, py::object metadata) {
py::object effects, py::object markers, py::bool_ enabled, py::object metadata) {
return new Item(name, source_range,
py_to_any_dictionary(metadata),
py_to_vector<Effect*>(effects),
py_to_vector<Marker*>(markers)); }),
py_to_vector<Marker*>(markers),
enabled); }),
py::arg_v("name"_a = std::string()),
"source_range"_a = nullopt,
"effects"_a = py::none(),
"markers"_a = py::none(),
"enabled"_a = true,
py::arg_v("metadata"_a = py::none()))
.def_property("enabled", &Item::enabled, &Item::set_enabled, "Enabled sets whether or not an Item contributes to compositions. Analogous to Mute in various NLEs.")
ThomasWilshaw marked this conversation as resolved.
Show resolved Hide resolved
.def_property("source_range", &Item::source_range, &Item::set_source_range)
.def("available_range", [](Item* item) {
return item->available_range(ErrorStatusHandler());
Expand Down
35 changes: 19 additions & 16 deletions src/py-opentimelineio/opentimelineio/adapters/cmx_3600.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,9 +924,9 @@ def write_to_string(input_otio, rate=None, style='avid', reelname_len=8):
# also only works for a single video track at the moment

video_tracks = [t for t in input_otio.tracks
if t.kind == schema.TrackKind.Video]
if t.kind == schema.TrackKind.Video and t.enabled]
audio_tracks = [t for t in input_otio.tracks
if t.kind == schema.TrackKind.Audio]
if t.kind == schema.TrackKind.Audio and t.enabled]

if len(video_tracks) != 1:
raise exceptions.NotSupportedError(
Expand Down Expand Up @@ -1038,27 +1038,30 @@ def get_content_for_track_at_index(self, idx, title):
)
)
elif isinstance(child, schema.Clip):
events.append(
Event(
child,
self._tracks,
track.kind,
self._rate,
self._style,
self._reelname_len
if child.enabled:
events.append(
Event(
child,
self._tracks,
track.kind,
self._rate,
self._style,
self._reelname_len
)
)
)
else:
pass
elif isinstance(child, schema.Gap):
# Gaps are represented as missing record timecode, no event
# needed.
pass

content = "TITLE: {}\n\n".format(title) if title else ''

# Convert each event/dissolve-event into plain text.
for idx, event in enumerate(events):
event.edit_number = idx + 1
content += event.to_edl_format() + '\n'
if track.enabled:
# Convert each event/dissolve-event into plain text.
for idx, event in enumerate(events):
event.edit_number = idx + 1
content += event.to_edl_format() + '\n'

return content

Expand Down
5 changes: 4 additions & 1 deletion src/py-opentimelineio/opentimelineio/core/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

@add_method(_otio.Item)
def __str__(self):
return "{}({}, {}, {}, {}, {})".format(
return "{}({}, {}, {}, {}, {}, {})".format(
self.__class__.__name__,
self.name,
str(self.source_range),
str(self.effects),
str(self.markers),
str(self.enabled),
str(self.metadata)
)

Expand All @@ -22,6 +23,7 @@ def __repr__(self):
"source_range={}, "
"effects={}, "
"markers={}, "
"enabled={}, "
"metadata={}"
")".format(
"core" if self.__class__ is _otio.Item else "schema",
Expand All @@ -30,6 +32,7 @@ def __repr__(self):
repr(self.source_range),
repr(self.effects),
repr(self.markers),
repr(self.enabled),
repr(self.metadata)
)
)
1 change: 1 addition & 0 deletions tests/baselines/empty_clip.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"name" : "test_clip",
"source_range" : null,
"markers" : [],
"enabled" : true,
"effects" : [],
"media_reference" : {
"FROM_TEST_FILE" : "empty_missingreference.json"
Expand Down
1 change: 1 addition & 0 deletions tests/baselines/empty_gap.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"metadata" : {},
"name" : "",
"markers" : [],
"enabled" : true,
"effects" : [],
"source_range" : {
"FROM_TEST_FILE" : "empty_timerange.json"
Expand Down
1 change: 1 addition & 0 deletions tests/baselines/empty_stack.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"source_range": null,
"children" : [],
"markers" : [],
"enabled" : true,
"effects" : []
}
1 change: 1 addition & 0 deletions tests/baselines/empty_track.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"source_range": null,
"children" : [],
"markers" : [],
"enabled" : true,
"effects" : [],
"kind" : "Video"
}
Loading